Bug 1275812 - Experiment with exporting track mime-type. r=kinetik, a=RyanVM to land on a CLOSED TREE
☠☠ backed out by 8aa94e6a0c5c ☠ ☠
authorRalph Giles <giles@mozilla.com>
Mon, 04 Apr 2016 11:28:05 -0700
changeset 299226 de91db2be2042556fd329c87dcf174a14fae5442
parent 299225 33e51331fe0359998d75b909258b602b63f8cac9
child 299227 8aa94e6a0c5cde954ad2b502551d85e82fbe137d
push idunknown
push userunknown
push dateunknown
reviewerskinetik, RyanVM
bugs1275812
milestone49.0a1
Bug 1275812 - Experiment with exporting track mime-type. r=kinetik, a=RyanVM to land on a CLOSED TREE MozReview-Commit-ID: 9CynVkwtUn2
CLOBBER
media/libstagefright/binding/include/mp4parse.h
media/libstagefright/binding/mp4parse-codecs.patch
media/libstagefright/binding/mp4parse/capi.rs
media/libstagefright/binding/update-rust.sh
--- a/CLOBBER
+++ b/CLOBBER
@@ -17,9 +17,9 @@
 #
 # Modifying this file will now automatically clobber the buildbot machines \o/
 #
 
 # Are you updating CLOBBER because you think it's needed for your WebIDL
 # changes to stick? As of bug 928195, this shouldn't be necessary! Please
 # don't change CLOBBER for WebIDL changes any more.
 
-Bug 1271829 - Compile nss with SSE2 optimizations
+Bug 1275812 - Seeing if a clobber makes Windows happy
--- a/media/libstagefright/binding/include/mp4parse.h
+++ b/media/libstagefright/binding/include/mp4parse.h
@@ -17,16 +17,22 @@ struct mp4parse_state;
 #define MP4PARSE_ERROR_UNSUPPORTED 3 // Error::Unsupported
 #define MP4PARSE_ERROR_EOF 4         // Error::UnexpectedEOF
 #define MP4PARSE_ASSERT 5            // Error::AssertCaught
 #define MP4PARSE_ERROR_IO 6          // Error::Io(_)
 
 #define MP4PARSE_TRACK_TYPE_H264 0 // "video/avc"
 #define MP4PARSE_TRACK_TYPE_AAC  1 // "audio/mp4a-latm"
 
