blob: bc667946ee5ce1449dc414d4a7fc4a99e141ccd3 [file] [log] [blame]
Andreas Hubere46b7be2009-07-14 16:56:47 -07001/*
2 * Copyright (C) 2009 The Android Open Source Project
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//#define LOG_NDEBUG 0
18#define LOG_TAG "MediaExtractor"
19#include <utils/Log.h>
20
21#include <media/stagefright/DataSource.h>
22#include <media/stagefright/MP3Extractor.h>
23#include <media/stagefright/MPEG4Extractor.h>
24#include <media/stagefright/MediaExtractor.h>
25#include <utils/String8.h>
26
27namespace android {
28
29// static
30MediaExtractor *MediaExtractor::Create(DataSource *source, const char *mime) {
31 String8 tmp;
32 if (mime == NULL) {
33 float confidence;
34 if (!source->sniff(&tmp, &confidence)) {
35 LOGE("FAILED to autodetect media content.");
36
37 return NULL;
38 }
39
40 mime = tmp.string();
41 LOGI("Autodetected media content as '%s' with confidence %.2f",
42 mime, confidence);
43 }
44
45 if (!strcasecmp(mime, "video/mp4") || !strcasecmp(mime, "audio/mp4")) {
46 return new MPEG4Extractor(source);
47 } else if (!strcasecmp(mime, "audio/mpeg")) {
48 return new MP3Extractor(source);
49 }
50
51 return NULL;
52}
53
54} // namespace android