Index: media/filters/decrypting_audio_decoder.h |
diff --git a/media/filters/decrypting_video_decoder.h b/media/filters/decrypting_audio_decoder.h |
similarity index 75% |
copy from media/filters/decrypting_video_decoder.h |
copy to media/filters/decrypting_audio_decoder.h |
index 900b0bb3db9e8a1c74b620bea286329df2d5fc85..769b3cb73c290dd9312169876f03f98f61426658 100644 |
--- a/media/filters/decrypting_video_decoder.h |
+++ b/media/filters/decrypting_audio_decoder.h |
@@ -2,14 +2,14 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef MEDIA_FILTERS_DECRYPTING_VIDEO_DECODER_H_ |
-#define MEDIA_FILTERS_DECRYPTING_VIDEO_DECODER_H_ |
+#ifndef MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ |
+#define MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ |
#include "base/callback.h" |
#include "base/memory/ref_counted.h" |
+#include "media/base/audio_decoder.h" |
#include "media/base/decryptor.h" |
#include "media/base/demuxer_stream.h" |
-#include "media/base/video_decoder.h" |
namespace base { |
class MessageLoopProxy; |
@@ -20,16 +20,16 @@ namespace media { |
class DecoderBuffer; |
class Decryptor; |
-// Decryptor-based VideoDecoder implementation that can decrypt and decode |
-// encrypted video buffers and return decrypted and decompressed video frames. |
+// Decryptor-based AudioDecoder implementation that can decrypt and decode |
+// encrypted audio buffers and return decrypted and decompressed audio frames. |
// All public APIs and callbacks are trampolined to the |message_loop_| so |
// that no locks are required for thread safety. |
// |
-// TODO(xhwang): For now, DecryptingVideoDecoder relies on the decryptor to do |
-// both decryption and video decoding. Add the path to use the decryptor for |
-// decryption only and use other VideoDecoder implementations within |
-// DecryptingVideoDecoder for video decoding. |
-class MEDIA_EXPORT DecryptingVideoDecoder : public VideoDecoder { |
+// TODO(xhwang): For now, DecryptingAudioDecoder relies on the decryptor to do |
+// both decryption and audio decoding. Add the path to use the decryptor for |
+// decryption only and use other AudioDecoder implementations within |
+// DecryptingAudioDecoder for audio decoding. |
+class MEDIA_EXPORT DecryptingAudioDecoder : public AudioDecoder { |
public: |
// Callback to get a message loop. |
typedef base::Callback< |
@@ -46,25 +46,28 @@ class MEDIA_EXPORT DecryptingVideoDecoder : public VideoDecoder { |
typedef base::Callback<void(const DecryptorNotificationCB&)> |
RequestDecryptorNotificationCB; |
- DecryptingVideoDecoder( |
+ DecryptingAudioDecoder( |
const MessageLoopFactoryCB& message_loop_factory_cb, |
const RequestDecryptorNotificationCB& request_decryptor_notification_cb); |
- // VideoDecoder implementation. |
+ // AudioDecoder implementation. |
virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, |
const PipelineStatusCB& status_cb, |
const StatisticsCB& statistics_cb) OVERRIDE; |
virtual void Read(const ReadCB& read_cb) OVERRIDE; |
virtual void Reset(const base::Closure& closure) OVERRIDE; |
- virtual void Stop(const base::Closure& closure) OVERRIDE; |
+ virtual int bits_per_channel() OVERRIDE; |
+ virtual ChannelLayout channel_layout() OVERRIDE; |
+ virtual int samples_per_second() OVERRIDE; |
protected: |
- virtual ~DecryptingVideoDecoder(); |
+ virtual ~DecryptingAudioDecoder(); |
private: |
// For a detailed state diagram please see this link: http://goo.gl/8jAok |
// TODO(xhwang): Add a ASCII state diagram in this file after this class |
// stabilizes. |
+ // TODO(xhwang): Update this diagram for DecryptingAudioDecoder. |
enum DecoderState { |
kUninitialized = 0, |
kDecryptorRequested, |
@@ -74,7 +77,6 @@ class MEDIA_EXPORT DecryptingVideoDecoder : public VideoDecoder { |
kPendingDecode, |
kWaitingForKey, |
kDecodeFinished, |
- kStopped |
}; |
// Carries out the initialization operation scheduled by Initialize(). |
@@ -85,7 +87,7 @@ class MEDIA_EXPORT DecryptingVideoDecoder : public VideoDecoder { |
// Callback for DecryptorHost::RequestDecryptor(). |
void SetDecryptor(Decryptor* decryptor); |
- // Callback for Decryptor::InitializeVideoDecoder(). |
+ // Callback for Decryptor::InitializeAudioDecoder(). |
void FinishInitialization(bool success); |
// Carries out the buffer reading operation scheduled by Read(). |
@@ -104,32 +106,29 @@ class MEDIA_EXPORT DecryptingVideoDecoder : public VideoDecoder { |
void DecodePendingBuffer(); |
- // Callback for Decryptor::DecryptAndDecodeVideo(). |
+ // Callback for Decryptor::DecryptAndDecodeAudio(). |
void DeliverFrame(int buffer_size, |
Decryptor::Status status, |
- const scoped_refptr<VideoFrame>& frame); |
+ const Decryptor::AudioBuffers& frames); |
// Carries out the frame delivery operation scheduled by DeliverFrame(). |
void DoDeliverFrame(int buffer_size, |
Decryptor::Status status, |
- const scoped_refptr<VideoFrame>& frame); |
+ const Decryptor::AudioBuffers& frames); |
- // Callback for the |decryptor_| to notify the DecryptingVideoDecoder that |
+ // Callback for the |decryptor_| to notify the DecryptingAudioDecoder that |
// a new key has been added. |
void OnKeyAdded(); |
// Reset decoder and call |reset_cb_|. |
void DoReset(); |
- // Free decoder resources and call |stop_cb_|. |
- void DoStop(); |
- |
// This is !is_null() iff Initialize() hasn't been called. |
MessageLoopFactoryCB message_loop_factory_cb_; |
scoped_refptr<base::MessageLoopProxy> message_loop_; |
- // Current state of the DecryptingVideoDecoder. |
+ // Current state of the DecryptingAudioDecoder. |
DecoderState state_; |
PipelineStatusCB init_cb_; |
@@ -155,9 +154,16 @@ class MEDIA_EXPORT DecryptingVideoDecoder : public VideoDecoder { |
// decryption key. |
bool key_added_while_pending_decode_; |
- DISALLOW_COPY_AND_ASSIGN(DecryptingVideoDecoder); |
+ Decryptor::AudioBuffers queued_audio_frames_; |
+ |
+ // Decoded audio format. |
+ int bits_per_channel_; |
+ ChannelLayout channel_layout_; |
+ int samples_per_second_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(DecryptingAudioDecoder); |
}; |
} // namespace media |
-#endif // MEDIA_FILTERS_DECRYPTING_VIDEO_DECODER_H_ |
+#endif // MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ |