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

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: overhaul: creates MediaClientAndroid (browser-side client), eliminates Java-based MediaDrmBridge ke… Created 5 years, 8 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
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 namespace {
14
15 const uint8_t kPlayreadyUuid[16] = {
16 0x9a, 0x04, 0xf0, 0x79, 0x98, 0x40, 0x42, 0x86,
17 0xab, 0x92, 0xe6, 0x5b, 0xe0, 0x88, 0x5f, 0x95};
18
19 const uint8_t kPlayreadyCustomDataUuid[] = {
20 0x2b, 0xf8, 0x66, 0x80, 0xc6, 0xe5, 0x4e, 0x24,
21 0xbe, 0x23, 0x0f, 0x81, 0x5a, 0x60, 0x6e, 0xb2 };
xhwang 2015/04/24 04:52:23 alignments are not consistent
gunsch 2015/04/27 23:44:12 Done.
22
23 // ASCII "uuid" as an 4-byte integer
24 const uint32_t kBoxTypeUuid = 1970628964;
25
26 } // namespace
xhwang 2015/04/24 04:52:23 tiny nit: no need to use anonymous namespace for c
gunsch 2015/04/27 23:44:12 Done.
27
28 PlayreadyDrmDelegateAndroid::PlayreadyDrmDelegateAndroid() {
29 }
30
31 PlayreadyDrmDelegateAndroid::~PlayreadyDrmDelegateAndroid() {
32 }
33
34 const std::vector<uint8_t> PlayreadyDrmDelegateAndroid::GetUUID() const {
35 return std::vector<uint8_t>(kPlayreadyUuid,
36 kPlayreadyUuid + arraysize(kPlayreadyUuid));
xhwang 2015/04/24 04:52:23 alignment is off?
gunsch 2015/04/27 23:44:12 Done.
37 }
38
39 bool PlayreadyDrmDelegateAndroid::OnCreateSession(
40 const ::media::EmeInitDataType init_data_type,
41 const uint8_t* init_data,
42 int init_data_length,
43 std::vector<uint8_t>& init_data_out,
xhwang 2015/04/24 04:52:23 /* init_data_out */ to be clear that we don't touc
gunsch 2015/04/27 23:44:12 Done.
44 std::vector<std::string>& optional_parameters_out) {
45 if (init_data_type == ::media::EmeInitDataType::CENC) {
46 ::media::BitReader reader(init_data, init_data_length);
47 while (reader.bits_available() > 64) {
48 uint32_t box_size;
49 uint32_t box_type;
50 reader.ReadBits(32, &box_size);
51 reader.ReadBits(32, &box_type);
52 int bytes_read = 8;
53
54 if (box_type != kBoxTypeUuid) {
55 if (box_size < 8 + sizeof(kPlayreadyCustomDataUuid)) {
56 break;
57 }
58 // Box size includes the bytes already consumed
59 reader.SkipBits((box_size - bytes_read) * 8);
60 continue;
61 }
62
63 // "uuid" was found, look for custom data format as per b/10246367
64 reader.SkipBits(128);
65 bytes_read += 16;
66 if (!memcmp(&init_data[0] + reader.bits_read() / 8,
67 kPlayreadyCustomDataUuid, 16)) {
68 reader.SkipBits((box_size - bytes_read) * 8);
69 continue;
70 }
71
72 int custom_data_size = box_size - bytes_read;
73 DCHECK(reader.bits_read() % 8 == 0);
74 int total_bytes_read = reader.bits_read() / 8;
75
76 optional_parameters_out.clear();
77 optional_parameters_out.push_back("PRCustomData");
78 optional_parameters_out.push_back(
79 std::string(&init_data[0] + total_bytes_read,
80 &init_data[0] + total_bytes_read + custom_data_size));
81 reader.SkipBits(custom_data_size * 8);
82 LOG(INFO) << "Including " << custom_data_size
83 << " bytes of custom PlayReady data";
84 }
85 }
86 return true;
87 }
88
89 } // namespace media
90 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698