Git Product home page Git Product logo

ebml-iterable's People

Contributors

austinleroy avatar wicpar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ebml-iterable's Issues

Better streaming support

Hi, I'm trying to use this crate to remux an ffmpeg output to add the Clues elements, my project requires that the output is streamed over HTTP so I need to be able to send stuff out even with un-closed tags, at the moment by reading the code my understanding is that everything is written to the destination only when flush is called or there are no open tags, problem with that is that the public flush() of the TagWriter also closes the tags ending the stream prematurely which make it impossible to send uncompleted data to the browser.

would it be possible to add a dirty flush or something like that?

`ToolError` is unnameable from outside

CorruptedTagData {
///
/// The id of the corrupted tag.
///
tag_id: u64,
///
/// An error describing why the data is corrupted.
///
problem: ToolError,
},

One of the variants of TagIteratorError uses the ToolError type, but the latter is not exported, making it "unnamable" from outside. This is the kind of situation described in rust-lang/rust#34537. I'd like to access data stored in this error, but there's no way to extract it.

Can you consider exporting ToolError (and maybe reexport it in webm-iterable)?

Incorrect iteration over large elements

I'm having trouble reading back some data written with the library (mkv in this case). This seems to happen if one element exceeds the default buffer size of the reader; and this element is not the last element in its parent master element; and that master element is towards the end of the file.

Reproduce with this minimize program:

    use ebml_iterable::specs::{ebml_specification, TagDataType, Master};
    
    #[ebml_specification]
    #[derive(Clone, Debug, PartialEq)]
    pub enum Trial {
        #[id(0x18538067)]
        #[data_type(TagDataType::Master)]
        Segment,

        #[id(0x1F43B675)]
        #[data_type(TagDataType::Master)]
        Cluster,

        #[id(0x4100)]
        #[data_type(TagDataType::UnsignedInt)]
        Count,

        #[id(0xa1)]
        #[data_type(TagDataType::Binary)]
        Block,
    }

    #[test]
    pub fn roundtrip() {
        use ebml_iterable::{TagIterator, TagWriter};
        use std::io::Cursor;
        let mut dest = Cursor::new(Vec::new());
        let mut writer = TagWriter::new(&mut dest);

        writer.write(&Trial::Segment(Master::Start)).expect("Error writing tag");
        writer.write(&Trial::Cluster(Master::Start)).expect("Error writing tag");
        // Why 0x10001 specifically? This exceeds the default buffer length (0x10000)?!
        writer.write_raw(0xa1, &[0x00; 0x10001]).expect("Error writing tag");
        writer.write(&Trial::Count(0x00)).expect("Error writing tag");
        writer.write(&Trial::Cluster(Master::End)).expect("Error writing tag");
        writer.write(&Trial::Segment(Master::End)).expect("Error writing tag");
        drop(writer);

        dest.set_position(0);
        let iter = TagIterator::<_, Trial>::new(dest, &[]);

        let tags: Vec<_> = iter.into_iter().collect();
        assert_eq!(tags.len(), 4+2, "Reading every tag that was written");
   }

While scouting code I found one suspicious line:

let read_result = self.ensure_data_read(self.internal_buffer_position);

If I understand correctly this tries to read at least self.internal_buffer_position more bytes of data. It's also called after that 0xa1 element and the internal buffer position is 65555 at that point. This will surely result in fully reading the file, then getting an empty read, and then returning Ok(false)—which in turn is interpreted as being done even though the tag was not finished.

To trigger this failure condition the large element must end at a full buffer, exactly, and at the same time less than a full buffer worth of data must be remaining in the file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.