Home | History | Annotate | Download | only in libstagefright
      1 /*
      2  * Copyright (C) 2009 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 "OMXClient"
     19 
     20 #ifdef __LP64__
     21 #define OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS
     22 #endif
     23 
     24 #include <utils/Log.h>
     25 #include <cutils/properties.h>
     26 
     27 #include <binder/IServiceManager.h>
     28 #include <media/stagefright/OMXClient.h>
     29 
     30 #include <media/IOMX.h>
     31 
     32 #include <media/omx/1.0/WOmx.h>
     33 
     34 namespace android {
     35 
     36 OMXClient::OMXClient() {
     37 }
     38 
     39 status_t OMXClient::connect() {
     40     return connect("default");
     41 }
     42 
     43 status_t OMXClient::connect(const char* name) {
     44     using namespace ::android::hardware::media::omx::V1_0;
     45     if (name == nullptr) {
     46         name = "default";
     47     }
     48     sp<IOmx> tOmx = IOmx::getService(name);
     49     if (tOmx.get() == nullptr) {
     50         ALOGE("Cannot obtain IOmx service.");
     51         return NO_INIT;
     52     }
     53     if (!tOmx->isRemote()) {
     54         ALOGE("IOmx service running in passthrough mode.");
     55         return NO_INIT;
     56     }
     57     mOMX = new utils::LWOmx(tOmx);
     58     ALOGI("IOmx service obtained");
     59     return OK;
     60 }
     61 
     62 void OMXClient::disconnect() {
     63     mOMX.clear();
     64 }
     65 
     66 sp<IOMX> OMXClient::interface() {
     67     return mOMX;
     68 }
     69 
     70 }  // namespace android
     71