pub struct FileDecoder { /* private fields */ }Expand description
FLV file decoder.
See the specification about the format of FLV file.
Implementations§
Source§impl FileDecoder
impl FileDecoder
Sourcepub fn new() -> Self
pub fn new() -> Self
Makes a new FileDecoder instance.
Examples found in repository?
examples/parse.rs (line 15)
11fn main() -> Result<(), MainError> {
12 let stdin = std::io::stdin();
13 let mut input = stdin.lock();
14 let mut buf = ReadBuf::new(vec![0; 1024]);
15 let mut decoder = FileDecoder::new();
16 let mut is_header_shown = false;
17
18 while !buf.stream_state().is_eos() {
19 track!(buf.fill(&mut input))?;
20 track!(decoder.decode_from_read_buf(&mut buf))?;
21 if let Some(h) = decoder.header() {
22 if !is_header_shown {
23 println!("[header]");
24 println!("has_audio = {}", h.has_audio);
25 println!("has_video = {}", h.has_video);
26 println!("");
27 is_header_shown = true;
28 }
29 }
30 if decoder.is_idle() {
31 let tag = track!(decoder.finish_decoding())?;
32 println!("[[tags]]");
33 println!("type = {:?}", tag_type(&tag));
34 println!("timestamp = {}", tag.timestamp().value());
35 println!("stream_id = {}", tag.stream_id().value());
36 println!("");
37 }
38 }
39
40 Ok(())
41}Sourcepub fn header(&self) -> Option<&Header>
pub fn header(&self) -> Option<&Header>
Returns the header of the FLV file.
If the header has not been decoded yet, it will return None.
Examples found in repository?
examples/parse.rs (line 21)
11fn main() -> Result<(), MainError> {
12 let stdin = std::io::stdin();
13 let mut input = stdin.lock();
14 let mut buf = ReadBuf::new(vec![0; 1024]);
15 let mut decoder = FileDecoder::new();
16 let mut is_header_shown = false;
17
18 while !buf.stream_state().is_eos() {
19 track!(buf.fill(&mut input))?;
20 track!(decoder.decode_from_read_buf(&mut buf))?;
21 if let Some(h) = decoder.header() {
22 if !is_header_shown {
23 println!("[header]");
24 println!("has_audio = {}", h.has_audio);
25 println!("has_video = {}", h.has_video);
26 println!("");
27 is_header_shown = true;
28 }
29 }
30 if decoder.is_idle() {
31 let tag = track!(decoder.finish_decoding())?;
32 println!("[[tags]]");
33 println!("type = {:?}", tag_type(&tag));
34 println!("timestamp = {}", tag.timestamp().value());
35 println!("stream_id = {}", tag.stream_id().value());
36 println!("");
37 }
38 }
39
40 Ok(())
41}Trait Implementations§
Source§impl Debug for FileDecoder
impl Debug for FileDecoder
Source§impl Decode for FileDecoder
impl Decode for FileDecoder
Source§fn decode(&mut self, buf: &[u8], eos: Eos) -> Result<usize>
fn decode(&mut self, buf: &[u8], eos: Eos) -> Result<usize>
Consumes the given buffer (a part of a byte sequence), and proceeds the decoding process. Read more
Source§fn finish_decoding(&mut self) -> Result<Self::Item>
fn finish_decoding(&mut self) -> Result<Self::Item>
Finishes the current decoding process and returns the decoded item. Read more
Source§fn is_idle(&self) -> bool
fn is_idle(&self) -> bool
Returns
true if there are no items to be decoded by the decoder
at the next invocation of decode method, otherwise false. Read moreSource§fn requiring_bytes(&self) -> ByteCount
fn requiring_bytes(&self) -> ByteCount
Returns the lower bound of the number of bytes needed to decode the next item. Read more
Source§impl Default for FileDecoder
impl Default for FileDecoder
Source§fn default() -> FileDecoder
fn default() -> FileDecoder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for FileDecoder
impl RefUnwindSafe for FileDecoder
impl Send for FileDecoder
impl Sync for FileDecoder
impl Unpin for FileDecoder
impl UnwindSafe for FileDecoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> DecodeExt for Twhere
T: Decode,
impl<T> DecodeExt for Twhere
T: Decode,
Source§fn map<T, F>(self, f: F) -> Map<Self, T, F>
fn map<T, F>(self, f: F) -> Map<Self, T, F>
Creates a decoder that converts decoded values by calling the given function. Read more
Source§fn try_map<T, E, F>(self, f: F) -> TryMap<Self, T, E, F>
fn try_map<T, E, F>(self, f: F) -> TryMap<Self, T, E, F>
Creates a decoder that tries to convert decoded values by calling the given function. Read more
Source§fn map_err<E, F>(self, f: F) -> MapErr<Self, E, F>
fn map_err<E, F>(self, f: F) -> MapErr<Self, E, F>
Creates a decoder for modifying decoding errors produced by
self. Read moreSource§fn and_then<D, F>(self, f: F) -> AndThen<Self, D, F>
fn and_then<D, F>(self, f: F) -> AndThen<Self, D, F>
Creates a decoder that enables conditional decoding. Read more
Source§fn collect<T>(self) -> Collect<Self, T>
fn collect<T>(self) -> Collect<Self, T>
Creates a decoder for collecting decoded items. Read more
Source§fn length(self, expected_bytes: u64) -> Length<Self>
fn length(self, expected_bytes: u64) -> Length<Self>
Creates a decoder that consumes the specified number of bytes exactly. Read more
Source§fn omit(self, do_omit: bool) -> Omittable<Self>
fn omit(self, do_omit: bool) -> Omittable<Self>
Creates a decoder that will omit decoding items if
do_omit = true is specified. Read moreSource§fn max_bytes(self, bytes: u64) -> MaxBytes<Self>
fn max_bytes(self, bytes: u64) -> MaxBytes<Self>
Creates a decoder that will fail if the number of consumed bytes exceeds
bytes. Read moreSource§fn chain<T>(self, other: T) -> TupleDecoder<(Self, T)>where
T: Decode,
fn chain<T>(self, other: T) -> TupleDecoder<(Self, T)>where
T: Decode,
Takes two decoders and creates a new decoder that decodes both items in sequence. Read more
Source§fn slice(self) -> Slice<Self>
fn slice(self) -> Slice<Self>
Creates a decoder that makes it possible to slice the input byte sequence in arbitrary units. Read more
Source§fn peekable(self) -> Peekable<Self>
fn peekable(self) -> Peekable<Self>
Creates a decoder that enables to peek decoded items before calling
finish_decoding method. Read more