| 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 "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "content/child/child_process.h" | 10 #include "content/child/child_process.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 const WebString example_unsupported_codecs_2(base::UTF8ToUTF16("vorbis")); | 174 const WebString example_unsupported_codecs_2(base::UTF8ToUTF16("vorbis")); |
| 175 EXPECT_FALSE(media_recorder_handler_->canSupportMimeType( | 175 EXPECT_FALSE(media_recorder_handler_->canSupportMimeType( |
| 176 mime_type_audio, example_unsupported_codecs_2)); | 176 mime_type_audio, example_unsupported_codecs_2)); |
| 177 } | 177 } |
| 178 | 178 |
| 179 // Checks that the initialization-destruction sequence works fine. | 179 // Checks that the initialization-destruction sequence works fine. |
| 180 TEST_P(MediaRecorderHandlerTest, InitializeStartStop) { | 180 TEST_P(MediaRecorderHandlerTest, InitializeStartStop) { |
| 181 AddTracks(); | 181 AddTracks(); |
| 182 const WebString mime_type(base::UTF8ToUTF16(GetParam().mime_type)); | 182 const WebString mime_type(base::UTF8ToUTF16(GetParam().mime_type)); |
| 183 const WebString codecs(base::UTF8ToUTF16(GetParam().codecs)); | 183 const WebString codecs(base::UTF8ToUTF16(GetParam().codecs)); |
| 184 EXPECT_TRUE(media_recorder_handler_->initialize(this, | 184 EXPECT_TRUE(media_recorder_handler_->initialize(this, registry_.test_stream(), |
| 185 registry_.test_stream(), | 185 mime_type, codecs, 0, 0)); |
| 186 mime_type, | |
| 187 codecs)); | |
| 188 EXPECT_FALSE(recording()); | 186 EXPECT_FALSE(recording()); |
| 189 EXPECT_FALSE(hasVideoRecorders()); | 187 EXPECT_FALSE(hasVideoRecorders()); |
| 190 EXPECT_FALSE(hasAudioRecorders()); | 188 EXPECT_FALSE(hasAudioRecorders()); |
| 191 | 189 |
| 192 EXPECT_TRUE(media_recorder_handler_->start()); | 190 EXPECT_TRUE(media_recorder_handler_->start()); |
| 193 EXPECT_TRUE(recording()); | 191 EXPECT_TRUE(recording()); |
| 194 | 192 |
| 195 EXPECT_TRUE(hasVideoRecorders() || !GetParam().has_video); | 193 EXPECT_TRUE(hasVideoRecorders() || !GetParam().has_video); |
| 196 EXPECT_TRUE(hasAudioRecorders() || !GetParam().has_audio); | 194 EXPECT_TRUE(hasAudioRecorders() || !GetParam().has_audio); |
| 197 | 195 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 209 TEST_P(MediaRecorderHandlerTest, EncodeVideoFrames) { | 207 TEST_P(MediaRecorderHandlerTest, EncodeVideoFrames) { |
| 210 // Video-only test. | 208 // Video-only test. |
| 211 if (GetParam().has_audio) | 209 if (GetParam().has_audio) |
| 212 return; | 210 return; |
| 213 | 211 |
| 214 AddTracks(); | 212 AddTracks(); |
| 215 | 213 |
| 216 const WebString mime_type(base::UTF8ToUTF16(GetParam().mime_type)); | 214 const WebString mime_type(base::UTF8ToUTF16(GetParam().mime_type)); |
| 217 const WebString codecs(base::UTF8ToUTF16(GetParam().codecs)); | 215 const WebString codecs(base::UTF8ToUTF16(GetParam().codecs)); |
| 218 EXPECT_TRUE(media_recorder_handler_->initialize(this, registry_.test_stream(), | 216 EXPECT_TRUE(media_recorder_handler_->initialize(this, registry_.test_stream(), |
| 219 mime_type, codecs)); | 217 mime_type, codecs, 0, 0)); |
| 220 EXPECT_TRUE(media_recorder_handler_->start()); | 218 EXPECT_TRUE(media_recorder_handler_->start()); |
| 221 | 219 |
| 222 InSequence s; | 220 InSequence s; |
| 223 const scoped_refptr<media::VideoFrame> video_frame = | 221 const scoped_refptr<media::VideoFrame> video_frame = |
| 224 media::VideoFrame::CreateBlackFrame(gfx::Size(160, 80)); | 222 media::VideoFrame::CreateBlackFrame(gfx::Size(160, 80)); |
| 225 | 223 |
| 226 { | 224 { |
| 227 base::RunLoop run_loop; | 225 base::RunLoop run_loop; |
| 228 base::Closure quit_closure = run_loop.QuitClosure(); | 226 base::Closure quit_closure = run_loop.QuitClosure(); |
| 229 // writeData() is pinged a number of times as the WebM header is written; | 227 // writeData() is pinged a number of times as the WebM header is written; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 | 266 |
| 269 // Sends 2 frames and expect them as WebM contained encoded data in writeData(). | 267 // Sends 2 frames and expect them as WebM contained encoded data in writeData(). |
| 270 TEST_P(MediaRecorderHandlerTest, EncodeAudioFrames) { | 268 TEST_P(MediaRecorderHandlerTest, EncodeAudioFrames) { |
| 271 // Audio-only test. | 269 // Audio-only test. |
| 272 if (GetParam().has_video) | 270 if (GetParam().has_video) |
| 273 return; | 271 return; |
| 274 | 272 |
| 275 AddTracks(); | 273 AddTracks(); |
| 276 | 274 |
| 277 const WebString mime_type(base::UTF8ToUTF16("audio/webm")); | 275 const WebString mime_type(base::UTF8ToUTF16("audio/webm")); |
| 278 EXPECT_TRUE(media_recorder_handler_->initialize(this, registry_.test_stream(), | 276 EXPECT_TRUE(media_recorder_handler_->initialize( |
| 279 mime_type, WebString())); | 277 this, registry_.test_stream(), mime_type, WebString(), 0, 0)); |
| 280 EXPECT_TRUE(media_recorder_handler_->start()); | 278 EXPECT_TRUE(media_recorder_handler_->start()); |
| 281 | 279 |
| 282 InSequence s; | 280 InSequence s; |
| 283 const scoped_ptr<media::AudioBus> audio_bus1 = NextAudioBus(); | 281 const scoped_ptr<media::AudioBus> audio_bus1 = NextAudioBus(); |
| 284 const scoped_ptr<media::AudioBus> audio_bus2 = NextAudioBus(); | 282 const scoped_ptr<media::AudioBus> audio_bus2 = NextAudioBus(); |
| 285 | 283 |
| 286 media::AudioParameters params( | 284 media::AudioParameters params( |
| 287 media::AudioParameters::AUDIO_PCM_LINEAR, media::CHANNEL_LAYOUT_STEREO, | 285 media::AudioParameters::AUDIO_PCM_LINEAR, media::CHANNEL_LAYOUT_STEREO, |
| 288 kTestAudioSampleRate, kTestAudioBitsPerSample, | 286 kTestAudioSampleRate, kTestAudioBitsPerSample, |
| 289 kTestAudioSampleRate * kTestAudioBufferDurationMS / 1000); | 287 kTestAudioSampleRate * kTestAudioBufferDurationMS / 1000); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 } | 320 } |
| 323 | 321 |
| 324 media_recorder_handler_->stop(); | 322 media_recorder_handler_->stop(); |
| 325 | 323 |
| 326 // Expect a last call on destruction, with size 0 and |lastInSlice| true. | 324 // Expect a last call on destruction, with size 0 and |lastInSlice| true. |
| 327 EXPECT_CALL(*this, writeData(nullptr, 0, true)).Times(1); | 325 EXPECT_CALL(*this, writeData(nullptr, 0, true)).Times(1); |
| 328 media_recorder_handler_.reset(); | 326 media_recorder_handler_.reset(); |
| 329 } | 327 } |
| 330 | 328 |
| 331 } // namespace content | 329 } // namespace content |
| OLD | NEW |