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

Side by Side Diff: media/muxers/webm_muxer_unittest.cc

Issue 2612403002: Release video frames earlier in MediaRecorder (Closed)
Patch Set: Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/muxers/webm_muxer.h" 5 #include "media/muxers/webm_muxer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 const gfx::Size frame_size(160, 80); 103 const gfx::Size frame_size(160, 80);
104 const scoped_refptr<VideoFrame> video_frame = 104 const scoped_refptr<VideoFrame> video_frame =
105 VideoFrame::CreateBlackFrame(frame_size); 105 VideoFrame::CreateBlackFrame(frame_size);
106 const std::string encoded_data("abcdefghijklmnopqrstuvwxyz"); 106 const std::string encoded_data("abcdefghijklmnopqrstuvwxyz");
107 107
108 EXPECT_CALL(*this, WriteCallback(_)) 108 EXPECT_CALL(*this, WriteCallback(_))
109 .Times(AtLeast(1)) 109 .Times(AtLeast(1))
110 .WillRepeatedly( 110 .WillRepeatedly(
111 WithArgs<0>(Invoke(this, &WebmMuxerTest::SaveEncodedDataLen))); 111 WithArgs<0>(Invoke(this, &WebmMuxerTest::SaveEncodedDataLen)));
112 webm_muxer_.OnEncodedVideo(video_frame, 112 webm_muxer_.OnEncodedVideo(WebmMuxer::VideoParameters(video_frame),
113 base::WrapUnique(new std::string(encoded_data)), 113 base::WrapUnique(new std::string(encoded_data)),
114 base::TimeTicks::Now(), false /* keyframe */); 114 base::TimeTicks::Now(), false /* keyframe */);
115 115
116 // First time around WriteCallback() is pinged a number of times to write the 116 // First time around WriteCallback() is pinged a number of times to write the
117 // Matroska header, but at the end it dumps |encoded_data|. 117 // Matroska header, but at the end it dumps |encoded_data|.
118 EXPECT_EQ(last_encoded_length_, encoded_data.size()); 118 EXPECT_EQ(last_encoded_length_, encoded_data.size());
119 EXPECT_EQ(GetWebmMuxerPosition(), accumulated_position_); 119 EXPECT_EQ(GetWebmMuxerPosition(), accumulated_position_);
120 EXPECT_GE(GetWebmMuxerPosition(), static_cast<int64_t>(last_encoded_length_)); 120 EXPECT_GE(GetWebmMuxerPosition(), static_cast<int64_t>(last_encoded_length_));
121 EXPECT_EQ(GetWebmSegmentMode(), mkvmuxer::Segment::kLive); 121 EXPECT_EQ(GetWebmSegmentMode(), mkvmuxer::Segment::kLive);
122 122
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 TEST_P(WebmMuxerTest, VideoIsStoredWhileWaitingForAudio) { 192 TEST_P(WebmMuxerTest, VideoIsStoredWhileWaitingForAudio) {
193 // This test is only relevant if we have both kinds of tracks. 193 // This test is only relevant if we have both kinds of tracks.
194 if (GetParam().num_video_tracks == 0 || GetParam().num_audio_tracks == 0) 194 if (GetParam().num_video_tracks == 0 || GetParam().num_audio_tracks == 0)
195 return; 195 return;
196 196
197 // First send a video keyframe 197 // First send a video keyframe
198 const gfx::Size frame_size(160, 80); 198 const gfx::Size frame_size(160, 80);
199 const scoped_refptr<VideoFrame> video_frame = 199 const scoped_refptr<VideoFrame> video_frame =
200 VideoFrame::CreateBlackFrame(frame_size); 200 VideoFrame::CreateBlackFrame(frame_size);
201 const std::string encoded_video("thisisanencodedvideopacket"); 201 const std::string encoded_video("thisisanencodedvideopacket");
202 webm_muxer_.OnEncodedVideo(video_frame, 202 webm_muxer_.OnEncodedVideo(WebmMuxer::VideoParameters(video_frame),
203 base::WrapUnique(new std::string(encoded_video)), 203 base::WrapUnique(new std::string(encoded_video)),
204 base::TimeTicks::Now(), true /* keyframe */); 204 base::TimeTicks::Now(), true /* keyframe */);
205 // A few encoded non key frames. 205 // A few encoded non key frames.
206 const int kNumNonKeyFrames = 2; 206 const int kNumNonKeyFrames = 2;
207 for (int i = 0; i < kNumNonKeyFrames; ++i) { 207 for (int i = 0; i < kNumNonKeyFrames; ++i) {
208 webm_muxer_.OnEncodedVideo(video_frame, 208 webm_muxer_.OnEncodedVideo(WebmMuxer::VideoParameters(video_frame),
209 base::WrapUnique(new std::string(encoded_video)), 209 base::WrapUnique(new std::string(encoded_video)),
210 base::TimeTicks::Now(), false /* keyframe */); 210 base::TimeTicks::Now(), false /* keyframe */);
211 } 211 }
212 212
213 // Send some audio. The header will be written and muxing will proceed 213 // Send some audio. The header will be written and muxing will proceed
214 // normally. 214 // normally.
215 const int sample_rate = 48000; 215 const int sample_rate = 48000;
216 const int bits_per_sample = 16; 216 const int bits_per_sample = 16;
217 const int frames_per_buffer = 480; 217 const int frames_per_buffer = 480;
218 media::AudioParameters audio_params( 218 media::AudioParameters audio_params(
(...skipping 25 matching lines...) Expand all
244 {kCodecVP9, 0, 1}, 244 {kCodecVP9, 0, 1},
245 {kCodecVP9, 1, 1}, 245 {kCodecVP9, 1, 1},
246 {kCodecH264, 1, 0}, 246 {kCodecH264, 1, 0},
247 {kCodecH264, 0, 1}, 247 {kCodecH264, 0, 1},
248 {kCodecH264, 1, 1}, 248 {kCodecH264, 1, 1},
249 }; 249 };
250 250
251 INSTANTIATE_TEST_CASE_P(, WebmMuxerTest, ValuesIn(kTestCases)); 251 INSTANTIATE_TEST_CASE_P(, WebmMuxerTest, ValuesIn(kTestCases));
252 252
253 } // namespace media 253 } // namespace media
OLDNEW
« media/muxers/webm_muxer.h ('K') | « media/muxers/webm_muxer_fuzzertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698