blob: f9c87112652a5d03ca3da9c1610370c06db410cc [file] [log] [blame]
Wei Jia53692fa2017-12-11 10:33:46 -08001/*
2 * Copyright 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef NUPLAYER2_DRM_H_
18#define NUPLAYER2_DRM_H_
19
20#include <binder/Parcel.h>
Wei Jia53692fa2017-12-11 10:33:46 -080021
22
23namespace android {
24
25 struct DrmUUID {
26 static const int UUID_SIZE = 16;
27
28 DrmUUID() {
29 memset(this->uuid, 0, sizeof(uuid));
30 }
31
32 // to allow defining Vector/KeyedVector of UUID type
33 DrmUUID(const DrmUUID &a) {
34 memcpy(this->uuid, a.uuid, sizeof(uuid));
35 }
36
37 // to allow defining Vector/KeyedVector of UUID type
38 DrmUUID(const uint8_t uuid_in[UUID_SIZE]) {
39 memcpy(this->uuid, uuid_in, sizeof(uuid));
40 }
41
42 const uint8_t *ptr() const {
43 return uuid;
44 }
45
46 String8 toHexString() const {
47 return arrayToHex(uuid, UUID_SIZE);
48 }
49
50 static String8 toHexString(const uint8_t uuid_in[UUID_SIZE]) {
51 return arrayToHex(uuid_in, UUID_SIZE);
52 }
53
54 static String8 arrayToHex(const uint8_t *array, int bytes) {
55 String8 result;
56 for (int i = 0; i < bytes; i++) {
57 result.appendFormat("%02x", array[i]);
58 }
59
60 return result;
61 }
62
63 protected:
64 uint8_t uuid[UUID_SIZE];
65 };
66
67
68 struct NuPlayer2Drm {
69
70 // static helpers - internal
71
72 protected:
73 static Vector<DrmUUID> parsePSSH(const void *pssh, size_t psshsize);
74 static Vector<DrmUUID> getSupportedDrmSchemes(const void *pssh, size_t psshsize);
75
76 // static helpers - public
77
78 public:
79 // Parcel has only private copy constructor so passing it in rather than returning
80 static void retrieveDrmInfo(const void *pssh, size_t psshsize, Parcel *parcel);
81
82 }; // NuPlayer2Drm
83
84} // android
85
86#endif //NUPLAYER2_DRM_H_