mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-09-03 10:13:47 +00:00
Use caps also for the demuxer sink/src pad templates instead of strings
This commit is contained in:
parent
e26cdc9187
commit
80ba9a8b8f
4 changed files with 42 additions and 27 deletions
|
@ -28,6 +28,7 @@ extern crate flavors;
|
||||||
|
|
||||||
use gst_plugin::plugin::*;
|
use gst_plugin::plugin::*;
|
||||||
use gst_plugin::demuxer::*;
|
use gst_plugin::demuxer::*;
|
||||||
|
use gst_plugin::caps::*;
|
||||||
|
|
||||||
mod flvdemux;
|
mod flvdemux;
|
||||||
|
|
||||||
|
@ -43,8 +44,8 @@ fn plugin_init(plugin: &Plugin) -> bool {
|
||||||
author: "Sebastian Dröge <sebastian@centricular.com>",
|
author: "Sebastian Dröge <sebastian@centricular.com>",
|
||||||
rank: 256 + 100,
|
rank: 256 + 100,
|
||||||
create_instance: FlvDemux::new_boxed,
|
create_instance: FlvDemux::new_boxed,
|
||||||
input_formats: "video/x-flv",
|
input_caps: &Caps::new_simple("video/x-flv", vec![]),
|
||||||
output_formats: "ANY",
|
output_caps: &Caps::new_any(),
|
||||||
});
|
});
|
||||||
|
|
||||||
true
|
true
|
||||||
|
|
|
@ -45,6 +45,26 @@ const TYPE_INT: usize = (6 << 2);
|
||||||
const TYPE_STRING: usize = (16 << 2);
|
const TYPE_STRING: usize = (16 << 2);
|
||||||
|
|
||||||
impl Caps {
|
impl Caps {
|
||||||
|
pub fn new_empty() -> Self {
|
||||||
|
extern "C" {
|
||||||
|
fn gst_caps_new_empty() -> *mut c_void;
|
||||||
|
}
|
||||||
|
|
||||||
|
let caps = Caps(unsafe { gst_caps_new_empty() });
|
||||||
|
|
||||||
|
caps
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn new_any() -> Self {
|
||||||
|
extern "C" {
|
||||||
|
fn gst_caps_new_any() -> *mut c_void;
|
||||||
|
}
|
||||||
|
|
||||||
|
let caps = Caps(unsafe { gst_caps_new_any() });
|
||||||
|
|
||||||
|
caps
|
||||||
|
}
|
||||||
|
|
||||||
pub fn new_simple(name: &str, values: Vec<(&str, &Value)>) -> Self {
|
pub fn new_simple(name: &str, values: Vec<(&str, &Value)>) -> Self {
|
||||||
extern "C" {
|
extern "C" {
|
||||||
fn gst_caps_new_empty() -> *mut c_void;
|
fn gst_caps_new_empty() -> *mut c_void;
|
||||||
|
|
|
@ -28,8 +28,8 @@ typedef struct
|
||||||
gchar *classification;
|
gchar *classification;
|
||||||
gchar *author;
|
gchar *author;
|
||||||
void *create_instance;
|
void *create_instance;
|
||||||
gchar *input_format;
|
GstCaps *input_caps;
|
||||||
gchar *output_formats;
|
GstCaps *output_caps;
|
||||||
} ElementData;
|
} ElementData;
|
||||||
static GHashTable *demuxers;
|
static GHashTable *demuxers;
|
||||||
|
|
||||||
|
@ -82,7 +82,6 @@ gst_rs_demuxer_class_init (GstRsDemuxerClass * klass)
|
||||||
GstElementClass *gstelement_class;
|
GstElementClass *gstelement_class;
|
||||||
ElementData *data = g_hash_table_lookup (demuxers,
|
ElementData *data = g_hash_table_lookup (demuxers,
|
||||||
GSIZE_TO_POINTER (G_TYPE_FROM_CLASS (klass)));
|
GSIZE_TO_POINTER (G_TYPE_FROM_CLASS (klass)));
|
||||||
GstCaps *caps;
|
|
||||||
GstPadTemplate *templ;
|
GstPadTemplate *templ;
|
||||||
g_assert (data != NULL);
|
g_assert (data != NULL);
|
||||||
|
|
||||||
|
@ -96,16 +95,14 @@ gst_rs_demuxer_class_init (GstRsDemuxerClass * klass)
|
||||||
gst_element_class_set_static_metadata (gstelement_class,
|
gst_element_class_set_static_metadata (gstelement_class,
|
||||||
data->long_name, data->classification, data->description, data->author);
|
data->long_name, data->classification, data->description, data->author);
|
||||||
|
|
||||||
caps = gst_caps_from_string (data->input_format);
|
templ =
|
||||||
templ = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, caps);
|
gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
|
||||||
gst_caps_unref (caps);
|
data->input_caps);
|
||||||
|
|
||||||
gst_element_class_add_pad_template (gstelement_class, templ);
|
gst_element_class_add_pad_template (gstelement_class, templ);
|
||||||
|
|
||||||
caps = gst_caps_from_string (data->output_formats);
|
templ =
|
||||||
templ = gst_pad_template_new ("src_%u", GST_PAD_SRC, GST_PAD_SOMETIMES, caps);
|
gst_pad_template_new ("src_%u", GST_PAD_SRC, GST_PAD_SOMETIMES,
|
||||||
gst_caps_unref (caps);
|
data->output_caps);
|
||||||
|
|
||||||
gst_element_class_add_pad_template (gstelement_class, templ);
|
gst_element_class_add_pad_template (gstelement_class, templ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,8 +520,7 @@ gboolean
|
||||||
gst_rs_demuxer_register (GstPlugin * plugin, const gchar * name,
|
gst_rs_demuxer_register (GstPlugin * plugin, const gchar * name,
|
||||||
const gchar * long_name, const gchar * description,
|
const gchar * long_name, const gchar * description,
|
||||||
const gchar * classification, const gchar * author, GstRank rank,
|
const gchar * classification, const gchar * author, GstRank rank,
|
||||||
void *create_instance, const gchar * input_format,
|
void *create_instance, GstCaps * input_caps, GstCaps * output_caps)
|
||||||
const gchar * output_formats)
|
|
||||||
{
|
{
|
||||||
GOnce gonce = G_ONCE_INIT;
|
GOnce gonce = G_ONCE_INIT;
|
||||||
GTypeInfo type_info = {
|
GTypeInfo type_info = {
|
||||||
|
@ -550,8 +546,8 @@ gst_rs_demuxer_register (GstPlugin * plugin, const gchar * name,
|
||||||
GST_DEBUG (" classification: %s", classification);
|
GST_DEBUG (" classification: %s", classification);
|
||||||
GST_DEBUG (" author: %s", author);
|
GST_DEBUG (" author: %s", author);
|
||||||
GST_DEBUG (" rank: %d", rank);
|
GST_DEBUG (" rank: %d", rank);
|
||||||
GST_DEBUG (" input formats: %s", input_format);
|
GST_DEBUG (" input caps: %" GST_PTR_FORMAT, input_caps);
|
||||||
GST_DEBUG (" output formats: %s", output_formats);
|
GST_DEBUG (" output caps: %" GST_PTR_FORMAT, output_caps);
|
||||||
|
|
||||||
data = g_new0 (ElementData, 1);
|
data = g_new0 (ElementData, 1);
|
||||||
data->long_name = g_strdup (long_name);
|
data->long_name = g_strdup (long_name);
|
||||||
|
@ -559,8 +555,8 @@ gst_rs_demuxer_register (GstPlugin * plugin, const gchar * name,
|
||||||
data->classification = g_strdup (classification);
|
data->classification = g_strdup (classification);
|
||||||
data->author = g_strdup (author);
|
data->author = g_strdup (author);
|
||||||
data->create_instance = create_instance;
|
data->create_instance = create_instance;
|
||||||
data->input_format = g_strdup (input_format);
|
data->input_caps = gst_caps_ref (input_caps);
|
||||||
data->output_formats = g_strdup (output_formats);
|
data->output_caps = gst_caps_ref (output_caps);
|
||||||
|
|
||||||
type_name = g_strconcat ("RsDemuxer-", name, NULL);
|
type_name = g_strconcat ("RsDemuxer-", name, NULL);
|
||||||
type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &type_info, 0);
|
type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &type_info, 0);
|
||||||
|
|
|
@ -496,8 +496,8 @@ pub struct DemuxerInfo<'a> {
|
||||||
pub author: &'a str,
|
pub author: &'a str,
|
||||||
pub rank: i32,
|
pub rank: i32,
|
||||||
pub create_instance: fn(Element) -> Box<Demuxer>,
|
pub create_instance: fn(Element) -> Box<Demuxer>,
|
||||||
pub input_formats: &'a str,
|
pub input_caps: &'a Caps,
|
||||||
pub output_formats: &'a str,
|
pub output_caps: &'a Caps,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn demuxer_register(plugin: &Plugin, demuxer_info: &DemuxerInfo) {
|
pub fn demuxer_register(plugin: &Plugin, demuxer_info: &DemuxerInfo) {
|
||||||
|
@ -510,8 +510,8 @@ pub fn demuxer_register(plugin: &Plugin, demuxer_info: &DemuxerInfo) {
|
||||||
author: *const c_char,
|
author: *const c_char,
|
||||||
rank: i32,
|
rank: i32,
|
||||||
create_instance: *const c_void,
|
create_instance: *const c_void,
|
||||||
input_format: *const c_char,
|
input_caps: *const c_void,
|
||||||
output_formats: *const c_char)
|
output_caps: *const c_void)
|
||||||
-> GBoolean;
|
-> GBoolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,8 +520,6 @@ pub fn demuxer_register(plugin: &Plugin, demuxer_info: &DemuxerInfo) {
|
||||||
let cdescription = CString::new(demuxer_info.description).unwrap();
|
let cdescription = CString::new(demuxer_info.description).unwrap();
|
||||||
let cclassification = CString::new(demuxer_info.classification).unwrap();
|
let cclassification = CString::new(demuxer_info.classification).unwrap();
|
||||||
let cauthor = CString::new(demuxer_info.author).unwrap();
|
let cauthor = CString::new(demuxer_info.author).unwrap();
|
||||||
let cinput_format = CString::new(demuxer_info.input_formats).unwrap();
|
|
||||||
let coutput_formats = CString::new(demuxer_info.output_formats).unwrap();
|
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
gst_rs_demuxer_register(plugin.as_ptr(),
|
gst_rs_demuxer_register(plugin.as_ptr(),
|
||||||
|
@ -532,7 +530,7 @@ pub fn demuxer_register(plugin: &Plugin, demuxer_info: &DemuxerInfo) {
|
||||||
cauthor.as_ptr(),
|
cauthor.as_ptr(),
|
||||||
demuxer_info.rank,
|
demuxer_info.rank,
|
||||||
demuxer_info.create_instance as *const c_void,
|
demuxer_info.create_instance as *const c_void,
|
||||||
cinput_format.as_ptr(),
|
demuxer_info.input_caps.as_ptr(),
|
||||||
coutput_formats.as_ptr());
|
demuxer_info.output_caps.as_ptr());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue