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_CLEAR_KEY_CDM_H_ | 5 #ifndef WEBKIT_MEDIA_CRYPTO_PPAPI_CLEAR_KEY_CDM_H_ |
6 #define WEBKIT_MEDIA_CRYPTO_PPAPI_CLEAR_KEY_CDM_H_ | 6 #define WEBKIT_MEDIA_CRYPTO_PPAPI_CLEAR_KEY_CDM_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
15 #include "media/base/decryptor_client.h" | |
16 #include "media/crypto/aes_decryptor.h" | 15 #include "media/crypto/aes_decryptor.h" |
17 #include "webkit/media/crypto/ppapi/cdm/content_decryption_module.h" | 16 #include "webkit/media/crypto/ppapi/cdm/content_decryption_module.h" |
18 | 17 |
19 // Enable this to use the fake decoder for testing. | 18 // Enable this to use the fake decoder for testing. |
20 // TODO(tomfinegan): Move fake audio decoder into a separate class. | 19 // TODO(tomfinegan): Move fake audio decoder into a separate class. |
21 #if 0 | 20 #if 0 |
22 #define CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER | 21 #define CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER |
23 #endif | 22 #endif |
24 | 23 |
25 namespace media { | 24 namespace media { |
(...skipping 30 matching lines...) Expand all Loading... |
56 virtual void DeinitializeDecoder(cdm::StreamType decoder_type) OVERRIDE; | 55 virtual void DeinitializeDecoder(cdm::StreamType decoder_type) OVERRIDE; |
57 virtual void ResetDecoder(cdm::StreamType decoder_type) OVERRIDE; | 56 virtual void ResetDecoder(cdm::StreamType decoder_type) OVERRIDE; |
58 virtual cdm::Status DecryptAndDecodeFrame( | 57 virtual cdm::Status DecryptAndDecodeFrame( |
59 const cdm::InputBuffer& encrypted_buffer, | 58 const cdm::InputBuffer& encrypted_buffer, |
60 cdm::VideoFrame* video_frame) OVERRIDE; | 59 cdm::VideoFrame* video_frame) OVERRIDE; |
61 virtual cdm::Status DecryptAndDecodeSamples( | 60 virtual cdm::Status DecryptAndDecodeSamples( |
62 const cdm::InputBuffer& encrypted_buffer, | 61 const cdm::InputBuffer& encrypted_buffer, |
63 cdm::AudioFrames* audio_frames) OVERRIDE; | 62 cdm::AudioFrames* audio_frames) OVERRIDE; |
64 | 63 |
65 private: | 64 private: |
66 class Client : public media::DecryptorClient { | 65 // TODO(xhwang): After we removed DecryptorClient. We probably can also remove |
| 66 // this Client class as well. Investigate this possibility. |
| 67 class Client { |
67 public: | 68 public: |
68 enum Status { | 69 enum Status { |
69 kKeyAdded, | 70 kKeyAdded, |
70 kKeyError, | 71 kKeyError, |
71 kKeyMessage, | 72 kKeyMessage, |
72 kNeedKey | 73 kNeedKey |
73 }; | 74 }; |
74 | 75 |
75 Client(); | 76 Client(); |
76 virtual ~Client(); | 77 virtual ~Client(); |
77 | 78 |
78 Status status() { return status_; } | 79 Status status() { return status_; } |
79 const std::string& session_id() { return session_id_; } | 80 const std::string& session_id() { return session_id_; } |
80 const std::string& key_message() { return key_message_; } | 81 const std::string& key_message() { return key_message_; } |
81 const std::string& default_url() { return default_url_; } | 82 const std::string& default_url() { return default_url_; } |
82 | 83 |
83 // Resets the Client to a clean state. | 84 // Resets the Client to a clean state. |
84 void Reset(); | 85 void Reset(); |
85 | 86 |
86 // media::DecryptorClient implementation. | 87 void KeyAdded(const std::string& key_system, const std::string& session_id); |
87 virtual void KeyAdded(const std::string& key_system, | 88 void KeyError(const std::string& key_system, |
88 const std::string& session_id) OVERRIDE; | 89 const std::string& session_id, |
89 virtual void KeyError(const std::string& key_system, | 90 media::Decryptor::KeyError error_code, |
90 const std::string& session_id, | 91 int system_code); |
91 media::Decryptor::KeyError error_code, | 92 void KeyMessage(const std::string& key_system, |
92 int system_code) OVERRIDE; | 93 const std::string& session_id, |
93 virtual void KeyMessage(const std::string& key_system, | 94 const std::string& message, |
94 const std::string& session_id, | 95 const std::string& default_url); |
95 const std::string& message, | 96 void NeedKey(const std::string& key_system, |
96 const std::string& default_url) OVERRIDE; | 97 const std::string& session_id, |
97 virtual void NeedKey(const std::string& key_system, | 98 const std::string& type, |
98 const std::string& session_id, | 99 scoped_array<uint8> init_data, int init_data_length); |
99 const std::string& type, | |
100 scoped_array<uint8> init_data, | |
101 int init_data_length) OVERRIDE; | |
102 | 100 |
103 private: | 101 private: |
104 Status status_; | 102 Status status_; |
105 std::string session_id_; | 103 std::string session_id_; |
106 std::string key_message_; | 104 std::string key_message_; |
107 std::string default_url_; | 105 std::string default_url_; |
108 }; | 106 }; |
109 | 107 |
110 // Prepares next heartbeat message and sets a timer for it. | 108 // Prepares next heartbeat message and sets a timer for it. |
111 void ScheduleNextHeartBeat(); | 109 void ScheduleNextHeartBeat(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER | 167 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER |
170 | 168 |
171 scoped_ptr<CdmVideoDecoder> video_decoder_; | 169 scoped_ptr<CdmVideoDecoder> video_decoder_; |
172 | 170 |
173 DISALLOW_COPY_AND_ASSIGN(ClearKeyCdm); | 171 DISALLOW_COPY_AND_ASSIGN(ClearKeyCdm); |
174 }; | 172 }; |
175 | 173 |
176 } // namespace webkit_media | 174 } // namespace webkit_media |
177 | 175 |
178 #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_CLEAR_KEY_CDM_H_ | 176 #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_CLEAR_KEY_CDM_H_ |
OLD | NEW |