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

Side by Side Diff: webkit/media/crypto/ppapi/clear_key_cdm.cc

Issue 11270057: Add type argument to pepper content decryptor method GenerateKeyRequest(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased on 11274065, and addressed comments. Created 8 years, 1 month 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 #include "webkit/media/crypto/ppapi/clear_key_cdm.h" 5 #include "webkit/media/crypto/ppapi/clear_key_cdm.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 }; 103 };
104 104
105 template<typename Type> 105 template<typename Type>
106 static Type* AllocateAndCopy(const Type* data, int size) { 106 static Type* AllocateAndCopy(const Type* data, int size) {
107 COMPILE_ASSERT(sizeof(Type) == 1, type_size_is_not_one); 107 COMPILE_ASSERT(sizeof(Type) == 1, type_size_is_not_one);
108 Type* copy = new Type[size]; 108 Type* copy = new Type[size];
109 memcpy(copy, data, size); 109 memcpy(copy, data, size);
110 return copy; 110 return copy;
111 } 111 }
112 112
113 cdm::ContentDecryptionModule* CreateCdmInstance( 113 cdm::ContentDecryptionModule* CreateCdmInstance(cdm::Allocator* allocator,
114 cdm::Allocator* allocator, cdm::CdmHost* host) { 114 cdm::CdmHost* host,
115 const char* key_system_arg,
116 int key_system_size) {
115 DVLOG(1) << "CreateCdmInstance()"; 117 DVLOG(1) << "CreateCdmInstance()";
118
119 const std::string key_system(key_system_arg, key_system_size);
120 const std::string kExternalClearKey = "org.chromium.externalclearkey";
xhwang 2012/10/26 23:08:09 how about defining this as file scoped static cons
Tom Finegan 2012/10/26 23:30:18 Done.
121 DCHECK_EQ(key_system, kExternalClearKey);
122
116 return new webkit_media::ClearKeyCdm(allocator, host); 123 return new webkit_media::ClearKeyCdm(allocator, host);
117 } 124 }
118 125
119 void DestroyCdmInstance(cdm::ContentDecryptionModule* instance) { 126 void DestroyCdmInstance(cdm::ContentDecryptionModule* instance) {
120 DVLOG(1) << "DestroyCdmInstance()"; 127 DVLOG(1) << "DestroyCdmInstance()";
121 delete instance; 128 delete instance;
122 } 129 }
123 130
124 const char* GetCdmVersion() { 131 const char* GetCdmVersion() {
125 return kClearKeyCdmVersion; 132 return kClearKeyCdmVersion;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 channel_count_ = 0; 189 channel_count_ = 0;
183 bits_per_channel_ = 0; 190 bits_per_channel_ = 0;
184 samples_per_second_ = 0; 191 samples_per_second_ = 0;
185 last_timestamp_ = media::kNoTimestamp(); 192 last_timestamp_ = media::kNoTimestamp();
186 last_duration_ = media::kInfiniteDuration(); 193 last_duration_ = media::kInfiniteDuration();
187 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER 194 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER
188 } 195 }
189 196
190 ClearKeyCdm::~ClearKeyCdm() {} 197 ClearKeyCdm::~ClearKeyCdm() {}
191 198
192 cdm::Status ClearKeyCdm::GenerateKeyRequest(const uint8_t* init_data, 199 cdm::Status ClearKeyCdm::GenerateKeyRequest(const char* key_system_arg,
200 int key_system_size,
201 const char* /* type */,
202 int /* type_size */,
203 const uint8_t* init_data,
193 int init_data_size, 204 int init_data_size,
194 cdm::KeyMessage* key_request) { 205 cdm::KeyMessage* key_request) {
195 DVLOG(1) << "GenerateKeyRequest()"; 206 DVLOG(1) << "GenerateKeyRequest()";
196 base::AutoLock auto_lock(client_lock_); 207 base::AutoLock auto_lock(client_lock_);
197 ScopedResetter<Client> auto_resetter(&client_); 208 ScopedResetter<Client> auto_resetter(&client_);
198 decryptor_.GenerateKeyRequest("", init_data, init_data_size); 209
210 // TODO(tomfinegan): Extend the Decryptor interface for passing |type|.
211 const std::string key_system(key_system_arg, key_system_size);
212 decryptor_.GenerateKeyRequest(key_system, init_data, init_data_size);
199 213
200 if (client_.status() != Client::kKeyMessage) 214 if (client_.status() != Client::kKeyMessage)
201 return cdm::kSessionError; 215 return cdm::kSessionError;
202 216
203 DCHECK(key_request); 217 DCHECK(key_request);
204 key_request->set_session_id(client_.session_id().data(), 218 key_request->set_session_id(client_.session_id().data(),
205 client_.session_id().size()); 219 client_.session_id().size());
206 220
207 // TODO(tomfinegan): Get rid of this copy. 221 // TODO(tomfinegan): Get rid of this copy.
208 key_request->set_message(allocator_->Allocate(client_.key_message_length())); 222 key_request->set_message(allocator_->Allocate(client_.key_message_length()));
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 551
538 static unsigned char color = 0; 552 static unsigned char color = 0;
539 color += 10; 553 color += 10;
540 554
541 memset(reinterpret_cast<void*>(video_frame->frame_buffer()->data()), 555 memset(reinterpret_cast<void*>(video_frame->frame_buffer()->data()),
542 color, frame_size); 556 color, frame_size);
543 } 557 }
544 #endif // CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER 558 #endif // CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER
545 559
546 } // namespace webkit_media 560 } // namespace webkit_media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698