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