From 45a146be260fbcf1d06a096f386dbe7e9f86faff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 14 May 2016 17:41:41 +0300 Subject: [PATCH] Allow registering GstPushSrc based types --- src/lib.rs | 9 ++++++--- src/rshttpsrc.rs | 2 +- src/rssource.c | 4 ++-- src/rssource.h | 6 +++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f53e87a4..e48bdca8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,7 +29,8 @@ extern "C" { author: *const c_char, rank: i32, create_instance: extern fn() -> *mut Box, - protocols: *const c_char) -> GBoolean; + protocols: *const c_char, + push_only: GBoolean) -> GBoolean; } #[no_mangle] @@ -44,7 +45,8 @@ pub extern "C" fn sources_register(plugin: *const c_void) -> GBoolean { CString::new("Sebastian Dröge ").unwrap().as_ptr(), 256 + 100, FileSrc::new_ptr, - CString::new("file").unwrap().as_ptr()); + CString::new("file").unwrap().as_ptr(), + GBoolean::False); gst_rs_source_register(plugin, CString::new("rshttpsrc").unwrap().as_ptr(), @@ -54,7 +56,8 @@ pub extern "C" fn sources_register(plugin: *const c_void) -> GBoolean { CString::new("Sebastian Dröge ").unwrap().as_ptr(), 256 + 100, HttpSrc::new_ptr, - CString::new("http:https").unwrap().as_ptr()); + CString::new("http:https").unwrap().as_ptr(), + GBoolean::True); } return GBoolean::True; diff --git a/src/rshttpsrc.rs b/src/rshttpsrc.rs index 80d83cc0..27bca6cd 100644 --- a/src/rshttpsrc.rs +++ b/src/rshttpsrc.rs @@ -116,7 +116,7 @@ impl Source for HttpSrc { } self.response = None; - true + return true; } fn fill(&mut self, offset: u64, data: &mut [u8]) -> Result { diff --git a/src/rssource.c b/src/rssource.c index 650b32f1..b6cf4ac9 100644 --- a/src/rssource.c +++ b/src/rssource.c @@ -266,7 +266,7 @@ gst_rs_source_plugin_init (GstPlugin * plugin) } gboolean -gst_rs_source_register (GstPlugin * plugin, const gchar *name, const gchar * long_name, const gchar * description, const gchar * classification, const gchar * author, GstRank rank, void * (*create_instance) (void), const gchar *protocols) +gst_rs_source_register (GstPlugin * plugin, const gchar *name, const gchar * long_name, const gchar * description, const gchar * classification, const gchar * author, GstRank rank, void * (*create_instance) (void), const gchar *protocols, gboolean push_only) { GTypeInfo type_info = { sizeof (GstRsSrcClass), @@ -298,7 +298,7 @@ gst_rs_source_register (GstPlugin * plugin, const gchar *name, const gchar * lon data->protocols = g_strsplit (protocols, ":", -1); type_name = g_strconcat ("RsSrc-", name, NULL); - type = g_type_register_static (GST_TYPE_BASE_SRC, type_name, &type_info, 0); + type = g_type_register_static (push_only ? GST_TYPE_PUSH_SRC : GST_TYPE_BASE_SRC, type_name, &type_info, 0); g_free (type_name); g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &iface_info); diff --git a/src/rssource.h b/src/rssource.h index 966f284d..f203401e 100644 --- a/src/rssource.h +++ b/src/rssource.h @@ -2,7 +2,7 @@ #define __GST_RS_SRC_H__ #include -#include +#include G_BEGIN_DECLS @@ -15,13 +15,13 @@ typedef struct _GstRsSrc GstRsSrc; typedef struct _GstRsSrcClass GstRsSrcClass; struct _GstRsSrc { - GstBaseSrc element; + GstPushSrc element; gpointer instance; }; struct _GstRsSrcClass { - GstBaseSrcClass parent_class; + GstPushSrcClass parent_class; }; G_GNUC_INTERNAL gboolean gst_rs_source_plugin_init (GstPlugin * plugin);