1/*
2* Copyright (c) 2009-2011 Intel Corporation.  All rights reserved.
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 "VideoEncoderMP4.h"
18#include "VideoEncoderH263.h"
19#include "VideoEncoderAVC.h"
20#include "VideoEncoderVP8.h"
21#ifndef IMG_GFX
22#include "PVSoftMPEG4Encoder.h"
23#endif
24#include "VideoEncoderHost.h"
25#include <string.h>
26#include <cutils/properties.h>
27#include <wrs_omxil_core/log.h>
28
29int32_t gLogLevel = 0;
30
31IVideoEncoder *createVideoEncoder(const char *mimeType) {
32
33    char logLevelProp[PROPERTY_VALUE_MAX];
34
35    if (property_get("libmix.debug", logLevelProp, NULL)) {
36        gLogLevel = atoi(logLevelProp);
37        LOGD("Debug level is %d", gLogLevel);
38    }
39
40    if (mimeType == NULL) {
41        LOGE("NULL mime type");
42        return NULL;
43    }
44
45    if (strcasecmp(mimeType, "video/avc") == 0 ||
46            strcasecmp(mimeType, "video/h264") == 0) {
47        VideoEncoderAVC *p = new VideoEncoderAVC();
48        return (IVideoEncoder *)p;
49    } else if (strcasecmp(mimeType, "video/h263") == 0) {
50#ifdef IMG_GFX
51        VideoEncoderH263 *p = new VideoEncoderH263();
52#else
53        PVSoftMPEG4Encoder *p = new PVSoftMPEG4Encoder("OMX.google.h263.encoder");
54#endif
55        return (IVideoEncoder *)p;
56    } else if (strcasecmp(mimeType, "video/mpeg4") == 0 ||
57            strcasecmp(mimeType, "video/mp4v-es") == 0) {
58#ifdef IMG_GFX
59        VideoEncoderMP4 *p = new VideoEncoderMP4();
60#else
61        PVSoftMPEG4Encoder *p = new PVSoftMPEG4Encoder("OMX.google.mpeg4.encoder");
62#endif
63        return (IVideoEncoder *)p;
64    } else if (strcasecmp(mimeType, "video/x-vnd.on2.vp8") == 0) {
65        VideoEncoderVP8 *p = new VideoEncoderVP8();
66        return (IVideoEncoder *)p;
67    } else {
68        LOGE ("Unknown mime type: %s", mimeType);
69    }
70    return NULL;
71}
72
73void releaseVideoEncoder(IVideoEncoder *p) {
74    if (p) delete p;
75}
76
77