| OLD | NEW |
| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 TEST_P(MediaRecorderHandlerTest, InitializeStartStop) { | 190 TEST_P(MediaRecorderHandlerTest, InitializeStartStop) { |
| 191 AddTracks(); | 191 AddTracks(); |
| 192 const WebString mime_type(base::UTF8ToUTF16(GetParam().mime_type)); | 192 const WebString mime_type(base::UTF8ToUTF16(GetParam().mime_type)); |
| 193 const WebString codecs(base::UTF8ToUTF16(GetParam().codecs)); | 193 const WebString codecs(base::UTF8ToUTF16(GetParam().codecs)); |
| 194 EXPECT_TRUE(media_recorder_handler_->initialize(this, registry_.test_stream(), | 194 EXPECT_TRUE(media_recorder_handler_->initialize(this, registry_.test_stream(), |
| 195 mime_type, codecs, 0, 0)); | 195 mime_type, codecs, 0, 0)); |
| 196 EXPECT_FALSE(recording()); | 196 EXPECT_FALSE(recording()); |
| 197 EXPECT_FALSE(hasVideoRecorders()); | 197 EXPECT_FALSE(hasVideoRecorders()); |
| 198 EXPECT_FALSE(hasAudioRecorders()); | 198 EXPECT_FALSE(hasAudioRecorders()); |
| 199 | 199 |
| 200 EXPECT_TRUE(media_recorder_handler_->start()); | 200 EXPECT_TRUE(media_recorder_handler_->start(0)); |
| 201 EXPECT_TRUE(recording()); | 201 EXPECT_TRUE(recording()); |
| 202 | 202 |
| 203 EXPECT_TRUE(hasVideoRecorders() || !GetParam().has_video); | 203 EXPECT_TRUE(hasVideoRecorders() || !GetParam().has_video); |
| 204 EXPECT_TRUE(hasAudioRecorders() || !GetParam().has_audio); | 204 EXPECT_TRUE(hasAudioRecorders() || !GetParam().has_audio); |
| 205 | 205 |
| 206 media_recorder_handler_->stop(); | 206 media_recorder_handler_->stop(); |
| 207 EXPECT_FALSE(recording()); | 207 EXPECT_FALSE(recording()); |
| 208 EXPECT_FALSE(hasVideoRecorders()); | 208 EXPECT_FALSE(hasVideoRecorders()); |
| 209 EXPECT_FALSE(hasAudioRecorders()); | 209 EXPECT_FALSE(hasAudioRecorders()); |
| 210 | 210 |
| 211 // Expect a last call on destruction. | 211 // Expect a last call on destruction. |
| 212 EXPECT_CALL(*this, writeData(_, _, true)).Times(1); | 212 EXPECT_CALL(*this, writeData(_, _, true)).Times(1); |
| 213 media_recorder_handler_.reset(); | 213 media_recorder_handler_.reset(); |
| 214 } | 214 } |
| 215 | 215 |
| 216 // Sends 2 frames and expect them as WebM contained encoded data in writeData(). | 216 // Sends 2 frames and expect them as WebM contained encoded data in writeData(). |
| 217 TEST_P(MediaRecorderHandlerTest, EncodeVideoFrames) { | 217 TEST_P(MediaRecorderHandlerTest, EncodeVideoFrames) { |
| 218 // Video-only test. | 218 // Video-only test. |
| 219 if (GetParam().has_audio) | 219 if (GetParam().has_audio) |
| 220 return; | 220 return; |
| 221 | 221 |
| 222 AddTracks(); | 222 AddTracks(); |
| 223 | 223 |
| 224 const WebString mime_type(base::UTF8ToUTF16(GetParam().mime_type)); | 224 const WebString mime_type(base::UTF8ToUTF16(GetParam().mime_type)); |
| 225 const WebString codecs(base::UTF8ToUTF16(GetParam().codecs)); | 225 const WebString codecs(base::UTF8ToUTF16(GetParam().codecs)); |
| 226 EXPECT_TRUE(media_recorder_handler_->initialize(this, registry_.test_stream(), | 226 EXPECT_TRUE(media_recorder_handler_->initialize(this, registry_.test_stream(), |
| 227 mime_type, codecs, 0, 0)); | 227 mime_type, codecs, 0, 0)); |
| 228 EXPECT_TRUE(media_recorder_handler_->start()); | 228 EXPECT_TRUE(media_recorder_handler_->start(0)); |
| 229 | 229 |
| 230 InSequence s; | 230 InSequence s; |
| 231 const scoped_refptr<media::VideoFrame> video_frame = | 231 const scoped_refptr<media::VideoFrame> video_frame = |
| 232 media::VideoFrame::CreateBlackFrame(gfx::Size(160, 80)); | 232 media::VideoFrame::CreateBlackFrame(gfx::Size(160, 80)); |
| 233 | 233 |
| 234 { | 234 { |
| 235 const size_t kEncodedSizeThreshold = 16; | 235 const size_t kEncodedSizeThreshold = 16; |
| 236 base::RunLoop run_loop; | 236 base::RunLoop run_loop; |
| 237 base::Closure quit_closure = run_loop.QuitClosure(); | 237 base::Closure quit_closure = run_loop.QuitClosure(); |
| 238 // writeData() is pinged a number of times as the WebM header is written; | 238 // writeData() is pinged a number of times as the WebM header is written; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 TEST_P(MediaRecorderHandlerTest, EncodeAudioFrames) { | 279 TEST_P(MediaRecorderHandlerTest, EncodeAudioFrames) { |
| 280 // Audio-only test. | 280 // Audio-only test. |
| 281 if (GetParam().has_video) | 281 if (GetParam().has_video) |
| 282 return; | 282 return; |
| 283 | 283 |
| 284 AddTracks(); | 284 AddTracks(); |
| 285 | 285 |
| 286 const WebString mime_type(base::UTF8ToUTF16("audio/webm")); | 286 const WebString mime_type(base::UTF8ToUTF16("audio/webm")); |
| 287 EXPECT_TRUE(media_recorder_handler_->initialize( | 287 EXPECT_TRUE(media_recorder_handler_->initialize( |
| 288 this, registry_.test_stream(), mime_type, WebString(), 0, 0)); | 288 this, registry_.test_stream(), mime_type, WebString(), 0, 0)); |
| 289 EXPECT_TRUE(media_recorder_handler_->start()); | 289 EXPECT_TRUE(media_recorder_handler_->start(0)); |
| 290 | 290 |
| 291 InSequence s; | 291 InSequence s; |
| 292 const std::unique_ptr<media::AudioBus> audio_bus1 = NextAudioBus(); | 292 const std::unique_ptr<media::AudioBus> audio_bus1 = NextAudioBus(); |
| 293 const std::unique_ptr<media::AudioBus> audio_bus2 = NextAudioBus(); | 293 const std::unique_ptr<media::AudioBus> audio_bus2 = NextAudioBus(); |
| 294 | 294 |
| 295 media::AudioParameters params( | 295 media::AudioParameters params( |
| 296 media::AudioParameters::AUDIO_PCM_LINEAR, media::CHANNEL_LAYOUT_STEREO, | 296 media::AudioParameters::AUDIO_PCM_LINEAR, media::CHANNEL_LAYOUT_STEREO, |
| 297 kTestAudioSampleRate, kTestAudioBitsPerSample, | 297 kTestAudioSampleRate, kTestAudioBitsPerSample, |
| 298 kTestAudioSampleRate * kTestAudioBufferDurationMs / 1000); | 298 kTestAudioSampleRate * kTestAudioBufferDurationMs / 1000); |
| 299 SetAudioFormatForTesting(params); | 299 SetAudioFormatForTesting(params); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 } | 333 } |
| 334 | 334 |
| 335 media_recorder_handler_->stop(); | 335 media_recorder_handler_->stop(); |
| 336 | 336 |
| 337 // Expect a last call on destruction, with size 0 and |lastInSlice| true. | 337 // Expect a last call on destruction, with size 0 and |lastInSlice| true. |
| 338 EXPECT_CALL(*this, writeData(nullptr, 0, true)).Times(1); | 338 EXPECT_CALL(*this, writeData(nullptr, 0, true)).Times(1); |
| 339 media_recorder_handler_.reset(); | 339 media_recorder_handler_.reset(); |
| 340 } | 340 } |
| 341 | 341 |
| 342 } // namespace content | 342 } // namespace content |
| OLD | NEW |