1 /* 2 * Copyright 2004-2009, Haiku. All rights reserved. 3 * Distributed under the terms of the MIT license. 4 * 5 * Authors: 6 * Marcus Overhagen 7 * Axel Dörfler 8 * Stephan Aßmus <superstippi@gmx.de> 9 */ 10 #ifndef _ADD_ON_MANAGER_H 11 #define _ADD_ON_MANAGER_H 12 13 14 /*! Manager for codec add-ons (reader, writer, encoder, decoder) 15 BMediaAddOn are handled in the NodeManager 16 */ 17 18 19 #include "DataExchange.h" 20 #include "TList.h" 21 22 #include "DecoderPlugin.h" 23 #include "EncoderPlugin.h" 24 #include "ReaderPlugin.h" 25 #include "WriterPlugin.h" 26 27 28 class AddOnManager { 29 public: 30 AddOnManager(); 31 ~AddOnManager(); 32 33 static AddOnManager* GetInstance(); 34 35 status_t GetDecoderForFormat(entry_ref* _ref, 36 const media_format& format); 37 38 status_t GetReaders(entry_ref* _ref, 39 int32* _count, int32 maxCount); 40 41 status_t GetEncoder(entry_ref* _ref, int32 id); 42 43 status_t GetWriter(entry_ref* _ref, 44 uint32 internalID); 45 46 status_t GetFileFormat(media_file_format* _fileFormat, 47 int32 cookie); 48 status_t GetCodecInfo(media_codec_info* _codecInfo, 49 media_format_family* _formatFamily, 50 media_format* _inputFormat, 51 media_format* _outputFormat, int32 cookie); 52 53 private: 54 void _RegisterAddOns(); 55 56 status_t _RegisterAddOn(const entry_ref& ref); 57 status_t _UnregisterAddOn(const entry_ref& ref); 58 59 void _RegisterReader(ReaderPlugin* reader, 60 const entry_ref& ref); 61 void _RegisterDecoder(DecoderPlugin* decoder, 62 const entry_ref& ref); 63 64 void _RegisterWriter(WriterPlugin* writer, 65 const entry_ref& ref); 66 void _RegisterEncoder(EncoderPlugin* encoder, 67 const entry_ref& ref); 68 69 bool _FindDecoder(const media_format& format, 70 const BPath& path, 71 entry_ref* _decoderRef); 72 void _GetReaders(const BPath& path, 73 entry_ref* outRefs, int32* outCount, 74 int32 maxCount); 75 76 private: 77 struct reader_info { 78 entry_ref ref; 79 }; 80 struct writer_info { 81 entry_ref ref; 82 uint32 internalID; 83 }; 84 struct decoder_info { 85 entry_ref ref; 86 List<media_format> formats; 87 }; 88 struct encoder_info { 89 entry_ref ref; 90 uint32 internalID; 91 media_codec_info codecInfo; 92 media_format_family formatFamily; 93 media_format intputFormat; 94 media_format outputFormat; 95 }; 96 97 BLocker fLock; 98 List<reader_info> fReaderList; 99 List<writer_info> fWriterList; 100 List<decoder_info> fDecoderList; 101 List<encoder_info> fEncoderList; 102 103 List<media_file_format> fWriterFileFormats; 104 105 uint32 fNextWriterFormatFamilyID; 106 uint32 fNextEncoderCodecInfoID; 107 108 static AddOnManager sInstance; 109 }; 110 111 #endif // _ADD_ON_MANAGER_H 112