blob: 14dc1b8da1767128deb3abed684ec34ca9033735 [file] [log] [blame]
Andreas Huber3d3864f2012-02-29 15:47:17 -08001/*
2 * Copyright 2012, 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#ifndef MEDIA_CODEC_LIST_H_
18
19#define MEDIA_CODEC_LIST_H_
20
21#include <media/stagefright/foundation/ABase.h>
22#include <media/stagefright/foundation/AString.h>
23
24#include <sys/types.h>
25#include <utils/Errors.h>
26#include <utils/KeyedVector.h>
27#include <utils/Vector.h>
28
29namespace android {
30
31struct MediaCodecList {
32 static const MediaCodecList *getInstance();
33
34 ssize_t findCodecByType(
35 const char *type, bool encoder, size_t startIndex = 0) const;
36
37 ssize_t findCodecByName(const char *name) const;
38
39 const char *getCodecName(size_t index) const;
40 bool codecHasQuirk(size_t index, const char *quirkName) const;
41
42private:
43 enum Section {
44 SECTION_TOPLEVEL,
45 SECTION_DECODERS,
46 SECTION_DECODER,
47 SECTION_ENCODERS,
48 SECTION_ENCODER,
49 };
50
51 struct CodecInfo {
52 AString mName;
53 bool mIsEncoder;
54 uint32_t mTypes;
55 uint32_t mQuirks;
56 };
57
58 static MediaCodecList *sCodecList;
59
60 status_t mInitCheck;
61 Section mCurrentSection;
62 int32_t mDepth;
63
64 Vector<CodecInfo> mCodecInfos;
65 KeyedVector<AString, size_t> mCodecQuirks;
66 KeyedVector<AString, size_t> mTypes;
67
68 MediaCodecList();
69 ~MediaCodecList();
70
71 status_t initCheck() const;
72 void parseXMLFile(FILE *file);
73
74 static void StartElementHandlerWrapper(
75 void *me, const char *name, const char **attrs);
76
77 static void EndElementHandlerWrapper(void *me, const char *name);
78
79 void startElementHandler(const char *name, const char **attrs);
80 void endElementHandler(const char *name);
81
82 status_t addMediaCodecFromAttributes(bool encoder, const char **attrs);
83 void addMediaCodec(bool encoder, const char *name, const char *type = NULL);
84
85 status_t addQuirk(const char **attrs);
86 status_t addTypeFromAttributes(const char **attrs);
87 void addType(const char *name);
88
89 DISALLOW_EVIL_CONSTRUCTORS(MediaCodecList);
90};
91
92} // namespace android
93
94#endif // MEDIA_CODEC_LIST_H_
95