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 WEBKIT_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ | 5 #ifndef WEBKIT_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ |
6 #define WEBKIT_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ | 6 #define WEBKIT_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "media/base/decryptor.h" | 12 #include "media/base/decryptor.h" |
| 13 #include "media/base/media_keys.h" |
13 #include "media/base/video_decoder_config.h" | 14 #include "media/base/video_decoder_config.h" |
14 | 15 |
15 namespace base { | 16 namespace base { |
16 class MessageLoopProxy; | 17 class MessageLoopProxy; |
17 } | 18 } |
18 | 19 |
19 namespace webkit { | 20 namespace webkit { |
20 namespace ppapi { | 21 namespace ppapi { |
21 class ContentDecryptorDelegate; | 22 class ContentDecryptorDelegate; |
22 class PluginInstance; | 23 class PluginInstance; |
23 } | 24 } |
24 } | 25 } |
25 | 26 |
26 namespace webkit_media { | 27 namespace webkit_media { |
27 | 28 |
28 // PpapiDecryptor implements media::Decryptor and forwards all calls to the | 29 // PpapiDecryptor implements media::Decryptor and forwards all calls to the |
29 // PluginInstance. | 30 // PluginInstance. |
30 // This class should always be created & destroyed on the main renderer thread. | 31 // This class should always be created & destroyed on the main renderer thread. |
31 class PpapiDecryptor : public media::Decryptor { | 32 class PpapiDecryptor : public media::MediaKeys, public media::Decryptor { |
32 public: | 33 public: |
33 PpapiDecryptor( | 34 PpapiDecryptor( |
34 const scoped_refptr<webkit::ppapi::PluginInstance>& plugin_instance, | 35 const scoped_refptr<webkit::ppapi::PluginInstance>& plugin_instance, |
35 const media::KeyAddedCB& key_added_cb, | 36 const media::KeyAddedCB& key_added_cb, |
36 const media::KeyErrorCB& key_error_cb, | 37 const media::KeyErrorCB& key_error_cb, |
37 const media::KeyMessageCB& key_message_cb, | 38 const media::KeyMessageCB& key_message_cb, |
38 const media::NeedKeyCB& need_key_cb); | 39 const media::NeedKeyCB& need_key_cb); |
39 virtual ~PpapiDecryptor(); | 40 virtual ~PpapiDecryptor(); |
40 | 41 |
41 // media::Decryptor implementation. | 42 // media::MediaKeys implementation. |
42 virtual bool GenerateKeyRequest(const std::string& key_system, | 43 virtual bool GenerateKeyRequest(const std::string& key_system, |
43 const std::string& type, | 44 const std::string& type, |
44 const uint8* init_data, | 45 const uint8* init_data, |
45 int init_data_length) OVERRIDE; | 46 int init_data_length) OVERRIDE; |
46 virtual void AddKey(const std::string& key_system, | 47 virtual void AddKey(const std::string& key_system, |
47 const uint8* key, | 48 const uint8* key, int key_length, |
48 int key_length, | 49 const uint8* init_data, int init_data_length, |
49 const uint8* init_data, | |
50 int init_data_length, | |
51 const std::string& session_id) OVERRIDE; | 50 const std::string& session_id) OVERRIDE; |
52 virtual void CancelKeyRequest(const std::string& key_system, | 51 virtual void CancelKeyRequest(const std::string& key_system, |
53 const std::string& session_id) OVERRIDE; | 52 const std::string& session_id) OVERRIDE; |
| 53 |
| 54 // media::Decryptor implementation. |
| 55 virtual media::MediaKeys* GetMediaKeys() OVERRIDE; |
54 virtual void RegisterNewKeyCB(StreamType stream_type, | 56 virtual void RegisterNewKeyCB(StreamType stream_type, |
55 const NewKeyCB& key_added_cb) OVERRIDE; | 57 const NewKeyCB& key_added_cb) OVERRIDE; |
56 virtual void Decrypt(StreamType stream_type, | 58 virtual void Decrypt(StreamType stream_type, |
57 const scoped_refptr<media::DecoderBuffer>& encrypted, | 59 const scoped_refptr<media::DecoderBuffer>& encrypted, |
58 const DecryptCB& decrypt_cb) OVERRIDE; | 60 const DecryptCB& decrypt_cb) OVERRIDE; |
59 virtual void CancelDecrypt(StreamType stream_type) OVERRIDE; | 61 virtual void CancelDecrypt(StreamType stream_type) OVERRIDE; |
60 virtual void InitializeAudioDecoder(const media::AudioDecoderConfig& config, | 62 virtual void InitializeAudioDecoder(const media::AudioDecoderConfig& config, |
61 const DecoderInitCB& init_cb) OVERRIDE; | 63 const DecoderInitCB& init_cb) OVERRIDE; |
62 virtual void InitializeVideoDecoder(const media::VideoDecoderConfig& config, | 64 virtual void InitializeVideoDecoder(const media::VideoDecoderConfig& config, |
63 const DecoderInitCB& init_cb) OVERRIDE; | 65 const DecoderInitCB& init_cb) OVERRIDE; |
64 virtual void DecryptAndDecodeAudio( | 66 virtual void DecryptAndDecodeAudio( |
65 const scoped_refptr<media::DecoderBuffer>& encrypted, | 67 const scoped_refptr<media::DecoderBuffer>& encrypted, |
66 const AudioDecodeCB& audio_decode_cb) OVERRIDE; | 68 const AudioDecodeCB& audio_decode_cb) OVERRIDE; |
67 virtual void DecryptAndDecodeVideo( | 69 virtual void DecryptAndDecodeVideo( |
68 const scoped_refptr<media::DecoderBuffer>& encrypted, | 70 const scoped_refptr<media::DecoderBuffer>& encrypted, |
69 const VideoDecodeCB& video_decode_cb) OVERRIDE; | 71 const VideoDecodeCB& video_decode_cb) OVERRIDE; |
70 virtual void ResetDecoder(StreamType stream_type) OVERRIDE; | 72 virtual void ResetDecoder(StreamType stream_type) OVERRIDE; |
71 virtual void DeinitializeDecoder(StreamType stream_type) OVERRIDE; | 73 virtual void DeinitializeDecoder(StreamType stream_type) OVERRIDE; |
72 | 74 |
73 private: | 75 private: |
74 void ReportFailureToCallPlugin(const std::string& key_system, | 76 void ReportFailureToCallPlugin(const std::string& key_system, |
75 const std::string& session_id); | 77 const std::string& session_id); |
76 | 78 |
77 void OnDecoderInitialized(StreamType stream_type, bool success); | 79 void OnDecoderInitialized(StreamType stream_type, bool success); |
78 | 80 |
79 // Callbacks for |plugin_cdm_delegate_| to fire key events. | 81 // Callbacks for |plugin_cdm_delegate_| to fire key events. |
80 void KeyAdded(const std::string& key_system, const std::string& session_id); | 82 void KeyAdded(const std::string& key_system, const std::string& session_id); |
81 void KeyError(const std::string& key_system, | 83 void KeyError(const std::string& key_system, |
82 const std::string& session_id, | 84 const std::string& session_id, |
83 media::Decryptor::KeyError error_code, | 85 media::MediaKeys::KeyError error_code, |
84 int system_code); | 86 int system_code); |
85 void KeyMessage(const std::string& key_system, | 87 void KeyMessage(const std::string& key_system, |
86 const std::string& session_id, | 88 const std::string& session_id, |
87 const std::string& message, | 89 const std::string& message, |
88 const std::string& default_url); | 90 const std::string& default_url); |
89 void NeedKey(const std::string& key_system, | 91 void NeedKey(const std::string& key_system, |
90 const std::string& session_id, | 92 const std::string& session_id, |
91 const std::string& type, | 93 const std::string& type, |
92 scoped_ptr<uint8[]> init_data, int init_data_size); | 94 scoped_ptr<uint8[]> init_data, int init_data_size); |
93 | 95 |
(...skipping 19 matching lines...) Expand all Loading... |
113 | 115 |
114 base::WeakPtrFactory<PpapiDecryptor> weak_ptr_factory_; | 116 base::WeakPtrFactory<PpapiDecryptor> weak_ptr_factory_; |
115 base::WeakPtr<PpapiDecryptor> weak_this_; | 117 base::WeakPtr<PpapiDecryptor> weak_this_; |
116 | 118 |
117 DISALLOW_COPY_AND_ASSIGN(PpapiDecryptor); | 119 DISALLOW_COPY_AND_ASSIGN(PpapiDecryptor); |
118 }; | 120 }; |
119 | 121 |
120 } // namespace webkit_media | 122 } // namespace webkit_media |
121 | 123 |
122 #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ | 124 #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ |
OLD | NEW |