1bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber/*
2bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber * Copyright (C) 2011 The Android Open Source Project
3bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber *
4bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber * Licensed under the Apache License, Version 2.0 (the "License");
5bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber * you may not use this file except in compliance with the License.
6bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber * You may obtain a copy of the License at
7bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber *
8bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber *      http://www.apache.org/licenses/LICENSE-2.0
9bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber *
10bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber * Unless required by applicable law or agreed to in writing, software
11bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber * distributed under the License is distributed on an "AS IS" BASIS,
12bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber * See the License for the specific language governing permissions and
14bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber * limitations under the License.
15bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber */
16bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber
17bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber//#define LOG_NDEBUG 0
18bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber#define LOG_TAG "SoftOMXPlugin"
19bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber#include <utils/Log.h>
20bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber
21bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber#include "SoftOMXPlugin.h"
22bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber#include "include/SoftOMXComponent.h"
23bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber
24f2af5a2c607e71ff4cd39da28b077c0a68b206feAndreas Huber#include <media/stagefright/foundation/ADebug.h>
25bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber#include <media/stagefright/foundation/AString.h>
26bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber
27bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber#include <dlfcn.h>
28bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber
29bbba88cb1bdc34705d1477208990a06904c022e7Andreas Hubernamespace android {
30bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber
31bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huberstatic const struct {
32bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    const char *mName;
33bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    const char *mLibNameSuffix;
34bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    const char *mRole;
35bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber
36bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber} kComponents[] = {
37bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    { "OMX.google.aac.decoder", "aacdec", "audio_decoder.aac" },
382b1892db4a2ab47bfc09e59a4c11751aea99e4eaAndreas Huber    { "OMX.google.aac.encoder", "aacenc", "audio_encoder.aac" },
39bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    { "OMX.google.amrnb.decoder", "amrdec", "audio_decoder.amrnb" },
40252353088a5ebf8508fbc01439ff417805ef1417Andreas Huber    { "OMX.google.amrnb.encoder", "amrnbenc", "audio_encoder.amrnb" },
41bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    { "OMX.google.amrwb.decoder", "amrdec", "audio_decoder.amrwb" },
4283f70f4472e9b0cacc5d372eddfcef4b02662d10Andreas Huber    { "OMX.google.amrwb.encoder", "amrwbenc", "audio_encoder.amrwb" },
430c1bc742181ded4930842b46e9507372f0b1b963James Dong    { "OMX.google.h264.decoder", "h264dec", "video_decoder.avc" },
445c61b361d1c55a93a215cfb2c325b4987f57f1c5James Dong    { "OMX.google.h264.encoder", "h264enc", "video_encoder.avc" },
45bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    { "OMX.google.g711.alaw.decoder", "g711dec", "audio_decoder.g711alaw" },
46bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    { "OMX.google.g711.mlaw.decoder", "g711dec", "audio_decoder.g711mlaw" },
47bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    { "OMX.google.h263.decoder", "mpeg4dec", "video_decoder.h263" },
481700744ae0ce2fcf722816453ae0af2cd5646458James Dong    { "OMX.google.h263.encoder", "mpeg4enc", "video_encoder.h263" },
49bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    { "OMX.google.mpeg4.decoder", "mpeg4dec", "video_decoder.mpeg4" },
501700744ae0ce2fcf722816453ae0af2cd5646458James Dong    { "OMX.google.mpeg4.encoder", "mpeg4enc", "video_encoder.mpeg4" },
51bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    { "OMX.google.mp3.decoder", "mp3dec", "audio_decoder.mp3" },
52bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    { "OMX.google.vorbis.decoder", "vorbisdec", "audio_decoder.vorbis" },
53bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    { "OMX.google.vpx.decoder", "vpxdec", "video_decoder.vpx" },
54ecdd39c5af016e2fa57cbfd837aa670b706dabd3Andreas Huber    { "OMX.google.raw.decoder", "rawdec", "audio_decoder.raw" },
552f74ef3cdc192f817ee1121f41765f0852c1d81eJean-Michel Trivi    { "OMX.google.flac.encoder", "flacenc", "audio_encoder.flac" },
56bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber};
57bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber
58bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huberstatic const size_t kNumComponents =
59bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    sizeof(kComponents) / sizeof(kComponents[0]);
60bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber
61bbba88cb1bdc34705d1477208990a06904c022e7Andreas HuberSoftOMXPlugin::SoftOMXPlugin() {
62bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber}
63bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber
64bbba88cb1bdc34705d1477208990a06904c022e7Andreas HuberOMX_ERRORTYPE SoftOMXPlugin::makeComponentInstance(
65bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber        const char *name,
66bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber        const OMX_CALLBACKTYPE *callbacks,
67bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber        OMX_PTR appData,
68bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber        OMX_COMPONENTTYPE **component) {
693856b090cd04ba5dd4a59a12430ed724d5995909Steve Block    ALOGV("makeComponentInstance '%s'", name);
70