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

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: Address 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // and call |av_register_all()| from there. 48 // and call |av_register_all()| from there.
49 av_register_all(); 49 av_register_all();
50 50
51 return true; 51 return true;
52 } 52 }
53 53
54 static bool g_cdm_module_initialized = InitializeFFmpegLibraries(); 54 static bool g_cdm_module_initialized = InitializeFFmpegLibraries();
55 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER 55 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER
56 56
57 static const char kClearKeyCdmVersion[] = "0.1.0.0"; 57 static const char kClearKeyCdmVersion[] = "0.1.0.0";
58 static const char kExternalClearKey[] = "org.chromium.externalclearkey";
58 59
59 // Copies |input_buffer| into a media::DecoderBuffer. If the |input_buffer| is 60 // Copies |input_buffer| into a media::DecoderBuffer. If the |input_buffer| is
60 // empty, an empty (end-of-stream) media::DecoderBuffer is returned. 61 // empty, an empty (end-of-stream) media::DecoderBuffer is returned.
61 static scoped_refptr<media::DecoderBuffer> CopyDecoderBufferFrom( 62 static scoped_refptr<media::DecoderBuffer> CopyDecoderBufferFrom(
62 const cdm::InputBuffer& input_buffer) { 63 const cdm::InputBuffer& input_buffer) {
63 if (!input_buffer.data) { 64 if (!input_buffer.data) {
64 DCHECK_EQ(input_buffer.data_size, 0); 65 DCHECK_EQ(input_buffer.data_size, 0);
65 return media::DecoderBuffer::CreateEOSBuffer(); 66 return media::DecoderBuffer::CreateEOSBuffer();
66 } 67 }
67 68
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 }; 104 };
104 105
105 template<typename Type> 106 template<typename Type>
106 static Type* AllocateAndCopy(const Type* data, int size) { 107 static Type* AllocateAndCopy(const Type* data, int size) {
107 COMPILE_ASSERT(sizeof(Type) == 1, type_size_is_not_one); 108 COMPILE_ASSERT(sizeof(Type) == 1, type_size_is_not_one);
108 Type* copy = new Type[size]; 109 Type* copy = new Type[size];
109 memcpy(copy, data, size); 110 memcpy(copy, data, size);
110 return copy; 111 return copy;
111 } 112 }
112 113
113 cdm::ContentDecryptionModule* CreateCdmInstance( 114 cdm::ContentDecryptionModule* CreateCdmInstance(const char* key_system_arg,
114 cdm::Allocator* allocator, cdm::CdmHost* host) { 115 int key_system_size,
116 cdm::Allocator* allocator,
117 cdm::CdmHost* host) {
115 DVLOG(1) << "CreateCdmInstance()"; 118 DVLOG(1) << "CreateCdmInstance()";
119
120 const std::string key_system(key_system_arg, key_system_size);
121 const std::string kExternalClearKeyString = kExternalClearKey;
xhwang 2012/10/26 23:39:15 does this work at all? DCHECK_EQ(key_system, kExt
ddorwin 2012/10/26 23:47:46 Whatever the case, we shouldn't create a std::stri
Tom Finegan 2012/10/26 23:52:25 Didn't even try... compiles/works fine, done.
122 DCHECK_EQ(key_system, kExternalClearKeyString);
ddorwin 2012/10/26 23:47:46 As discussed offline.
123
116 return new webkit_media::ClearKeyCdm(allocator, host); 124 return new webkit_media::ClearKeyCdm(allocator, host);
117 } 125 }
118 126
119 void DestroyCdmInstance(cdm::ContentDecryptionModule* instance) { 127 void DestroyCdmInstance(cdm::ContentDecryptionModule* instance) {
120 DVLOG(1) << "DestroyCdmInstance()"; 128 DVLOG(1) << "DestroyCdmInstance()";
121 delete instance; 129 delete instance;
122 } 130 }
123 131
124 const char* GetCdmVersion() { 132 const char* GetCdmVersion() {
125 return kClearKeyCdmVersion; 133 return kClearKeyCdmVersion;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 channel_count_ = 0; 190 channel_count_ = 0;
183 bits_per_channel_ = 0; 191 bits_per_channel_ = 0;
184 samples_per_second_ = 0; 192 samples_per_second_ = 0;
185 last_timestamp_ = media::kNoTimestamp(); 193 last_timestamp_ = media::kNoTimestamp();
186 last_duration_ = media::kInfiniteDuration(); 194 last_duration_ = media::kInfiniteDuration();
187 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER 195 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER
188 } 196 }
189 197
190 ClearKeyCdm::~ClearKeyCdm() {} 198 ClearKeyCdm::~ClearKeyCdm() {}
191 199
192 cdm::Status ClearKeyCdm::GenerateKeyRequest(const uint8_t* init_data, 200 cdm::Status ClearKeyCdm::GenerateKeyRequest(const char* /* type */,
201 int /* type_size */,
202 const uint8_t* init_data,
193 int init_data_size, 203 int init_data_size,
194 cdm::KeyMessage* key_request) { 204 cdm::KeyMessage* key_request) {
195 DVLOG(1) << "GenerateKeyRequest()"; 205 DVLOG(1) << "GenerateKeyRequest()";
196 base::AutoLock auto_lock(client_lock_); 206 base::AutoLock auto_lock(client_lock_);
197 ScopedResetter<Client> auto_resetter(&client_); 207 ScopedResetter<Client> auto_resetter(&client_);
198 decryptor_.GenerateKeyRequest("", init_data, init_data_size); 208
209 // TODO(tomfinegan): Extend the Decryptor interface for passing |type|.
210 const std::string key_system = kExternalClearKey;
211 decryptor_.GenerateKeyRequest(key_system, init_data, init_data_size);
xhwang 2012/10/26 23:39:15 nit: pass in kExternalClearKey directly?
Tom Finegan 2012/10/26 23:52:25 Done.
199 212
200 if (client_.status() != Client::kKeyMessage) 213 if (client_.status() != Client::kKeyMessage)
201 return cdm::kSessionError; 214 return cdm::kSessionError;
202 215
203 DCHECK(key_request); 216 DCHECK(key_request);
204 key_request->set_session_id(client_.session_id().data(), 217 key_request->set_session_id(client_.session_id().data(),
205 client_.session_id().size()); 218 client_.session_id().size());
206 219
207 // TODO(tomfinegan): Get rid of this copy. 220 // TODO(tomfinegan): Get rid of this copy.
208 key_request->set_message(allocator_->Allocate(client_.key_message_length())); 221 key_request->set_message(allocator_->Allocate(client_.key_message_length()));
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 550
538 static unsigned char color = 0; 551 static unsigned char color = 0;
539 color += 10; 552 color += 10;
540 553
541 memset(reinterpret_cast<void*>(video_frame->frame_buffer()->data()), 554 memset(reinterpret_cast<void*>(video_frame->frame_buffer()->data()),
542 color, frame_size); 555 color, frame_size);
543 } 556 }
544 #endif // CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER 557 #endif // CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER
545 558
546 } // namespace webkit_media 559 } // namespace webkit_media
OLDNEW
« no previous file with comments | « webkit/media/crypto/ppapi/clear_key_cdm.h ('k') | webkit/media/crypto/ppapi/content_decryption_module.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698