mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Remove video-metadata from android platform
This commit is contained in:
parent
556cb99bf2
commit
1d53dae960
5 changed files with 34 additions and 219 deletions
|
@ -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"]}
|
||||
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
.PHONY: all
|
||||
all: ffmpeg
|
||||
@: # No-op to silence the "make: Nothing to be done for 'all'." message.
|
||||
|
||||
.PHONY: ffmpeg
|
||||
ffmpeg: ffmpeg-libs
|
||||
|
||||
ffmpeg-libs: ffmpeg-libs/Configure
|
||||
./ffmpeg.sh ${ANDROID_NDK}
|
||||
|
||||
ffmpeg-libs/Configure:
|
||||
wget https://www.guillaume-gomez.fr/ffmpeg-android.tar.gz
|
||||
tar -zxf ffmpeg-android.tar.gz
|
|
@ -1,187 +0,0 @@
|
|||
#!/bin/bash
|
||||
# Wrote by Guillaume Gomez <guillaume1.gomez@gmail.com> for ffmpeg
|
||||
# build for android build server
|
||||
|
||||
#####################################################################
|
||||
|
||||
# Set ANDROID_NDK_ROOT to you NDK location. For example,
|
||||
# /opt/android-ndk-r8e or /opt/android-ndk-r9. This can be done in a
|
||||
# login script. If ANDROID_NDK_ROOT is not specified, the script will
|
||||
# try to pick it up with the value of _ANDROID_NDK_ROOT below. If
|
||||
# ANDROID_NDK_ROOT is set, then the value is ignored.
|
||||
# _ANDROID_NDK="android-ndk-r8e"
|
||||
_ANDROID_NDK="android-ndk-r9"
|
||||
# _ANDROID_NDK="android-ndk-r10"
|
||||
|
||||
# Set _ANDROID_EABI to the EABI you want to use. You can find the
|
||||
# list in $ANDROID_NDK_ROOT/toolchains. This value is always used.
|
||||
# _ANDROID_EABI="x86-4.6"
|
||||
# _ANDROID_EABI="arm-linux-androideabi-4.6"
|
||||
_ANDROID_EABI="arm-linux-androideabi-4.8"
|
||||
|
||||
# Set _ANDROID_ARCH to the architecture you are building for.
|
||||
# This value is always used.
|
||||
# _ANDROID_ARCH=arch-x86
|
||||
_ANDROID_ARCH=arch-arm
|
||||
|
||||
# Set _ANDROID_API to the API you want to use. You should set it
|
||||
# to one of: android-14, android-9, android-8, android-14, android-5
|
||||
# android-4, or android-3. You can't set it to the latest (for
|
||||
# example, API-17) because the NDK does not supply the platform. At
|
||||
# Android 5.0, there will likely be another platform added (android-22?).
|
||||
# This value is always used.
|
||||
# _ANDROID_API="android-14"
|
||||
_ANDROID_API="$ANDROID_PLATFORM"
|
||||
# _ANDROID_API="android-19"
|
||||
|
||||
#####################################################################
|
||||
|
||||
# If the user did not specify the NDK location, try and pick it up.
|
||||
# We expect something like ANDROID_NDK_ROOT=/opt/android-ndk-r8e
|
||||
# or ANDROID_NDK_ROOT=/usr/local/android-ndk-r8e.
|
||||
export ANDROID_NDK_ROOT=$1
|
||||
echo $ANDROID_NDK_ROOT
|
||||
# Error checking
|
||||
# ANDROID_NDK_ROOT should always be set by the user (even when not running this script)
|
||||
# http://groups.google.com/group/android-ndk/browse_thread/thread/a998e139aca71d77
|
||||
if [ -z "$ANDROID_NDK_ROOT" ] || [ ! -d "$ANDROID_NDK_ROOT" ]; then
|
||||
echo "Error: ANDROID_NDK_ROOT is not a valid path. Please edit this script."
|
||||
# echo "$ANDROID_NDK_ROOT"
|
||||
# exit 1
|
||||
fi
|
||||
|
||||
# Error checking
|
||||
if [ ! -d "$ANDROID_NDK_ROOT/toolchains" ]; then
|
||||
echo "Error: ANDROID_NDK_ROOT/toolchains is not a valid path. Please edit this script."
|
||||
# echo "$ANDROID_NDK_ROOT/toolchains"
|
||||
# exit 1
|
||||
fi
|
||||
|
||||
# Error checking
|
||||
if [ ! -d "$ANDROID_NDK_ROOT/toolchains/$_ANDROID_EABI" ]; then
|
||||
echo "Error: ANDROID_EABI is not a valid path. Please edit this script."
|
||||
# echo "$ANDROID_NDK_ROOT/toolchains/$_ANDROID_EABI"
|
||||
# exit 1
|
||||
fi
|
||||
|
||||
#####################################################################
|
||||
|
||||
# Based on ANDROID_NDK_ROOT, try and pick up the required toolchain. We expect something like:
|
||||
# /opt/android-ndk-r83/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin
|
||||
# Once we locate the toolchain, we add it to the PATH. Note: this is the 'hard way' of
|
||||
# doing things according to the NDK documentation for Ice Cream Sandwich.
|
||||
# https://android.googlesource.com/platform/ndk/+/ics-mr0/docs/STANDALONE-TOOLCHAIN.html
|
||||
|
||||
ANDROID_TOOLCHAIN=""
|
||||
for host in "linux-x86_64" "linux-x86" "darwin-x86_64" "darwin-x86"
|
||||
do
|
||||
if [ -d "$ANDROID_NDK_ROOT/toolchains/$_ANDROID_EABI/prebuilt/$host/bin" ]; then
|
||||
ANDROID_TOOLCHAIN="$ANDROID_NDK_ROOT/toolchains/$_ANDROID_EABI/prebuilt/$host/bin"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Error checking
|
||||
if [ -z "$ANDROID_TOOLCHAIN" ] || [ ! -d "$ANDROID_TOOLCHAIN" ]; then
|
||||
echo "Error: ANDROID_TOOLCHAIN is not valid. Please edit this script."
|
||||
# echo "$ANDROID_TOOLCHAIN"
|
||||
# exit 1
|
||||
fi
|
||||
|
||||
case $_ANDROID_ARCH in
|
||||
arch-arm)
|
||||
ANDROID_TOOLS="arm-linux-androideabi-gcc arm-linux-androideabi-ranlib arm-linux-androideabi-ld"
|
||||
;;
|
||||
arch-x86)
|
||||
ANDROID_TOOLS="i686-linux-android-gcc i686-linux-android-ranlib i686-linux-android-ld"
|
||||
;;
|
||||
*)
|
||||
echo "ERROR ERROR ERROR"
|
||||
;;
|
||||
esac
|
||||
|
||||
for tool in $ANDROID_TOOLS
|
||||
do
|
||||
# Error checking
|
||||
if [ ! -e "$ANDROID_TOOLCHAIN/$tool" ]; then
|
||||
echo "Error: Failed to find $tool. Please edit this script."
|
||||
# echo "$ANDROID_TOOLCHAIN/$tool"
|
||||
# exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# Only modify/export PATH if ANDROID_TOOLCHAIN good
|
||||
if [ ! -z "$ANDROID_TOOLCHAIN" ]; then
|
||||
export ANDROID_TOOLCHAIN="$ANDROID_TOOLCHAIN"
|
||||
export PATH="$ANDROID_TOOLCHAIN":"$PATH"
|
||||
fi
|
||||
|
||||
#####################################################################
|
||||
|
||||
# For the Android SYSROOT. Can be used on the command line with --sysroot
|
||||
# https://android.googlesource.com/platform/ndk/+/ics-mr0/docs/STANDALONE-TOOLCHAIN.html
|
||||
export ANDROID_SYSROOT="$ANDROID_NDK_ROOT/platforms/$_ANDROID_API/$_ANDROID_ARCH"
|
||||
export SYSROOT="$ANDROID_SYSROOT"
|
||||
export NDK_SYSROOT="$ANDROID_SYSROOT"
|
||||
|
||||
# Error checking
|
||||
if [ -z "$ANDROID_SYSROOT" ] || [ ! -d "$ANDROID_SYSROOT" ]; then
|
||||
echo "Error: ANDROID_SYSROOT is not valid. Please edit this script."
|
||||
# echo "$ANDROID_SYSROOT"
|
||||
# exit 1
|
||||
fi
|
||||
|
||||
#####################################################################
|
||||
|
||||
#####################################################################
|
||||
|
||||
# Most of these should be OK (MACHINE, SYSTEM, ARCH). RELEASE is ignored.
|
||||
export MACHINE=armv7
|
||||
export RELEASE=2.6.37
|
||||
export SYSTEM=android
|
||||
export ARCH=arm
|
||||
export CROSS_COMPILE="arm-linux-androideabi-"
|
||||
|
||||
if [ "$_ANDROID_ARCH" == "arch-x86" ]; then
|
||||
export MACHINE=i686
|
||||
export RELEASE=2.6.37
|
||||
export SYSTEM=android
|
||||
export ARCH=x86
|
||||
export CROSS_COMPILE="i686-linux-android-"
|
||||
fi
|
||||
|
||||
# For the Android toolchain
|
||||
# https://android.googlesource.com/platform/ndk/+/ics-mr0/docs/STANDALONE-TOOLCHAIN.html
|
||||
export ANDROID_SYSROOT="$ANDROID_NDK_ROOT/platforms/$_ANDROID_API/$_ANDROID_ARCH"
|
||||
export SYSROOT="$ANDROID_SYSROOT"
|
||||
export NDK_SYSROOT="$ANDROID_SYSROOT"
|
||||
export ANDROID_NDK_SYSROOT="$ANDROID_SYSROOT"
|
||||
export ANDROID_API="$_ANDROID_API"
|
||||
|
||||
export HOSTCC=gcc
|
||||
|
||||
VERBOSE=1
|
||||
if [ ! -z "$VERBOSE" ] && [ "$VERBOSE" != "0" ]; then
|
||||
echo "ANDROID_NDK_ROOT: $ANDROID_NDK_ROOT"
|
||||
echo "ANDROID_ARCH: $_ANDROID_ARCH"
|
||||
echo "ANDROID_EABI: $_ANDROID_EABI"
|
||||
echo "ANDROID_API: $ANDROID_API"
|
||||
echo "ANDROID_SYSROOT: $ANDROID_SYSROOT"
|
||||
echo "ANDROID_TOOLCHAIN: $ANDROID_TOOLCHAIN"
|
||||
echo "FIPS_SIG: $FIPS_SIG"
|
||||
echo "CROSS_COMPILE: $CROSS_COMPILE"
|
||||
echo "ANDROID_DEV: $ANDROID_DEV"
|
||||
fi
|
||||
|
||||
cd ffmpeg-HEAD-aa86ccc.android
|
||||
make distclean
|
||||
./configure --enable-shared --disable-static --disable-programs
|
||||
make 2>&1
|
||||
# We give access to header files.
|
||||
ln -s `pwd`/libavcodec/ "$ANDROID_NDK_ROOT/toolchains/$_ANDROID_EABI/prebuilt/$host/include/"
|
||||
ln -s `pwd`/libavformat/ "$ANDROID_NDK_ROOT/toolchains/$_ANDROID_EABI/prebuilt/$host/include/"
|
||||
ln -s `pwd`/libavutil/ "$ANDROID_NDK_ROOT/toolchains/$_ANDROID_EABI/prebuilt/$host/include/"
|
||||
# We give access to dynamic libraries.
|
||||
ln -s `pwd`/libavcodec/libavcodec.so "$ANDROID_NDK_ROOT/toolchains/$_ANDROID_EABI/prebuilt/$host/"
|
||||
ln -s `pwd`/libavcodec/libavutil.so "$ANDROID_NDK_ROOT/toolchains/$_ANDROID_EABI/prebuilt/$host/"
|
||||
ln -s `pwd`/libavcodec/libavformat.so "$ANDROID_NDK_ROOT/toolchains/$_ANDROID_EABI/prebuilt/$host/"
|
Loading…
Add table
Add a link
Reference in a new issue