X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=nihav-core%2Fsrc%2Fcodecs%2Fmod.rs;h=b6a1820d6bcf6bb87b3c9cad6f0c41aea7af6dc4;hb=HEAD;hp=37857d98d1f3cc7d4779bc628171b2c8ec68747a;hpb=e6aaad5c5273cd814b5748b7faf3751835a37217;p=nihav.git diff --git a/nihav-core/src/codecs/mod.rs b/nihav-core/src/codecs/mod.rs index 37857d9..e009b31 100644 --- a/nihav-core/src/codecs/mod.rs +++ b/nihav-core/src/codecs/mod.rs @@ -285,9 +285,13 @@ pub const ENC_CAPS_PARAMCHANGE: u64 = 1 << 2; pub struct EncodeParameters { /// Input format. pub format: NACodecTypeInfo, - /// Time base numerator. Ignored for audio. + /// Time base numerator. + /// + /// Audio encoders generally do not need it but some may use it to set e.g. frame length, so set it to the video/container codec timebase in such case. pub tb_num: u32, - /// Time base denominator. Ignored for audio. + /// Time base denominator. + /// + /// Audio encoders generally do not need it but some may use it to set e.g. frame length, so set it to the video/container codec timebase in such case. pub tb_den: u32, /// Bitrate in bits per second. pub bitrate: u32, @@ -427,16 +431,22 @@ impl RegisteredEncoders { /// Trait for packetisers (objects that form full packets from raw stream data). pub trait NAPacketiser { + /// Provides the reference stream from the demuxer to the packetiser. + /// + /// This may be useful in cases when packetiser cannot determine stream parameters by itself. + fn attach_stream(&mut self, stream: NAStreamRef); /// Queues new raw stream data for parsing. /// /// Returns false is the internal buffer grows too large. fn add_data(&mut self, src: &[u8]) -> bool; /// Tries to retrieve stream information from the data. /// - /// Returns [`NAStream`] reference on success (with stream ID set to `id`), [`ShortData`] when there is not enough data to parse the headers and other errors in case there was an error parsing the data. + /// Returns [`NAStream`] reference on success (with stream ID set to `id`), [`ShortData`] when there is not enough data to parse the headers, [`MissingReference`] when stream parsing is not possible without reference information provided by [`attach_stream`] and other errors in case there was an error parsing the data. /// /// [`NAStream`]: ../frame/struct.NAStream.html /// [`ShortData`]: ./enum.DecoderError.html#variant.ShortData + /// [`MissingReference`]: ./enum.DecoderError.html#variant.MissingReference + /// [`attach_stream`]: ./trait.NAPacketiser.html#tymethod.attach_stream fn parse_stream(&mut self, id: u32) -> DecoderResult; /// Tries to discard junk data until the first possible packet header. ///