summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorxhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-24 22:33:54 +0000
committerxhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-24 22:33:54 +0000
commitecbb97687dd14622163c5ab5861fc6f8392e35c6 (patch)
tree3a08fb89e0da0801e006141f5740b5d0529930c6 /media
parent2bd7d9ec294434bc9819ee7cd553545c6eb765a3 (diff)
downloadchromium_src-ecbb97687dd14622163c5ab5861fc6f8392e35c6.zip
chromium_src-ecbb97687dd14622163c5ab5861fc6f8392e35c6.tar.gz
chromium_src-ecbb97687dd14622163c5ab5861fc6f8392e35c6.tar.bz2
Update PluginInstance for audio support for content decryption.
BUG=123421 TEST=none Review URL: https://chromiumcodereview.appspot.com/11189082 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163931 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/base/decryptor.h1
-rw-r--r--media/filters/decrypting_audio_decoder.cc5
-rw-r--r--media/filters/decrypting_audio_decoder_unittest.cc51
3 files changed, 19 insertions, 38 deletions
diff --git a/media/base/decryptor.h b/media/base/decryptor.h
index f01b8cc..37f5e7a 100644
--- a/media/base/decryptor.h
+++ b/media/base/decryptor.h
@@ -137,6 +137,7 @@ class MEDIA_EXPORT Decryptor {
const KeyAddedCB& key_added_cb) = 0;
// Helper structure for managing multiple decoded audio buffers per input.
+ // TODO(xhwang): Rename this to AudioFrames.
typedef std::list<scoped_refptr<Buffer> > AudioBuffers;
// Indicates completion of audio/video decrypt-and-decode operation.
diff --git a/media/filters/decrypting_audio_decoder.cc b/media/filters/decrypting_audio_decoder.cc
index 298b11b..4ef49b0 100644
--- a/media/filters/decrypting_audio_decoder.cc
+++ b/media/filters/decrypting_audio_decoder.cc
@@ -197,8 +197,8 @@ void DecryptingAudioDecoder::DoRead(const ReadCB& read_cb) {
}
if (!queued_audio_frames_.empty()) {
- if (queued_audio_frames_.front()->IsEndOfStream())
- state_ = kDecodeFinished;
+ DCHECK(!queued_audio_frames_.front()->IsEndOfStream());
+ DCHECK_GT(queued_audio_frames_.front()->GetDataSize(), 0);
read_cb.Run(kOk, queued_audio_frames_.front());
queued_audio_frames_.pop_front();
return;
@@ -368,6 +368,7 @@ void DecryptingAudioDecoder::DoDeliverFrame(
// No frames returned in the list should be an end-of-stream (EOS) frame.
// EOS frame should be returned separately as (kNeedMoreData, NULL).
DCHECK(!first_frame->IsEndOfStream());
+ DCHECK_GT(first_frame->GetDataSize(), 0);
state_ = kIdle;
base::ResetAndReturn(&read_cb_).Run(kOk, first_frame);
}
diff --git a/media/filters/decrypting_audio_decoder_unittest.cc b/media/filters/decrypting_audio_decoder_unittest.cc
index 46265d0..a77438a 100644
--- a/media/filters/decrypting_audio_decoder_unittest.cc
+++ b/media/filters/decrypting_audio_decoder_unittest.cc
@@ -96,9 +96,14 @@ class DecryptingAudioDecoderTest : public testing::Test {
decryptor_(new StrictMock<MockDecryptor>()),
demuxer_(new StrictMock<MockDemuxerStream>()),
encrypted_buffer_(CreateFakeEncryptedBuffer()),
- decoded_frame_(new DataBuffer(kFakeAudioFrameSize)),
+ decoded_frame_(NULL),
end_of_stream_frame_(new DataBuffer(0)),
- decoded_frame_list_(1, decoded_frame_) {
+ decoded_frame_list_() {
+ // TODO(xhwang): Fix this after DataBuffer(data, size) is public.
+ scoped_refptr<DataBuffer> buffer = new DataBuffer(kFakeAudioFrameSize);
+ buffer->SetDataSize(kFakeAudioFrameSize);
+ decoded_frame_ = buffer;
+ decoded_frame_list_.push_back(decoded_frame_);
}
void InitializeAndExpectStatus(const AudioDecoderConfig& config,
@@ -325,10 +330,12 @@ TEST_F(DecryptingAudioDecoderTest, DecryptAndDecode_NeedMoreData) {
TEST_F(DecryptingAudioDecoderTest, DecryptAndDecode_MultipleFrames) {
Initialize();
- scoped_refptr<Buffer> decoded_frame_a(new DataBuffer(kFakeAudioFrameSize));
- scoped_refptr<Buffer> decoded_frame_b(new DataBuffer(kFakeAudioFrameSize));
- decoded_frame_list_.push_back(decoded_frame_a);
- decoded_frame_list_.push_back(decoded_frame_b);
+ scoped_refptr<DataBuffer> frame_a = new DataBuffer(kFakeAudioFrameSize);
+ frame_a->SetDataSize(kFakeAudioFrameSize);
+ scoped_refptr<DataBuffer> frame_b = new DataBuffer(kFakeAudioFrameSize);
+ frame_b->SetDataSize(kFakeAudioFrameSize);
+ decoded_frame_list_.push_back(frame_a);
+ decoded_frame_list_.push_back(frame_b);
EXPECT_CALL(*demuxer_, Read(_))
.WillOnce(ReturnBuffer(encrypted_buffer_));
@@ -337,8 +344,8 @@ TEST_F(DecryptingAudioDecoderTest, DecryptAndDecode_MultipleFrames) {
EXPECT_CALL(statistics_cb_, OnStatistics(_));
ReadAndExpectFrameReadyWith(AudioDecoder::kOk, decoded_frame_);
- ReadAndExpectFrameReadyWith(AudioDecoder::kOk, decoded_frame_a);
- ReadAndExpectFrameReadyWith(AudioDecoder::kOk, decoded_frame_b);
+ ReadAndExpectFrameReadyWith(AudioDecoder::kOk, frame_a);
+ ReadAndExpectFrameReadyWith(AudioDecoder::kOk, frame_b);
}
// Test the case where the decryptor receives end-of-stream buffer.
@@ -348,34 +355,6 @@ TEST_F(DecryptingAudioDecoderTest, DecryptAndDecode_EndOfStream) {
EnterEndOfStreamState();
}
-// Test the case where the decryptor returns multiple decoded frames, the last
-// of which is end-of-stream frame.
-TEST_F(DecryptingAudioDecoderTest, DecryptAndDecode_MultipleFramesWithEos) {
- Initialize();
-
- scoped_refptr<Buffer> decoded_frame_a(new DataBuffer(kFakeAudioFrameSize));
- scoped_refptr<Buffer> decoded_frame_b(new DataBuffer(kFakeAudioFrameSize));
- Decryptor::AudioBuffers second_decoded_frame_list;
- second_decoded_frame_list.push_back(decoded_frame_a);
- second_decoded_frame_list.push_back(decoded_frame_b);
- second_decoded_frame_list.push_back(end_of_stream_frame_);
-
- EXPECT_CALL(*demuxer_, Read(_))
- .WillOnce(ReturnBuffer(encrypted_buffer_))
- .WillOnce(ReturnBuffer(DecoderBuffer::CreateEOSBuffer()));
- EXPECT_CALL(*decryptor_, DecryptAndDecodeAudio(_, _))
- .WillOnce(RunCallback2(Decryptor::kSuccess, decoded_frame_list_))
- .WillOnce(RunCallback2(Decryptor::kSuccess, second_decoded_frame_list));
- // Expect only one OnStatistics() here because EOS input buffer doesn't
- // trigger statistics reporting.
- EXPECT_CALL(statistics_cb_, OnStatistics(_));
-
- ReadAndExpectFrameReadyWith(AudioDecoder::kOk, decoded_frame_);
- ReadAndExpectFrameReadyWith(AudioDecoder::kOk, decoded_frame_a);
- ReadAndExpectFrameReadyWith(AudioDecoder::kOk, decoded_frame_b);
- ReadAndExpectFrameReadyWith(AudioDecoder::kOk, end_of_stream_frame_);
-}
-
// Test the case where the a key is added when the decryptor is in
// kWaitingForKey state.
TEST_F(DecryptingAudioDecoderTest, KeyAdded_DuringWaitingForKey) {