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

Side by Side Diff: media/filters/decrypting_audio_decoder.h

Issue 1423163004: media: Replace DecryptorReadyCB with CdmReadyCB. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix android Created 5 years, 1 month 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 unified diff | Download patch
OLDNEW
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 "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "media/base/audio_decoder.h" 13 #include "media/base/audio_decoder.h"
14 #include "media/base/cdm_context.h"
14 #include "media/base/decryptor.h" 15 #include "media/base/decryptor.h"
15 #include "media/base/demuxer_stream.h" 16 #include "media/base/demuxer_stream.h"
16 17
17 namespace base { 18 namespace base {
18 class SingleThreadTaskRunner; 19 class SingleThreadTaskRunner;
19 } 20 }
20 21
21 namespace media { 22 namespace media {
22 23
23 class AudioTimestampHelper; 24 class AudioTimestampHelper;
24 class DecoderBuffer; 25 class DecoderBuffer;
25 class Decryptor; 26 class Decryptor;
26 class MediaLog; 27 class MediaLog;
27 28
28 // Decryptor-based AudioDecoder implementation that can decrypt and decode 29 // Decryptor-based AudioDecoder implementation that can decrypt and decode
29 // encrypted audio buffers and return decrypted and decompressed audio frames. 30 // encrypted audio buffers and return decrypted and decompressed audio frames.
30 // All public APIs and callbacks are trampolined to the |task_runner_| so 31 // All public APIs and callbacks are trampolined to the |task_runner_| so
31 // that no locks are required for thread safety. 32 // that no locks are required for thread safety.
32 class MEDIA_EXPORT DecryptingAudioDecoder : public AudioDecoder { 33 class MEDIA_EXPORT DecryptingAudioDecoder : public AudioDecoder {
33 public: 34 public:
34 DecryptingAudioDecoder( 35 DecryptingAudioDecoder(
35 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 36 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
36 const scoped_refptr<MediaLog>& media_log, 37 const scoped_refptr<MediaLog>& media_log,
37 const SetDecryptorReadyCB& set_decryptor_ready_cb, 38 const SetCdmReadyCB& set_cdm_ready_cb,
38 const base::Closure& waiting_for_decryption_key_cb); 39 const base::Closure& waiting_for_decryption_key_cb);
39 ~DecryptingAudioDecoder() override; 40 ~DecryptingAudioDecoder() override;
40 41
41 // AudioDecoder implementation. 42 // AudioDecoder implementation.
42 std::string GetDisplayName() const override; 43 std::string GetDisplayName() const override;
43 void Initialize(const AudioDecoderConfig& config, 44 void Initialize(const AudioDecoderConfig& config,
44 const InitCB& init_cb, 45 const InitCB& init_cb,
45 const OutputCB& output_cb) override; 46 const OutputCB& output_cb) override;
46 void Decode(const scoped_refptr<DecoderBuffer>& buffer, 47 void Decode(const scoped_refptr<DecoderBuffer>& buffer,
47 const DecodeCB& decode_cb) override; 48 const DecodeCB& decode_cb) override;
48 void Reset(const base::Closure& closure) override; 49 void Reset(const base::Closure& closure) override;
49 50
50 private: 51 private:
51 // For a detailed state diagram please see this link: http://goo.gl/8jAok 52 // For a detailed state diagram please see this link: http://goo.gl/8jAok
52 // TODO(xhwang): Add a ASCII state diagram in this file after this class 53 // TODO(xhwang): Add a ASCII state diagram in this file after this class
53 // stabilizes. 54 // stabilizes.
54 // TODO(xhwang): Update this diagram for DecryptingAudioDecoder. 55 // TODO(xhwang): Update this diagram for DecryptingAudioDecoder.
55 enum State { 56 enum State {
56 kUninitialized = 0, 57 kUninitialized = 0,
57 kDecryptorRequested, 58 kDecryptorRequested,
58 kPendingDecoderInit, 59 kPendingDecoderInit,
59 kIdle, 60 kIdle,
60 kPendingDecode, 61 kPendingDecode,
61 kWaitingForKey, 62 kWaitingForKey,
62 kDecodeFinished, 63 kDecodeFinished,
63 kError 64 kError
64 }; 65 };
65 66
66 // Callback for DecryptorHost::RequestDecryptor(). |decryptor_attached_cb| is 67 // Callback to set CDM. |cdm_attached_cb| is called when the decryptor in the
67 // called when the decryptor has been completely attached to the pipeline. 68 // CDM has been completely attached to the pipeline.
68 void SetDecryptor(Decryptor* decryptor, 69 void SetCdm(CdmContext* cdm_context, const CdmAttachedCB& cdm_attached_cb);
69 const DecryptorAttachedCB& decryptor_attached_cb);
70 70
71 // Initializes the audio decoder on the |decryptor_| with |config_|. 71 // Initializes the audio decoder on the |decryptor_| with |config_|.
72 void InitializeDecoder(); 72 void InitializeDecoder();
73 73
74 // Callback for Decryptor::InitializeAudioDecoder() during initialization. 74 // Callback for Decryptor::InitializeAudioDecoder() during initialization.
75 void FinishInitialization(bool success); 75 void FinishInitialization(bool success);
76 76
77 void DecodePendingBuffer(); 77 void DecodePendingBuffer();
78 78
79 // Callback for Decryptor::DecryptAndDecodeAudio(). 79 // Callback for Decryptor::DecryptAndDecodeAudio().
(...skipping 19 matching lines...) Expand all
99 99
100 InitCB init_cb_; 100 InitCB init_cb_;
101 OutputCB output_cb_; 101 OutputCB output_cb_;
102 DecodeCB decode_cb_; 102 DecodeCB decode_cb_;
103 base::Closure reset_cb_; 103 base::Closure reset_cb_;
104 base::Closure waiting_for_decryption_key_cb_; 104 base::Closure waiting_for_decryption_key_cb_;
105 105
106 // The current decoder configuration. 106 // The current decoder configuration.
107 AudioDecoderConfig config_; 107 AudioDecoderConfig config_;
108 108
109 // Callback to request/cancel decryptor creation notification. 109 // Callback to request/cancel CDM ready notification.
110 SetDecryptorReadyCB set_decryptor_ready_cb_; 110 SetCdmReadyCB set_cdm_ready_cb_;
111 111
112 Decryptor* decryptor_; 112 Decryptor* decryptor_;
113 113
114 // The buffer that needs decrypting/decoding. 114 // The buffer that needs decrypting/decoding.
115 scoped_refptr<media::DecoderBuffer> pending_buffer_to_decode_; 115 scoped_refptr<media::DecoderBuffer> pending_buffer_to_decode_;
116 116
117 // Indicates the situation where new key is added during pending decode 117 // Indicates the situation where new key is added during pending decode
118 // (in other words, this variable can only be set in state kPendingDecode). 118 // (in other words, this variable can only be set in state kPendingDecode).
119 // If this variable is true and kNoKey is returned then we need to try 119 // If this variable is true and kNoKey is returned then we need to try
120 // decrypting/decoding again in case the newly added key is the correct 120 // decrypting/decoding again in case the newly added key is the correct
121 // decryption key. 121 // decryption key.
122 bool key_added_while_decode_pending_; 122 bool key_added_while_decode_pending_;
123 123
124 scoped_ptr<AudioTimestampHelper> timestamp_helper_; 124 scoped_ptr<AudioTimestampHelper> timestamp_helper_;
125 125
126 base::WeakPtr<DecryptingAudioDecoder> weak_this_; 126 base::WeakPtr<DecryptingAudioDecoder> weak_this_;
127 base::WeakPtrFactory<DecryptingAudioDecoder> weak_factory_; 127 base::WeakPtrFactory<DecryptingAudioDecoder> weak_factory_;
128 128
129 DISALLOW_COPY_AND_ASSIGN(DecryptingAudioDecoder); 129 DISALLOW_COPY_AND_ASSIGN(DecryptingAudioDecoder);
130 }; 130 };
131 131
132 } // namespace media 132 } // namespace media
133 133
134 #endif // MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ 134 #endif // MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698