[−]Struct gstreamer_audio::AudioDecoder
This base class is for audio decoders turning encoded data into raw audio samples.
GstAudioDecoder and subclass should cooperate as follows.
Configuration
- Initially, GstAudioDecoder calls
start
when the decoder element is activated, which allows subclass to perform any global setup. Base class (context) parameters can already be set according to subclass capabilities (or possibly upon receive more information in subsequentset_format
). - GstAudioDecoder calls
set_format
to inform subclass of the format of input audio data that it is about to receive. While unlikely, it might be called more than once, if changing input parameters require reconfiguration. - GstAudioDecoder calls
stop
at end of all processing.
As of configuration stage, and throughout processing, GstAudioDecoder provides various (context) parameters, e.g. describing the format of output audio data (valid when output caps have been set) or current parsing state. Conversely, subclass can and should configure context to inform base class of its expectation w.r.t. buffer handling.
Data processing
- Base class gathers input data, and optionally allows subclass to parse this into subsequently manageable (as defined by subclass) chunks. Such chunks are subsequently referred to as 'frames', though they may or may not correspond to 1 (or more) audio format frame.
- Input frame is provided to subclass'
handle_frame
. - If codec processing results in decoded data, subclass should call
AudioDecoder::finish_frame
to have decoded data pushed downstream. - Just prior to actually pushing a buffer downstream,
it is passed to
pre_push
. Subclass should either use this callback to arrange for additional downstream pushing or otherwise ensure such custom pushing occurs after at least a method call has finished since setting src pad caps. - During the parsing process GstAudioDecoderClass will handle both
srcpad and sinkpad events. Sink events will be passed to subclass
if
event
callback has been provided.
Shutdown phase
- GstAudioDecoder class calls
stop
to inform the subclass that data parsing will be stopped.
Subclass is responsible for providing pad template caps for
source and sink pads. The pads need to be named "sink" and "src". It also
needs to set the fixed caps on srcpad, when the format is ensured. This
is typically when base class calls subclass' set_format
function, though
it might be delayed until calling AudioDecoder::finish_frame
.
In summary, above process should have subclass concentrating on
codec data processing while leaving other matters to base class,
such as most notably timestamp handling. While it may exert more control
in this area (see e.g. pre_push
), it is very much not recommended.
In particular, base class will try to arrange for perfect output timestamps
as much as possible while tracking upstream timestamps.
To this end, if deviation between the next ideal expected perfect timestamp
and upstream exceeds AudioDecoder:tolerance
, then resync to upstream
occurs (which would happen always if the tolerance mechanism is disabled).
In non-live pipelines, baseclass can also (configurably) arrange for output buffer aggregation which may help to redue large(r) numbers of small(er) buffers being pushed and processed downstream. Note that this feature is only available if the buffer layout is interleaved. For planar buffers, the decoder implementation is fully responsible for the output buffer size.
On the other hand, it should be noted that baseclass only provides limited seeking support (upon explicit subclass request), as full-fledged support should rather be left to upstream demuxer, parser or alike. This simple approach caters for seeking and duration reporting using estimated input bitrates.
Things that subclass need to take care of:
-
Provide pad templates
-
Set source pad caps when appropriate
-
Set user-configurable properties to sane defaults for format and implementing codec at hand, and convey some subclass capabilities and expectations in context.
-
Accept data in
handle_frame
and provide encoded results toAudioDecoder::finish_frame
. If it is prepared to perform PLC, it should also accept NULL data inhandle_frame
and provide for data for indicated duration.
Implements
AudioDecoderExt
, gst::ElementExt
, gst::ObjectExt
, glib::object::ObjectExt
Trait Implementations
impl Clone for AudioDecoder
[+]
impl Debug for AudioDecoder
[+]
impl Eq for AudioDecoder
impl Hash for AudioDecoder
[+]
impl IsA<Element> for AudioDecoder
impl IsA<Object> for AudioDecoder
impl Ord for AudioDecoder
[+]
impl<T: ObjectType> PartialEq<T> for AudioDecoder
[+]
impl<T: ObjectType> PartialOrd<T> for AudioDecoder
[+]
impl Send for AudioDecoder
[src]
impl StaticType for AudioDecoder
[+]
impl Sync for AudioDecoder
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src][+]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<Super, Sub> CanDowncast<Sub> for Super where
Sub: IsA<Super>,
Super: IsA<Super>,
[src]
Sub: IsA<Super>,
Super: IsA<Super>,
impl<T> Cast for T where
T: ObjectType,
[src][+]
T: ObjectType,
impl<O> ElementExt for O where
O: IsA<Element>,
[src][+]
O: IsA<Element>,
impl<O> ElementExtManual for O where
O: IsA<Element>,
[src][+]
O: IsA<Element>,
impl<T> From<T> for T
[src][+]
impl<O> GObjectExtManualGst for O where
O: IsA<Object>,
[src][+]
O: IsA<Object>,
impl<O> GstObjectExt for O where
O: IsA<Object>,
[src][+]
O: IsA<Object>,
impl<O> GstObjectExtManual for O where
O: IsA<Object>,
[src][+]
O: IsA<Object>,
impl<T, U> Into<U> for T where
U: From<T>,
[src][+]
U: From<T>,
impl<T> ObjectExt for T where
T: ObjectType,
[src][+]
T: ObjectType,
impl<'a, T> ToGlibContainerFromSlice<'a, *const GList> for T where
T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>,
[src][+]
T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>,
impl<'a, T> ToGlibContainerFromSlice<'a, *const GPtrArray> for T where
T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>,
[src][+]
T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>,
impl<'a, T> ToGlibContainerFromSlice<'a, *mut GArray> for T where
T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>,
[src][+]
T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>,
impl<'a, T> ToGlibContainerFromSlice<'a, *mut GList> for T where
T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>,
[src][+]
T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>,
impl<'a, T> ToGlibContainerFromSlice<'a, *mut GPtrArray> for T where
T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>,
[src][+]
T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>,
impl<T> ToOwned for T where
T: Clone,
[src][+]
T: Clone,
impl<T> ToSendValue for T where
T: ToValue + SetValue + Send + ?Sized,
[src][+]
T: ToValue + SetValue + Send + ?Sized,
impl<T> ToValue for T where
T: SetValue + ?Sized,
[src][+]
T: SetValue + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src][+]
U: Into<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src][+]
U: TryFrom<T>,