Auto merge of #13094 - GuillaumeGomez:the_comeback, r=KiChjang

Put back video metadata

I updated the `video-metadata-rs` crate: now, no more ffmpeg, just pure rust. The webm format isn't checked yet.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13094)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-09-09 16:28:34 -05:00 committed by GitHub
commit 142578f2e9
13 changed files with 158 additions and 6 deletions

View file

@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use audio_video_metadata;
use document_loader::LoadType;
use dom::attr::Attr;
use dom::bindings::cell::DOMRefCell;
@ -159,12 +160,24 @@ impl HTMLMediaElementContext {
}
fn check_metadata(&mut self, elem: &HTMLMediaElement) {
// Step 6.
//
// TODO: Properly implement once we have figured out the build and
// licensing ffmpeg issues.
elem.change_ready_state(HAVE_METADATA);
self.have_metadata = true;
match audio_video_metadata::get_format_from_slice(&self.data) {
Ok(audio_video_metadata::Metadata::Video(meta)) => {
let dur = meta.audio.duration.unwrap_or(::std::time::Duration::new(0, 0));
*elem.video.borrow_mut() = Some(VideoMedia {
format: format!("{:?}", meta.format),
duration: Duration::seconds(dur.as_secs() as i64) +
Duration::nanoseconds(dur.subsec_nanos() as i64),
width: meta.dimensions.width,
height: meta.dimensions.height,
video: meta.video.unwrap_or("".to_owned()),
audio: meta.audio.audio,
});
// Step 6
elem.change_ready_state(HAVE_METADATA);
self.have_metadata = true;
}
_ => {}
}
}
}