OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 "chromecast/media/cdm/chromecast_init_data.h" | 5 #include "chromecast/media/cdm/chromecast_init_data.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/stl_util.h" | |
9 #include "media/base/bit_reader.h" | 8 #include "media/base/bit_reader.h" |
10 #include "media/cdm/cenc_utils.h" | 9 #include "media/cdm/cenc_utils.h" |
11 | 10 |
12 namespace chromecast { | 11 namespace chromecast { |
13 namespace media { | 12 namespace media { |
14 | 13 |
15 #define RCHECK(x) \ | 14 #define RCHECK(x) \ |
16 do { \ | 15 do { \ |
17 if (!(x)) \ | 16 if (!(x)) \ |
18 return false; \ | 17 return false; \ |
(...skipping 25 matching lines...) Expand all Loading... |
44 | 43 |
45 std::vector<uint8_t> pssh_data; | 44 std::vector<uint8_t> pssh_data; |
46 if (!::media::GetPsshData( | 45 if (!::media::GetPsshData( |
47 init_data, std::vector<uint8_t>(kChromecastPlayreadyUuid, | 46 init_data, std::vector<uint8_t>(kChromecastPlayreadyUuid, |
48 kChromecastPlayreadyUuid + | 47 kChromecastPlayreadyUuid + |
49 sizeof(kChromecastPlayreadyUuid)), | 48 sizeof(kChromecastPlayreadyUuid)), |
50 &pssh_data)) { | 49 &pssh_data)) { |
51 return false; | 50 return false; |
52 } | 51 } |
53 | 52 |
54 ::media::BitReader reader(vector_as_array(&pssh_data), pssh_data.size()); | 53 ::media::BitReader reader(pssh_data.data(), pssh_data.size()); |
55 | 54 |
56 uint16_t msg_type; | 55 uint16_t msg_type; |
57 RCHECK(reader.ReadBits(2 * 8, &msg_type)); | 56 RCHECK(reader.ReadBits(2 * 8, &msg_type)); |
58 RCHECK(msg_type < static_cast<uint16_t>(InitDataMessageType::END)); | 57 RCHECK(msg_type < static_cast<uint16_t>(InitDataMessageType::END)); |
59 RCHECK(msg_type == static_cast<uint16_t>(type)); | 58 RCHECK(msg_type == static_cast<uint16_t>(type)); |
60 | 59 |
61 chromecast_init_data_out->type = static_cast<InitDataMessageType>(msg_type); | 60 chromecast_init_data_out->type = static_cast<InitDataMessageType>(msg_type); |
62 chromecast_init_data_out->data.assign( | 61 chromecast_init_data_out->data.assign( |
63 pssh_data.begin() + reader.bits_read() / 8, pssh_data.end()); | 62 pssh_data.begin() + reader.bits_read() / 8, pssh_data.end()); |
64 return true; | 63 return true; |
65 } | 64 } |
66 | 65 |
67 } // namespace media | 66 } // namespace media |
68 } // namespace chromecast | 67 } // namespace chromecast |
OLD | NEW |