| 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 // function names. But for testing purpose, they all use an audio input | 112 // function names. But for testing purpose, they all use an audio input |
| 113 // demuxer stream. | 113 // demuxer stream. |
| 114 | 114 |
| 115 void Initialize() { | 115 void Initialize() { |
| 116 EXPECT_CALL(*this, RequestDecryptorNotification(_)) | 116 EXPECT_CALL(*this, RequestDecryptorNotification(_)) |
| 117 .WillOnce(RunCallbackIfNotNull(decryptor_.get())); | 117 .WillOnce(RunCallbackIfNotNull(decryptor_.get())); |
| 118 EXPECT_CALL(*decryptor_, RegisterNewKeyCB(Decryptor::kAudio, _)) | 118 EXPECT_CALL(*decryptor_, RegisterNewKeyCB(Decryptor::kAudio, _)) |
| 119 .WillOnce(SaveArg<1>(&key_added_cb_)); | 119 .WillOnce(SaveArg<1>(&key_added_cb_)); |
| 120 | 120 |
| 121 AudioDecoderConfig input_config( | 121 AudioDecoderConfig input_config( |
| 122 kCodecVorbis, 16, CHANNEL_LAYOUT_STEREO, 44100, NULL, 0, true); | 122 kCodecVorbis, kSampleFormatPlanarF32, CHANNEL_LAYOUT_STEREO, 44100, |
| 123 NULL, 0, true); |
| 123 InitializeAudioAndExpectStatus(input_config, PIPELINE_OK); | 124 InitializeAudioAndExpectStatus(input_config, PIPELINE_OK); |
| 124 | 125 |
| 125 const AudioDecoderConfig& output_config = | 126 const AudioDecoderConfig& output_config = |
| 126 demuxer_stream_->audio_decoder_config(); | 127 demuxer_stream_->audio_decoder_config(); |
| 127 EXPECT_EQ(DemuxerStream::AUDIO, demuxer_stream_->type()); | 128 EXPECT_EQ(DemuxerStream::AUDIO, demuxer_stream_->type()); |
| 128 EXPECT_FALSE(output_config.is_encrypted()); | 129 EXPECT_FALSE(output_config.is_encrypted()); |
| 129 EXPECT_EQ(16, output_config.bits_per_channel()); | 130 EXPECT_EQ(input_config.bits_per_channel(), |
| 130 EXPECT_EQ(CHANNEL_LAYOUT_STEREO, output_config.channel_layout()); | 131 output_config.bits_per_channel()); |
| 131 EXPECT_EQ(44100, output_config.samples_per_second()); | 132 EXPECT_EQ(input_config.channel_layout(), output_config.channel_layout()); |
| 133 EXPECT_EQ(input_config.sample_format(), output_config.sample_format()); |
| 134 EXPECT_EQ(input_config.samples_per_second(), |
| 135 output_config.samples_per_second()); |
| 132 } | 136 } |
| 133 | 137 |
| 134 void ReadAndExpectBufferReadyWith( | 138 void ReadAndExpectBufferReadyWith( |
| 135 DemuxerStream::Status status, | 139 DemuxerStream::Status status, |
| 136 const scoped_refptr<DecoderBuffer>& decrypted_buffer) { | 140 const scoped_refptr<DecoderBuffer>& decrypted_buffer) { |
| 137 if (status != DemuxerStream::kOk) | 141 if (status != DemuxerStream::kOk) |
| 138 EXPECT_CALL(*this, BufferReady(status, IsNull())); | 142 EXPECT_CALL(*this, BufferReady(status, IsNull())); |
| 139 else if (decrypted_buffer->IsEndOfStream()) | 143 else if (decrypted_buffer->IsEndOfStream()) |
| 140 EXPECT_CALL(*this, BufferReady(status, IsEndOfStream())); | 144 EXPECT_CALL(*this, BufferReady(status, IsEndOfStream())); |
| 141 else | 145 else |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 base::ResetAndReturn(&pending_demuxer_read_cb_).Run(DemuxerStream::kAborted, | 407 base::ResetAndReturn(&pending_demuxer_read_cb_).Run(DemuxerStream::kAborted, |
| 404 NULL); | 408 NULL); |
| 405 message_loop_.RunUntilIdle(); | 409 message_loop_.RunUntilIdle(); |
| 406 } | 410 } |
| 407 | 411 |
| 408 // Test config change on the input demuxer stream. | 412 // Test config change on the input demuxer stream. |
| 409 TEST_F(DecryptingDemuxerStreamTest, DemuxerRead_ConfigChanged) { | 413 TEST_F(DecryptingDemuxerStreamTest, DemuxerRead_ConfigChanged) { |
| 410 Initialize(); | 414 Initialize(); |
| 411 | 415 |
| 412 AudioDecoderConfig new_config( | 416 AudioDecoderConfig new_config( |
| 413 kCodecVorbis, 32, CHANNEL_LAYOUT_STEREO, 88200, NULL, 0, true); | 417 kCodecVorbis, kSampleFormatPlanarF32, CHANNEL_LAYOUT_STEREO, 88200, NULL, |
| 418 0, true); |
| 414 | 419 |
| 415 EXPECT_CALL(*input_audio_stream_, audio_decoder_config()) | 420 EXPECT_CALL(*input_audio_stream_, audio_decoder_config()) |
| 416 .WillRepeatedly(ReturnRef(new_config)); | 421 .WillRepeatedly(ReturnRef(new_config)); |
| 417 | 422 |
| 418 EXPECT_CALL(*input_audio_stream_, Read(_)) | 423 EXPECT_CALL(*input_audio_stream_, Read(_)) |
| 419 .WillOnce(RunCallback<0>(DemuxerStream::kConfigChanged, | 424 .WillOnce(RunCallback<0>(DemuxerStream::kConfigChanged, |
| 420 scoped_refptr<DecoderBuffer>())); | 425 scoped_refptr<DecoderBuffer>())); |
| 421 | 426 |
| 422 ReadAndExpectBufferReadyWith(DemuxerStream::kConfigChanged, NULL); | 427 ReadAndExpectBufferReadyWith(DemuxerStream::kConfigChanged, NULL); |
| 423 } | 428 } |
| 424 | 429 |
| 425 } // namespace media | 430 } // namespace media |
| OLD | NEW |