Bug 1185230 - p1: Added mp4 test case to libstagefright gtest - r=rillian
authorGerald Squelart <gsquelart@mozilla.com>
Thu, 05 Nov 2015 23:20:00 +0100
changeset 271589 d79ccfd9bbe7159551e7cdb275c34829edccfa8f
parent 271588 586b898cca97997325fdd0e1c0e99fba0fc6374f
child 271590 4ba6798c125bdabc50cb6b0923f36033827199bc
push id16135
push usercbook@mozilla.com
push dateMon, 09 Nov 2015 13:59:56 +0000
treeherderfx-team@5898d8162f44 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrillian
bugs1185230
milestone45.0a1
Bug 1185230 - p1: Added mp4 test case to libstagefright gtest - r=rillian
media/libstagefright/gtest/TestParser.cpp
media/libstagefright/gtest/moz.build
media/libstagefright/gtest/test_case_1185230.mp4
--- a/media/libstagefright/gtest/TestParser.cpp
+++ b/media/libstagefright/gtest/TestParser.cpp
@@ -157,65 +157,83 @@ ReadTestFile(const char* aFilename)
 }
 
 struct TestFileData
 {
   const char* mFilename;
   uint32_t mNumberVideoTracks;
   int32_t mWidth;
   int32_t mHeight;
+  uint32_t mNumberAudioTracks;
 };
 static const TestFileData testFiles[] = {
-  { "test_case_1156505.mp4", 0, 0, 0 },
-  { "test_case_1181213.mp4", 0, 0, 0 },
-  { "test_case_1181215.mp4", 0, 0, 0 },
-  { "test_case_1181220.mp4", 0, 0, 0 },
-  { "test_case_1181223.mp4", 0, 0, 0 },
-  { "test_case_1181719.mp4", 0, 0, 0 },
-  { "test_case_1187067.mp4", 1, 160, 90 },
-  { "test_case_1200326.mp4", 0, 0, 0 },
-  { "test_case_1204580.mp4", 1, 320, 180 }
+  { "test_case_1156505.mp4", 0,   0,   0, 0 },
+  { "test_case_1181213.mp4", 0,   0,   0, 0 },
+  { "test_case_1181215.mp4", 0,   0,   0, 0 },
+  { "test_case_1181220.mp4", 0,   0,   0, 0 },
+  { "test_case_1181223.mp4", 0,   0,   0, 0 },
+  { "test_case_1181719.mp4", 0,   0,   0, 0 },
+  { "test_case_1185230.mp4", 1, 320, 240, 1 },
+  { "test_case_1187067.mp4", 1, 160,  90, 0 },
+  { "test_case_1200326.mp4", 0,   0,   0, 0 },
+  { "test_case_1204580.mp4", 1, 320, 180, 0 }
 };
 
 TEST(stagefright_MPEG4Metadata, test_case_mp4)
 {
   for (size_t test = 0; test < ArrayLength(testFiles); ++test) {
     nsTArray<uint8_t> buffer = ReadTestFile(testFiles[test].mFilename);
     ASSERT_FALSE(buffer.IsEmpty());
     RefPtr<Stream> stream = new TestStream(buffer.Elements(), buffer.Length());
 
     EXPECT_TRUE(MP4Metadata::HasCompleteMetadata(stream));
     RefPtr<MediaByteBuffer> metadataBuffer = MP4Metadata::Metadata(stream);
     EXPECT_TRUE(metadataBuffer);
 
     MP4Metadata metadata(stream);
     EXPECT_EQ(0u, metadata.GetNumberTracks(TrackInfo::kUndefinedTrack));
-    EXPECT_EQ(0u, metadata.GetNumberTracks(TrackInfo::kAudioTrack));
+    EXPECT_EQ(testFiles[test].mNumberAudioTracks,
+              metadata.GetNumberTracks(TrackInfo::kAudioTrack));
     EXPECT_EQ(testFiles[test].mNumberVideoTracks,
               metadata.GetNumberTracks(TrackInfo::kVideoTrack));
     EXPECT_EQ(0u, metadata.GetNumberTracks(TrackInfo::kTextTrack));
     EXPECT_EQ(0u, metadata.GetNumberTracks(static_cast<TrackInfo::TrackType>(-1)));
     EXPECT_FALSE(metadata.GetTrackInfo(TrackInfo::kUndefinedTrack, 0));
-    EXPECT_FALSE(metadata.GetTrackInfo(TrackInfo::kAudioTrack, 0));
     UniquePtr<TrackInfo> trackInfo = metadata.GetTrackInfo(TrackInfo::kVideoTrack, 0);
     if (testFiles[test].mNumberVideoTracks == 0) {
       EXPECT_TRUE(!trackInfo);
     } else {
-      EXPECT_TRUE(!!trackInfo);
-      if (trackInfo) {
-        const VideoInfo* videoInfo = trackInfo->GetAsVideoInfo();
-        EXPECT_TRUE(!!videoInfo);
-        if (videoInfo) {
-          EXPECT_TRUE(videoInfo->IsValid());
-          EXPECT_TRUE(videoInfo->IsVideo());
-          EXPECT_EQ(testFiles[test].mWidth, videoInfo->mDisplay.width);
-          EXPECT_EQ(testFiles[test].mHeight, videoInfo->mDisplay.height);
-          FallibleTArray<mp4_demuxer::Index::Indice> indices;
-          EXPECT_TRUE(metadata.ReadTrackIndex(indices, videoInfo->mTrackId));
-        }
+      ASSERT_TRUE(!!trackInfo);
+      const VideoInfo* videoInfo = trackInfo->GetAsVideoInfo();
+      ASSERT_TRUE(!!videoInfo);
+      EXPECT_TRUE(videoInfo->IsValid());
+      EXPECT_TRUE(videoInfo->IsVideo());
+      EXPECT_EQ(testFiles[test].mWidth, videoInfo->mDisplay.width);
+      EXPECT_EQ(testFiles[test].mHeight, videoInfo->mDisplay.height);
+      FallibleTArray<mp4_demuxer::Index::Indice> indices;
+      EXPECT_TRUE(metadata.ReadTrackIndex(indices, videoInfo->mTrackId));
+      for (const mp4_demuxer::Index::Indice& indice : indices) {
+        EXPECT_TRUE(indice.start_offset <= indice.end_offset);
+        EXPECT_TRUE(indice.start_composition <= indice.end_composition);
+      }
+    }
+    trackInfo = metadata.GetTrackInfo(TrackInfo::kAudioTrack, 0);
+    if (testFiles[test].mNumberAudioTracks == 0) {
+      EXPECT_TRUE(!trackInfo);
+    } else {
+      ASSERT_TRUE(!!trackInfo);
+      const AudioInfo* audioInfo = trackInfo->GetAsAudioInfo();
+      ASSERT_TRUE(!!audioInfo);
+      EXPECT_TRUE(audioInfo->IsValid());
+      EXPECT_TRUE(audioInfo->IsAudio());
+      FallibleTArray<mp4_demuxer::Index::Indice> indices;
+      EXPECT_TRUE(metadata.ReadTrackIndex(indices, audioInfo->mTrackId));
+      for (const mp4_demuxer::Index::Indice& indice : indices) {
+        EXPECT_TRUE(indice.start_offset <= indice.end_offset);
+        EXPECT_TRUE(indice.start_composition <= indice.end_composition);
       }
     }
     EXPECT_FALSE(metadata.GetTrackInfo(TrackInfo::kTextTrack, 0));
     EXPECT_FALSE(metadata.GetTrackInfo(static_cast<TrackInfo::TrackType>(-1), 0));
     // We can see anywhere in any MPEG4.
     EXPECT_TRUE(metadata.CanSeek());
     EXPECT_FALSE(metadata.Crypto().valid);
   }
--- a/media/libstagefright/gtest/moz.build
+++ b/media/libstagefright/gtest/moz.build
@@ -13,16 +13,17 @@ SOURCES += [
 
 TEST_HARNESS_FILES.gtest += [
     'test_case_1156505.mp4',
     'test_case_1181213.mp4',
     'test_case_1181215.mp4',
     'test_case_1181220.mp4',
     'test_case_1181223.mp4',
     'test_case_1181719.mp4',
+    'test_case_1185230.mp4',
     'test_case_1187067.mp4',
     'test_case_1200326.mp4',
     'test_case_1204580.mp4',
 ]
 
 if CONFIG['MOZ_RUST']:
     UNIFIED_SOURCES += ['TestMP4Rust.cpp',]
     TEST_HARNESS_FILES.gtest += [
new file mode 100644
index 0000000000000000000000000000000000000000..ac5cbdbe85d57dc91f52eff2444ba13c8ac9a5ea
GIT binary patch
literal 3250
zc%1E3&1(};5TCb66Ag+%Q?1fU8k*vzr5n>*(G)%8pa_Z|h?i~Nrit0jhU`l~PdR80
zB6tzc3W^B*2lV8j7wJLhMf6Y*FM^liF^F;IWz)P(Obz1AJa%^8yf^da&CG9i03e<h
zcPd5Ku>mw7j+8R$Io+<LbpY6xubL)6NVgrQj<RLf3mkkS@D+e<0|R=xgZZ_3<qYgO
z0(hSfqH2_IeoK_3&qMvEv1fgjL-=L%+L7Xn$%Tu2(zIOBwV-o@o~?Gt=0yW1ahvzX
zzJL^is~b|7D{!mY*{K(~scK$B*~uDZZkeRRns%|AC+oT`4^^)@!`pk4ylUo^Fb>qJ
zR@}Sb8&|AYIDg^_mn%AJRJ;MHpul$^i<9gijlMC_YEhhc>N&>YVCyp+TSdP9ae29E
zHK<Vdng~CLZ88WIzJ1wDyd^7F$h3BRL<n9KE#6jLC%TdA>h1@r81(id9`DE<J8hW#
zQ|K$_t!dtVFDF_;y}L@pcxZ45Rko0Bqx=r(Q=8a*q%oW~J$GqW<Q(Phh=)iLk&2(n
zky(IojO%zBVCpHr^h1CoeP;LefVJj@u&t~yrbf5B>K8M9aS*Iu<ENZy+p-^nV7(Q7
zk1=1){0`QxQ!A^wS5W2(tY3Ptj=Hw*&|x55@*ut11L^DdFEaYV)*wo3{k)V;n=Y3i
z3N#vx1a1bA$1>y6=I3LgF<j9OM?=UM<vFfkl;l_!M;fIwqu?h9e%y3qqA_KiFc9+Q
zg&thtT^Raf;@|RK42I8ORv%#n&dQMB=tY1NSof1J01|5evxq@hsc}Imy=j}GliF#u
z&WMewQK?vJt>=nuFeP6Jha66ELmJDPTrleS#l?9&HLowEVANPfjpYwx)L8zz#?t;<
Rj~dIUvHVSAd9Huo_yrdQgW~`I