summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorxhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-15 06:25:03 +0000
committerxhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-15 06:25:03 +0000
commitca1d8f72d5a3ba5ab084ce43d8bd0d437363e725 (patch)
treeb36b1a1922062fc64d036eb7ff36b2ac99a27ad7 /media
parent408ba4f5dfaf7292da71d9fc906e562590934eb0 (diff)
downloadchromium_src-ca1d8f72d5a3ba5ab084ce43d8bd0d437363e725.zip
chromium_src-ca1d8f72d5a3ba5ab084ce43d8bd0d437363e725.tar.gz
chromium_src-ca1d8f72d5a3ba5ab084ce43d8bd0d437363e725.tar.bz2
Encrypted Media: Enforcing the CDM to decode audio into S16 integers.
After the new FFmpeg roll, FFmpeg decodes into float instead of integers. Therefore, it may be confusing about what the CDMs are returning. In this CL, we limit the DecryptingAudioDecoder to support S16 only to work around this issue. All CDM implementations are expected to return S16. This is a short term fix for the audio corruption in CDMs. In the future, we need to be able to accept any format returned by the CDMs (see http://crbug.com/169105). BUG=168862 TEST=media_unittests pass; clearkeycdm audio works well. Review URL: https://chromiumcodereview.appspot.com/11778079 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176805 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/filters/decrypting_audio_decoder.cc28
-rw-r--r--media/filters/decrypting_audio_decoder.h7
-rw-r--r--media/filters/decrypting_audio_decoder_unittest.cc3
3 files changed, 33 insertions, 5 deletions
diff --git a/media/filters/decrypting_audio_decoder.cc b/media/filters/decrypting_audio_decoder.cc
index f94d1ec..10232f2 100644
--- a/media/filters/decrypting_audio_decoder.cc
+++ b/media/filters/decrypting_audio_decoder.cc
@@ -25,6 +25,8 @@ namespace media {
#define BIND_TO_LOOP(function) \
media::BindToLoop(message_loop_, base::Bind(function, this))
+const int DecryptingAudioDecoder::kSupportedBitsPerChannel = 16;
+
static inline bool IsOutOfSync(const base::TimeDelta& timestamp_1,
const base::TimeDelta& timestamp_2) {
// Out of sync of 100ms would be pretty noticeable and we should keep any
@@ -170,8 +172,17 @@ void DecryptingAudioDecoder::SetDecryptor(Decryptor* decryptor) {
set_decryptor_ready_cb_.Reset();
decryptor_ = decryptor;
+ const AudioDecoderConfig& input_config =
+ demuxer_stream_->audio_decoder_config();
scoped_ptr<AudioDecoderConfig> scoped_config(new AudioDecoderConfig());
- scoped_config->CopyFrom(demuxer_stream_->audio_decoder_config());
+ scoped_config->Initialize(input_config.codec(),
+ kSampleFormatS16,
+ input_config.channel_layout(),
+ input_config.samples_per_second(),
+ input_config.extra_data(),
+ input_config.extra_data_size(),
+ input_config.is_encrypted(),
+ false);
state_ = kPendingDecoderInit;
decryptor_->InitializeAudioDecoder(
@@ -281,8 +292,17 @@ void DecryptingAudioDecoder::DoDecryptAndDecodeBuffer(
if (status == DemuxerStream::kConfigChanged) {
DVLOG(2) << "DoDecryptAndDecodeBuffer() - kConfigChanged";
- scoped_ptr<AudioDecoderConfig> scoped_config(new AudioDecoderConfig());
- scoped_config->CopyFrom(demuxer_stream_->audio_decoder_config());
+ const AudioDecoderConfig& input_config =
+ demuxer_stream_->audio_decoder_config();
+ scoped_ptr<AudioDecoderConfig> scoped_config(new AudioDecoderConfig());
+ scoped_config->Initialize(input_config.codec(),
+ kSampleFormatS16,
+ input_config.channel_layout(),
+ input_config.samples_per_second(),
+ input_config.extra_data(),
+ input_config.extra_data_size(),
+ input_config.is_encrypted(),
+ false);
state_ = kPendingConfigChange;
decryptor_->DeinitializeDecoder(Decryptor::kAudio);
@@ -445,7 +465,7 @@ void DecryptingAudioDecoder::DoReset() {
void DecryptingAudioDecoder::UpdateDecoderConfig() {
const AudioDecoderConfig& config = demuxer_stream_->audio_decoder_config();
- bits_per_channel_ = config.bits_per_channel();
+ bits_per_channel_ = kSupportedBitsPerChannel;
channel_layout_ = config.channel_layout();
samples_per_second_ = config.samples_per_second();
const int kBitsPerByte = 8;
diff --git a/media/filters/decrypting_audio_decoder.h b/media/filters/decrypting_audio_decoder.h
index 2984fcd..e0bad06 100644
--- a/media/filters/decrypting_audio_decoder.h
+++ b/media/filters/decrypting_audio_decoder.h
@@ -26,6 +26,13 @@ class Decryptor;
// that no locks are required for thread safety.
class MEDIA_EXPORT DecryptingAudioDecoder : public AudioDecoder {
public:
+ // We do not currently have a way to let the Decryptor choose the output
+ // audio sample format and notify us of its choice. Therefore, we require all
+ // Decryptor implementations to decode audio into a fixed integer sample
+ // format designated by kSupportedBitsPerChannel.
+ // TODO(xhwang): Remove this restriction after http://crbug.com/169105 fixed.
+ static const int kSupportedBitsPerChannel;
+
DecryptingAudioDecoder(
const scoped_refptr<base::MessageLoopProxy>& message_loop,
const SetDecryptorReadyCB& set_decryptor_ready_cb);
diff --git a/media/filters/decrypting_audio_decoder_unittest.cc b/media/filters/decrypting_audio_decoder_unittest.cc
index 2107799..a601fe6 100644
--- a/media/filters/decrypting_audio_decoder_unittest.cc
+++ b/media/filters/decrypting_audio_decoder_unittest.cc
@@ -114,7 +114,8 @@ class DecryptingAudioDecoderTest : public testing::Test {
CHANNEL_LAYOUT_STEREO, 44100, NULL, 0, true, true);
InitializeAndExpectStatus(config_, PIPELINE_OK);
- EXPECT_EQ(config_.bits_per_channel(), decoder_->bits_per_channel());
+ EXPECT_EQ(DecryptingAudioDecoder::kSupportedBitsPerChannel,
+ decoder_->bits_per_channel());
EXPECT_EQ(config_.channel_layout(), decoder_->channel_layout());
EXPECT_EQ(config_.samples_per_second(), decoder_->samples_per_second());
}