OSDN Git Service

Merge "Unify error/status codes"
authorMarco Nelissen <marcone@google.com>
Thu, 15 May 2014 21:58:36 +0000 (21:58 +0000)
committerAndroid (Google) Code Review <android-gerrit@google.com>
Thu, 15 May 2014 21:58:36 +0000 (21:58 +0000)
1  2 
include/ndk/NdkMediaDrm.h
media/ndk/NdkMediaDrm.cpp

Simple merge
@@@ -57,91 -47,41 +57,90 @@@ struct AMediaDrm 
      String8 mPropertyString;
      Vector<uint8_t> mPropertyByteArray;
      List<Vector<uint8_t> > mSecureStops;
 +    sp<DrmListener> mListener;
  };
  
 +void DrmListener::notify(DrmPlugin::EventType eventType, int extra, const Parcel *obj) {
 +    if (!mListener) {
 +        return;
 +    }
 +
 +    AMediaDrmSessionId sessionId = {NULL, 0};
 +    int32_t sessionIdSize = obj->readInt32();
 +    if (sessionIdSize) {
 +        uint8_t *sessionIdData = new uint8_t[sessionIdSize];
 +        sessionId.ptr = sessionIdData;
 +        sessionId.length = sessionIdSize;
 +        obj->read(sessionIdData, sessionId.length);
 +    }
 +
 +    int32_t dataSize = obj->readInt32();
 +    uint8_t *data = NULL;
 +    if (dataSize) {
 +        data = new uint8_t[dataSize];
 +        obj->read(data, dataSize);
 +    }
 +
 +    // translate DrmPlugin event types into their NDK equivalents
 +    AMediaDrmEventType ndkEventType;
 +    switch(eventType) {
 +        case DrmPlugin::kDrmPluginEventProvisionRequired:
 +            ndkEventType = EVENT_PROVISION_REQUIRED;
 +            break;
 +        case DrmPlugin::kDrmPluginEventKeyNeeded:
 +            ndkEventType = EVENT_KEY_REQUIRED;
 +            break;
 +        case DrmPlugin::kDrmPluginEventKeyExpired:
 +            ndkEventType = EVENT_KEY_EXPIRED;
 +            break;
 +        case DrmPlugin::kDrmPluginEventVendorDefined:
 +            ndkEventType = EVENT_VENDOR_DEFINED;
 +            break;
 +        default:
 +            ALOGE("Invalid event DrmPlugin::EventType %d, ignored", (int)eventType);
 +            return;
 +    }
 +
 +    (*mListener)(mObj, sessionId, ndkEventType, extra, data, dataSize);
 +
 +    delete [] sessionId.ptr;
 +    delete [] data;
 +}
 +
 +
  extern "C" {
  
- static mediadrm_status_t translateStatus(status_t status) {
-     mediadrm_status_t result = MEDIADRM_UNKNOWN_ERROR;
+ static media_status_t translateStatus(status_t status) {
+     media_status_t result = AMEDIA_ERROR_UNKNOWN;
      switch (status) {
          case OK:
-             result = MEDIADRM_OK;
+             result = AMEDIA_OK;
              break;
          case android::ERROR_DRM_NOT_PROVISIONED:
-             result = MEDIADRM_NOT_PROVISIONED_ERROR;
+             result = AMEDIA_DRM_NOT_PROVISIONED;
              break;
          case android::ERROR_DRM_RESOURCE_BUSY:
-             result = MEDIADRM_RESOURCE_BUSY_ERROR;
+             result = AMEDIA_DRM_RESOURCE_BUSY;
              break;
          case android::ERROR_DRM_DEVICE_REVOKED:
-             result = MEDIADRM_DEVICE_REVOKED_ERROR;
+             result = AMEDIA_DRM_DEVICE_REVOKED;
              break;
          case android::ERROR_DRM_CANNOT_HANDLE:
-             result = MEDIADRM_INVALID_PARAMETER_ERROR;
+             result = AMEDIA_ERROR_INVALID_PARAMETER;
              break;
          case android::ERROR_DRM_TAMPER_DETECTED:
-             result = MEDIADRM_TAMPER_DETECTED_ERROR;
+             result = AMEDIA_DRM_TAMPER_DETECTED;
              break;
          case android::ERROR_DRM_SESSION_NOT_OPENED:
-             result = MEDIADRM_SESSION_NOT_OPENED_ERROR;
+             result = AMEDIA_DRM_SESSION_NOT_OPENED;
              break;
          case android::ERROR_DRM_NO_LICENSE:
-             result = MEDIADRM_NEED_KEY_ERROR;
+             result = AMEDIA_DRM_NEED_KEY;
              break;
          case android::ERROR_DRM_LICENSE_EXPIRED:
-             result = MEDIADRM_LICENSE_EXPIRED_ERROR;
+             result = AMEDIA_DRM_LICENSE_EXPIRED;
              break;
          default:
-             result = MEDIADRM_UNKNOWN_ERROR;
              break;
      }
      return result;