2 * Copyright (C) 2015 The CyanogenMod Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #define LOG_TAG "FFmpegOMXPlugin"
19 #include <utils/Log.h>
21 #include <media/stagefright/omx/SoftOMXComponent.h>
23 #include <media/stagefright/foundation/ADebug.h>
24 #include <media/stagefright/foundation/AString.h>
26 #include "FFmpegOMXPlugin.h"
27 #include "FFmpegComponents.h"
28 #include "SoftFFmpegAudio.h"
29 #include "SoftFFmpegVideo.h"
33 OMXPluginBase *createOMXPlugin() {
34 return new FFmpegOMXPlugin();
37 FFmpegOMXPlugin::FFmpegOMXPlugin() {
40 OMX_ERRORTYPE FFmpegOMXPlugin::makeComponentInstance(
42 const OMX_CALLBACKTYPE *callbacks,
44 OMX_COMPONENTTYPE **component) {
46 ALOGV("makeComponentInstance '%s'", name);
48 sp<SoftOMXComponent> codec;
50 for (size_t i = 0; i < kNumAudioComponents; ++i) {
51 if (!strcasecmp(name, android::kAudioComponents[i].mName)) {
52 codec = SoftFFmpegAudio::createSoftOMXComponent(name, callbacks, appData, component);
58 for (size_t i = 0; i < kNumVideoComponents; ++i) {
59 if (!strcasecmp(name, android::kVideoComponents[i].mName)) {
60 codec = SoftFFmpegVideo::createSoftOMXComponent(name, callbacks, appData, component);
67 OMX_ERRORTYPE err = codec->initCheck();
68 if (err != OMX_ErrorNone) {
72 codec->incStrong(this);
77 return OMX_ErrorInvalidComponentName;
80 OMX_ERRORTYPE FFmpegOMXPlugin::destroyComponentInstance(
81 OMX_COMPONENTTYPE *component) {
82 SoftOMXComponent *me =
84 ((OMX_COMPONENTTYPE *)component)->pComponentPrivate;
86 me->prepareForDestruction();
88 CHECK_EQ(me->getStrongCount(), 1);
95 OMX_ERRORTYPE FFmpegOMXPlugin::enumerateComponents(
99 if (index >= kNumComponents) {
100 return OMX_ErrorNoMore;
103 if (index < kNumAudioComponents) {
104 strcpy(name, kAudioComponents[index].mName);
106 strcpy(name, kVideoComponents[index - kNumAudioComponents].mName);
109 return OMX_ErrorNone;
112 OMX_ERRORTYPE FFmpegOMXPlugin::getRolesOfComponent(
114 Vector<String8> *roles) {
116 for (size_t i = 0; i < kNumAudioComponents; ++i) {
117 if (strcmp(name, kAudioComponents[i].mName)) {
122 roles->push(String8(kAudioComponents[i].mRole));
124 return OMX_ErrorNone;
127 for (size_t i = 0; i < kNumVideoComponents; ++i) {
128 if (strcmp(name, kVideoComponents[i].mName)) {
133 roles->push(String8(kVideoComponents[i].mRole));
135 return OMX_ErrorNone;
138 return OMX_ErrorInvalidComponentName;
141 } // namespace android