Home | History | Annotate | Download | only in default
      1 /*
      2  * Copyright (C) 2014 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 //#define LOG_NDEBUG 0
     18 #define LOG_TAG "ClearKeyDrmFactory"
     19 #include <utils/Log.h>
     20 
     21 #include <utils/Errors.h>
     22 
     23 #include "DrmFactory.h"
     24 
     25 #include "DrmPlugin.h"
     26 #include "ClearKeyUUID.h"
     27 #include "MimeType.h"
     28 #include "SessionLibrary.h"
     29 
     30 namespace clearkeydrm {
     31 
     32 bool DrmFactory::isCryptoSchemeSupported(const uint8_t uuid[16]) {
     33     return isClearKeyUUID(uuid);
     34 }
     35 
     36 bool DrmFactory::isContentTypeSupported(const android::String8 &type) {
     37     // This should match the types handed by InitDataParser.
     38     return type == kIsoBmffVideoMimeType ||
     39         type == kIsoBmffAudioMimeType ||
     40         type == kCencInitDataFormat ||
     41         type == kWebmVideoMimeType ||
     42         type == kWebmAudioMimeType ||
     43         type == kWebmInitDataFormat;
     44 }
     45 
     46 android::status_t DrmFactory::createDrmPlugin(
     47         const uint8_t uuid[16],
     48         android::DrmPlugin** plugin) {
     49     if (!isCryptoSchemeSupported(uuid)) {
     50         *plugin = NULL;
     51         return android::BAD_VALUE;
     52     }
     53 
     54     *plugin = new DrmPlugin(SessionLibrary::get());
     55     return android::OK;
     56 }
     57 
     58 } // namespace clearkeydrm
     59