DrmManagerClient.cpp 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*
  2. * Copyright (C) 2010 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. #include <utils/String8.h>
  17. #include <binder/IServiceManager.h>
  18. #include <drm/DrmManagerClient.h>
  19. #include "DrmManagerClientImpl.h"
  20. using namespace android;
  21. DrmManagerClient::DrmManagerClient():
  22. mUniqueId(0), mDrmManagerClientImpl(NULL) {
  23. mDrmManagerClientImpl = DrmManagerClientImpl::create(&mUniqueId, true);
  24. mDrmManagerClientImpl->addClient(mUniqueId);
  25. }
  26. DrmManagerClient::~DrmManagerClient() {
  27. mDrmManagerClientImpl->remove(mUniqueId);
  28. mDrmManagerClientImpl->removeClient(mUniqueId);
  29. mDrmManagerClientImpl->setOnInfoListener(mUniqueId, NULL);
  30. }
  31. status_t DrmManagerClient::setOnInfoListener(
  32. const sp<DrmManagerClient::OnInfoListener>& infoListener) {
  33. return mDrmManagerClientImpl->setOnInfoListener(mUniqueId, infoListener);
  34. }
  35. DrmConstraints* DrmManagerClient::getConstraints(const String8* path, const int action) {
  36. return mDrmManagerClientImpl->getConstraints(mUniqueId, path, action);
  37. }
  38. DrmMetadata* DrmManagerClient::getMetadata(const String8* path) {
  39. return mDrmManagerClientImpl->getMetadata(mUniqueId, path);
  40. }
  41. bool DrmManagerClient::canHandle(const String8& path, const String8& mimeType) {
  42. return mDrmManagerClientImpl->canHandle(mUniqueId, path, mimeType);
  43. }
  44. DrmInfoStatus* DrmManagerClient::processDrmInfo(const DrmInfo* drmInfo) {
  45. return mDrmManagerClientImpl->processDrmInfo(mUniqueId, drmInfo);
  46. }
  47. DrmInfo* DrmManagerClient::acquireDrmInfo(const DrmInfoRequest* drmInfoRequest) {
  48. return mDrmManagerClientImpl->acquireDrmInfo(mUniqueId, drmInfoRequest);
  49. }
  50. status_t DrmManagerClient::saveRights(
  51. const DrmRights& drmRights, const String8& rightsPath, const String8& contentPath) {
  52. return mDrmManagerClientImpl->saveRights(mUniqueId, drmRights, rightsPath, contentPath);
  53. }
  54. String8 DrmManagerClient::getOriginalMimeType(const String8& path, int fd) {
  55. return mDrmManagerClientImpl->getOriginalMimeType(mUniqueId, path, fd);
  56. }
  57. int DrmManagerClient::getDrmObjectType(const String8& path, const String8& mimeType) {
  58. return mDrmManagerClientImpl->getDrmObjectType( mUniqueId, path, mimeType);
  59. }
  60. int DrmManagerClient::checkRightsStatus(const String8& path, int action) {
  61. return mDrmManagerClientImpl->checkRightsStatus(mUniqueId, path, action);
  62. }
  63. status_t DrmManagerClient::consumeRights(
  64. sp<DecryptHandle> &decryptHandle, int action, bool reserve) {
  65. return mDrmManagerClientImpl->consumeRights(mUniqueId, decryptHandle, action, reserve);
  66. }
  67. status_t DrmManagerClient::setPlaybackStatus(
  68. sp<DecryptHandle> &decryptHandle, int playbackStatus, int64_t position) {
  69. return mDrmManagerClientImpl
  70. ->setPlaybackStatus(mUniqueId, decryptHandle, playbackStatus, position);
  71. }
  72. bool DrmManagerClient::validateAction(
  73. const String8& path, int action, const ActionDescription& description) {
  74. return mDrmManagerClientImpl->validateAction(mUniqueId, path, action, description);
  75. }
  76. status_t DrmManagerClient::removeRights(const String8& path) {
  77. return mDrmManagerClientImpl->removeRights(mUniqueId, path);
  78. }
  79. status_t DrmManagerClient::removeAllRights() {
  80. return mDrmManagerClientImpl->removeAllRights(mUniqueId);
  81. }
  82. int DrmManagerClient::openConvertSession(const String8& mimeType) {
  83. return mDrmManagerClientImpl->openConvertSession(mUniqueId, mimeType);
  84. }
  85. DrmConvertedStatus* DrmManagerClient::convertData(int convertId, const DrmBuffer* inputData) {
  86. return mDrmManagerClientImpl->convertData(mUniqueId, convertId, inputData);
  87. }
  88. DrmConvertedStatus* DrmManagerClient::closeConvertSession(int convertId) {
  89. return mDrmManagerClientImpl->closeConvertSession(mUniqueId, convertId);
  90. }
  91. status_t DrmManagerClient::getAllSupportInfo(int* length, DrmSupportInfo** drmSupportInfoArray) {
  92. return mDrmManagerClientImpl->getAllSupportInfo(mUniqueId, length, drmSupportInfoArray);
  93. }
  94. sp<DecryptHandle> DrmManagerClient::openDecryptSession(
  95. int fd, off64_t offset, off64_t length, const char* mime) {
  96. return mDrmManagerClientImpl->openDecryptSession(
  97. mUniqueId, fd, offset, length, mime);
  98. }
  99. sp<DecryptHandle> DrmManagerClient::openDecryptSession(
  100. const char* uri, const char* mime) {
  101. return mDrmManagerClientImpl->openDecryptSession(
  102. mUniqueId, uri, mime);
  103. }
  104. sp<DecryptHandle> DrmManagerClient::openDecryptSession(
  105. const DrmBuffer& buf, const String8& mimeType) {
  106. return mDrmManagerClientImpl->openDecryptSession(mUniqueId, buf, mimeType);
  107. }
  108. status_t DrmManagerClient::closeDecryptSession(sp<DecryptHandle> &decryptHandle) {
  109. return mDrmManagerClientImpl->closeDecryptSession(mUniqueId, decryptHandle);
  110. }
  111. status_t DrmManagerClient::initializeDecryptUnit(
  112. sp<DecryptHandle> &decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) {
  113. return mDrmManagerClientImpl->initializeDecryptUnit(
  114. mUniqueId, decryptHandle, decryptUnitId, headerInfo);
  115. }
  116. status_t DrmManagerClient::decrypt(
  117. sp<DecryptHandle> &decryptHandle, int decryptUnitId,
  118. const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
  119. return mDrmManagerClientImpl->decrypt(
  120. mUniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV);
  121. }
  122. status_t DrmManagerClient::finalizeDecryptUnit(
  123. sp<DecryptHandle> &decryptHandle, int decryptUnitId) {
  124. return mDrmManagerClientImpl->finalizeDecryptUnit(mUniqueId,
  125. decryptHandle, decryptUnitId);
  126. }
  127. ssize_t DrmManagerClient::pread(
  128. sp<DecryptHandle> &decryptHandle, void* buffer, ssize_t numBytes, off64_t offset) {
  129. return mDrmManagerClientImpl->pread(mUniqueId, decryptHandle, buffer, numBytes, offset);
  130. }