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

Side by Side Diff: webkit/media/crypto/ppapi_decryptor.h

Issue 15772012: Separate MediaKeys interface from Decryptor interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 months 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 | Annotate | Revision Log
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 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.
54 virtual void RegisterNewKeyCB(StreamType stream_type, 55 virtual void RegisterNewKeyCB(StreamType stream_type,
55 const NewKeyCB& key_added_cb) OVERRIDE; 56 const NewKeyCB& key_added_cb) OVERRIDE;
56 virtual void Decrypt(StreamType stream_type, 57 virtual void Decrypt(StreamType stream_type,
57 const scoped_refptr<media::DecoderBuffer>& encrypted, 58 const scoped_refptr<media::DecoderBuffer>& encrypted,
58 const DecryptCB& decrypt_cb) OVERRIDE; 59 const DecryptCB& decrypt_cb) OVERRIDE;
59 virtual void CancelDecrypt(StreamType stream_type) OVERRIDE; 60 virtual void CancelDecrypt(StreamType stream_type) OVERRIDE;
60 virtual void InitializeAudioDecoder(const media::AudioDecoderConfig& config, 61 virtual void InitializeAudioDecoder(const media::AudioDecoderConfig& config,
61 const DecoderInitCB& init_cb) OVERRIDE; 62 const DecoderInitCB& init_cb) OVERRIDE;
62 virtual void InitializeVideoDecoder(const media::VideoDecoderConfig& config, 63 virtual void InitializeVideoDecoder(const media::VideoDecoderConfig& config,
63 const DecoderInitCB& init_cb) OVERRIDE; 64 const DecoderInitCB& init_cb) OVERRIDE;
64 virtual void DecryptAndDecodeAudio( 65 virtual void DecryptAndDecodeAudio(
65 const scoped_refptr<media::DecoderBuffer>& encrypted, 66 const scoped_refptr<media::DecoderBuffer>& encrypted,
66 const AudioDecodeCB& audio_decode_cb) OVERRIDE; 67 const AudioDecodeCB& audio_decode_cb) OVERRIDE;
67 virtual void DecryptAndDecodeVideo( 68 virtual void DecryptAndDecodeVideo(
68 const scoped_refptr<media::DecoderBuffer>& encrypted, 69 const scoped_refptr<media::DecoderBuffer>& encrypted,
69 const VideoDecodeCB& video_decode_cb) OVERRIDE; 70 const VideoDecodeCB& video_decode_cb) OVERRIDE;
70 virtual void ResetDecoder(StreamType stream_type) OVERRIDE; 71 virtual void ResetDecoder(StreamType stream_type) OVERRIDE;
71 virtual void DeinitializeDecoder(StreamType stream_type) OVERRIDE; 72 virtual void DeinitializeDecoder(StreamType stream_type) OVERRIDE;
72 73
73 private: 74 private:
74 void ReportFailureToCallPlugin(const std::string& key_system, 75 void ReportFailureToCallPlugin(const std::string& key_system,
75 const std::string& session_id); 76 const std::string& session_id);
76 77
77 void OnDecoderInitialized(StreamType stream_type, bool success); 78 void OnDecoderInitialized(StreamType stream_type, bool success);
78 79
79 // Callbacks for |plugin_cdm_delegate_| to fire key events. 80 // Callbacks for |plugin_cdm_delegate_| to fire key events.
80 void KeyAdded(const std::string& key_system, const std::string& session_id); 81 void KeyAdded(const std::string& key_system, const std::string& session_id);
81 void KeyError(const std::string& key_system, 82 void KeyError(const std::string& key_system,
82 const std::string& session_id, 83 const std::string& session_id,
83 media::Decryptor::KeyError error_code, 84 media::MediaKeys::KeyError error_code,
84 int system_code); 85 int system_code);
85 void KeyMessage(const std::string& key_system, 86 void KeyMessage(const std::string& key_system,
86 const std::string& session_id, 87 const std::string& session_id,
87 const std::string& message, 88 const std::string& message,
88 const std::string& default_url); 89 const std::string& default_url);
89 void NeedKey(const std::string& key_system, 90 void NeedKey(const std::string& key_system,
90 const std::string& session_id, 91 const std::string& session_id,
91 const std::string& type, 92 const std::string& type,
92 scoped_ptr<uint8[]> init_data, int init_data_size); 93 scoped_ptr<uint8[]> init_data, int init_data_size);
93 94
(...skipping 19 matching lines...) Expand all
113 114
114 base::WeakPtrFactory<PpapiDecryptor> weak_ptr_factory_; 115 base::WeakPtrFactory<PpapiDecryptor> weak_ptr_factory_;
115 base::WeakPtr<PpapiDecryptor> weak_this_; 116 base::WeakPtr<PpapiDecryptor> weak_this_;
116 117
117 DISALLOW_COPY_AND_ASSIGN(PpapiDecryptor); 118 DISALLOW_COPY_AND_ASSIGN(PpapiDecryptor);
118 }; 119 };
119 120
120 } // namespace webkit_media 121 } // namespace webkit_media
121 122
122 #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_ 123 #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_DECRYPTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698