Skip to content

Commit

Permalink
Auto merge of #13094 - GuillaumeGomez:the_comeback, r=<try>
Browse files Browse the repository at this point in the history
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 -->
  • Loading branch information
bors-servo committed Aug 29, 2016
2 parents 9e726b4 + 04a9f1b commit 14c1a39
Show file tree
Hide file tree
Showing 13 changed files with 183 additions and 6 deletions.
3 changes: 3 additions & 0 deletions components/script/Cargo.toml
Expand Up @@ -74,6 +74,9 @@ uuid = {version = "0.3.1", features = ["v4"]}
websocket = "0.17"
xml5ever = {version = "0.1.2", features = ["unstable"]}

[dependencies.audio-video-metadata]
git = "https://github.com/GuillaumeGomez/audio-video-metadata"

[dependencies.webrender_traits]
git = "https://github.com/servo/webrender"
default_features = false
Expand Down
25 changes: 19 additions & 6 deletions components/script/dom/htmlmediaelement.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -160,12 +161,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;
}
_ => {}
}
}
}

Expand Down
1 change: 1 addition & 0 deletions components/script/lib.rs
Expand Up @@ -31,6 +31,7 @@

extern crate angle;
extern crate app_units;
extern crate audio_video_metadata;
#[allow(unused_extern_crates)]
#[macro_use]
extern crate bitflags;
Expand Down
112 changes: 112 additions & 0 deletions components/servo/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -0,0 +1,3 @@
[send-network-error-sync-events.sub.htm]
type: testharness
expected: TIMEOUT
@@ -0,0 +1,6 @@
[error.html]
type: testharness
expected: TIMEOUT
[audio.error after successful load]
expected: TIMEOUT

Expand Up @@ -7,3 +7,6 @@
[setting src attribute on autoplay video should trigger loadeddata event]
expected: NOTRUN

[setting src attribute on autoplay audio should trigger loadeddata event]
expected: NOTRUN

@@ -0,0 +1,6 @@
[event_loadeddata_noautoplay.html]
type: testharness
expected: TIMEOUT
[setting src attribute on non-autoplay audio should trigger loadeddata event]
expected: NOTRUN

@@ -0,0 +1,6 @@
[event_loadedmetadata.html]
type: testharness
expected: TIMEOUT
[setting src attribute on autoplay audio should trigger loadedmetadata event]
expected: NOTRUN

@@ -0,0 +1,6 @@
[event_loadedmetadata_noautoplay.html]
type: testharness
expected: TIMEOUT
[setting src attribute on non-autoplay audio should trigger loadedmetadata event]
expected: NOTRUN

@@ -0,0 +1,6 @@
[event_order_loadedmetadata_loadeddata.html]
type: testharness
expected: TIMEOUT
[setting src attribute on autoplay audio should trigger loadedmetadata then loadeddata event]
expected: NOTRUN

@@ -0,0 +1,6 @@
[readyState_during_loadeddata.html]
type: testharness
expected: TIMEOUT
[audio.readyState should be >= HAVE_CURRENT_DATA during loadeddata event]
expected: NOTRUN

@@ -0,0 +1,6 @@
[readyState_during_loadedmetadata.html]
type: testharness
expected: TIMEOUT
[audio.readyState should be >= HAVE_METADATA during loadedmetadata event]
expected: NOTRUN

0 comments on commit 14c1a39

Please sign in to comment.