MediaCodecList.h revision afc16d667afa23f5aa00154ccad62f8c45cf5419
1afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber/* 2afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber * Copyright 2012, The Android Open Source Project 3afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber * 4afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber * Licensed under the Apache License, Version 2.0 (the "License"); 5afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber * you may not use this file except in compliance with the License. 6afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber * You may obtain a copy of the License at 7afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber * 8afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber * http://www.apache.org/licenses/LICENSE-2.0 9afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber * 10afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber * Unless required by applicable law or agreed to in writing, software 11afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber * distributed under the License is distributed on an "AS IS" BASIS, 12afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber * See the License for the specific language governing permissions and 14afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber * limitations under the License. 15afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber */ 16afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber 17afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber#ifndef MEDIA_CODEC_LIST_H_ 18afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber 19afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber#define MEDIA_CODEC_LIST_H_ 20afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber 21afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber#include <media/stagefright/foundation/ABase.h> 22afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber#include <media/stagefright/foundation/AString.h> 23afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber 24afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber#include <sys/types.h> 25afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber#include <utils/Errors.h> 26afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber#include <utils/KeyedVector.h> 27afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber#include <utils/Vector.h> 28afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber 29afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Hubernamespace android { 30afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber 31afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huberstruct MediaCodecList { 32afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber static const MediaCodecList *getInstance(); 33afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber 34afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber ssize_t findCodecByType( 35afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber const char *type, bool encoder, size_t startIndex = 0) const; 36afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber 37afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber ssize_t findCodecByName(const char *name) const; 38afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber 39afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber const char *getCodecName(size_t index) const; 40afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber bool codecHasQuirk(size_t index, const char *quirkName) const; 41afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber 42afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huberprivate: 43afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber enum Section { 44afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber SECTION_TOPLEVEL, 45afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber SECTION_DECODERS, 46afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber SECTION_DECODER, 47afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber SECTION_ENCODERS, 48afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber SECTION_ENCODER, 49afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber }; 50afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber 51afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber struct CodecInfo { 52afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber AString mName; 53afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber bool mIsEncoder; 54afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber uint32_t mTypes; 55afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber uint32_t mQuirks; 56afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber }; 57afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber 58afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber static MediaCodecList *sCodecList; 59afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber 60afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber status_t mInitCheck; 61afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber Section mCurrentSection; 62afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber int32_t mDepth; 63afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber 64afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber Vector<CodecInfo> mCodecInfos; 65afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber KeyedVector<AString, size_t> mCodecQuirks; 66afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber KeyedVector<AString, size_t> mTypes; 67afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber 68afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber MediaCodecList(); 69afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber ~MediaCodecList(); 70afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber 71afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber status_t initCheck() const; 72afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber void parseXMLFile(FILE *file); 73afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber 74afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber static void StartElementHandlerWrapper( 75afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber void *me, const char *name, const char **attrs); 76afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber 77afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber static void EndElementHandlerWrapper(void *me, const char *name); 78afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber 79afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber void startElementHandler(const char *name, const char **attrs); 80afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber void endElementHandler(const char *name); 81afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber 82afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber status_t addMediaCodecFromAttributes(bool encoder, const char **attrs); 83afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber void addMediaCodec(bool encoder, const char *name, const char *type = NULL); 84afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber 85afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber status_t addQuirk(const char **attrs); 86afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber status_t addTypeFromAttributes(const char **attrs); 87afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber void addType(const char *name); 88afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber 89afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber DISALLOW_EVIL_CONSTRUCTORS(MediaCodecList); 90afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber}; 91afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber 92afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber} // namespace android 93afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber 94afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber#endif // MEDIA_CODEC_LIST_H_ 95afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber 96