Skip to content

Conversation

@alfredoyang
Copy link
Contributor

Parse fragment_duration for https://bugzilla.mozilla.org/show_bug.cgi?id=1304254.

Test will be added in another PR later.

Copy link
Contributor

@rillian rillian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. r=m with comments addressed.

return MP4PARSE_OK;
match context.mvex {
Some(_) => {},
None => return MP4PARSE_OK,
Copy link
Contributor

@rillian rillian Sep 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When taking action on a single branch of an Option match, I think is_none() is better. The Some line doesn't do anything useful here.

if context.mvex.is_none() {
    return MP4PARSE_OK;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


fn read_mvex<T: Read>(src: &mut BMFFBox<T>) -> Result<MovieExtendsBox> {
let mut iter = src.box_iter();
let mut duration: Option<u64> = None;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compiler should be able to infer this type from the signature of read_mehd so you only need this if you especially want to document it locally. Up to you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

})
}

fn read_mehd<T: Read>(src: &mut BMFFBox<T>) -> Result<Option<u64>> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mehd always has a fragment duration, so you don't need to return an Option here. A simpler Result<u64> or Result<MediaScaledTime> would work. This complicates the way you update duration, but I think it's better to have a temporary there and keep the semantics of the function signature correct.

e.g.

let mut fragment_duration = None;
...
            let duration = try!(read_mehd(&mut b));
            fragment_duration = Some(duration);
...
Ok(MovieExtendsBox {
    fragment_duration: fragment_duration,
})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

The duration of a fragmented file can be found if MovieExtendsHeaderBox
is exist. Add mp4parse_get_fragment_info() to retrieve information in
MovieExtendsBox.
@alfredoyang
Copy link
Contributor Author

Should I update parser to gecko in the same bug? Because there is another gecko patch depending on this in the same bug.

@rillian rillian merged commit 67addd3 into mozilla:master Sep 23, 2016
@rillian
Copy link
Contributor

rillian commented Sep 23, 2016

If you need these changes in gecko we can bump the in-tree version on the bugzilla side. You can do it, or I can, I've had lots of practice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants