OSDN Git Service

add the extrator plugins for stagefright
[android-x86/external-stagefright-plugins.git] / libstagefright / NamExtractor.cpp
1 /*
2  * Copyright (C) 2009 The Android Open Source Project
3  * Copyright (C) 2010-2011 Code Aurora Forum
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #define LOG_NDEBUG 0
19 #define LOG_TAG "NamExtractor"
20 #include <utils/Log.h>
21
22 #include <media/stagefright/foundation/AMessage.h>
23 #include <media/stagefright/DataSource.h>
24 #include <media/stagefright/MediaDefs.h>
25 #include <media/stagefright/MediaExtractor.h>
26 #include <media/stagefright/MetaData.h>
27 #include <utils/String8.h>
28
29 #include "include/FFmpegExtractor.h"
30 #undef strcasecmp
31 #include <strings.h>
32
33 namespace android {
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 // TODO, SniffFFMPEG, SniffVLC, SniffMPLAYER
40 static const DataSource::SnifferFunc gNamSniffers[] = {
41     SniffFFMPEG,
42 };
43
44 // static
45 void snifferArray(const DataSource::SnifferFunc *snifferArray[], int *count)
46 {
47     *count = sizeof(gNamSniffers) / sizeof(gNamSniffers[0]);
48     *snifferArray = gNamSniffers;
49 }
50
51 // static
52 MediaExtractor *createExtractor(const sp<DataSource> &source, const char *mime) {
53     MediaExtractor *ret = NULL;
54
55     if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG4)     ||
56         !strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_MPEG)          ||
57         !strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MOV)       ||
58         !strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MATROSKA)  ||
59         !strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_TS)        ||
60         !strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_AVI)       ||
61         !strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_ASF)       ||
62         !strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_WEBM)      ||
63         !strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_WMV)       ||
64         !strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPG)       ||
65         !strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_FLV)       ||
66         !strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_DIVX)      ||
67         !strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_RM)        ||
68         !strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_FLAC)      ||
69         !strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_APE)       ||
70         !strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MP2)       ||
71         !strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_RA)        ||
72         !strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_WMA)) {
73         ret = new FFmpegExtractor(source);
74     }
75
76     if (ret)
77         LOGI("NamExtractor support the mime: %s", mime);
78     else
79         LOGI("NamExtractor don't support the mime: %s", mime);
80
81     return ret;
82 }
83
84 #ifdef __cplusplus
85 }
86 #endif
87
88 }   //namespace android