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 "VideoDecoderWMV.h"
18 #include "VideoDecoderMPEG4.h"
19 #include "VideoDecoderAVC.h"
20
21 #ifdef USE_INTEL_SECURE_AVC
22 #include "VideoDecoderAVCSecure.h"
23 #endif
24
25 #ifdef USE_HW_VP8
26 #include "VideoDecoderVP8.h"
27 #endif
28 #include "VideoDecoderHost.h"
29 #include "VideoDecoderTrace.h"
30 #include <string.h>
31
createVideoDecoder(const char * mimeType)32 IVideoDecoder* createVideoDecoder(const char* mimeType) {
33 if (mimeType == NULL) {
34 ETRACE("NULL mime type.");
35 return NULL;
36 }
37
38 if (strcasecmp(mimeType, "video/wmv") == 0 ||
39 strcasecmp(mimeType, "video/vc1") == 0 ||
40 strcasecmp(mimeType, "video/x-ms-wmv") == 0) {
41 VideoDecoderWMV *p = new VideoDecoderWMV(mimeType);
42 return (IVideoDecoder *)p;
43 } else if (strcasecmp(mimeType, "video/avc") == 0 ||
44 strcasecmp(mimeType, "video/h264") == 0) {
45 VideoDecoderAVC *p = new VideoDecoderAVC(mimeType);
46 return (IVideoDecoder *)p;
47 } else if (strcasecmp(mimeType, "video/mp4v-es") == 0 ||
48 strcasecmp(mimeType, "video/mpeg4") == 0 ||
49 strcasecmp(mimeType, "video/h263") == 0 ||
50 strcasecmp(mimeType, "video/3gpp") == 0) {
51 VideoDecoderMPEG4 *p = new VideoDecoderMPEG4(mimeType);
52 return (IVideoDecoder *)p;
53 }
54 #ifdef USE_INTEL_SECURE_AVC
55 else if (strcasecmp(mimeType, "video/avc-secure") == 0) {
56 VideoDecoderAVC *p = new VideoDecoderAVCSecure(mimeType);
57 return (IVideoDecoder *)p;
58 }
59 #endif
60
61 #ifdef USE_HW_VP8
62 else if (strcasecmp(mimeType, "video/vp8") == 0 ||
63 strcasecmp(mimeType, "video/x-vnd.on2.vp8") == 0) {
64 VideoDecoderVP8 *p = new VideoDecoderVP8(mimeType);
65 return (IVideoDecoder *)p;
66 }
67 #endif
68
69 else {
70 ETRACE("Unknown mime type: %s", mimeType);
71 }
72 return NULL;
73 }
74
releaseVideoDecoder(IVideoDecoder * p)75 void releaseVideoDecoder(IVideoDecoder* p) {
76 if (p) {
77 const VideoFormatInfo *info = p->getFormatInfo();
78 if (info && info->mimeType) {
79 ITRACE("Deleting decoder for %s", info->mimeType);
80 }
81 }
82 delete p;
83 }
84
85
86