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/dav1d | |
parent | 875c3efb916f2400df355f8517f1daeff6f7ae85 (diff) |
Update for glib/gstreamer bindings API changes
Diffstat (limited to 'video/dav1d')
-rw-r--r-- | video/dav1d/src/dav1ddec/imp.rs | 97 |
1 files changed, 54 insertions, 43 deletions
diff --git a/video/dav1d/src/dav1ddec/imp.rs b/video/dav1d/src/dav1ddec/imp.rs index fb1a258d0..c17501194 100644 --- a/video/dav1d/src/dav1ddec/imp.rs +++ b/video/dav1d/src/dav1ddec/imp.rs @@ -349,6 +349,7 @@ impl ObjectSubclass for Dav1dDec { const NAME: &'static str = "RsDav1dDec"; type Type = super::Dav1dDec; type ParentType = gst_video::VideoDecoder; + type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct<Self>; type Class = subclass::simple::ClassStruct<Self>; @@ -364,54 +365,64 @@ impl ObjectSubclass for Dav1dDec { }), } } +} - fn class_init(klass: &mut Self::Class) { - klass.set_metadata( - "Dav1d AV1 Decoder", - "Codec/Decoder/Video", - "Decode AV1 video streams with dav1d", - "Philippe Normand <philn@igalia.com>", - ); +impl ObjectImpl for Dav1dDec {} - let sink_caps = gst::Caps::new_simple("video/x-av1", &[]); - 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::List::from_owned(video_output_formats())), - ("width", &gst::IntRange::<i32>::new(1, i32::MAX)), - ("height", &gst::IntRange::<i32>::new(1, i32::MAX)), - ( - "framerate", - &gst::FractionRange::new( - gst::Fraction::new(0, 1), - gst::Fraction::new(i32::MAX, 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 ElementImpl for Dav1dDec { + fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { + static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| { + gst::subclass::ElementMetadata::new( + "Dav1d AV1 Decoder", + "Codec/Decoder/Video", + "Decode AV1 video streams with dav1d", + "Philippe Normand <philn@igalia.com>", + ) + }); + + Some(&*ELEMENT_METADATA) } -} -impl ObjectImpl for Dav1dDec {} + fn pad_templates() -> &'static [gst::PadTemplate] { + static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { + let sink_caps = gst::Caps::new_simple("video/x-av1", &[]); + let sink_pad_template = gst::PadTemplate::new( + "sink", + gst::PadDirection::Sink, + gst::PadPresence::Always, + &sink_caps, + ) + .unwrap(); -impl ElementImpl for Dav1dDec {} + let src_caps = gst::Caps::new_simple( + "video/x-raw", + &[ + ("format", &gst::List::from_owned(video_output_formats())), + ("width", &gst::IntRange::<i32>::new(1, i32::MAX)), + ("height", &gst::IntRange::<i32>::new(1, i32::MAX)), + ( + "framerate", + &gst::FractionRange::new( + gst::Fraction::new(0, 1), + gst::Fraction::new(i32::MAX, 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 Dav1dDec { fn start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> { |