Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1117)

Unified Diff: media/filters/decrypting_audio_decoder_unittest.cc

Issue 11198017: Add DecryptingAudioDecoder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add unittests Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/filters/decrypting_audio_decoder_unittest.cc
diff --git a/media/filters/decrypting_video_decoder_unittest.cc b/media/filters/decrypting_audio_decoder_unittest.cc
similarity index 55%
copy from media/filters/decrypting_video_decoder_unittest.cc
copy to media/filters/decrypting_audio_decoder_unittest.cc
index 55aa906f1fcbaa87e923b5ce8aba8884c8669935..a22f4543b2308b519776ab9f7ef8d3b98f2683f3 100644
--- a/media/filters/decrypting_video_decoder_unittest.cc
+++ b/media/filters/decrypting_audio_decoder_unittest.cc
@@ -8,12 +8,13 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/message_loop.h"
+#include "media/base/buffers.h"
+#include "media/base/data_buffer.h"
#include "media/base/decoder_buffer.h"
#include "media/base/decrypt_config.h"
#include "media/base/mock_callback.h"
#include "media/base/mock_filters.h"
-#include "media/base/video_frame.h"
-#include "media/filters/decrypting_video_decoder.h"
+#include "media/filters/decrypting_audio_decoder.h"
#include "media/filters/ffmpeg_decoder_unittest.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -27,12 +28,12 @@ using ::testing::StrictMock;
namespace media {
-static const VideoFrame::Format kVideoFormat = VideoFrame::YV12;
static const gfx::Size kCodedSize(320, 240);
static const gfx::Rect kVisibleRect(320, 240);
static const gfx::Size kNaturalSize(320, 240);
static const uint8 kFakeKeyId[] = { 0x4b, 0x65, 0x79, 0x20, 0x49, 0x44 };
static const uint8 kFakeIv[DecryptConfig::kDecryptionKeySize] = { 0 };
+static const int kFakeAudioFrameSize = 16;
// Create a fake non-empty encrypted buffer.
static scoped_refptr<DecoderBuffer> CreateFakeEncryptedBuffer() {
@@ -75,30 +76,30 @@ MATCHER(IsNullCallback, "") {
return (arg.is_null());
}
-class DecryptingVideoDecoderTest : public testing::Test {
+class DecryptingAudioDecoderTest : public testing::Test {
public:
- DecryptingVideoDecoderTest()
- : decoder_(new StrictMock<DecryptingVideoDecoder>(
+ DecryptingAudioDecoderTest()
+ : decoder_(new StrictMock<DecryptingAudioDecoder>(
base::Bind(&Identity<scoped_refptr<base::MessageLoopProxy> >,
message_loop_.message_loop_proxy()),
base::Bind(
- &DecryptingVideoDecoderTest::RequestDecryptorNotification,
+ &DecryptingAudioDecoderTest::RequestDecryptorNotification,
base::Unretained(this)))),
decryptor_(new StrictMock<MockDecryptor>()),
demuxer_(new StrictMock<MockDemuxerStream>()),
encrypted_buffer_(CreateFakeEncryptedBuffer()),
- decoded_video_frame_(VideoFrame::CreateBlackFrame(kCodedSize)),
- null_video_frame_(scoped_refptr<VideoFrame>()),
- end_of_stream_video_frame_(VideoFrame::CreateEmptyFrame()) {
+ default_audio_frame_(new DataBuffer(kFakeAudioFrameSize)),
+ end_of_stream_frame_(new DataBuffer(0)),
+ decoded_frames_(1, default_audio_frame_) {
}
- virtual ~DecryptingVideoDecoderTest() {
+ virtual ~DecryptingAudioDecoderTest() {
Stop();
}
- void InitializeAndExpectStatus(const VideoDecoderConfig& config,
+ void InitializeAndExpectStatus(const AudioDecoderConfig& config,
PipelineStatus status) {
- EXPECT_CALL(*demuxer_, video_decoder_config())
+ EXPECT_CALL(*demuxer_, audio_decoder_config())
.WillRepeatedly(ReturnRef(config));
EXPECT_CALL(*this, RequestDecryptorNotification(_))
.WillRepeatedly(RunCallback0(decryptor_.get()));
@@ -110,47 +111,53 @@ class DecryptingVideoDecoderTest : public testing::Test {
}
void Initialize() {
- EXPECT_CALL(*decryptor_, InitializeVideoDecoderMock(_, _, _))
+ EXPECT_CALL(*decryptor_, InitializeAudioDecoderMock(_, _, _))
.Times(AtMost(1))
.WillOnce(DoAll(RunCallback1(true), SaveArg<2>(&key_added_cb_)));
- config_.Initialize(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, kVideoFormat,
- kCodedSize, kVisibleRect, kNaturalSize,
+ config_.Initialize(kCodecVorbis, 16, CHANNEL_LAYOUT_STEREO, 44100,
NULL, 0, true, true);
InitializeAndExpectStatus(config_, PIPELINE_OK);
}
void ReadAndExpectFrameReadyWith(
- VideoDecoder::Status status,
- const scoped_refptr<VideoFrame>& video_frame) {
- EXPECT_CALL(*this, FrameReady(status, video_frame));
-
- decoder_->Read(base::Bind(&DecryptingVideoDecoderTest::FrameReady,
+ AudioDecoder::Status status,
+ const scoped_refptr<Buffer>& audio_frame) {
+ if (status != AudioDecoder::kOk)
+ EXPECT_CALL(*this, FrameReady(status, IsNull()));
+ else
+ EXPECT_CALL(*this, FrameReady(status, audio_frame));
+
+ decoder_->Read(base::Bind(&DecryptingAudioDecoderTest::FrameReady,
base::Unretained(this)));
message_loop_.RunAllPending();
}
- // Sets up expectations and actions to put DecryptingVideoDecoder in an
+ // Sets up expectations and actions to put DecryptingAudioDecoder in an
// active normal decoding state.
void EnterNormalDecodingState() {
+ Decryptor::AudioBuffers end_of_stream_frames_(1,
+ end_of_stream_frame_);
+
EXPECT_CALL(*demuxer_, Read(_))
.WillOnce(ReturnBuffer(encrypted_buffer_))
.WillRepeatedly(ReturnBuffer(DecoderBuffer::CreateEOSBuffer()));
- EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _))
- .WillOnce(RunCallback2(Decryptor::kSuccess, decoded_video_frame_))
+ EXPECT_CALL(*decryptor_, DecryptAndDecodeAudio(_, _))
+ .WillOnce(RunCallback2(Decryptor::kSuccess,
+ decoded_frames_))
.WillRepeatedly(RunCallback2(Decryptor::kSuccess,
- end_of_stream_video_frame_));
+ end_of_stream_frames_));
EXPECT_CALL(statistics_cb_, OnStatistics(_));
- ReadAndExpectFrameReadyWith(VideoDecoder::kOk, decoded_video_frame_);
+ ReadAndExpectFrameReadyWith(AudioDecoder::kOk, default_audio_frame_);
}
- // Sets up expectations and actions to put DecryptingVideoDecoder in an end
+ // Sets up expectations and actions to put DecryptingAudioDecoder in an end
// of stream state. This function must be called after
// EnterNormalDecodingState() to work.
void EnterEndOfStreamState() {
- ReadAndExpectFrameReadyWith(VideoDecoder::kOk, end_of_stream_video_frame_);
+ ReadAndExpectFrameReadyWith(AudioDecoder::kOk, end_of_stream_frame_);
}
// Make the read callback pending by saving and not firing it.
@@ -158,237 +165,279 @@ class DecryptingVideoDecoderTest : public testing::Test {
EXPECT_TRUE(pending_demuxer_read_cb_.is_null());
EXPECT_CALL(*demuxer_, Read(_))
.WillOnce(SaveArg<0>(&pending_demuxer_read_cb_));
- decoder_->Read(base::Bind(&DecryptingVideoDecoderTest::FrameReady,
+ decoder_->Read(base::Bind(&DecryptingAudioDecoderTest::FrameReady,
base::Unretained(this)));
message_loop_.RunAllPending();
// Make sure the Read() on the decoder triggers a Read() on the demuxer.
EXPECT_FALSE(pending_demuxer_read_cb_.is_null());
}
- // Make the video decode callback pending by saving and not firing it.
+ // Make the audio decode callback pending by saving and not firing it.
void EnterPendingDecodeState() {
- EXPECT_TRUE(pending_video_decode_cb_.is_null());
+ EXPECT_TRUE(pending_audio_decode_cb_.is_null());
EXPECT_CALL(*demuxer_, Read(_))
.WillRepeatedly(ReturnBuffer(encrypted_buffer_));
- EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(encrypted_buffer_, _))
- .WillOnce(SaveArg<1>(&pending_video_decode_cb_));
+ EXPECT_CALL(*decryptor_, DecryptAndDecodeAudio(encrypted_buffer_, _))
+ .WillOnce(SaveArg<1>(&pending_audio_decode_cb_));
- decoder_->Read(base::Bind(&DecryptingVideoDecoderTest::FrameReady,
+ decoder_->Read(base::Bind(&DecryptingAudioDecoderTest::FrameReady,
base::Unretained(this)));
message_loop_.RunAllPending();
// Make sure the Read() on the decoder triggers a DecryptAndDecode() on the
// decryptor.
- EXPECT_FALSE(pending_video_decode_cb_.is_null());
+ EXPECT_FALSE(pending_audio_decode_cb_.is_null());
}
void EnterWaitingForKeyState() {
EXPECT_CALL(*demuxer_, Read(_))
.WillRepeatedly(ReturnBuffer(encrypted_buffer_));
- EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _))
- .WillRepeatedly(RunCallback2(Decryptor::kNoKey, null_video_frame_));
- decoder_->Read(base::Bind(&DecryptingVideoDecoderTest::FrameReady,
+ EXPECT_CALL(*decryptor_, DecryptAndDecodeAudio(_, _))
+ .WillRepeatedly(RunCallback2(Decryptor::kNoKey,
+ Decryptor::AudioBuffers()));
+ decoder_->Read(base::Bind(&DecryptingAudioDecoderTest::FrameReady,
base::Unretained(this)));
message_loop_.RunAllPending();
}
- void AbortPendingVideoDecodeCB() {
- if (!pending_video_decode_cb_.is_null()) {
- base::ResetAndReturn(&pending_video_decode_cb_).Run(
- Decryptor::kSuccess, scoped_refptr<VideoFrame>(NULL));
+ void AbortPendingAudioDecodeCB() {
+ if (!pending_audio_decode_cb_.is_null()) {
+ base::ResetAndReturn(&pending_audio_decode_cb_).Run(
+ Decryptor::kSuccess, Decryptor::AudioBuffers());
}
}
void AbortAllPendingCBs() {
if (!pending_init_cb_.is_null()) {
- ASSERT_TRUE(pending_video_decode_cb_.is_null());
+ ASSERT_TRUE(pending_audio_decode_cb_.is_null());
base::ResetAndReturn(&pending_init_cb_).Run(false);
return;
}
- AbortPendingVideoDecodeCB();
+ AbortPendingAudioDecodeCB();
}
void Reset() {
- EXPECT_CALL(*decryptor_, ResetDecoder(Decryptor::kVideo))
+ EXPECT_CALL(*decryptor_, ResetDecoder(Decryptor::kAudio))
.WillRepeatedly(InvokeWithoutArgs(
- this, &DecryptingVideoDecoderTest::AbortPendingVideoDecodeCB));
+ this, &DecryptingAudioDecoderTest::AbortPendingAudioDecodeCB));
decoder_->Reset(NewExpectedClosure());
message_loop_.RunAllPending();
}
void Stop() {
- EXPECT_CALL(*decryptor_, DeinitializeDecoder(Decryptor::kVideo))
+ EXPECT_CALL(*decryptor_, DeinitializeDecoder(Decryptor::kAudio))
.WillRepeatedly(InvokeWithoutArgs(
- this, &DecryptingVideoDecoderTest::AbortAllPendingCBs));
+ this, &DecryptingAudioDecoderTest::AbortAllPendingCBs));
decoder_->Stop(NewExpectedClosure());
message_loop_.RunAllPending();
}
MOCK_METHOD1(RequestDecryptorNotification,
- void(const DecryptingVideoDecoder::DecryptorNotificationCB&));
+ void(const DecryptingAudioDecoder::DecryptorNotificationCB&));
- MOCK_METHOD2(FrameReady, void(VideoDecoder::Status,
- const scoped_refptr<VideoFrame>&));
+ MOCK_METHOD2(FrameReady, void(AudioDecoder::Status,
+ const scoped_refptr<Buffer>&));
MessageLoop message_loop_;
- scoped_refptr<StrictMock<DecryptingVideoDecoder> > decoder_;
+ scoped_refptr<StrictMock<DecryptingAudioDecoder> > decoder_;
scoped_ptr<StrictMock<MockDecryptor> > decryptor_;
scoped_refptr<StrictMock<MockDemuxerStream> > demuxer_;
MockStatisticsCB statistics_cb_;
- VideoDecoderConfig config_;
+ AudioDecoderConfig config_;
DemuxerStream::ReadCB pending_demuxer_read_cb_;
Decryptor::DecoderInitCB pending_init_cb_;
Decryptor::KeyAddedCB key_added_cb_;
- Decryptor::VideoDecodeCB pending_video_decode_cb_;
+ Decryptor::AudioDecodeCB pending_audio_decode_cb_;
// Constant buffer/frames to be returned by the |demuxer_| and |decryptor_|.
scoped_refptr<DecoderBuffer> encrypted_buffer_;
- scoped_refptr<VideoFrame> decoded_video_frame_;
- scoped_refptr<VideoFrame> null_video_frame_;
- scoped_refptr<VideoFrame> end_of_stream_video_frame_;
+ scoped_refptr<Buffer> default_audio_frame_;
+ scoped_refptr<Buffer> end_of_stream_frame_;
+ Decryptor::AudioBuffers decoded_frames_;
private:
- DISALLOW_COPY_AND_ASSIGN(DecryptingVideoDecoderTest);
+ DISALLOW_COPY_AND_ASSIGN(DecryptingAudioDecoderTest);
};
-TEST_F(DecryptingVideoDecoderTest, Initialize_Normal) {
+TEST_F(DecryptingAudioDecoderTest, Initialize_Normal) {
Initialize();
}
-// Ensure that DecryptingVideoDecoder only accepts encrypted video.
-TEST_F(DecryptingVideoDecoderTest, Initialize_UnencryptedVideoConfig) {
- VideoDecoderConfig config(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN,
- kVideoFormat,
- kCodedSize, kVisibleRect, kNaturalSize,
+// Ensure that DecryptingAudioDecoder only accepts encrypted audio.
+TEST_F(DecryptingAudioDecoderTest, Initialize_UnencryptedAudioConfig) {
+ AudioDecoderConfig config(kCodecVorbis, 16, CHANNEL_LAYOUT_STEREO, 44100,
NULL, 0, false);
InitializeAndExpectStatus(config, DECODER_ERROR_NOT_SUPPORTED);
}
-// Ensure decoder handles invalid video configs without crashing.
-TEST_F(DecryptingVideoDecoderTest, Initialize_InvalidVideoConfig) {
- VideoDecoderConfig config(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN,
- VideoFrame::INVALID,
- kCodedSize, kVisibleRect, kNaturalSize,
+// Ensure decoder handles invalid audio configs without crashing.
+TEST_F(DecryptingAudioDecoderTest, Initialize_InvalidAudioConfig) {
+ AudioDecoderConfig config(kUnknownAudioCodec, 0, CHANNEL_LAYOUT_STEREO, 0,
NULL, 0, true);
InitializeAndExpectStatus(config, PIPELINE_ERROR_DECODE);
}
-// Ensure decoder handles unsupported video configs without crashing.
-TEST_F(DecryptingVideoDecoderTest, Initialize_UnsupportedVideoConfig) {
- EXPECT_CALL(*decryptor_, InitializeVideoDecoderMock(_, _, _))
+// Ensure decoder handles unsupported audio configs without crashing.
+TEST_F(DecryptingAudioDecoderTest, Initialize_UnsupportedAudioConfig) {
+ EXPECT_CALL(*decryptor_, InitializeAudioDecoderMock(_, _, _))
.WillOnce(RunCallback1(false));
- VideoDecoderConfig config(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN,
- kVideoFormat,
- kCodedSize, kVisibleRect, kNaturalSize,
+ AudioDecoderConfig config(kCodecVorbis, 16, CHANNEL_LAYOUT_STEREO, 44100,
NULL, 0, true);
-
InitializeAndExpectStatus(config, DECODER_ERROR_NOT_SUPPORTED);
}
// Test normal decrypt and decode case.
-TEST_F(DecryptingVideoDecoderTest, DecryptAndDecode_Normal) {
+TEST_F(DecryptingAudioDecoderTest, DecryptAndDecode_Normal) {
Initialize();
EnterNormalDecodingState();
}
// Test the case where the decryptor returns error when doing decrypt and
// decode.
-TEST_F(DecryptingVideoDecoderTest, DecryptAndDecode_DecodeError) {
+TEST_F(DecryptingAudioDecoderTest, DecryptAndDecode_DecodeError) {
Initialize();
EXPECT_CALL(*demuxer_, Read(_))
.WillRepeatedly(ReturnBuffer(encrypted_buffer_));
- EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _))
+ EXPECT_CALL(*decryptor_, DecryptAndDecodeAudio(_, _))
.WillRepeatedly(RunCallback2(Decryptor::kError,
- scoped_refptr<VideoFrame>(NULL)));
+ Decryptor::AudioBuffers()));
- ReadAndExpectFrameReadyWith(VideoDecoder::kDecodeError, null_video_frame_);
+ ReadAndExpectFrameReadyWith(AudioDecoder::kDecodeError, NULL);
}
// Test the case where the decryptor returns kNeedMoreData to ask for more
// buffers before it can produce a frame.
-TEST_F(DecryptingVideoDecoderTest, DecryptAndDecode_NeedMoreData) {
+TEST_F(DecryptingAudioDecoderTest, DecryptAndDecode_NeedMoreData) {
Initialize();
EXPECT_CALL(*demuxer_, Read(_))
.Times(2)
.WillRepeatedly(ReturnBuffer(encrypted_buffer_));
- EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _))
+ EXPECT_CALL(*decryptor_, DecryptAndDecodeAudio(_, _))
.WillOnce(RunCallback2(Decryptor::kNeedMoreData,
- scoped_refptr<VideoFrame>()))
- .WillRepeatedly(RunCallback2(Decryptor::kSuccess, decoded_video_frame_));
+ Decryptor::AudioBuffers()))
+ .WillRepeatedly(RunCallback2(Decryptor::kSuccess, decoded_frames_));
EXPECT_CALL(statistics_cb_, OnStatistics(_))
.Times(2);
- ReadAndExpectFrameReadyWith(VideoDecoder::kOk, decoded_video_frame_);
+ ReadAndExpectFrameReadyWith(AudioDecoder::kOk, default_audio_frame_);
+}
+
+// Test the case where the decryptor returns multiple decoded frames.
+TEST_F(DecryptingAudioDecoderTest, DecryptAndDecode_MultipleFrames) {
+ Initialize();
+
+ scoped_refptr<Buffer> audio_frame_a(new DataBuffer(kFakeAudioFrameSize));
+ scoped_refptr<Buffer> audio_frame_b(new DataBuffer(kFakeAudioFrameSize));
+ decoded_frames_.push_back(audio_frame_a);
+ decoded_frames_.push_back(audio_frame_b);
+
+ EXPECT_CALL(*demuxer_, Read(_))
+ .WillOnce(ReturnBuffer(encrypted_buffer_));
+ EXPECT_CALL(*decryptor_, DecryptAndDecodeAudio(_, _))
+ .WillOnce(RunCallback2(Decryptor::kSuccess, decoded_frames_));
+ EXPECT_CALL(statistics_cb_, OnStatistics(_));
+
+ ReadAndExpectFrameReadyWith(AudioDecoder::kOk, default_audio_frame_);
+ ReadAndExpectFrameReadyWith(AudioDecoder::kOk, audio_frame_a);
+ ReadAndExpectFrameReadyWith(AudioDecoder::kOk, audio_frame_b);
}
// Test the case where the decryptor receives end-of-stream buffer.
-TEST_F(DecryptingVideoDecoderTest, DecryptAndDecode_EndOfStream) {
+TEST_F(DecryptingAudioDecoderTest, DecryptAndDecode_EndOfStream) {
Initialize();
EnterNormalDecodingState();
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> audio_frame_a(new DataBuffer(kFakeAudioFrameSize));
+ scoped_refptr<Buffer> audio_frame_b(new DataBuffer(kFakeAudioFrameSize));
+ Decryptor::AudioBuffers decoded_frames_a;
+ decoded_frames_a.push_back(audio_frame_a);
+ decoded_frames_a.push_back(audio_frame_b);
+ decoded_frames_a.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_frames_))
+ .WillOnce(RunCallback2(Decryptor::kSuccess, decoded_frames_a));
+ // Expect only one OnStatistics() here because EOS input buffer doesn't
+ // trigger statistics reporting.
+ EXPECT_CALL(statistics_cb_, OnStatistics(_));
+
+ ReadAndExpectFrameReadyWith(AudioDecoder::kOk, default_audio_frame_);
+ ReadAndExpectFrameReadyWith(AudioDecoder::kOk, audio_frame_a);
+ ReadAndExpectFrameReadyWith(AudioDecoder::kOk, audio_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(DecryptingVideoDecoderTest, KeyAdded_DuringWaitingForKey) {
+TEST_F(DecryptingAudioDecoderTest, KeyAdded_DuringWaitingForKey) {
Initialize();
EnterWaitingForKeyState();
- EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _))
- .WillRepeatedly(RunCallback2(Decryptor::kSuccess, decoded_video_frame_));
+ EXPECT_CALL(*decryptor_, DecryptAndDecodeAudio(_, _))
+ .WillRepeatedly(RunCallback2(Decryptor::kSuccess, decoded_frames_));
EXPECT_CALL(statistics_cb_, OnStatistics(_));
- EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, decoded_video_frame_));
+ EXPECT_CALL(*this, FrameReady(AudioDecoder::kOk, default_audio_frame_));
key_added_cb_.Run();
message_loop_.RunAllPending();
}
// Test the case where the a key is added when the decryptor is in
// kPendingDecode state.
-TEST_F(DecryptingVideoDecoderTest, KeyAdded_DruingPendingDecode) {
+TEST_F(DecryptingAudioDecoderTest, KeyAdded_DruingPendingDecode) {
Initialize();
EnterPendingDecodeState();
- EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _))
- .WillRepeatedly(RunCallback2(Decryptor::kSuccess, decoded_video_frame_));
+ EXPECT_CALL(*decryptor_, DecryptAndDecodeAudio(_, _))
+ .WillRepeatedly(RunCallback2(Decryptor::kSuccess, decoded_frames_));
EXPECT_CALL(statistics_cb_, OnStatistics(_));
- EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, decoded_video_frame_));
- // The video decode callback is returned after the correct decryption key is
+ EXPECT_CALL(*this, FrameReady(AudioDecoder::kOk, default_audio_frame_));
+ // The audio decode callback is returned after the correct decryption key is
// added.
key_added_cb_.Run();
- base::ResetAndReturn(&pending_video_decode_cb_).Run(Decryptor::kNoKey,
- null_video_frame_);
+ base::ResetAndReturn(&pending_audio_decode_cb_)
+ .Run(Decryptor::kNoKey, Decryptor::AudioBuffers());
message_loop_.RunAllPending();
}
// Test resetting when the decoder is in kIdle state but has not decoded any
// frame.
-TEST_F(DecryptingVideoDecoderTest, Reset_DuringIdleAfterInitialization) {
+TEST_F(DecryptingAudioDecoderTest, Reset_DuringIdleAfterInitialization) {
Initialize();
Reset();
}
// Test resetting when the decoder is in kIdle state after it has decoded one
// frame.
-TEST_F(DecryptingVideoDecoderTest, Reset_DuringIdleAfterDecodedOneFrame) {
+TEST_F(DecryptingAudioDecoderTest, Reset_DuringIdleAfterDecodedOneFrame) {
Initialize();
EnterNormalDecodingState();
Reset();
}
// Test resetting when the decoder is in kPendingDemuxerRead state.
-TEST_F(DecryptingVideoDecoderTest, Reset_DuringPendingDemuxerRead) {
+TEST_F(DecryptingAudioDecoderTest, Reset_DuringPendingDemuxerRead) {
Initialize();
EnterPendingReadState();
- EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, IsNull()));
+ EXPECT_CALL(*this, FrameReady(AudioDecoder::kOk, IsNull()));
Reset();
base::ResetAndReturn(&pending_demuxer_read_cb_).Run(DemuxerStream::kOk,
@@ -397,28 +446,28 @@ TEST_F(DecryptingVideoDecoderTest, Reset_DuringPendingDemuxerRead) {
}
// Test resetting when the decoder is in kPendingDecode state.
-TEST_F(DecryptingVideoDecoderTest, Reset_DuringPendingDecode) {
+TEST_F(DecryptingAudioDecoderTest, Reset_DuringPendingDecode) {
Initialize();
EnterPendingDecodeState();
- EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, IsNull()));
+ EXPECT_CALL(*this, FrameReady(AudioDecoder::kOk, IsNull()));
Reset();
}
// Test resetting when the decoder is in kWaitingForKey state.
-TEST_F(DecryptingVideoDecoderTest, Reset_DuringWaitingForKey) {
+TEST_F(DecryptingAudioDecoderTest, Reset_DuringWaitingForKey) {
Initialize();
EnterWaitingForKeyState();
- EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, IsNull()));
+ EXPECT_CALL(*this, FrameReady(AudioDecoder::kOk, IsNull()));
Reset();
}
// Test resetting when the decoder has hit end of stream and is in
// kDecodeFinished state.
-TEST_F(DecryptingVideoDecoderTest, Reset_AfterDecodeFinished) {
+TEST_F(DecryptingAudioDecoderTest, Reset_AfterDecodeFinished) {
Initialize();
EnterNormalDecodingState();
EnterEndOfStreamState();
@@ -426,7 +475,7 @@ TEST_F(DecryptingVideoDecoderTest, Reset_AfterDecodeFinished) {
}
// Test resetting after the decoder has been reset.
-TEST_F(DecryptingVideoDecoderTest, Reset_AfterReset) {
+TEST_F(DecryptingAudioDecoderTest, Reset_AfterReset) {
Initialize();
EnterNormalDecodingState();
Reset();
@@ -434,13 +483,12 @@ TEST_F(DecryptingVideoDecoderTest, Reset_AfterReset) {
}
// Test stopping when the decoder is in kDecryptorRequested state.
-TEST_F(DecryptingVideoDecoderTest, Stop_DuringDecryptorRequested) {
- config_.Initialize(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, kVideoFormat,
- kCodedSize, kVisibleRect, kNaturalSize,
+TEST_F(DecryptingAudioDecoderTest, Stop_DuringDecryptorRequested) {
+ config_.Initialize(kCodecVorbis, 16, CHANNEL_LAYOUT_STEREO, 44100,
NULL, 0, true, true);
- EXPECT_CALL(*demuxer_, video_decoder_config())
+ EXPECT_CALL(*demuxer_, audio_decoder_config())
.WillRepeatedly(ReturnRef(config_));
- DecryptingVideoDecoder::DecryptorNotificationCB decryptor_notification_cb;
+ DecryptingAudioDecoder::DecryptorNotificationCB decryptor_notification_cb;
EXPECT_CALL(*this, RequestDecryptorNotification(_))
.WillOnce(SaveArg<0>(&decryptor_notification_cb));
decoder_->Initialize(demuxer_,
@@ -460,13 +508,12 @@ TEST_F(DecryptingVideoDecoderTest, Stop_DuringDecryptorRequested) {
}
// Test stopping when the decoder is in kPendingDecoderInit state.
-TEST_F(DecryptingVideoDecoderTest, Stop_DuringPendingDecoderInit) {
- EXPECT_CALL(*decryptor_, InitializeVideoDecoderMock(_, _, _))
+TEST_F(DecryptingAudioDecoderTest, Stop_DuringPendingDecoderInit) {
+ EXPECT_CALL(*decryptor_, InitializeAudioDecoderMock(_, _, _))
.WillOnce(SaveArg<1>(&pending_init_cb_));
- config_.Initialize(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, kVideoFormat,
- kCodedSize, kVisibleRect, kNaturalSize, NULL, 0, true,
- true);
+ config_.Initialize(kCodecVorbis, 16, CHANNEL_LAYOUT_STEREO, 44100,
+ NULL, 0, true, true);
InitializeAndExpectStatus(config_, DECODER_ERROR_NOT_SUPPORTED);
EXPECT_FALSE(pending_init_cb_.is_null());
@@ -475,25 +522,25 @@ TEST_F(DecryptingVideoDecoderTest, Stop_DuringPendingDecoderInit) {
// Test stopping when the decoder is in kIdle state but has not decoded any
// frame.
-TEST_F(DecryptingVideoDecoderTest, Stop_DuringIdleAfterInitialization) {
+TEST_F(DecryptingAudioDecoderTest, Stop_DuringIdleAfterInitialization) {
Initialize();
Stop();
}
// Test stopping when the decoder is in kIdle state after it has decoded one
// frame.
-TEST_F(DecryptingVideoDecoderTest, Stop_DuringIdleAfterDecodedOneFrame) {
+TEST_F(DecryptingAudioDecoderTest, Stop_DuringIdleAfterDecodedOneFrame) {
Initialize();
EnterNormalDecodingState();
Stop();
}
// Test stopping when the decoder is in kPendingDemuxerRead state.
-TEST_F(DecryptingVideoDecoderTest, Stop_DuringPendingDemuxerRead) {
+TEST_F(DecryptingAudioDecoderTest, Stop_DuringPendingDemuxerRead) {
Initialize();
EnterPendingReadState();
- EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, IsNull()));
+ EXPECT_CALL(*this, FrameReady(AudioDecoder::kOk, IsNull()));
Stop();
base::ResetAndReturn(&pending_demuxer_read_cb_).Run(DemuxerStream::kOk,
@@ -502,28 +549,28 @@ TEST_F(DecryptingVideoDecoderTest, Stop_DuringPendingDemuxerRead) {
}
// Test stopping when the decoder is in kPendingDecode state.
-TEST_F(DecryptingVideoDecoderTest, Stop_DuringPendingDecode) {
+TEST_F(DecryptingAudioDecoderTest, Stop_DuringPendingDecode) {
Initialize();
EnterPendingDecodeState();
- EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, IsNull()));
+ EXPECT_CALL(*this, FrameReady(AudioDecoder::kOk, IsNull()));
Stop();
}
// Test stopping when the decoder is in kWaitingForKey state.
-TEST_F(DecryptingVideoDecoderTest, Stop_DuringWaitingForKey) {
+TEST_F(DecryptingAudioDecoderTest, Stop_DuringWaitingForKey) {
Initialize();
EnterWaitingForKeyState();
- EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, IsNull()));
+ EXPECT_CALL(*this, FrameReady(AudioDecoder::kOk, IsNull()));
Stop();
}
// Test stopping when the decoder has hit end of stream and is in
// kDecodeFinished state.
-TEST_F(DecryptingVideoDecoderTest, Stop_AfterDecodeFinished) {
+TEST_F(DecryptingAudioDecoderTest, Stop_AfterDecodeFinished) {
Initialize();
EnterNormalDecodingState();
EnterEndOfStreamState();
@@ -531,21 +578,21 @@ TEST_F(DecryptingVideoDecoderTest, Stop_AfterDecodeFinished) {
}
// Test stopping when there is a pending reset on the decoder.
-// Reset is pending because it cannot complete when the video decode callback
+// Reset is pending because it cannot complete when the audio decode callback
// is pending.
-TEST_F(DecryptingVideoDecoderTest, Stop_DuringPendingReset) {
+TEST_F(DecryptingAudioDecoderTest, Stop_DuringPendingReset) {
Initialize();
EnterPendingDecodeState();
- EXPECT_CALL(*decryptor_, ResetDecoder(Decryptor::kVideo));
- EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, IsNull()));
+ EXPECT_CALL(*decryptor_, ResetDecoder(Decryptor::kAudio));
+ EXPECT_CALL(*this, FrameReady(AudioDecoder::kOk, IsNull()));
decoder_->Reset(NewExpectedClosure());
Stop();
}
// Test stopping after the decoder has been reset.
-TEST_F(DecryptingVideoDecoderTest, Stop_AfterReset) {
+TEST_F(DecryptingAudioDecoderTest, Stop_AfterReset) {
Initialize();
EnterNormalDecodingState();
Reset();
@@ -553,7 +600,7 @@ TEST_F(DecryptingVideoDecoderTest, Stop_AfterReset) {
}
// Test stopping after the decoder has been stopped.
-TEST_F(DecryptingVideoDecoderTest, Stop_AfterStop) {
+TEST_F(DecryptingAudioDecoderTest, Stop_AfterStop) {
Initialize();
EnterNormalDecodingState();
Stop();
@@ -561,23 +608,23 @@ TEST_F(DecryptingVideoDecoderTest, Stop_AfterStop) {
}
// Test aborted read on the demuxer stream.
-TEST_F(DecryptingVideoDecoderTest, DemuxerRead_Aborted) {
+TEST_F(DecryptingAudioDecoderTest, DemuxerRead_Aborted) {
Initialize();
// ReturnBuffer() with NULL triggers aborted demuxer read.
EXPECT_CALL(*demuxer_, Read(_))
.WillOnce(ReturnBuffer(scoped_refptr<DecoderBuffer>()));
- ReadAndExpectFrameReadyWith(VideoDecoder::kOk, null_video_frame_);
+ ReadAndExpectFrameReadyWith(AudioDecoder::kOk, NULL);
}
// Test aborted read on the demuxer stream when the decoder is being reset.
-TEST_F(DecryptingVideoDecoderTest, DemuxerRead_AbortedDuringReset) {
+TEST_F(DecryptingAudioDecoderTest, DemuxerRead_AbortedDuringReset) {
Initialize();
EnterPendingReadState();
- // Make sure we get a NULL video frame returned.
- EXPECT_CALL(*this, FrameReady(VideoDecoder::kOk, IsNull()));
+ // Make sure we get a NULL audio frame returned.
+ EXPECT_CALL(*this, FrameReady(AudioDecoder::kOk, IsNull()));
Reset();
base::ResetAndReturn(&pending_demuxer_read_cb_).Run(DemuxerStream::kAborted,
@@ -586,15 +633,15 @@ TEST_F(DecryptingVideoDecoderTest, DemuxerRead_AbortedDuringReset) {
}
// Test config change on the demuxer stream.
-TEST_F(DecryptingVideoDecoderTest, DemuxerRead_ConfigChanged) {
+TEST_F(DecryptingAudioDecoderTest, DemuxerRead_ConfigChanged) {
Initialize();
EXPECT_CALL(*demuxer_, Read(_))
.WillOnce(ReturnConfigChanged());
// TODO(xhwang): Update this test when kConfigChanged is supported in
- // DecryptingVideoDecoder.
- ReadAndExpectFrameReadyWith(VideoDecoder::kDecodeError, null_video_frame_);
+ // DecryptingAudioDecoder.
+ ReadAndExpectFrameReadyWith(AudioDecoder::kDecodeError, NULL);
}
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698