Bug 1267887 - Update script for mp4parse v0.4.0. r=kinetik draft
authorRalph Giles <giles@mozilla.com>
Thu, 23 Jun 2016 09:38:19 -0700
changeset 382112 eba90c68e5d8ea3bc2ee266c084ea282bccd8f35
parent 382111 9c409138bfb64be5af9bbde2854c4c65bfdf6080
child 382113 4d4a010fe15bf416f9270495468d75af47e64947
push id21620
push userbmo:giles@thaumas.net
push dateTue, 28 Jun 2016 22:04:53 +0000
reviewerskinetik
bugs1267887
milestone50.0a1
Bug 1267887 - Update script for mp4parse v0.4.0. r=kinetik Remove patches for issues which are fixed upstream. Update the script to generate the C api header file by running `cargo build` before copying it. Update byteorder mod-ification patch to apply to 0.5.3. MozReview-Commit-ID: 8FDpbcSWt1o
media/libstagefright/binding/byteorder-mod.patch
media/libstagefright/binding/mp4parse-thread.patch
media/libstagefright/binding/update-rust.sh
--- a/media/libstagefright/binding/byteorder-mod.patch
+++ b/media/libstagefright/binding/byteorder-mod.patch
@@ -1,39 +1,55 @@
 diff --git a/media/libstagefright/binding/mp4parse/byteorder/mod.rs b/media/libstagefright/binding/mp4parse/byteorder/mod.rs
-index 7eea1e3..8a108cf 100644
+index a25bab6..13db30a 100644
 --- a/media/libstagefright/binding/mp4parse/byteorder/mod.rs
 +++ b/media/libstagefright/binding/mp4parse/byteorder/mod.rs
