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_DEMUXER_STREAM_H_ | 5 #ifndef MEDIA_FILTERS_DECRYPTING_DEMUXER_STREAM_H_ |
6 #define MEDIA_FILTERS_DECRYPTING_DEMUXER_STREAM_H_ | 6 #define MEDIA_FILTERS_DECRYPTING_DEMUXER_STREAM_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/decryptor.h" | 10 #include "media/base/decryptor.h" |
11 #include "media/base/demuxer_stream.h" | 11 #include "media/base/demuxer_stream.h" |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 class MessageLoopProxy; | 14 class MessageLoopProxy; |
15 } | 15 } |
16 | 16 |
17 namespace media { | 17 namespace media { |
18 | 18 |
19 class DecoderBuffer; | 19 class DecoderBuffer; |
20 | 20 |
21 // Decryptor-based DemuxerStream implementation that converts a potentially | 21 // Decryptor-based DemuxerStream implementation that converts a potentially |
22 // encrypted demuxer stream to a clear demuxer stream. | 22 // encrypted demuxer stream to a clear demuxer stream. |
23 // All public APIs and callbacks are trampolined to the |message_loop_| so | 23 // All public APIs and callbacks are trampolined to the |message_loop_| so |
24 // that no locks are required for thread safety. | 24 // that no locks are required for thread safety. |
25 class MEDIA_EXPORT DecryptingDemuxerStream : public DemuxerStream { | 25 class MEDIA_EXPORT DecryptingDemuxerStream : public DemuxerStream { |
26 public: | 26 public: |
27 // Callback to notify decryptor creation. | |
28 typedef base::Callback<void(Decryptor*)> DecryptorNotificationCB; | |
29 | |
30 // Callback to request/cancel decryptor creation notification. | |
31 // Calling this callback with a non-null callback registers decryptor creation | |
32 // notification. When the decryptor is created, notification will be sent | |
33 // through the provided callback. | |
34 // Calling this callback with a null callback cancels previously registered | |
35 // decryptor creation notification. Any previously provided callback will be | |
36 // fired immediately with NULL. | |
37 typedef base::Callback<void(const DecryptorNotificationCB&)> | |
38 RequestDecryptorNotificationCB; | |
39 | |
40 DecryptingDemuxerStream( | 27 DecryptingDemuxerStream( |
41 const scoped_refptr<base::MessageLoopProxy>& message_loop, | 28 const scoped_refptr<base::MessageLoopProxy>& message_loop, |
42 const RequestDecryptorNotificationCB& request_decryptor_notification_cb); | 29 const SetDecryptorReadyCB& set_decryptor_ready_cb); |
43 | 30 |
44 void Initialize(const scoped_refptr<DemuxerStream>& stream, | 31 void Initialize(const scoped_refptr<DemuxerStream>& stream, |
45 const PipelineStatusCB& status_cb); | 32 const PipelineStatusCB& status_cb); |
46 void Reset(const base::Closure& closure); | 33 void Reset(const base::Closure& closure); |
47 | 34 |
48 // DemuxerStream implementation. | 35 // DemuxerStream implementation. |
49 virtual void Read(const ReadCB& read_cb) OVERRIDE; | 36 virtual void Read(const ReadCB& read_cb) OVERRIDE; |
50 virtual const AudioDecoderConfig& audio_decoder_config() OVERRIDE; | 37 virtual const AudioDecoderConfig& audio_decoder_config() OVERRIDE; |
51 virtual const VideoDecoderConfig& video_decoder_config() OVERRIDE; | 38 virtual const VideoDecoderConfig& video_decoder_config() OVERRIDE; |
52 virtual Type type() OVERRIDE; | 39 virtual Type type() OVERRIDE; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 base::Closure reset_cb_; | 100 base::Closure reset_cb_; |
114 | 101 |
115 // Pointer to the input demuxer stream that will feed us encrypted buffers. | 102 // Pointer to the input demuxer stream that will feed us encrypted buffers. |
116 scoped_refptr<DemuxerStream> demuxer_stream_; | 103 scoped_refptr<DemuxerStream> demuxer_stream_; |
117 | 104 |
118 Type stream_type_; | 105 Type stream_type_; |
119 scoped_ptr<AudioDecoderConfig> audio_config_; | 106 scoped_ptr<AudioDecoderConfig> audio_config_; |
120 scoped_ptr<VideoDecoderConfig> video_config_; | 107 scoped_ptr<VideoDecoderConfig> video_config_; |
121 | 108 |
122 // Callback to request/cancel decryptor creation notification. | 109 // Callback to request/cancel decryptor creation notification. |
123 RequestDecryptorNotificationCB request_decryptor_notification_cb_; | 110 SetDecryptorReadyCB set_decryptor_ready_cb_; |
124 | 111 |
125 Decryptor* decryptor_; | 112 Decryptor* decryptor_; |
126 | 113 |
127 // The buffer returned by the demuxer that needs to be decrypted. | 114 // The buffer returned by the demuxer that needs to be decrypted. |
128 scoped_refptr<media::DecoderBuffer> pending_buffer_to_decrypt_; | 115 scoped_refptr<media::DecoderBuffer> pending_buffer_to_decrypt_; |
129 | 116 |
130 // Indicates the situation where new key is added during pending decryption | 117 // Indicates the situation where new key is added during pending decryption |
131 // (in other words, this variable can only be set in state kPendingDecrypt). | 118 // (in other words, this variable can only be set in state kPendingDecrypt). |
132 // 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 |
133 // decrypting again in case the newly added key is the correct decryption key. | 120 // decrypting again in case the newly added key is the correct decryption key. |
134 bool key_added_while_decrypt_pending_; | 121 bool key_added_while_decrypt_pending_; |
135 | 122 |
136 DISALLOW_COPY_AND_ASSIGN(DecryptingDemuxerStream); | 123 DISALLOW_COPY_AND_ASSIGN(DecryptingDemuxerStream); |
137 }; | 124 }; |
138 | 125 |
139 } // namespace media | 126 } // namespace media |
140 | 127 |
141 #endif // MEDIA_FILTERS_DECRYPTING_DEMUXER_STREAM_H_ | 128 #endif // MEDIA_FILTERS_DECRYPTING_DEMUXER_STREAM_H_ |
OLD | NEW |