OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 } | 83 } |
84 | 84 |
85 void InitializeAndExpectResult(const AudioDecoderConfig& config, | 85 void InitializeAndExpectResult(const AudioDecoderConfig& config, |
86 bool success) { | 86 bool success) { |
87 // Initialize data now that the config is known. Since the code uses | 87 // Initialize data now that the config is known. Since the code uses |
88 // invalid values (that CreateEmptyBuffer() doesn't support), tweak them | 88 // invalid values (that CreateEmptyBuffer() doesn't support), tweak them |
89 // just for CreateEmptyBuffer(). | 89 // just for CreateEmptyBuffer(). |
90 int channels = ChannelLayoutToChannelCount(config.channel_layout()); | 90 int channels = ChannelLayoutToChannelCount(config.channel_layout()); |
91 if (channels < 0) | 91 if (channels < 0) |
92 channels = 0; | 92 channels = 0; |
93 decoded_frame_ = AudioBuffer::CreateEmptyBuffer(config.channel_layout(), | 93 decoded_frame_ = AudioBuffer::CreateEmptyBuffer( |
94 channels, | 94 config.channel_layout(), channels, kSampleRate, kFakeAudioFrameSize, |
95 kSampleRate, | 95 kNoTimestamp); |
96 kFakeAudioFrameSize, | |
97 kNoTimestamp()); | |
98 decoded_frame_list_.push_back(decoded_frame_); | 96 decoded_frame_list_.push_back(decoded_frame_); |
99 | 97 |
100 decoder_->Initialize(config, cdm_context_.get(), NewExpectedBoolCB(success), | 98 decoder_->Initialize(config, cdm_context_.get(), NewExpectedBoolCB(success), |
101 base::Bind(&DecryptingAudioDecoderTest::FrameReady, | 99 base::Bind(&DecryptingAudioDecoderTest::FrameReady, |
102 base::Unretained(this))); | 100 base::Unretained(this))); |
103 base::RunLoop().RunUntilIdle(); | 101 base::RunLoop().RunUntilIdle(); |
104 } | 102 } |
105 | 103 |
106 enum CdmType { CDM_WITHOUT_DECRYPTOR, CDM_WITH_DECRYPTOR }; | 104 enum CdmType { CDM_WITHOUT_DECRYPTOR, CDM_WITH_DECRYPTOR }; |
107 | 105 |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 | 336 |
339 DecodeAndExpect(encrypted_buffer_, DecodeStatus::DECODE_ERROR); | 337 DecodeAndExpect(encrypted_buffer_, DecodeStatus::DECODE_ERROR); |
340 } | 338 } |
341 | 339 |
342 // Test the case where the decryptor returns multiple decoded frames. | 340 // Test the case where the decryptor returns multiple decoded frames. |
343 TEST_F(DecryptingAudioDecoderTest, DecryptAndDecode_MultipleFrames) { | 341 TEST_F(DecryptingAudioDecoderTest, DecryptAndDecode_MultipleFrames) { |
344 Initialize(); | 342 Initialize(); |
345 | 343 |
346 scoped_refptr<AudioBuffer> frame_a = AudioBuffer::CreateEmptyBuffer( | 344 scoped_refptr<AudioBuffer> frame_a = AudioBuffer::CreateEmptyBuffer( |
347 config_.channel_layout(), | 345 config_.channel_layout(), |
348 ChannelLayoutToChannelCount(config_.channel_layout()), | 346 ChannelLayoutToChannelCount(config_.channel_layout()), kSampleRate, |
349 kSampleRate, | 347 kFakeAudioFrameSize, kNoTimestamp); |
350 kFakeAudioFrameSize, | |
351 kNoTimestamp()); | |
352 scoped_refptr<AudioBuffer> frame_b = AudioBuffer::CreateEmptyBuffer( | 348 scoped_refptr<AudioBuffer> frame_b = AudioBuffer::CreateEmptyBuffer( |
353 config_.channel_layout(), | 349 config_.channel_layout(), |
354 ChannelLayoutToChannelCount(config_.channel_layout()), | 350 ChannelLayoutToChannelCount(config_.channel_layout()), kSampleRate, |
355 kSampleRate, | 351 kFakeAudioFrameSize, kNoTimestamp); |
356 kFakeAudioFrameSize, | |
357 kNoTimestamp()); | |
358 decoded_frame_list_.push_back(frame_a); | 352 decoded_frame_list_.push_back(frame_a); |
359 decoded_frame_list_.push_back(frame_b); | 353 decoded_frame_list_.push_back(frame_b); |
360 | 354 |
361 EXPECT_CALL(*decryptor_, DecryptAndDecodeAudio(_, _)) | 355 EXPECT_CALL(*decryptor_, DecryptAndDecodeAudio(_, _)) |
362 .WillOnce(RunCallback<1>(Decryptor::kSuccess, decoded_frame_list_)); | 356 .WillOnce(RunCallback<1>(Decryptor::kSuccess, decoded_frame_list_)); |
363 | 357 |
364 EXPECT_CALL(*this, FrameReady(decoded_frame_)); | 358 EXPECT_CALL(*this, FrameReady(decoded_frame_)); |
365 EXPECT_CALL(*this, FrameReady(frame_a)); | 359 EXPECT_CALL(*this, FrameReady(frame_a)); |
366 EXPECT_CALL(*this, FrameReady(frame_b)); | 360 EXPECT_CALL(*this, FrameReady(frame_b)); |
367 DecodeAndExpect(encrypted_buffer_, DecodeStatus::OK); | 361 DecodeAndExpect(encrypted_buffer_, DecodeStatus::OK); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 | 467 |
474 // Test resetting after the decoder has been reset. | 468 // Test resetting after the decoder has been reset. |
475 TEST_F(DecryptingAudioDecoderTest, Reset_AfterReset) { | 469 TEST_F(DecryptingAudioDecoderTest, Reset_AfterReset) { |
476 Initialize(); | 470 Initialize(); |
477 EnterNormalDecodingState(); | 471 EnterNormalDecodingState(); |
478 Reset(); | 472 Reset(); |
479 Reset(); | 473 Reset(); |
480 } | 474 } |
481 | 475 |
482 } // namespace media | 476 } // namespace media |
OLD | NEW |