NuPlayer2Drm.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. #ifndef NUPLAYER2_DRM_H_
  17. #define NUPLAYER2_DRM_H_
  18. #include <media/NdkMediaExtractor.h>
  19. #include <media/stagefright/foundation/ABuffer.h>
  20. #include <utils/String8.h>
  21. #include <utils/Vector.h>
  22. #include "mediaplayer2.pb.h"
  23. using android::media::MediaPlayer2Proto::PlayerMessage;
  24. namespace android {
  25. struct DrmUUID {
  26. static const int UUID_SIZE = 16;
  27. DrmUUID() {
  28. memset(this->uuid, 0, sizeof(uuid));
  29. }
  30. // to allow defining Vector/KeyedVector of UUID type
  31. DrmUUID(const DrmUUID &a) {
  32. memcpy(this->uuid, a.uuid, sizeof(uuid));
  33. }
  34. // to allow defining Vector/KeyedVector of UUID type
  35. DrmUUID(const uint8_t uuid_in[UUID_SIZE]) {
  36. memcpy(this->uuid, uuid_in, sizeof(uuid));
  37. }
  38. const uint8_t *ptr() const {
  39. return uuid;
  40. }
  41. String8 toHexString() const {
  42. return arrayToHex(uuid, UUID_SIZE);
  43. }
  44. static String8 toHexString(const uint8_t uuid_in[UUID_SIZE]) {
  45. return arrayToHex(uuid_in, UUID_SIZE);
  46. }
  47. static String8 arrayToHex(const uint8_t *array, int bytes) {
  48. String8 result;
  49. for (int i = 0; i < bytes; i++) {
  50. result.appendFormat("%02x", array[i]);
  51. }
  52. return result;
  53. }
  54. protected:
  55. uint8_t uuid[UUID_SIZE];
  56. };
  57. struct NuPlayer2Drm {
  58. // static helpers - internal
  59. protected:
  60. static Vector<DrmUUID> parsePSSH(const void *pssh, size_t psshsize);
  61. static Vector<DrmUUID> getSupportedDrmSchemes(const void *pssh, size_t psshsize);
  62. // static helpers - public
  63. public:
  64. static sp<ABuffer> retrieveDrmInfo(const void *pssh, uint32_t psshsize);
  65. static status_t retrieveDrmInfo(PsshInfo *, PlayerMessage *);
  66. }; // NuPlayer2Drm
  67. } // android
  68. #endif //NUPLAYER2_DRM_H_