Bug 1296531 - Add gtest for a VideoTrackEncoder suspended throughout the entire recording. r=jesup
authorAndreas Pehrson <pehrsons@gmail.com>
Mon, 30 Jan 2017 18:11:08 +0100
changeset 670655 c4fae1605712ec3c9f597c139102d3c0550a1aea
parent 670654 bc3d9b8fa333e43dec72975ad5f5090127ccec71
child 670656 81c3fc64fe9f32ff38a10632f273104724cf7919
push id81678
push userkgupta@mozilla.com
push dateTue, 26 Sep 2017 17:28:53 +0000
reviewersjesup
bugs1296531
milestone58.0a1
Bug 1296531 - Add gtest for a VideoTrackEncoder suspended throughout the entire recording. r=jesup MozReview-Commit-ID: DrUOijuqlVu
dom/media/gtest/TestVideoTrackEncoder.cpp
--- a/dom/media/gtest/TestVideoTrackEncoder.cpp
+++ b/dom/media/gtest/TestVideoTrackEncoder.cpp
@@ -694,16 +694,53 @@ TEST(VP8VideoTrackEncoder, SuspendedUnti
   uint64_t totalDuration = 0;
   for (auto& frame : container.GetEncodedFrames()) {
     totalDuration += frame->GetDuration();
   }
   const uint64_t pointOne = PR_USEC_PER_SEC / 10;
   EXPECT_EQ(pointOne, totalDuration);
 }
 
+// Test that ending a track that was always suspended works.
+TEST(VP8VideoTrackEncoder, AlwaysSuspended)
+{
+  // Initiate VP8 encoder
+  TestVP8TrackEncoder encoder;
+  InitParam param = {true, 640, 480};
+  encoder.TestInit(param);
+
+  // Suspend and then pass a frame with duration 2s.
+  YUVBufferGenerator generator;
+  generator.Init(mozilla::gfx::IntSize(640, 480));
+
+  encoder.Suspend();
+
+  VideoSegment segment;
+  segment.AppendFrame(generator.GenerateI420Image(),
+                      mozilla::StreamTime(180000), // 2s
+                      generator.GetSize(),
+                      PRINCIPAL_HANDLE_NONE,
+                      false,
+                      TimeStamp::Now());
+
+  encoder.AppendVideoSegment(Move(segment));
+  encoder.NotifyCurrentTime(180000);
+
+  encoder.NotifyEndOfStream();
+
+  EncodedFrameContainer container;
+  ASSERT_TRUE(NS_SUCCEEDED(encoder.GetEncodedTrack(container)));
+
+  EXPECT_TRUE(encoder.IsEncodingComplete());
+
+  // Verify that we have one encoded frames and a total duration of 0.1s.
+  const uint64_t none = 0;
+  EXPECT_EQ(none, container.GetEncodedFrames().Length());
+}
+
 // EOS test
 TEST(VP8VideoTrackEncoder, EncodeComplete)
 {
   // Initiate VP8 encoder
   TestVP8TrackEncoder encoder;
   InitParam param = {true, 640, 480};
   encoder.TestInit(param);