blob: 968d1bea2d30d86296ff3353bcf0c50386eb32f6 [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
Robert Shih48843252018-01-09 15:24:07 -080020#include <media/NdkMediaExtractor.h>
21#include <media/stagefright/foundation/ABuffer.h>
Wei Jia53692fa2017-12-11 10:33:46 -080022
Robert Shih48843252018-01-09 15:24:07 -080023#include <utils/String8.h>
24#include <utils/Vector.h>
Wei Jia53692fa2017-12-11 10:33:46 -080025
Dongwon Kang41929fb2018-09-09 08:29:56 -070026#include "mediaplayer2.pb.h"
27
28using android::media::MediaPlayer2Proto::PlayerMessage;
29
Wei Jia53692fa2017-12-11 10:33:46 -080030namespace android {
31
32 struct DrmUUID {
33 static const int UUID_SIZE = 16;
34
35 DrmUUID() {
36 memset(this->uuid, 0, sizeof(uuid));
37 }
38
39 // to allow defining Vector/KeyedVector of UUID type
40 DrmUUID(const DrmUUID &a) {
41 memcpy(this->uuid, a.uuid, sizeof(uuid));
42 }
43
44 // to allow defining Vector/KeyedVector of UUID type
45 DrmUUID(const uint8_t uuid_in[UUID_SIZE]) {
46 memcpy(this->uuid, uuid_in, sizeof(uuid));
47 }
48
49 const uint8_t *ptr() const {
50 return uuid;
51 }
52
53 String8 toHexString() const {
54 return arrayToHex(uuid, UUID_SIZE);
55 }
56
57 static String8 toHexString(const uint8_t uuid_in[UUID_SIZE]) {
58 return arrayToHex(uuid_in, UUID_SIZE);
59 }
60
61 static String8 arrayToHex(const uint8_t *array, int bytes) {
62 String8 result;
63 for (int i = 0; i < bytes; i++) {
64 result.appendFormat("%02x", array[i]);
65 }
66
67 return result;
68 }
69
70 protected:
71 uint8_t uuid[UUID_SIZE];
72 };
73
74
75 struct NuPlayer2Drm {
76
77 // static helpers - internal
78
79 protected:
80 static Vector<DrmUUID> parsePSSH(const void *pssh, size_t psshsize);
81 static Vector<DrmUUID> getSupportedDrmSchemes(const void *pssh, size_t psshsize);
82
83 // static helpers - public
84
85 public:
Robert Shih48843252018-01-09 15:24:07 -080086 static sp<ABuffer> retrieveDrmInfo(const void *pssh, uint32_t psshsize);
Dongwon Kang41929fb2018-09-09 08:29:56 -070087 static status_t retrieveDrmInfo(PsshInfo *, PlayerMessage *);
Wei Jia53692fa2017-12-11 10:33:46 -080088
89 }; // NuPlayer2Drm
90
91} // android
92
93#endif //NUPLAYER2_DRM_H_