From c969627510c9cb2718e5a906a3908e90b8e14417 Mon Sep 17 00:00:00 2001 From: Tangent 128 Date: Mon, 7 Aug 2017 01:03:20 -0400 Subject: [PATCH] Extend stub WebM structure --- src/bin/stub.rs | 3 +++ src/webm.rs | 12 +++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/bin/stub.rs b/src/bin/stub.rs index 509ebe8..3b26f35 100644 --- a/src/bin/stub.rs +++ b/src/bin/stub.rs @@ -7,6 +7,9 @@ pub fn main() { let mut cursor = Cursor::new(Vec::new()); encode_webm_element(WebmElement::EbmlHead, &mut cursor).unwrap(); + encode_webm_element(WebmElement::Segment, &mut cursor).unwrap(); + + encode_webm_element(WebmElement::Cluster, &mut cursor).unwrap(); stdout().write_all(&cursor.get_ref()).unwrap(); } diff --git a/src/webm.rs b/src/webm.rs index 5330145..b2f134c 100644 --- a/src/webm.rs +++ b/src/webm.rs @@ -82,11 +82,13 @@ fn decode_simple_block(bytes: &[u8]) -> Result { pub fn encode_webm_element(element: WebmElement, output: &mut T) -> IoResult<()> { match element { - WebmElement::EbmlHead => { - encode_element(EBML_HEAD_ID, output, |output| { - encode_string(DOC_TYPE_ID, "webm", output) - }) - } + WebmElement::EbmlHead => encode_element(EBML_HEAD_ID, output, |output| { + encode_string(DOC_TYPE_ID, "webm", output) + }), + WebmElement::Segment => encode_tag_header(SEGMENT_ID, Varint::Unknown, output), + WebmElement::SeekHead => Ok(()), + WebmElement::Cues => Ok(()), + WebmElement::Cluster => encode_tag_header(CLUSTER_ID, Varint::Unknown, output), _ => Err(IoError::new(ErrorKind::InvalidInput, WriteError::OutOfRange)) } }