Allow registering GstPushSrc based types

This commit is contained in:
Sebastian Dröge 2016-05-14 17:41:41 +03:00
parent 2298fc3353
commit 45a146be26
4 changed files with 12 additions and 9 deletions

View file

@ -29,7 +29,8 @@ extern "C" {
author: *const c_char, author: *const c_char,
rank: i32, rank: i32,
create_instance: extern fn() -> *mut Box<Source>, create_instance: extern fn() -> *mut Box<Source>,
protocols: *const c_char) -> GBoolean; protocols: *const c_char,
push_only: GBoolean) -> GBoolean;
} }
#[no_mangle] #[no_mangle]
@ -44,7 +45,8 @@ pub extern "C" fn sources_register(plugin: *const c_void) -> GBoolean {
CString::new("Sebastian Dröge <sebastian@centricular.com>").unwrap().as_ptr(), CString::new("Sebastian Dröge <sebastian@centricular.com>").unwrap().as_ptr(),
256 + 100, 256 + 100,
FileSrc::new_ptr, FileSrc::new_ptr,
CString::new("file").unwrap().as_ptr()); CString::new("file").unwrap().as_ptr(),
GBoolean::False);
gst_rs_source_register(plugin, gst_rs_source_register(plugin,
CString::new("rshttpsrc").unwrap().as_ptr(), 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 <sebastian@centricular.com>").unwrap().as_ptr(), CString::new("Sebastian Dröge <sebastian@centricular.com>").unwrap().as_ptr(),
256 + 100, 256 + 100,
HttpSrc::new_ptr, HttpSrc::new_ptr,
CString::new("http:https").unwrap().as_ptr()); CString::new("http:https").unwrap().as_ptr(),
GBoolean::True);
} }
return GBoolean::True; return GBoolean::True;

View file

@ -116,7 +116,7 @@ impl Source for HttpSrc {
} }
self.response = None; self.response = None;
true return true;
} }
fn fill(&mut self, offset: u64, data: &mut [u8]) -> Result<usize, GstFlowReturn> { fn fill(&mut self, offset: u64, data: &mut [u8]) -> Result<usize, GstFlowReturn> {

View file

@ -266,7 +266,7 @@ gst_rs_source_plugin_init (GstPlugin * plugin)
} }
gboolean 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 = { GTypeInfo type_info = {
sizeof (GstRsSrcClass), sizeof (GstRsSrcClass),
@ -298,7 +298,7 @@ gst_rs_source_register (GstPlugin * plugin, const gchar *name, const gchar * lon
data->protocols = g_strsplit (protocols, ":", -1); data->protocols = g_strsplit (protocols, ":", -1);
type_name = g_strconcat ("RsSrc-", name, NULL); 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_free (type_name);
g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &iface_info); g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &iface_info);

View file

@ -2,7 +2,7 @@
#define __GST_RS_SRC_H__ #define __GST_RS_SRC_H__
#include <gst/gst.h> #include <gst/gst.h>
#include <gst/base/gstbasesrc.h> #include <gst/base/base.h>
G_BEGIN_DECLS G_BEGIN_DECLS
@ -15,13 +15,13 @@ typedef struct _GstRsSrc GstRsSrc;
typedef struct _GstRsSrcClass GstRsSrcClass; typedef struct _GstRsSrcClass GstRsSrcClass;
struct _GstRsSrc { struct _GstRsSrc {
GstBaseSrc element; GstPushSrc element;
gpointer instance; gpointer instance;
}; };
struct _GstRsSrcClass { struct _GstRsSrcClass {
GstBaseSrcClass parent_class; GstPushSrcClass parent_class;
}; };
G_GNUC_INTERNAL gboolean gst_rs_source_plugin_init (GstPlugin * plugin); G_GNUC_INTERNAL gboolean gst_rs_source_plugin_init (GstPlugin * plugin);