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

Side by Side Diff: chromecast/media/cdm/playready_drm_delegate_android.cc

Issue 962793005: Adds MediaClientAndroid to support embedder/MediaDrmBridge interaction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename createSession to createSessionFromNative to avoid bug in FindBugs 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 | « chromecast/media/cdm/playready_drm_delegate_android.h ('k') | chromecast/media/media.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chromecast/media/cdm/playready_drm_delegate_android.h"
6
7 #include "base/logging.h"
8 #include "media/base/bit_reader.h"
9
10 namespace chromecast {
11 namespace media {
12
13 const uint8_t kPlayreadyUuid[16] = {
14 0x9a, 0x04, 0xf0, 0x79, 0x98, 0x40, 0x42, 0x86,
15 0xab, 0x92, 0xe6, 0x5b, 0xe0, 0x88, 0x5f, 0x95};
16
17 const uint8_t kPlayreadyCustomDataUuid[] = {
18 0x2b, 0xf8, 0x66, 0x80, 0xc6, 0xe5, 0x4e, 0x24,
19 0xbe, 0x23, 0x0f, 0x81, 0x5a, 0x60, 0x6e, 0xb2};
20
21 // ASCII "uuid" as an 4-byte integer
22 const uint32_t kBoxTypeUuid = 1970628964;
23
24 PlayreadyDrmDelegateAndroid::PlayreadyDrmDelegateAndroid() {
25 }
26
27 PlayreadyDrmDelegateAndroid::~PlayreadyDrmDelegateAndroid() {
28 }
29
30 const ::media::UUID PlayreadyDrmDelegateAndroid::GetUUID() const {
31 return ::media::UUID(kPlayreadyUuid,
32 kPlayreadyUuid + arraysize(kPlayreadyUuid));
33 }
34
35 bool PlayreadyDrmDelegateAndroid::OnCreateSession(
36 const ::media::EmeInitDataType init_data_type,
37 const std::vector<uint8_t>& init_data,
38 std::vector<uint8_t>* /* init_data_out */,
39 std::vector<std::string>* optional_parameters_out) {
40 if (init_data_type == ::media::EmeInitDataType::CENC) {
41 ::media::BitReader reader(&init_data[0], init_data.size());
42 while (reader.bits_available() > 64) {
43 uint32_t box_size;
44 uint32_t box_type;
45 reader.ReadBits(32, &box_size);
46 reader.ReadBits(32, &box_type);
47 int bytes_read = 8;
48
49 if (box_type != kBoxTypeUuid) {
50 if (box_size < 8 + sizeof(kPlayreadyCustomDataUuid)) {
51 break;
52 }
53 // Box size includes the bytes already consumed
54 reader.SkipBits((box_size - bytes_read) * 8);
55 continue;
56 }
57
58 // "uuid" was found, look for custom data format as per b/10246367
59 reader.SkipBits(128);
60 bytes_read += 16;
61 if (!memcmp(&init_data[0] + reader.bits_read() / 8,
62 kPlayreadyCustomDataUuid, 16)) {
63 reader.SkipBits((box_size - bytes_read) * 8);
64 continue;
65 }
66
67 int custom_data_size = box_size - bytes_read;
68 DCHECK(reader.bits_read() % 8 == 0);
69 int total_bytes_read = reader.bits_read() / 8;
70
71 optional_parameters_out->clear();
72 optional_parameters_out->push_back("PRCustomData");
73 optional_parameters_out->push_back(
74 std::string(&init_data[0] + total_bytes_read,
75 &init_data[0] + total_bytes_read + custom_data_size));
76 reader.SkipBits(custom_data_size * 8);
77 LOG(INFO) << "Including " << custom_data_size
78 << " bytes of custom PlayReady data";
79 }
80 }
81 return true;
82 }
83
84 } // namespace media
85 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/media/cdm/playready_drm_delegate_android.h ('k') | chromecast/media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698