Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 kMaxKeyIdLength = 128 / 8; | |
|
ddorwin
2015/04/29 21:19:56
We could always have a limit (i.e. 1024 or whateve
jrummell
2015/05/15 00:52:59
Renamed. The existing global limit is not currentl
| |
| 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 337 | 342 |
| 338 scoped_ptr<NewSessionPromise> promise( | 343 scoped_ptr<NewSessionPromise> promise( |
| 339 new NewSessionPromise(this, render_frame_id, cdm_id, promise_id)); | 344 new NewSessionPromise(this, render_frame_id, cdm_id, promise_id)); |
| 340 | 345 |
| 341 if (init_data.size() > media::limits::kMaxInitDataLength) { | 346 if (init_data.size() > media::limits::kMaxInitDataLength) { |
| 342 LOG(WARNING) << "InitData for ID: " << cdm_id | 347 LOG(WARNING) << "InitData for ID: " << cdm_id |
| 343 << " too long: " << init_data.size(); | 348 << " too long: " << init_data.size(); |
| 344 promise->reject(MediaKeys::INVALID_ACCESS_ERROR, 0, "Init data too long."); | 349 promise->reject(MediaKeys::INVALID_ACCESS_ERROR, 0, "Init data too long."); |
| 345 return; | 350 return; |
| 346 } | 351 } |
| 352 #if defined(OS_ANDROID) | |
| 353 if (init_data_type == INIT_DATA_TYPE_WEBM && | |
| 354 init_data.size() > kMaxKeyIdLength) { | |
| 355 promise->reject(MediaKeys::INVALID_ACCESS_ERROR, 0, | |
| 356 "Init data for WEBM too long."); | |
|
ddorwin
2015/04/29 21:19:56
"'webm' initData is too long."
jrummell
2015/05/15 00:52:59
Done.
| |
| 357 return; | |
| 358 } | |
| 359 #endif | |
| 347 | 360 |
| 348 media::EmeInitDataType eme_init_data_type; | 361 media::EmeInitDataType eme_init_data_type; |
| 349 switch (init_data_type) { | 362 switch (init_data_type) { |
| 350 case INIT_DATA_TYPE_WEBM: | 363 case INIT_DATA_TYPE_WEBM: |
| 351 eme_init_data_type = media::EmeInitDataType::WEBM; | 364 eme_init_data_type = media::EmeInitDataType::WEBM; |
| 352 break; | 365 break; |
| 353 #if defined(USE_PROPRIETARY_CODECS) | 366 #if defined(USE_PROPRIETARY_CODECS) |
| 354 case INIT_DATA_TYPE_CENC: | 367 case INIT_DATA_TYPE_CENC: |
| 355 eme_init_data_type = media::EmeInitDataType::CENC; | 368 eme_init_data_type = media::EmeInitDataType::CENC; |
| 356 break; | 369 break; |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 574 } | 587 } |
| 575 | 588 |
| 576 // Only the temporary session type is supported in browser CDM path. | 589 // Only the temporary session type is supported in browser CDM path. |
| 577 // TODO(xhwang): Add SessionType support if needed. | 590 // TODO(xhwang): Add SessionType support if needed. |
| 578 cdm->CreateSessionAndGenerateRequest(media::MediaKeys::TEMPORARY_SESSION, | 591 cdm->CreateSessionAndGenerateRequest(media::MediaKeys::TEMPORARY_SESSION, |
| 579 init_data_type, init_data, | 592 init_data_type, init_data, |
| 580 promise.Pass()); | 593 promise.Pass()); |
| 581 } | 594 } |
| 582 | 595 |
| 583 } // namespace content | 596 } // namespace content |
| OLD | NEW |