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 kAndroidKeyIdBytes = 128 / 8; | |
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 Loading... | |
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 // On Android 'webm' initData should contain exactly 1 key. | |
ddorwin
2015/05/15 16:54:35
Remove "On Android ". This is always true for WebM
jrummell
2015/05/15 17:52:21
Done.
| |
355 if (init_data_type == INIT_DATA_TYPE_WEBM && | |
356 init_data.size() != kAndroidKeyIdBytes) { | |
357 promise->reject(MediaKeys::INVALID_ACCESS_ERROR, 0, | |
358 "'webm' initData does not contain a single key."); | |
ddorwin
2015/05/15 16:54:35
By definition, it is a single key ID. The problem
jrummell
2015/05/15 17:52:21
Done.
| |
359 return; | |
360 } | |
361 #endif | |
348 | 362 |
349 media::EmeInitDataType eme_init_data_type; | 363 media::EmeInitDataType eme_init_data_type; |
350 switch (init_data_type) { | 364 switch (init_data_type) { |
351 case INIT_DATA_TYPE_WEBM: | 365 case INIT_DATA_TYPE_WEBM: |
352 eme_init_data_type = media::EmeInitDataType::WEBM; | 366 eme_init_data_type = media::EmeInitDataType::WEBM; |
353 break; | 367 break; |
354 #if defined(USE_PROPRIETARY_CODECS) | 368 #if defined(USE_PROPRIETARY_CODECS) |
355 case INIT_DATA_TYPE_CENC: | 369 case INIT_DATA_TYPE_CENC: |
356 eme_init_data_type = media::EmeInitDataType::CENC; | 370 eme_init_data_type = media::EmeInitDataType::CENC; |
357 break; | 371 break; |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
578 } | 592 } |
579 | 593 |
580 // Only the temporary session type is supported in browser CDM path. | 594 // Only the temporary session type is supported in browser CDM path. |
581 // TODO(xhwang): Add SessionType support if needed. | 595 // TODO(xhwang): Add SessionType support if needed. |
582 cdm->CreateSessionAndGenerateRequest(media::MediaKeys::TEMPORARY_SESSION, | 596 cdm->CreateSessionAndGenerateRequest(media::MediaKeys::TEMPORARY_SESSION, |
583 init_data_type, init_data, | 597 init_data_type, init_data, |
584 promise.Pass()); | 598 promise.Pass()); |
585 } | 599 } |
586 | 600 |
587 } // namespace content | 601 } // namespace content |
OLD | NEW |