| Wei Jia | 53692fa | 2017-12-11 10:33:46 -0800 | [diff] [blame] | 1 | /* | 
|  | 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> | 
|  | 21 | #include <media/stagefright/MetaData.h> // for CryptInfo | 
|  | 22 |  | 
|  | 23 |  | 
|  | 24 | namespace android { | 
|  | 25 |  | 
|  | 26 | struct DrmUUID { | 
|  | 27 | static const int UUID_SIZE = 16; | 
|  | 28 |  | 
|  | 29 | DrmUUID() { | 
|  | 30 | memset(this->uuid, 0, sizeof(uuid)); | 
|  | 31 | } | 
|  | 32 |  | 
|  | 33 | // to allow defining Vector/KeyedVector of UUID type | 
|  | 34 | DrmUUID(const DrmUUID &a) { | 
|  | 35 | memcpy(this->uuid, a.uuid, sizeof(uuid)); | 
|  | 36 | } | 
|  | 37 |  | 
|  | 38 | // to allow defining Vector/KeyedVector of UUID type | 
|  | 39 | DrmUUID(const uint8_t uuid_in[UUID_SIZE]) { | 
|  | 40 | memcpy(this->uuid, uuid_in, sizeof(uuid)); | 
|  | 41 | } | 
|  | 42 |  | 
|  | 43 | const uint8_t *ptr() const { | 
|  | 44 | return uuid; | 
|  | 45 | } | 
|  | 46 |  | 
|  | 47 | String8 toHexString() const { | 
|  | 48 | return arrayToHex(uuid, UUID_SIZE); | 
|  | 49 | } | 
|  | 50 |  | 
|  | 51 | static String8 toHexString(const uint8_t uuid_in[UUID_SIZE]) { | 
|  | 52 | return arrayToHex(uuid_in, UUID_SIZE); | 
|  | 53 | } | 
|  | 54 |  | 
|  | 55 | static String8 arrayToHex(const uint8_t *array, int bytes) { | 
|  | 56 | String8 result; | 
|  | 57 | for (int i = 0; i < bytes; i++) { | 
|  | 58 | result.appendFormat("%02x", array[i]); | 
|  | 59 | } | 
|  | 60 |  | 
|  | 61 | return result; | 
|  | 62 | } | 
|  | 63 |  | 
|  | 64 | protected: | 
|  | 65 | uint8_t uuid[UUID_SIZE]; | 
|  | 66 | }; | 
|  | 67 |  | 
|  | 68 |  | 
|  | 69 | struct NuPlayer2Drm { | 
|  | 70 |  | 
|  | 71 | // static helpers - internal | 
|  | 72 |  | 
|  | 73 | protected: | 
|  | 74 | static Vector<DrmUUID> parsePSSH(const void *pssh, size_t psshsize); | 
|  | 75 | static Vector<DrmUUID> getSupportedDrmSchemes(const void *pssh, size_t psshsize); | 
|  | 76 |  | 
|  | 77 | // static helpers - public | 
|  | 78 |  | 
|  | 79 | public: | 
|  | 80 | // Parcel has only private copy constructor so passing it in rather than returning | 
|  | 81 | static void retrieveDrmInfo(const void *pssh, size_t psshsize, Parcel *parcel); | 
|  | 82 |  | 
|  | 83 | };  // NuPlayer2Drm | 
|  | 84 |  | 
|  | 85 | }   // android | 
|  | 86 |  | 
|  | 87 | #endif     //NUPLAYER2_DRM_H_ |