Home | History | Annotate | Download | only in lvpp
      1 /*
      2  * Copyright (C) 2011 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 #include <I420ColorConverter.h>
     18 #include <cutils/log.h>
     19 #include <dlfcn.h>
     20 
     21 I420ColorConverter::I420ColorConverter() {
     22     // Open the shared library
     23     mHandle = dlopen("libI420colorconvert.so", RTLD_NOW);
     24 
     25     if (mHandle == NULL) {
     26         LOGW("I420ColorConverter: cannot load libI420colorconvert.so");
     27         return;
     28     }
     29 
     30     // Find the entry point
     31     void (*getI420ColorConverter)(I420ColorConverter *converter) =
     32         (void (*)(I420ColorConverter*)) dlsym(mHandle, "getI420ColorConverter");
     33 
     34     if (getI420ColorConverter == NULL) {
     35         LOGW("I420ColorConverter: cannot load getI420ColorConverter");
     36         dlclose(mHandle);
     37         mHandle = NULL;
     38         return;
     39     }
     40 
     41     // Fill the function pointers.
     42     getI420ColorConverter(this);
     43 
     44     LOGI("I420ColorConverter: libI420colorconvert.so loaded");
     45 }
     46 
     47 bool I420ColorConverter::isLoaded() {
     48     return mHandle != NULL;
     49 }
     50 
     51 I420ColorConverter::~I420ColorConverter() {
     52     if (mHandle) {
     53         dlclose(mHandle);
     54     }
     55 }
     56