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

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, 3 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
« media/capture/webm_muxer.h ('K') | « 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..95adf997ee82b0cf91e27d9712e9f0e49cb67f53 100644
--- a/media/capture/webm_muxer_unittest.cc
+++ b/media/capture/webm_muxer_unittest.cc
@@ -47,6 +47,11 @@ class WebmMuxerTest : public testing::Test {
return webm_muxer_.segment_.mode();
}
+ bool HasTrack(int track_index) const {
+ return webm_muxer_.segment_.GetTrackByNumber(
+ webm_muxer_.video_muxer_args_[track_index].track_number) != NULL;
+ }
+
mkvmuxer::int32 WebmMuxerWrite(const void* buf, mkvmuxer::uint32 len) {
return webm_muxer_.Write(buf, len);
}
@@ -78,12 +83,14 @@ TEST_F(WebmMuxerTest, OnEncodedVideoTwoFrames) {
const scoped_refptr<VideoFrame> video_frame =
VideoFrame::CreateBlackFrame(frame_size);
const std::string encoded_data("abcdefghijklmnopqrstuvwxyz");
+ int track_index = webm_muxer_.GetNextVideoTrackIndex();
EXPECT_CALL(*this, WriteCallback(_))
.Times(AtLeast(1))
.WillRepeatedly(WithArgs<0>(
Invoke(this, &WebmMuxerTest::SaveEncodedDataLen)));
- webm_muxer_.OnEncodedVideo(video_frame,
+ webm_muxer_.OnEncodedVideo(track_index,
+ video_frame,
make_scoped_ptr(new std::string(encoded_data)),
base::TimeTicks::Now(),
false /* keyframe */);
@@ -100,7 +107,54 @@ TEST_F(WebmMuxerTest, OnEncodedVideoTwoFrames) {
.Times(AtLeast(1))
.WillRepeatedly(WithArgs<0>(
Invoke(this, &WebmMuxerTest::SaveEncodedDataLen)));
- webm_muxer_.OnEncodedVideo(video_frame,
+ webm_muxer_.OnEncodedVideo(track_index,
+ 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");
+ int track_index_1 = webm_muxer_.GetNextVideoTrackIndex();
+ EXPECT_CALL(*this, WriteCallback(_))
+ .Times(AtLeast(1))
+ .WillRepeatedly(WithArgs<0>(
+ Invoke(this, &WebmMuxerTest::SaveEncodedDataLen)));
+ webm_muxer_.OnEncodedVideo(track_index_1,
+ 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);
+
+ int track_index_2 = webm_muxer_.GetNextVideoTrackIndex();
+
+ const int64_t begin_of_second_block = accumulated_position_;
+ EXPECT_CALL(*this, WriteCallback(_))
+ .Times(AtLeast(1))
+ .WillRepeatedly(WithArgs<0>(
+ Invoke(this, &WebmMuxerTest::SaveEncodedDataLen)));
+ webm_muxer_.OnEncodedVideo(track_index_2,
+ video_frame,
make_scoped_ptr(new std::string(encoded_data)),
base::TimeTicks::Now(),
false /* keyframe */);
@@ -113,6 +167,8 @@ TEST_F(WebmMuxerTest, OnEncodedVideoTwoFrames) {
EXPECT_EQ(static_cast<int64_t>(begin_of_second_block + kSimpleBlockSize +
encoded_data.size()),
accumulated_position_);
+ EXPECT_TRUE(HasTrack(track_index_1));
+ EXPECT_TRUE(HasTrack(track_index_2));
}
} // namespace media
« media/capture/webm_muxer.h ('K') | « media/capture/webm_muxer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698