Add additional error conditions to MediaDrm
Merge of http://go/wvgerrit/70163 New codes are being added to handle resource contention, lost session state, frame size too large and insufficient security level for decryption. Also cleans up inconsistent use of tamper detected error where invalid state error should have been used. bug:111504510 bug:111505796 test: cts and gts media tests, widevine integration tests Change-Id: I96ee441717d32ccbcabaa85c8f6a0013055ce16e
This commit is contained in:
62
libwvdrmengine/include_hidl/HidlTypes.h
Normal file
62
libwvdrmengine/include_hidl/HidlTypes.h
Normal file
@@ -0,0 +1,62 @@
|
||||
//
|
||||
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine Master
|
||||
// License Agreement.
|
||||
//
|
||||
|
||||
#ifndef HIDL_TYPES_H_
|
||||
#define HIDL_TYPES_H_
|
||||
|
||||
#include <android/hardware/drm/1.1/types.h>
|
||||
#include <android/hardware/drm/1.2/ICryptoFactory.h>
|
||||
#include <android/hardware/drm/1.2/ICryptoPlugin.h>
|
||||
#include <android/hardware/drm/1.2/types.h>
|
||||
#include <android/hardware/drm/1.2/IDrmFactory.h>
|
||||
#include <android/hardware/drm/1.2/IDrmPlugin.h>
|
||||
#include <android/hardware/drm/1.2/IDrmPluginListener.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
|
||||
using ::android::hardware::configureRpcThreadpool;
|
||||
using ::android::hardware::hidl_array;
|
||||
using ::android::hardware::hidl_handle;
|
||||
using ::android::hardware::hidl_memory;
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::joinRpcThreadpool;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::sp;
|
||||
|
||||
namespace drm = ::android::hardware::drm;
|
||||
using drm::V1_0::BufferType;
|
||||
using drm::V1_0::DestinationBuffer;
|
||||
using drm::V1_0::EventType;
|
||||
using drm::V1_0::IDrmPluginListener;
|
||||
using drm::V1_0::KeyRequestType;
|
||||
using drm::V1_0::KeyStatus;
|
||||
using drm::V1_0::KeyStatusType;
|
||||
using drm::V1_0::KeyType;
|
||||
using drm::V1_0::KeyValue;
|
||||
using drm::V1_0::Mode;
|
||||
using drm::V1_0::Pattern;
|
||||
using drm::V1_0::SecureStop;
|
||||
using drm::V1_0::SecureStopId;
|
||||
using drm::V1_0::SharedBuffer;
|
||||
using drm::V1_0::Status;
|
||||
using drm::V1_0::SubSample;
|
||||
using drm::V1_1::DrmMetricGroup;
|
||||
using drm::V1_1::HdcpLevel;
|
||||
using drm::V1_1::SecureStopRelease;
|
||||
using drm::V1_1::SecurityLevel;
|
||||
using drm::V1_2::ICryptoFactory;
|
||||
using drm::V1_2::ICryptoPlugin;
|
||||
using drm::V1_2::IDrmFactory;
|
||||
using drm::V1_2::IDrmPlugin;
|
||||
using drm::V1_2::KeySetId;
|
||||
using drm::V1_2::OfflineLicenseState;
|
||||
|
||||
typedef drm::V1_1::KeyRequestType KeyRequestType_V1_1;
|
||||
typedef drm::V1_2::IDrmPluginListener IDrmPluginListener_V1_2;
|
||||
typedef drm::V1_2::Status Status_V1_2;
|
||||
|
||||
#endif
|
||||
@@ -16,12 +16,12 @@
|
||||
|
||||
#ifndef WVDRM_ANDROID_HARDWARE_DRM_V1_1_TYPECONVERT
|
||||
#define WVDRM_ANDROID_HARDWARE_DRM_V1_1_TYPECONVERT
|
||||
#include "utils/Errors.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <android/hardware/drm/1.0/types.h>
|
||||
#include <media/stagefright/MediaErrors.h>
|
||||
#include "media/stagefright/MediaErrors.h"
|
||||
#include "HidlTypes.h"
|
||||
#include "utils/Errors.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
@@ -29,9 +29,6 @@ namespace drm {
|
||||
namespace V1_2 {
|
||||
namespace widevine {
|
||||
|
||||
using ::android::hardware::hidl_array;
|
||||
using ::android::hardware::hidl_vec;
|
||||
|
||||
template<typename T> const hidl_vec<T> toHidlVec(const std::vector<T> &vec) {
|
||||
hidl_vec<T> hVec;
|
||||
hVec.setToExternal(const_cast<T *>(vec.data()), vec.size());
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
#ifndef WV_CREATE_PLUGIN_FACTORIES_H_
|
||||
#define WV_CREATE_PLUGIN_FACTORIES_H_
|
||||
|
||||
#include <android/hardware/drm/1.1/ICryptoFactory.h>
|
||||
#include <android/hardware/drm/1.1/IDrmFactory.h>
|
||||
#include "HidlTypes.h"
|
||||
|
||||
namespace wvdrm {
|
||||
namespace hardware {
|
||||
@@ -16,9 +15,6 @@ namespace drm {
|
||||
namespace V1_2 {
|
||||
namespace widevine {
|
||||
|
||||
using ::android::hardware::drm::V1_1::ICryptoFactory;
|
||||
using ::android::hardware::drm::V1_1::IDrmFactory;
|
||||
|
||||
extern "C" {
|
||||
IDrmFactory* createDrmFactory();
|
||||
ICryptoFactory* createCryptoFactory();
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
#ifndef WV_CRYPTO_FACTORY_H_
|
||||
#define WV_CRYPTO_FACTORY_H_
|
||||
|
||||
#include <android/hardware/drm/1.1/ICryptoFactory.h>
|
||||
|
||||
#include "HidlTypes.h"
|
||||
#include "WVTypes.h"
|
||||
|
||||
namespace wvdrm {
|
||||
@@ -17,12 +16,6 @@ namespace drm {
|
||||
namespace V1_2 {
|
||||
namespace widevine {
|
||||
|
||||
using ::android::hardware::drm::V1_1::ICryptoFactory;
|
||||
using ::android::hardware::drm::V1_0::ICryptoPlugin;
|
||||
using ::android::hardware::hidl_array;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::Return;
|
||||
|
||||
struct WVCryptoFactory : public ICryptoFactory {
|
||||
public:
|
||||
WVCryptoFactory() {}
|
||||
|
||||
@@ -7,9 +7,7 @@
|
||||
#ifndef WV_DRM_FACTORY_H_
|
||||
#define WV_DRM_FACTORY_H_
|
||||
|
||||
#include <android/hardware/drm/1.1/IDrmFactory.h>
|
||||
#include <android/hardware/drm/1.2/IDrmPlugin.h>
|
||||
|
||||
#include "HidlTypes.h"
|
||||
#include "WVGenericCryptoInterface.h"
|
||||
#include "WVTypes.h"
|
||||
|
||||
@@ -19,12 +17,6 @@ namespace drm {
|
||||
namespace V1_2 {
|
||||
namespace widevine {
|
||||
|
||||
using ::android::hardware::drm::V1_1::IDrmFactory;
|
||||
using ::android::hardware::drm::V1_2::IDrmPlugin;
|
||||
using ::android::hardware::hidl_array;
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::hardware::Return;
|
||||
|
||||
struct WVDrmFactory : public IDrmFactory {
|
||||
WVDrmFactory() {}
|
||||
virtual ~WVDrmFactory() {}
|
||||
|
||||
@@ -10,12 +10,11 @@
|
||||
#include "media/stagefright/MediaErrors.h"
|
||||
#include "utils/Errors.h"
|
||||
#include "wv_cdm_types.h"
|
||||
#include "HidlTypes.h"
|
||||
#include "WVErrors.h"
|
||||
|
||||
namespace wvdrm {
|
||||
|
||||
using ::android::hardware::drm::V1_0::Status;
|
||||
|
||||
static Status mapCdmResponseType(wvcdm::CdmResponseType res) {
|
||||
switch (res) {
|
||||
case wvcdm::KEY_ADDED:
|
||||
@@ -321,6 +320,26 @@ static Status mapCdmResponseType(wvcdm::CdmResponseType res) {
|
||||
return Status::ERROR_DRM_UNKNOWN;
|
||||
}
|
||||
|
||||
static Status_V1_2 mapCdmResponseType_1_2(
|
||||
wvcdm::CdmResponseType res) {
|
||||
switch(res) {
|
||||
case wvcdm::KEY_PROHIBITED_FOR_SECURITY_LEVEL:
|
||||
return Status_V1_2::ERROR_DRM_INSUFFICIENT_SECURITY;
|
||||
|
||||
// TODO(b/120572706): define in CDM
|
||||
// case wvcdm::xxx:
|
||||
// return Status_V1_2::ERROR_DRM_FRAME_TOO_LARGE;
|
||||
// case wvcdm::xxx:
|
||||
// return Status_V1_2::ERROR_DRM_SESSION_LOST_STATE;
|
||||
// case wvcdm::xxx:
|
||||
// return Status_V1_2::ERROR_DRM_RESOURCE_CONTENTION;
|
||||
|
||||
default:
|
||||
return static_cast<Status_V1_2>(mapCdmResponseType(res));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static inline bool isCdmResponseTypeSuccess(wvcdm::CdmResponseType res) {
|
||||
return mapCdmResponseType(res) == Status::OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user