Chromium Code Reviews| 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 #ifndef MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ | 5 #ifndef MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ |
| 6 #define MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ | 6 #define MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "media/base/audio_decoder.h" | 10 #include "media/base/audio_decoder.h" |
| 11 #include "media/base/decryptor.h" | 11 #include "media/base/decryptor.h" |
| 12 #include "media/base/demuxer_stream.h" | 12 #include "media/base/demuxer_stream.h" |
| 13 | 13 |
| 14 namespace base { | 14 namespace base { |
| 15 class MessageLoopProxy; | 15 class MessageLoopProxy; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace media { | 18 namespace media { |
| 19 | 19 |
| 20 class DecoderBuffer; | 20 class DecoderBuffer; |
| 21 class Decryptor; | 21 class Decryptor; |
| 22 | 22 |
| 23 // Decryptor-based AudioDecoder implementation that can decrypt and decode | 23 // Decryptor-based AudioDecoder implementation that can decrypt and decode |
| 24 // encrypted audio buffers and return decrypted and decompressed audio frames. | 24 // encrypted audio buffers and return decrypted and decompressed audio frames. |
| 25 // All public APIs and callbacks are trampolined to the |message_loop_| so | 25 // All public APIs and callbacks are trampolined to the |message_loop_| so |
| 26 // that no locks are required for thread safety. | 26 // that no locks are required for thread safety. |
| 27 // | |
| 28 // TODO(xhwang): For now, DecryptingAudioDecoder relies on the decryptor to do | |
| 29 // both decryption and audio decoding. Add the path to use the decryptor for | |
| 30 // decryption only and use other AudioDecoder implementations within | |
| 31 // DecryptingAudioDecoder for audio decoding. | |
| 32 class MEDIA_EXPORT DecryptingAudioDecoder : public AudioDecoder { | 27 class MEDIA_EXPORT DecryptingAudioDecoder : public AudioDecoder { |
| 33 public: | 28 public: |
| 34 DecryptingAudioDecoder( | 29 DecryptingAudioDecoder( |
| 35 const scoped_refptr<base::MessageLoopProxy>& message_loop, | 30 const scoped_refptr<base::MessageLoopProxy>& message_loop, |
| 36 const SetDecryptorReadyCB& set_decryptor_ready_cb); | 31 const SetDecryptorReadyCB& set_decryptor_ready_cb); |
| 37 | 32 |
| 38 // AudioDecoder implementation. | 33 // AudioDecoder implementation. |
| 39 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, | 34 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, |
| 40 const PipelineStatusCB& status_cb, | 35 const PipelineStatusCB& status_cb, |
| 41 const StatisticsCB& statistics_cb) OVERRIDE; | 36 const StatisticsCB& statistics_cb) OVERRIDE; |
| 42 virtual void Read(const ReadCB& read_cb) OVERRIDE; | 37 virtual void Read(const ReadCB& read_cb) OVERRIDE; |
| 43 virtual void Reset(const base::Closure& closure) OVERRIDE; | 38 virtual void Reset(const base::Closure& closure) OVERRIDE; |
| 44 virtual int bits_per_channel() OVERRIDE; | 39 virtual int bits_per_channel() OVERRIDE; |
| 45 virtual ChannelLayout channel_layout() OVERRIDE; | 40 virtual ChannelLayout channel_layout() OVERRIDE; |
| 46 virtual int samples_per_second() OVERRIDE; | 41 virtual int samples_per_second() OVERRIDE; |
| 47 | 42 |
| 48 protected: | 43 protected: |
| 49 virtual ~DecryptingAudioDecoder(); | 44 virtual ~DecryptingAudioDecoder(); |
| 50 | 45 |
| 51 private: | 46 private: |
| 52 // For a detailed state diagram please see this link: http://goo.gl/8jAok | 47 // For a detailed state diagram please see this link: http://goo.gl/8jAok |
| 53 // TODO(xhwang): Add a ASCII state diagram in this file after this class | 48 // TODO(xhwang): Add a ASCII state diagram in this file after this class |
| 54 // stabilizes. | 49 // stabilizes. |
| 55 // TODO(xhwang): Update this diagram for DecryptingAudioDecoder. | 50 // TODO(xhwang): Update this diagram for DecryptingAudioDecoder. |
| 56 enum State { | 51 enum State { |
| 57 kUninitialized = 0, | 52 kUninitialized = 0, |
| 58 kDecryptorRequested, | 53 kDecryptorRequested, |
| 59 kPendingDecoderInit, | 54 kPendingDecoderInit, |
| 60 kIdle, | 55 kIdle, |
| 56 kPendingConfigChange, | |
| 61 kPendingDemuxerRead, | 57 kPendingDemuxerRead, |
| 62 kPendingDecode, | 58 kPendingDecode, |
| 63 kWaitingForKey, | 59 kWaitingForKey, |
| 64 kDecodeFinished, | 60 kDecodeFinished, |
| 65 }; | 61 }; |
| 66 | 62 |
| 67 // Carries out the initialization operation scheduled by Initialize(). | 63 // Carries out the initialization operation scheduled by Initialize(). |
| 68 void DoInitialize(const scoped_refptr<DemuxerStream>& stream, | 64 void DoInitialize(const scoped_refptr<DemuxerStream>& stream, |
| 69 const PipelineStatusCB& status_cb, | 65 const PipelineStatusCB& status_cb, |
| 70 const StatisticsCB& statistics_cb); | 66 const StatisticsCB& statistics_cb); |
| 71 | 67 |
| 72 // Callback for DecryptorHost::RequestDecryptor(). | 68 // Callback for DecryptorHost::RequestDecryptor(). |
| 73 void SetDecryptor(Decryptor* decryptor); | 69 void SetDecryptor(Decryptor* decryptor); |
| 74 | 70 |
| 75 // Callback for Decryptor::InitializeAudioDecoder(). | 71 // Callback for Decryptor::InitializeAudioDecoder() during initialization. |
| 76 void FinishInitialization(bool success); | 72 void FinishInitialization(bool success); |
| 77 | 73 |
| 74 // Callback for Decryptor::InitializeVideoDecoder() during config change. | |
|
acolwell GONE FROM CHROMIUM
2013/01/05 01:25:30
s/Video/Audio
xhwang
2013/01/05 04:09:24
Done.
| |
| 75 void FinishConfigChange(bool success); | |
| 76 | |
| 78 // Carries out the buffer reading operation scheduled by Read(). | 77 // Carries out the buffer reading operation scheduled by Read(). |
| 79 void DoRead(const ReadCB& read_cb); | 78 void DoRead(const ReadCB& read_cb); |
| 80 | 79 |
| 81 void ReadFromDemuxerStream(); | 80 void ReadFromDemuxerStream(); |
| 82 | 81 |
| 83 // Callback for DemuxerStream::Read(). | 82 // Callback for DemuxerStream::Read(). |
| 84 void DoDecryptAndDecodeBuffer(DemuxerStream::Status status, | 83 void DoDecryptAndDecodeBuffer(DemuxerStream::Status status, |
| 85 const scoped_refptr<DecoderBuffer>& buffer); | 84 const scoped_refptr<DecoderBuffer>& buffer); |
| 86 | 85 |
| 87 void DecodePendingBuffer(); | 86 void DecodePendingBuffer(); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 | 147 |
| 149 base::TimeDelta output_timestamp_base_; | 148 base::TimeDelta output_timestamp_base_; |
| 150 int total_samples_decoded_; | 149 int total_samples_decoded_; |
| 151 | 150 |
| 152 DISALLOW_COPY_AND_ASSIGN(DecryptingAudioDecoder); | 151 DISALLOW_COPY_AND_ASSIGN(DecryptingAudioDecoder); |
| 153 }; | 152 }; |
| 154 | 153 |
| 155 } // namespace media | 154 } // namespace media |
| 156 | 155 |
| 157 #endif // MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ | 156 #endif // MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ |
| OLD | NEW |