mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Implement video-metadata check
This commit is contained in:
parent
20ab47cb1a
commit
1d9d77ee78
3 changed files with 36 additions and 6 deletions
|
@ -90,7 +90,7 @@ pacman -Su
|
|||
pacman -Sy git mingw-w64-x86_64-toolchain mingw-w64-x86_64-freetype \
|
||||
mingw-w64-x86_64-icu mingw-w64-x86_64-nspr mingw-w64-x86_64-ca-certificates \
|
||||
mingw-w64-x86_64-expat mingw-w64-x86_64-cmake tar diffutils patch \
|
||||
patchutils make python2-setuptools
|
||||
patchutils make python2-setuptools mingw-w64-x86_64-ffmpeg
|
||||
export GCC_URL=http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-gcc
|
||||
export GCC_EXT=5.4.0-1-any.pkg.tar.xz
|
||||
pacman -U --noconfirm $GCC_URL-$GCC_EXT $GCC_URL-ada-$GCC_EXT \
|
||||
|
|
|
@ -91,6 +91,7 @@ use style::element_state::*;
|
|||
use style::properties::PropertyDeclarationBlock;
|
||||
use style::selector_impl::{PseudoElement, ElementSnapshot};
|
||||
use style::values::specified::Length;
|
||||
use time::Duration;
|
||||
use url::Origin as UrlOrigin;
|
||||
use url::Url;
|
||||
use uuid::Uuid;
|
||||
|
@ -109,6 +110,8 @@ no_jsmanaged_fields!(EncodingRef);
|
|||
|
||||
no_jsmanaged_fields!(Reflector);
|
||||
|
||||
no_jsmanaged_fields!(Duration);
|
||||
|
||||
/// Trace a `JSVal`.
|
||||
pub fn trace_jsval(tracer: *mut JSTracer, description: &str, val: &Heap<JSVal>) {
|
||||
unsafe {
|
||||
|
|
|
@ -35,6 +35,7 @@ use string_cache::Atom;
|
|||
use task_source::TaskSource;
|
||||
use time::{self, Timespec, Duration};
|
||||
use url::Url;
|
||||
use video_metadata;
|
||||
|
||||
struct HTMLMediaElementContext {
|
||||
/// The element that initiated the request.
|
||||
|
@ -88,11 +89,24 @@ 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 {
|
||||
//TODO: actually check if the payload contains the full 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;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
} else {
|
||||
elem.change_ready_state(HAVE_CURRENT_DATA);
|
||||
}
|
||||
|
@ -164,6 +178,17 @@ impl HTMLMediaElementContext {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(JSTraceable, HeapSizeOf)]
|
||||
pub struct VideoMedia {
|
||||
format: String,
|
||||
#[ignore_heap_size_of = "defined in time"]
|
||||
duration: Duration,
|
||||
width: u32,
|
||||
height: u32,
|
||||
video: String,
|
||||
audio: Option<String>,
|
||||
}
|
||||
|
||||
#[dom_struct]
|
||||
pub struct HTMLMediaElement {
|
||||
htmlelement: HTMLElement,
|
||||
|
@ -175,6 +200,7 @@ pub struct HTMLMediaElement {
|
|||
error: MutNullableHeap<JS<MediaError>>,
|
||||
paused: Cell<bool>,
|
||||
autoplaying: Cell<bool>,
|
||||
video: DOMRefCell<Option<VideoMedia>>,
|
||||
}
|
||||
|
||||
impl HTMLMediaElement {
|
||||
|
@ -192,6 +218,7 @@ impl HTMLMediaElement {
|
|||
error: Default::default(),
|
||||
paused: Cell::new(true),
|
||||
autoplaying: Cell::new(true),
|
||||
video: DOMRefCell::new(None),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue