]> git.nihav.org Git - nihav.git/blobdiff - nihav-core/src/codecs/mod.rs
Acorn Super Moving Blocks Decoder
[nihav.git] / nihav-core / src / codecs / mod.rs
index 04d480a81db0d02766ebed9014ff503bb67f6c85..80e2da813ff4084ec814eb570ac0726b4258b2c3 100644 (file)
@@ -203,9 +203,10 @@ impl RegisteredMTDecoders {
 }
 
 /// Frame skipping mode for decoders.
-#[derive(Clone,Copy,PartialEq,Debug)]
+#[derive(Clone,Copy,PartialEq,Debug,Default)]
 pub enum FrameSkipMode {
     /// Decode all frames.
+    #[default]
     None,
     /// Decode all key frames.
     KeyframesOnly,
@@ -213,12 +214,6 @@ pub enum FrameSkipMode {
     IntraOnly,
 }
 
-impl Default for FrameSkipMode {
-    fn default() -> Self {
-        FrameSkipMode::None
-    }
-}
-
 impl FromStr for FrameSkipMode {
     type Err = DecoderError;
 
@@ -432,16 +427,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<NAStreamRef>;
     /// Tries to discard junk data until the first possible packet header.
     ///