MediaCodecList.h revision 77c185d5499d6174e7a97b3e1512994d3a803151
1/* 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#include <media/IMediaCodecList.h> 24#include <media/IOMX.h> 25#include <media/MediaCodecInfo.h> 26 27#include <sys/types.h> 28#include <utils/Errors.h> 29#include <utils/KeyedVector.h> 30#include <utils/Vector.h> 31#include <utils/StrongPointer.h> 32 33namespace android { 34 35struct AMessage; 36 37struct MediaCodecList : public BnMediaCodecList { 38 static sp<IMediaCodecList> getInstance(); 39 40 virtual ssize_t findCodecByType( 41 const char *type, bool encoder, size_t startIndex = 0) const; 42 43 virtual ssize_t findCodecByName(const char *name) const; 44 45 virtual size_t countCodecs() const; 46 47 virtual sp<MediaCodecInfo> getCodecInfo(size_t index) const { 48 if (index >= mCodecInfos.size()) { 49 ALOGE("b/24445127"); 50 return NULL; 51 } 52 return mCodecInfos.itemAt(index); 53 } 54 55 // to be used by MediaPlayerService alone 56 static sp<IMediaCodecList> getLocalInstance(); 57 58private: 59 enum Section { 60 SECTION_TOPLEVEL, 61 SECTION_DECODERS, 62 SECTION_DECODER, 63 SECTION_DECODER_TYPE, 64 SECTION_ENCODERS, 65 SECTION_ENCODER, 66 SECTION_ENCODER_TYPE, 67 SECTION_INCLUDE, 68 }; 69 70 static sp<IMediaCodecList> sCodecList; 71 static sp<IMediaCodecList> sRemoteList; 72 73 status_t mInitCheck; 74 Section mCurrentSection; 75 Vector<Section> mPastSections; 76 int32_t mDepth; 77 AString mHrefBase; 78 79 Vector<sp<MediaCodecInfo> > mCodecInfos; 80 sp<MediaCodecInfo> mCurrentInfo; 81 sp<IOMX> mOMX; 82 83 MediaCodecList(); 84 ~MediaCodecList(); 85 86 status_t initCheck() const; 87 void parseXMLFile(const char *path); 88 void parseTopLevelXMLFile(const char *path); 89 90 static void StartElementHandlerWrapper( 91 void *me, const char *name, const char **attrs); 92 93 static void EndElementHandlerWrapper(void *me, const char *name); 94 95 void startElementHandler(const char *name, const char **attrs); 96 void endElementHandler(const char *name); 97 98 status_t includeXMLFile(const char **attrs); 99 status_t addMediaCodecFromAttributes(bool encoder, const char **attrs); 100 void addMediaCodec(bool encoder, const char *name, const char *type = NULL); 101 102 status_t addQuirk(const char **attrs); 103 status_t addTypeFromAttributes(const char **attrs); 104 status_t addLimit(const char **attrs); 105 status_t addFeature(const char **attrs); 106 void addType(const char *name); 107 108 status_t initializeCapabilities(const char *type); 109 110 DISALLOW_EVIL_CONSTRUCTORS(MediaCodecList); 111}; 112 113} // namespace android 114 115#endif // MEDIA_CODEC_LIST_H_ 116 117