diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2021-01-21 21:21:29 +0300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2021-01-25 15:43:05 +0300 |
commit | d4ce1a33f2257ea19f873711c78b7b57d5cb7e5f (patch) | |
tree | 7a4ff75e550640afd69786a2d8a41f07b6b6c593 /video/cdg | |
parent | 875c3efb916f2400df355f8517f1daeff6f7ae85 (diff) |
Update for glib/gstreamer bindings API changes
Diffstat (limited to 'video/cdg')
-rw-r--r-- | video/cdg/src/cdgdec/imp.rs | 87 | ||||
-rw-r--r-- | video/cdg/src/cdgparse/imp.rs | 87 |
2 files changed, 98 insertions, 76 deletions
diff --git a/video/cdg/src/cdgdec/imp.rs b/video/cdg/src/cdgdec/imp.rs index 64cbbbf5e..6893478ce 100644 --- a/video/cdg/src/cdgdec/imp.rs +++ b/video/cdg/src/cdgdec/imp.rs @@ -32,6 +32,7 @@ impl ObjectSubclass for CdgDec { const NAME: &'static str = "CdgDec"; type Type = super::CdgDec; type ParentType = gst_video::VideoDecoder; + type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct<Self>; type Class = subclass::simple::ClassStruct<Self>; @@ -43,48 +44,58 @@ impl ObjectSubclass for CdgDec { output_info: Mutex::new(None), } } - - fn class_init(klass: &mut Self::Class) { - klass.set_metadata( - "CDG decoder", - "Decoder/Video", - "CDG decoder", - "Guillaume Desmottes <guillaume.desmottes@collabora.com>", - ); - - let sink_caps = gst::Caps::new_simple("video/x-cdg", &[("parsed", &true)]); - let sink_pad_template = gst::PadTemplate::new( - "sink", - gst::PadDirection::Sink, - gst::PadPresence::Always, - &sink_caps, - ) - .unwrap(); - klass.add_pad_template(sink_pad_template); - - let src_caps = gst::Caps::new_simple( - "video/x-raw", - &[ - ("format", &gst_video::VideoFormat::Rgba.to_str()), - ("width", &(CDG_WIDTH as i32)), - ("height", &(CDG_HEIGHT as i32)), - ("framerate", &gst::Fraction::new(0, 1)), - ], - ); - let src_pad_template = gst::PadTemplate::new( - "src", - gst::PadDirection::Src, - gst::PadPresence::Always, - &src_caps, - ) - .unwrap(); - klass.add_pad_template(src_pad_template); - } } impl ObjectImpl for CdgDec {} -impl ElementImpl for CdgDec {} +impl ElementImpl for CdgDec { + fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { + static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| { + gst::subclass::ElementMetadata::new( + "CDG decoder", + "Decoder/Video", + "CDG decoder", + "Guillaume Desmottes <guillaume.desmottes@collabora.com>", + ) + }); + + Some(&*ELEMENT_METADATA) + } + + fn pad_templates() -> &'static [gst::PadTemplate] { + static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { + let sink_caps = gst::Caps::new_simple("video/x-cdg", &[("parsed", &true)]); + let sink_pad_template = gst::PadTemplate::new( + "sink", + gst::PadDirection::Sink, + gst::PadPresence::Always, + &sink_caps, + ) + .unwrap(); + + let src_caps = gst::Caps::new_simple( + "video/x-raw", + &[ + ("format", &gst_video::VideoFormat::Rgba.to_str()), + ("width", &(CDG_WIDTH as i32)), + ("height", &(CDG_HEIGHT as i32)), + ("framerate", &gst::Fraction::new(0, 1)), + ], + ); + let src_pad_template = gst::PadTemplate::new( + "src", + gst::PadDirection::Src, + gst::PadPresence::Always, + &src_caps, + ) + .unwrap(); + + vec![src_pad_template, sink_pad_template] + }); + + PAD_TEMPLATES.as_ref() + } +} impl VideoDecoderImpl for CdgDec { fn start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> { diff --git a/video/cdg/src/cdgparse/imp.rs b/video/cdg/src/cdgparse/imp.rs index 697575b59..756dee536 100644 --- a/video/cdg/src/cdgparse/imp.rs +++ b/video/cdg/src/cdgparse/imp.rs @@ -39,6 +39,7 @@ impl ObjectSubclass for CdgParse { const NAME: &'static str = "CdgParse"; type Type = super::CdgParse; type ParentType = gst_base::BaseParse; + type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct<Self>; type Class = subclass::simple::ClassStruct<Self>; @@ -47,48 +48,58 @@ impl ObjectSubclass for CdgParse { fn new() -> Self { Self } - - fn class_init(klass: &mut Self::Class) { - klass.set_metadata( - "CDG parser", - "Codec/Parser/Video", - "CDG parser", - "Guillaume Desmottes <guillaume.desmottes@collabora.com>", - ); - - let sink_caps = gst::Caps::new_simple("video/x-cdg", &[]); - let sink_pad_template = gst::PadTemplate::new( - "sink", - gst::PadDirection::Sink, - gst::PadPresence::Always, - &sink_caps, - ) - .unwrap(); - klass.add_pad_template(sink_pad_template); - - let src_caps = gst::Caps::new_simple( - "video/x-cdg", - &[ - ("width", &(CDG_WIDTH as i32)), - ("height", &(CDG_HEIGHT as i32)), - ("framerate", &gst::Fraction::new(0, 1)), - ("parsed", &true), - ], - ); - let src_pad_template = gst::PadTemplate::new( - "src", - gst::PadDirection::Src, - gst::PadPresence::Always, - &src_caps, - ) - .unwrap(); - klass.add_pad_template(src_pad_template); - } } impl ObjectImpl for CdgParse {} -impl ElementImpl for CdgParse {} +impl ElementImpl for CdgParse { + fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { + static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| { + gst::subclass::ElementMetadata::new( + "CDG parser", + "Codec/Parser/Video", + "CDG parser", + "Guillaume Desmottes <guillaume.desmottes@collabora.com>", + ) + }); + + Some(&*ELEMENT_METADATA) + } + + fn pad_templates() -> &'static [gst::PadTemplate] { + static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { + let sink_caps = gst::Caps::new_simple("video/x-cdg", &[]); + let sink_pad_template = gst::PadTemplate::new( + "sink", + gst::PadDirection::Sink, + gst::PadPresence::Always, + &sink_caps, + ) + .unwrap(); + + let src_caps = gst::Caps::new_simple( + "video/x-cdg", + &[ + ("width", &(CDG_WIDTH as i32)), + ("height", &(CDG_HEIGHT as i32)), + ("framerate", &gst::Fraction::new(0, 1)), + ("parsed", &true), + ], + ); + let src_pad_template = gst::PadTemplate::new( + "src", + gst::PadDirection::Src, + gst::PadPresence::Always, + &src_caps, + ) + .unwrap(); + + vec![src_pad_template, sink_pad_template] + }); + + PAD_TEMPLATES.as_ref() + } +} fn bytes_to_time(bytes: Bytes) -> gst::ClockTime { match bytes { |