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

Side by Side Diff: content/browser/media/cdm/browser_cdm_manager.cc

Issue 1113883003: Restrict WEBM Key ID data to 128-bits for Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changes Created 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/media/cdm/browser_cdm_manager.h" 5 #include "content/browser/media/cdm/browser_cdm_manager.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 18 matching lines...) Expand all
29 #include "content/public/common/renderer_preferences.h" 29 #include "content/public/common/renderer_preferences.h"
30 #endif 30 #endif
31 31
32 namespace content { 32 namespace content {
33 33
34 using media::BrowserCdm; 34 using media::BrowserCdm;
35 using media::MediaKeys; 35 using media::MediaKeys;
36 36
37 namespace { 37 namespace {
38 38
39 #if defined(OS_ANDROID)
40 // Android only supports 128-bit key IDs.
41 const size_t kAndroidMaxKeyIdLengthForWebM = 128 / 8;
ddorwin 2015/05/15 04:12:35 I believe this key ID length applies to all contai
jrummell 2015/05/15 16:41:19 Done.
42 #endif
43
39 // The ID used in this class is a concatenation of |render_frame_id| and 44 // The ID used in this class is a concatenation of |render_frame_id| and
40 // |cdm_id|, i.e. (render_frame_id << 32) + cdm_id. 45 // |cdm_id|, i.e. (render_frame_id << 32) + cdm_id.
41 46
42 uint64 GetId(int render_frame_id, int cdm_id) { 47 uint64 GetId(int render_frame_id, int cdm_id) {
43 return (static_cast<uint64>(render_frame_id) << 32) + 48 return (static_cast<uint64>(render_frame_id) << 32) +
44 static_cast<uint64>(cdm_id); 49 static_cast<uint64>(cdm_id);
45 } 50 }
46 51
47 bool IdBelongsToFrame(uint64 id, int render_frame_id) { 52 bool IdBelongsToFrame(uint64 id, int render_frame_id) {
48 return (id >> 32) == static_cast<uint64>(render_frame_id); 53 return (id >> 32) == static_cast<uint64>(render_frame_id);
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 343
339 scoped_ptr<NewSessionPromise> promise( 344 scoped_ptr<NewSessionPromise> promise(
340 new NewSessionPromise(this, render_frame_id, cdm_id, promise_id)); 345 new NewSessionPromise(this, render_frame_id, cdm_id, promise_id));
341 346
342 if (init_data.size() > media::limits::kMaxInitDataLength) { 347 if (init_data.size() > media::limits::kMaxInitDataLength) {
343 LOG(WARNING) << "InitData for ID: " << cdm_id 348 LOG(WARNING) << "InitData for ID: " << cdm_id
344 << " too long: " << init_data.size(); 349 << " too long: " << init_data.size();
345 promise->reject(MediaKeys::INVALID_ACCESS_ERROR, 0, "Init data too long."); 350 promise->reject(MediaKeys::INVALID_ACCESS_ERROR, 0, "Init data too long.");
346 return; 351 return;
347 } 352 }
353 #if defined(OS_ANDROID)
354 if (init_data_type == INIT_DATA_TYPE_WEBM &&
355 init_data.size() > kAndroidMaxKeyIdLengthForWebM) {
ddorwin 2015/05/15 04:12:35 s/>/!=/ Then update the message too.
jrummell 2015/05/15 16:41:19 Done.
356 promise->reject(MediaKeys::INVALID_ACCESS_ERROR, 0,
357 "'webm' initData is too long.");
358 return;
359 }
360 #endif
348 361
349 media::EmeInitDataType eme_init_data_type; 362 media::EmeInitDataType eme_init_data_type;
350 switch (init_data_type) { 363 switch (init_data_type) {
351 case INIT_DATA_TYPE_WEBM: 364 case INIT_DATA_TYPE_WEBM:
352 eme_init_data_type = media::EmeInitDataType::WEBM; 365 eme_init_data_type = media::EmeInitDataType::WEBM;
353 break; 366 break;
354 #if defined(USE_PROPRIETARY_CODECS) 367 #if defined(USE_PROPRIETARY_CODECS)
355 case INIT_DATA_TYPE_CENC: 368 case INIT_DATA_TYPE_CENC:
356 eme_init_data_type = media::EmeInitDataType::CENC; 369 eme_init_data_type = media::EmeInitDataType::CENC;
357 break; 370 break;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 } 591 }
579 592
580 // Only the temporary session type is supported in browser CDM path. 593 // Only the temporary session type is supported in browser CDM path.
581 // TODO(xhwang): Add SessionType support if needed. 594 // TODO(xhwang): Add SessionType support if needed.
582 cdm->CreateSessionAndGenerateRequest(media::MediaKeys::TEMPORARY_SESSION, 595 cdm->CreateSessionAndGenerateRequest(media::MediaKeys::TEMPORARY_SESSION,
583 init_data_type, init_data, 596 init_data_type, init_data,
584 promise.Pass()); 597 promise.Pass());
585 } 598 }
586 599
587 } // namespace content 600 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698