Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1004)

Unified Diff: media/capture/webm_muxer_unittest.cc

Issue 1352243002: Implemented Multiple video track recoding. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/capture/webm_muxer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/capture/webm_muxer_unittest.cc
diff --git a/media/capture/webm_muxer_unittest.cc b/media/capture/webm_muxer_unittest.cc
index 7e162fa0a676b0422cb17b88956486dd6de22e7c..0df1db81712b85432c1a2a30f9b51993b8725675 100644
--- a/media/capture/webm_muxer_unittest.cc
+++ b/media/capture/webm_muxer_unittest.cc
@@ -79,14 +79,63 @@ TEST_F(WebmMuxerTest, OnEncodedVideoTwoFrames) {
VideoFrame::CreateBlackFrame(frame_size);
const std::string encoded_data("abcdefghijklmnopqrstuvwxyz");
+ WebmMuxer::EncodedVideoCB encoded_video_cb =
+ webm_muxer_.GenerateOnEncodedVideoCallback();
+
+ EXPECT_CALL(*this, WriteCallback(_))
+ .Times(AtLeast(1))
+ .WillRepeatedly(WithArgs<0>(
+ Invoke(this, &WebmMuxerTest::SaveEncodedDataLen)));
+
+ encoded_video_cb.Run(video_frame,
+ make_scoped_ptr(new std::string(encoded_data)),
+ base::TimeTicks::Now(),
+ false /* keyframe */);
+
+ // First time around WriteCallback() is pinged a number of times to write the
+ // Matroska header, but at the end it dumps |encoded_data|.
+ EXPECT_EQ(last_encoded_length_, encoded_data.size());
+ EXPECT_EQ(GetWebmMuxerPosition(), accumulated_position_);
+ EXPECT_GE(GetWebmMuxerPosition(), static_cast<int64_t>(last_encoded_length_));
+ EXPECT_EQ(GetWebmSegmentMode(), mkvmuxer::Segment::kLive);
+
+ const int64_t begin_of_second_block = accumulated_position_;
+ EXPECT_CALL(*this, WriteCallback(_))
+ .Times(AtLeast(1))
+ .WillRepeatedly(WithArgs<0>(
+ Invoke(this, &WebmMuxerTest::SaveEncodedDataLen)));
+ encoded_video_cb.Run(video_frame,
+ make_scoped_ptr(new std::string(encoded_data)),
+ base::TimeTicks::Now(),
+ false /* keyframe */);
+
+ // The second time around the callbacks should include a SimpleBlock header,
+ // namely the track index, a timestamp and a flags byte, for a total of 6B.
+ EXPECT_EQ(last_encoded_length_, encoded_data.size());
+ EXPECT_EQ(GetWebmMuxerPosition(), accumulated_position_);
+ const uint32_t kSimpleBlockSize = 6u;
+ EXPECT_EQ(static_cast<int64_t>(begin_of_second_block + kSimpleBlockSize +
+ encoded_data.size()),
+ accumulated_position_);
+}
+
+TEST_F(WebmMuxerTest, OnEncodedVideoTwoTracks) {
+ const gfx::Size frame_size(160, 80);
+ const scoped_refptr<VideoFrame> video_frame =
+ VideoFrame::CreateBlackFrame(frame_size);
+ const std::string encoded_data("abcdefghijklmnopqrstuvwxyz");
+ WebmMuxer::EncodedVideoCB encoded_video_cb_1 =
+ webm_muxer_.GenerateOnEncodedVideoCallback();
+ WebmMuxer::EncodedVideoCB encoded_video_cb_2 =
+ webm_muxer_.GenerateOnEncodedVideoCallback();
EXPECT_CALL(*this, WriteCallback(_))
.Times(AtLeast(1))
.WillRepeatedly(WithArgs<0>(
Invoke(this, &WebmMuxerTest::SaveEncodedDataLen)));
- webm_muxer_.OnEncodedVideo(video_frame,
- make_scoped_ptr(new std::string(encoded_data)),
- base::TimeTicks::Now(),
- false /* keyframe */);
+ encoded_video_cb_1.Run(video_frame,
+ make_scoped_ptr(new std::string(encoded_data)),
+ base::TimeTicks::Now(),
+ false /* keyframe */);
// First time around WriteCallback() is pinged a number of times to write the
// Matroska header, but at the end it dumps |encoded_data|.
@@ -100,10 +149,10 @@ TEST_F(WebmMuxerTest, OnEncodedVideoTwoFrames) {
.Times(AtLeast(1))
.WillRepeatedly(WithArgs<0>(
Invoke(this, &WebmMuxerTest::SaveEncodedDataLen)));
- webm_muxer_.OnEncodedVideo(video_frame,
- make_scoped_ptr(new std::string(encoded_data)),
- base::TimeTicks::Now(),
- false /* keyframe */);
+ encoded_video_cb_2.Run(video_frame,
+ make_scoped_ptr(new std::string(encoded_data)),
+ base::TimeTicks::Now(),
+ false /* keyframe */);
// The second time around the callbacks should include a SimpleBlock header,
// namely the track index, a timestamp and a flags byte, for a total of 6B.
« no previous file with comments | « media/capture/webm_muxer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698