+#define MP4PARSE_TRACK_CODEC_UNKNOWN 0
+#define MP4PARSE_TRACK_CODEC_AAC 1
+#define MP4PARSE_TRACK_CODEC_OPUS 2
+#define MP4PARSE_TRACK_CODEC_H264 3
+#define MP4PARSE_TRACK_CODEC_VP9 4
+
 struct mp4parse_track_audio_info {
   uint16_t channels;
   uint16_t bit_depth;
   uint32_t sample_rate;
 };
 
 struct mp4parse_track_video_info {
   uint32_t display_width;
new file mode 100644
--- /dev/null
+++ b/media/libstagefright/binding/mp4parse-codecs.patch
@@ -0,0 +1,42 @@
+diff --git a/media/libstagefright/binding/mp4parse/capi.rs b/media/libstagefright/binding/mp4parse/capi.rs
+index ed7e566..2441d2a 100644
+--- a/media/libstagefright/binding/mp4parse/capi.rs
++++ b/media/libstagefright/binding/mp4parse/capi.rs
+@@ -49,12 +49,20 @@ const MP4PARSE_ERROR_IO: i32 = 6;
+ const TRACK_TYPE_H264: u32 = 0;
+ const TRACK_TYPE_AAC: u32 = 1;
+ 
++/// Map Track mime_type to uint32 constants.
++const TRACK_CODEC_UNKNOWN: u32 = 0;
++const TRACK_CODEC_AAC: u32 = 1;
++const TRACK_CODEC_OPUS: u32 = 2;
++const TRACK_CODEC_H264: u32 = 3;
++const TRACK_CODEC_VP9: u32 = 4;
++
+ // These structs *must* match those declared in include/mp4parse.h.
+ 
+ #[repr(C)]
+ pub struct TrackInfo {
+     track_type: u32,
+     track_id: u32,
++    codec: u32,
+     duration: u64,
+     media_time: i64, // wants to be u64? understand how elst adjustment works
+     // TODO(kinetik): include crypto guff
+@@ -166,6 +174,16 @@ pub unsafe extern "C" fn mp4parse_get_track_info(context: *mut MediaContext, tra
+         TrackType::Unknown => return MP4PARSE_ERROR_UNSUPPORTED,
+     };
+ 
++    info.codec = match &*context.tracks[track_index].mime_type {
++        "audio/opus" => TRACK_CODEC_OPUS,
++        "audio/aac" |
++        "audio/mp4a-latm" => TRACK_CODEC_AAC,
++        "video/vp9" => TRACK_CODEC_VP9,
++        "video/h264" |
++        "video/avc" => TRACK_CODEC_H264,
++        _ => TRACK_CODEC_UNKNOWN,
++    };
++
+     // Maybe context & track should just have a single simple is_valid() instead?
+     if context.timescale.is_none() ||
+        context.tracks[track_index].timescale.is_none() ||
--- a/media/libstagefright/binding/mp4parse/capi.rs
+++ b/media/libstagefright/binding/mp4parse/capi.rs
@@ -44,22 +44,30 @@ const MP4PARSE_ERROR_UNSUPPORTED: i32 = 
 const MP4PARSE_ERROR_EOF: i32 = 4;
 const MP4PARSE_ASSERT: i32 = 5;
 const MP4PARSE_ERROR_IO: i32 = 6;
 
 /// Map TrackType to uint32 constants.
 const TRACK_TYPE_H264: u32 = 0;
 const TRACK_TYPE_AAC: u32 = 1;
 
+/// Map Track mime_type to uint32 constants.
+const TRACK_CODEC_UNKNOWN: u32 = 0;
+const TRACK_CODEC_AAC: u32 = 1;
+const TRACK_CODEC_OPUS: u32 = 2;
+const TRACK_CODEC_H264: u32 = 3;
+const TRACK_CODEC_VP9: u32 = 4;
+
 // These structs *must* match those declared in include/mp4parse.h.
 
 #[repr(C)]
 pub struct TrackInfo {
     track_type: u32,
     track_id: u32,
+    codec: u32,
     duration: u64,
     media_time: i64, // wants to be u64? understand how elst adjustment works
     // TODO(kinetik): include crypto guff
 }
 
 #[repr(C)]
 pub struct TrackAudioInfo {
     channels: u16,
@@ -168,16 +176,24 @@ pub unsafe extern "C" fn mp4parse_get_tr
     }
 
     info.track_type = match context.tracks[track_index].track_type {
         TrackType::Video => TRACK_TYPE_H264,
         TrackType::Audio => TRACK_TYPE_AAC,
         TrackType::Unknown => return MP4PARSE_ERROR_UNSUPPORTED,
     };
 
+    info.codec = match &*context.tracks[track_index].mime_type {
+        "audio/opus" => TRACK_CODEC_OPUS,
+        "video/vp9" => TRACK_CODEC_VP9,
+        "video/h264" => TRACK_CODEC_H264,
+        "audio/aac" => TRACK_CODEC_AAC,
+        _ => TRACK_CODEC_UNKNOWN,
+    };
+
     // Maybe context & track should just have a single simple is_valid() instead?
     if context.timescale.is_none() ||
        context.tracks[track_index].timescale.is_none() ||
        context.tracks[track_index].duration.is_none() ||
        context.tracks[track_index].track_id.is_none() {
         return MP4PARSE_ERROR_INVALID;
     }
 
--- a/media/libstagefright/binding/update-rust.sh
+++ b/media/libstagefright/binding/update-rust.sh
@@ -30,13 +30,14 @@ 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
+patch -p4 < mp4parse-codecs.patch
 
 echo "Cleaning up..."
 rm -rf _upstream
 
 echo "Updated to ${VER}."