OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CONTENT_RENDERER_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ |
6 #define CONTENT_RENDERER_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ | 6 #define CONTENT_RENDERER_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 // PpapiDecryptor implements media::MediaKeys and media::Decryptor and forwards | 29 // PpapiDecryptor implements media::MediaKeys and media::Decryptor and forwards |
30 // all calls to the PluginInstance. | 30 // all calls to the PluginInstance. |
31 // 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. |
32 class PpapiDecryptor : public media::MediaKeys, public media::Decryptor { | 32 class PpapiDecryptor : public media::MediaKeys, public media::Decryptor { |
33 public: | 33 public: |
34 static scoped_ptr<PpapiDecryptor> Create( | 34 static scoped_ptr<PpapiDecryptor> Create( |
35 const std::string& key_system, | 35 const std::string& key_system, |
36 const GURL& security_origin, | 36 const GURL& security_origin, |
37 const CreatePepperCdmCB& create_pepper_cdm_cb, | 37 const CreatePepperCdmCB& create_pepper_cdm_cb, |
38 const media::SessionCreatedCB& session_created_cb, | |
39 const media::SessionMessageCB& session_message_cb, | 38 const media::SessionMessageCB& session_message_cb, |
40 const media::SessionReadyCB& session_ready_cb, | 39 const media::SessionReadyCB& session_ready_cb, |
41 const media::SessionClosedCB& session_closed_cb, | 40 const media::SessionClosedCB& session_closed_cb, |
42 const media::SessionErrorCB& session_error_cb); | 41 const media::SessionErrorCB& session_error_cb); |
43 | 42 |
44 virtual ~PpapiDecryptor(); | 43 virtual ~PpapiDecryptor(); |
45 | 44 |
46 // media::MediaKeys implementation. | 45 // media::MediaKeys implementation. |
47 virtual bool CreateSession(uint32 session_id, | 46 virtual void CreateSession( |
48 const std::string& content_type, | 47 const std::string& init_data_type, |
49 const uint8* init_data, | 48 const uint8* init_data, |
50 int init_data_length) OVERRIDE; | 49 int init_data_length, |
51 virtual void LoadSession(uint32 session_id, | 50 SessionType session_type, |
52 const std::string& web_session_id) OVERRIDE; | 51 scoped_ptr<media::NewSessionCdmPromise> promise) OVERRIDE; |
53 virtual void UpdateSession(uint32 session_id, | 52 virtual void LoadSession( |
54 const uint8* response, | 53 const std::string& web_session_id, |
55 int response_length) OVERRIDE; | 54 scoped_ptr<media::NewSessionCdmPromise> promise) OVERRIDE; |
56 virtual void ReleaseSession(uint32 session_id) OVERRIDE; | 55 virtual void UpdateSession( |
| 56 const std::string& web_session_id, |
| 57 const uint8* response, |
| 58 int response_length, |
| 59 scoped_ptr<media::SimpleCdmPromise> promise) OVERRIDE; |
| 60 virtual void ReleaseSession( |
| 61 const std::string& web_session_id, |
| 62 scoped_ptr<media::SimpleCdmPromise> promise) OVERRIDE; |
57 virtual Decryptor* GetDecryptor() OVERRIDE; | 63 virtual Decryptor* GetDecryptor() OVERRIDE; |
58 | 64 |
59 // media::Decryptor implementation. | 65 // media::Decryptor implementation. |
60 virtual void RegisterNewKeyCB(StreamType stream_type, | 66 virtual void RegisterNewKeyCB(StreamType stream_type, |
61 const NewKeyCB& key_added_cb) OVERRIDE; | 67 const NewKeyCB& key_added_cb) OVERRIDE; |
62 virtual void Decrypt(StreamType stream_type, | 68 virtual void Decrypt(StreamType stream_type, |
63 const scoped_refptr<media::DecoderBuffer>& encrypted, | 69 const scoped_refptr<media::DecoderBuffer>& encrypted, |
64 const DecryptCB& decrypt_cb) OVERRIDE; | 70 const DecryptCB& decrypt_cb) OVERRIDE; |
65 virtual void CancelDecrypt(StreamType stream_type) OVERRIDE; | 71 virtual void CancelDecrypt(StreamType stream_type) OVERRIDE; |
66 virtual void InitializeAudioDecoder(const media::AudioDecoderConfig& config, | 72 virtual void InitializeAudioDecoder(const media::AudioDecoderConfig& config, |
67 const DecoderInitCB& init_cb) OVERRIDE; | 73 const DecoderInitCB& init_cb) OVERRIDE; |
68 virtual void InitializeVideoDecoder(const media::VideoDecoderConfig& config, | 74 virtual void InitializeVideoDecoder(const media::VideoDecoderConfig& config, |
69 const DecoderInitCB& init_cb) OVERRIDE; | 75 const DecoderInitCB& init_cb) OVERRIDE; |
70 virtual void DecryptAndDecodeAudio( | 76 virtual void DecryptAndDecodeAudio( |
71 const scoped_refptr<media::DecoderBuffer>& encrypted, | 77 const scoped_refptr<media::DecoderBuffer>& encrypted, |
72 const AudioDecodeCB& audio_decode_cb) OVERRIDE; | 78 const AudioDecodeCB& audio_decode_cb) OVERRIDE; |
73 virtual void DecryptAndDecodeVideo( | 79 virtual void DecryptAndDecodeVideo( |
74 const scoped_refptr<media::DecoderBuffer>& encrypted, | 80 const scoped_refptr<media::DecoderBuffer>& encrypted, |
75 const VideoDecodeCB& video_decode_cb) OVERRIDE; | 81 const VideoDecodeCB& video_decode_cb) OVERRIDE; |
76 virtual void ResetDecoder(StreamType stream_type) OVERRIDE; | 82 virtual void ResetDecoder(StreamType stream_type) OVERRIDE; |
77 virtual void DeinitializeDecoder(StreamType stream_type) OVERRIDE; | 83 virtual void DeinitializeDecoder(StreamType stream_type) OVERRIDE; |
78 | 84 |
79 private: | 85 private: |
80 PpapiDecryptor(const std::string& key_system, | 86 PpapiDecryptor(const std::string& key_system, |
81 scoped_ptr<PepperCdmWrapper> pepper_cdm_wrapper, | 87 scoped_ptr<PepperCdmWrapper> pepper_cdm_wrapper, |
82 const media::SessionCreatedCB& session_created_cb, | |
83 const media::SessionMessageCB& session_message_cb, | 88 const media::SessionMessageCB& session_message_cb, |
84 const media::SessionReadyCB& session_ready_cb, | 89 const media::SessionReadyCB& session_ready_cb, |
85 const media::SessionClosedCB& session_closed_cb, | 90 const media::SessionClosedCB& session_closed_cb, |
86 const media::SessionErrorCB& session_error_cb); | 91 const media::SessionErrorCB& session_error_cb); |
87 | 92 |
88 void ReportFailureToCallPlugin(uint32 session_id); | |
89 | |
90 void OnDecoderInitialized(StreamType stream_type, bool success); | 93 void OnDecoderInitialized(StreamType stream_type, bool success); |
91 | 94 |
92 // Callbacks for |plugin_cdm_delegate_| to fire session events. | 95 // Callbacks for |plugin_cdm_delegate_| to fire session events. |
93 void OnSessionCreated(uint32 session_id, const std::string& web_session_id); | 96 void OnSessionMessage(const std::string& web_session_id, |
94 void OnSessionMessage(uint32 session_id, | |
95 const std::vector<uint8>& message, | 97 const std::vector<uint8>& message, |
96 const GURL& destination_url); | 98 const GURL& destination_url); |
97 void OnSessionReady(uint32 session_id); | 99 void OnSessionReady(const std::string& web_session_id); |
98 void OnSessionClosed(uint32 session_id); | 100 void OnSessionClosed(const std::string& web_session_id); |
99 void OnSessionError(uint32 session_id, | 101 void OnSessionError(const std::string& web_session_id, |
100 media::MediaKeys::KeyError error_code, | 102 MediaKeys::Exception exception_code, |
101 uint32 system_code); | 103 uint32 system_code, |
| 104 const std::string& error_description); |
| 105 |
| 106 // On a successful Update() or SessionReady event, trigger playback to resume. |
| 107 void ResumePlayback(); |
102 | 108 |
103 // Callback to notify that a fatal error happened in |plugin_cdm_delegate_|. | 109 // Callback to notify that a fatal error happened in |plugin_cdm_delegate_|. |
104 // The error is terminal and |plugin_cdm_delegate_| should not be used after | 110 // The error is terminal and |plugin_cdm_delegate_| should not be used after |
105 // this call. | 111 // this call. |
106 void OnFatalPluginError(); | 112 void OnFatalPluginError(); |
107 | 113 |
108 ContentDecryptorDelegate* CdmDelegate(); | 114 ContentDecryptorDelegate* CdmDelegate(); |
109 | 115 |
110 // Hold a reference of the Pepper CDM wrapper to make sure the plugin lives | 116 // Hold a reference of the Pepper CDM wrapper to make sure the plugin lives |
111 // as long as needed. | 117 // as long as needed. |
112 scoped_ptr<PepperCdmWrapper> pepper_cdm_wrapper_; | 118 scoped_ptr<PepperCdmWrapper> pepper_cdm_wrapper_; |
113 | 119 |
114 // Callbacks for firing session events. | 120 // Callbacks for firing session events. |
115 media::SessionCreatedCB session_created_cb_; | |
116 media::SessionMessageCB session_message_cb_; | 121 media::SessionMessageCB session_message_cb_; |
117 media::SessionReadyCB session_ready_cb_; | 122 media::SessionReadyCB session_ready_cb_; |
118 media::SessionClosedCB session_closed_cb_; | 123 media::SessionClosedCB session_closed_cb_; |
119 media::SessionErrorCB session_error_cb_; | 124 media::SessionErrorCB session_error_cb_; |
120 | 125 |
121 scoped_refptr<base::MessageLoopProxy> render_loop_proxy_; | 126 scoped_refptr<base::MessageLoopProxy> render_loop_proxy_; |
122 | 127 |
123 DecoderInitCB audio_decoder_init_cb_; | 128 DecoderInitCB audio_decoder_init_cb_; |
124 DecoderInitCB video_decoder_init_cb_; | 129 DecoderInitCB video_decoder_init_cb_; |
125 NewKeyCB new_audio_key_cb_; | 130 NewKeyCB new_audio_key_cb_; |
126 NewKeyCB new_video_key_cb_; | 131 NewKeyCB new_video_key_cb_; |
127 | 132 |
128 // NOTE: Weak pointers must be invalidated before all other member variables. | 133 // NOTE: Weak pointers must be invalidated before all other member variables. |
129 base::WeakPtrFactory<PpapiDecryptor> weak_ptr_factory_; | 134 base::WeakPtrFactory<PpapiDecryptor> weak_ptr_factory_; |
130 | 135 |
131 DISALLOW_COPY_AND_ASSIGN(PpapiDecryptor); | 136 DISALLOW_COPY_AND_ASSIGN(PpapiDecryptor); |
132 }; | 137 }; |
133 | 138 |
134 } // namespace content | 139 } // namespace content |
135 | 140 |
136 #endif // CONTENT_RENDERER_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ | 141 #endif // CONTENT_RENDERER_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ |
OLD | NEW |