-@@ -36,7 +36,6 @@ assert_eq!(wtr, vec![5, 2, 0, 3]);
+@@ -36,24 +36,17 @@ assert_eq!(wtr, vec![5, 2, 0, 3]);
  ```
  */
  
 -#![crate_name = "byteorder"]
  #![doc(html_root_url = "http://burntsushi.net/rustdoc/byteorder")]
  
+-#![cfg_attr(not(feature = "std"), no_std)]
+-
  #![deny(missing_docs)]
-@@ -45,10 +44,11 @@ use std::mem::transmute;
- use std::ptr::copy_nonoverlapping;
  
- #[cfg(not(feature = "no-std"))]
--pub use new::{ReadBytesExt, WriteBytesExt, Error, Result};
-+pub use byteorder::new::{ReadBytesExt, WriteBytesExt, Error, Result};
+-#[cfg(feature = "std")]
+-extern crate core;
+-
+-use core::mem::transmute;
+-use core::ptr::copy_nonoverlapping;
++use std::mem::transmute;
++use std::ptr::copy_nonoverlapping;
  
- #[cfg(not(feature = "no-std"))]
+-#[cfg(feature = "std")]
+-pub use new::{ReadBytesExt, WriteBytesExt};
++pub use byteorder::new::{ReadBytesExt, WriteBytesExt};
+ 
+-#[cfg(feature = "std")]
 -mod new;
-+// Re-export new so gecko can build us as a mod intead of a crate.
++// Re-export new so gecko can build us as a mod instead of a crate.
 +pub mod new;
  
  #[inline]
  fn extend_sign(val: u64, nbytes: usize) -> i64 {
+@@ -300,7 +293,7 @@ pub type NativeEndian = BigEndian;
+ 
+ macro_rules! read_num_bytes {
+     ($ty:ty, $size:expr, $src:expr, $which:ident) => ({
+-        assert!($size == ::core::mem::size_of::<$ty>());
++        assert!($size == ::std::mem::size_of::<$ty>());
+         assert!($size <= $src.len());
+         let mut data: $ty = 0;
+         unsafe {
 diff --git a/media/libstagefright/binding/mp4parse/byteorder/new.rs b/media/libstagefright/binding/mp4parse/byteorder/new.rs
-index 54ee6a7..4efcbc3 100644
+index b5f3770..b32f97b 100644
 --- a/media/libstagefright/binding/mp4parse/byteorder/new.rs
 +++ b/media/libstagefright/binding/mp4parse/byteorder/new.rs
-@@ -3,7 +3,7 @@ use std::fmt;
- use std::io;
- use std::result;
+@@ -1,6 +1,6 @@
+ use std::io::{self, Result};
  
 -use ByteOrder;
 +use byteorder::ByteOrder;
  
- /// A short-hand for `result::Result<T, byteorder::Error>`.
- pub type Result<T> = result::Result<T, Error>;
+ /// Extends `Read` with methods for reading numbers. (For `std::io`.)
+ ///
deleted file mode 100644
--- a/media/libstagefright/binding/mp4parse-thread.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-diff --git a/media/libstagefright/binding/mp4parse/capi.rs b/media/libstagefright/binding/mp4parse/capi.rs
-index 6e8c6f9..ed7e566 100644
---- a/media/libstagefright/binding/mp4parse/capi.rs
-+++ b/media/libstagefright/binding/mp4parse/capi.rs
-@@ -174,22 +174,21 @@ pub unsafe extern "C" fn mp4parse_get_track_info(context: *mut MediaContext, tra
-         return MP4PARSE_ERROR_INVALID;
-     }
- 
--    std::thread::spawn(move || {
--        let track = &context.tracks[track_index];
--        let empty_duration = if track.empty_duration.is_some() {
--            media_time_to_ms(track.empty_duration.unwrap(), context.timescale.unwrap())
--        } else {
--            0
--        };
--        info.media_time = if track.media_time.is_some() {
--            track_time_to_ms(track.media_time.unwrap(), track.timescale.unwrap()) as i64 - empty_duration as i64
--        } else {
--            0
--        };
--        info.duration = track_time_to_ms(track.duration.unwrap(), track.timescale.unwrap());
--        info.track_id = track.track_id.unwrap();
--        MP4PARSE_OK
--    }).join().unwrap_or(MP4PARSE_ERROR_INVALID)
-+    let track = &context.tracks[track_index];
-+    let empty_duration = if track.empty_duration.is_some() {
-+        media_time_to_ms(track.empty_duration.unwrap(), context.timescale.unwrap())
-+    } else {
-+        0
-+    };
-+    info.media_time = if track.media_time.is_some() {
-+        track_time_to_ms(track.media_time.unwrap(), track.timescale.unwrap()) as i64 - empty_duration as i64
-+    } else {
-+        0
-+    };
-+    info.duration = track_time_to_ms(track.duration.unwrap(), track.timescale.unwrap());
-+    info.track_id = track.track_id.unwrap();
-+
-+    MP4PARSE_OK
- }
- 
- #[no_mangle]
--- a/media/libstagefright/binding/update-rust.sh
+++ b/media/libstagefright/binding/update-rust.sh
@@ -1,42 +1,43 @@
 #!/bin/sh
 # Script to update mp4parse-rust sources to latest upstream
 
 # Default version.
-VER=v0.2.1
+VER=v0.4.0
 
 # Accept version or commit from the command line.
 if test -n "$1"; then
   VER=$1
 fi
 
 echo "Fetching sources..."
 rm -rf _upstream
 git clone https://github.com/mozilla/mp4parse-rust _upstream/mp4parse
 pushd _upstream/mp4parse
 git checkout ${VER}
+echo "Constructing C api header..."
+cargo build
 popd
 rm -rf mp4parse
 mkdir mp4parse
 cp _upstream/mp4parse/src/*.rs mp4parse/
 cp _upstream/mp4parse/include/mp4parse.h include/
 
 # TODO: download deps from crates.io.
 
 git clone https://github.com/BurntSushi/byteorder _upstream/byteorder
 pushd _upstream/byteorder
-git checkout 0.4.2
+git checkout 0.5.3
 popd
 rm -rf mp4parse/byteorder
 mkdir mp4parse/byteorder
 cp _upstream/byteorder/src/lib.rs mp4parse/byteorder/mod.rs
 cp _upstream/byteorder/src/new.rs mp4parse/byteorder/new.rs
 
 echo "Applying patches..."
 patch -p4 < byteorder-mod.patch
 patch -p4 < mp4parse-mod.patch
-patch -p4 < mp4parse-thread.patch
 
 echo "Cleaning up..."
 rm -rf _upstream
 
 echo "Updated to ${VER}."