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/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "media/base/audio_decoder.h" | 14 #include "media/base/audio_decoder.h" |
15 #include "media/base/cdm_context.h" | 15 #include "media/base/cdm_context.h" |
jrummell
2016/02/03 23:32:28
nit: Since you've removed the #include and added "
xhwang
2016/02/09 22:23:58
Done in the .cc file.
| |
16 #include "media/base/decryptor.h" | 16 #include "media/base/decryptor.h" |
17 #include "media/base/demuxer_stream.h" | 17 #include "media/base/demuxer_stream.h" |
18 | 18 |
19 namespace base { | 19 namespace base { |
20 class SingleThreadTaskRunner; | 20 class SingleThreadTaskRunner; |
21 } | 21 } |
22 | 22 |
23 namespace media { | 23 namespace media { |
24 | 24 |
25 class AudioTimestampHelper; | 25 class AudioTimestampHelper; |
26 class DecoderBuffer; | 26 class DecoderBuffer; |
27 class Decryptor; | 27 class Decryptor; |
28 class MediaLog; | 28 class MediaLog; |
29 | 29 |
30 // Decryptor-based AudioDecoder implementation that can decrypt and decode | 30 // Decryptor-based AudioDecoder implementation that can decrypt and decode |
31 // encrypted audio buffers and return decrypted and decompressed audio frames. | 31 // encrypted audio buffers and return decrypted and decompressed audio frames. |
32 // All public APIs and callbacks are trampolined to the |task_runner_| so | 32 // All public APIs and callbacks are trampolined to the |task_runner_| so |
33 // that no locks are required for thread safety. | 33 // that no locks are required for thread safety. |
34 class MEDIA_EXPORT DecryptingAudioDecoder : public AudioDecoder { | 34 class MEDIA_EXPORT DecryptingAudioDecoder : public AudioDecoder { |
35 public: | 35 public: |
36 DecryptingAudioDecoder( | 36 DecryptingAudioDecoder( |
37 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 37 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
38 const scoped_refptr<MediaLog>& media_log, | 38 const scoped_refptr<MediaLog>& media_log, |
39 const base::Closure& waiting_for_decryption_key_cb); | 39 const base::Closure& waiting_for_decryption_key_cb); |
40 ~DecryptingAudioDecoder() override; | 40 ~DecryptingAudioDecoder() override; |
41 | 41 |
42 // AudioDecoder implementation. | 42 // AudioDecoder implementation. |
43 std::string GetDisplayName() const override; | 43 std::string GetDisplayName() const override; |
44 void Initialize(const AudioDecoderConfig& config, | 44 void Initialize(const AudioDecoderConfig& config, |
45 const SetCdmReadyCB& set_cdm_ready_cb, | 45 CdmContext* cdm_context, |
46 const InitCB& init_cb, | 46 const InitCB& init_cb, |
47 const OutputCB& output_cb) override; | 47 const OutputCB& output_cb) override; |
48 void Decode(const scoped_refptr<DecoderBuffer>& buffer, | 48 void Decode(const scoped_refptr<DecoderBuffer>& buffer, |
49 const DecodeCB& decode_cb) override; | 49 const DecodeCB& decode_cb) override; |
50 void Reset(const base::Closure& closure) override; | 50 void Reset(const base::Closure& closure) override; |
51 | 51 |
52 private: | 52 private: |
53 // For a detailed state diagram please see this link: http://goo.gl/8jAok | 53 // For a detailed state diagram please see this link: http://goo.gl/8jAok |
54 // TODO(xhwang): Add a ASCII state diagram in this file after this class | 54 // TODO(xhwang): Add a ASCII state diagram in this file after this class |
55 // stabilizes. | 55 // stabilizes. |
56 // TODO(xhwang): Update this diagram for DecryptingAudioDecoder. | 56 // TODO(xhwang): Update this diagram for DecryptingAudioDecoder. |
57 enum State { | 57 enum State { |
58 kUninitialized = 0, | 58 kUninitialized = 0, |
59 kDecryptorRequested, | |
60 kPendingDecoderInit, | 59 kPendingDecoderInit, |
61 kIdle, | 60 kIdle, |
62 kPendingDecode, | 61 kPendingDecode, |
63 kWaitingForKey, | 62 kWaitingForKey, |
64 kDecodeFinished, | 63 kDecodeFinished, |
65 kError | 64 kError |
66 }; | 65 }; |
67 | 66 |
68 // Callback to set CDM. |cdm_attached_cb| is called when the decryptor in the | 67 // Callback to set CDM. |cdm_attached_cb| is called when the decryptor in the |
69 // CDM has been completely attached to the pipeline. | 68 // CDM has been completely attached to the pipeline. |
(...skipping 30 matching lines...) Expand all Loading... | |
100 | 99 |
101 InitCB init_cb_; | 100 InitCB init_cb_; |
102 OutputCB output_cb_; | 101 OutputCB output_cb_; |
103 DecodeCB decode_cb_; | 102 DecodeCB decode_cb_; |
104 base::Closure reset_cb_; | 103 base::Closure reset_cb_; |
105 base::Closure waiting_for_decryption_key_cb_; | 104 base::Closure waiting_for_decryption_key_cb_; |
106 | 105 |
107 // The current decoder configuration. | 106 // The current decoder configuration. |
108 AudioDecoderConfig config_; | 107 AudioDecoderConfig config_; |
109 | 108 |
110 // Callback to request/cancel CDM ready notification. | |
111 SetCdmReadyCB set_cdm_ready_cb_; | |
112 | |
113 Decryptor* decryptor_; | 109 Decryptor* decryptor_; |
114 | 110 |
115 // The buffer that needs decrypting/decoding. | 111 // The buffer that needs decrypting/decoding. |
116 scoped_refptr<media::DecoderBuffer> pending_buffer_to_decode_; | 112 scoped_refptr<media::DecoderBuffer> pending_buffer_to_decode_; |
117 | 113 |
118 // Indicates the situation where new key is added during pending decode | 114 // Indicates the situation where new key is added during pending decode |
119 // (in other words, this variable can only be set in state kPendingDecode). | 115 // (in other words, this variable can only be set in state kPendingDecode). |
120 // If this variable is true and kNoKey is returned then we need to try | 116 // If this variable is true and kNoKey is returned then we need to try |
121 // decrypting/decoding again in case the newly added key is the correct | 117 // decrypting/decoding again in case the newly added key is the correct |
122 // decryption key. | 118 // decryption key. |
123 bool key_added_while_decode_pending_; | 119 bool key_added_while_decode_pending_; |
124 | 120 |
125 scoped_ptr<AudioTimestampHelper> timestamp_helper_; | 121 scoped_ptr<AudioTimestampHelper> timestamp_helper_; |
126 | 122 |
127 base::WeakPtr<DecryptingAudioDecoder> weak_this_; | 123 base::WeakPtr<DecryptingAudioDecoder> weak_this_; |
128 base::WeakPtrFactory<DecryptingAudioDecoder> weak_factory_; | 124 base::WeakPtrFactory<DecryptingAudioDecoder> weak_factory_; |
129 | 125 |
130 DISALLOW_COPY_AND_ASSIGN(DecryptingAudioDecoder); | 126 DISALLOW_COPY_AND_ASSIGN(DecryptingAudioDecoder); |
131 }; | 127 }; |
132 | 128 |
133 } // namespace media | 129 } // namespace media |
134 | 130 |
135 #endif // MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ | 131 #endif // MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ |
OLD | NEW |