Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Copyright (C) 2014-2015 Jolla Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Authored by: Mohammed Hassan <mohammed.hassan@jolla.com>
- */
- #include "droidmediaconvert.h"
- #include "droidmediabuffer.h"
- #include <media/editor/II420ColorConverter.h>
- #include <media/openmax/OMX_IVCommon.h>
- #include <cutils/log.h>
- #include <dlfcn.h>
- typedef void (*_getI420ColorConverter)(II420ColorConverter *converter);
- #define LOG_TAG "DroidMediaConvert"
- extern "C" {
- struct _DroidMediaConvert : public II420ColorConverter
- {
- public:
- _DroidMediaConvert() :
- m_handle(NULL) {
- ALOGE("%s", __func__);
- m_crop.top = m_crop.left = m_crop.bottom = m_crop.right = -1;
- m_width = m_height = 0;
- }
- ~_DroidMediaConvert() {
- ALOGE("%s", __func__);
- if (m_handle) {
- dlclose(m_handle);
- m_handle = NULL;
- }
- }
- bool init() {
- ALOGE("%s", __func__);
- if (m_handle) {
- ALOGW("already loaded");
- return true;
- }
- m_handle = dlopen("libI420colorconvert.so", RTLD_NOW);
- if (!m_handle) {
- ALOGE("failed to load libI420colorconvert.so. %s", dlerror());
- return false;
- }
- _getI420ColorConverter func = (_getI420ColorConverter)dlsym(m_handle, "getI420ColorConverter");
- if (!func) {
- ALOGE("failed to find symbol getI420ColorConverter");
- dlclose(m_handle);
- m_handle = NULL;
- return false;
- }
- func(this);
- return true;
- }
- void *m_handle;
- ARect m_crop;
- int32_t m_width;
- int32_t m_height;
- };
- DroidMediaConvert *droid_media_convert_create()
- {
- ALOGE("a%s", __func__);
- DroidMediaConvert *conv = new DroidMediaConvert;
- if (conv->init()) {
- return conv;
- }
- delete conv;
- return NULL;
- }
- DroidMediaConvert *convert;
- int main(int argc, char *argv[])
- {
- convert = droid_media_convert_create();
- delete convert;
- return 0;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement