Remove video-metadata from android platform

This commit is contained in:
Guillaume Gomez 2016-07-26 15:17:06 +02:00
parent 556cb99bf2
commit 1d53dae960
5 changed files with 34 additions and 219 deletions

View file

@ -17,6 +17,9 @@ debugmozjs = ['js/debugmozjs']
[target.'cfg(any(target_os = "macos", target_os = "linux"))'.dependencies]
tinyfiledialogs = {git = "https://github.com/jdm/tinyfiledialogs"}
[target.'cfg(not(target_os = "android"))'.dependencies]
video-metadata = {git = "https://github.com/GuillaumeGomez/video-metadata-rs"}
[dependencies]
angle = {git = "https://github.com/servo/angle", branch = "servo"}
app_units = "0.2.5"
@ -67,7 +70,6 @@ time = "0.1.12"
url = {version = "1.0.0", features = ["heap_size", "query_encoding"]}
util = {path = "../util"}
uuid = {version = "0.2", features = ["v4"]}
video-metadata = {git = "https://github.com/GuillaumeGomez/video-metadata-rs"}
websocket = "0.17"
xml5ever = {version = "0.1.2", features = ["unstable"]}

View file

@ -89,24 +89,7 @@ impl AsyncResponseListener for HTMLMediaElementContext {
// https://html.spec.whatwg.org/multipage/#media-data-processing-steps-list
// => "Once enough of the media data has been fetched to determine the duration..."
if !self.have_metadata {
match video_metadata::get_format_from_slice(&self.data) {
Ok(meta) => {
let dur = meta.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.size.width,
height: meta.size.height,
video: meta.video,
audio: meta.audio,
});
// Step 6
elem.change_ready_state(HAVE_METADATA);
self.have_metadata = true;
}
_ => {}
}
self.check_metadata(&elem);
} else {
elem.change_ready_state(HAVE_CURRENT_DATA);
}
@ -176,6 +159,35 @@ impl HTMLMediaElementContext {
ignore_response: false,
}
}
#[cfg(not(target_os = "android"))]
fn check_metadata(&mut self, elem: &HTMLMediaElement) {
match video_metadata::get_format_from_slice(&self.data) {
Ok(meta) => {
let dur = meta.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.size.width,
height: meta.size.height,
video: meta.video,
audio: meta.audio,
});
// Step 6
elem.change_ready_state(HAVE_METADATA);
self.have_metadata = true;
}
_ => {}
}
}
#[cfg(target_os = "android")]
fn check_metadata(&mut self, _elem: &HTMLMediaElement) {
// Step 6.
elem.change_ready_state(HAVE_METADATA);
self.have_metadata = true;
}
}
#[derive(JSTraceable, HeapSizeOf)]

View file

@ -88,6 +88,7 @@ extern crate url;
#[macro_use]
extern crate util;
extern crate uuid;
#[cfg(not(target_os = "android"))]
extern crate video_metadata;
extern crate webrender_traits;
extern crate websocket;