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 "StreamerPlugin.h" 26 #include "WriterPlugin.h" 27 28 29 namespace BPrivate { 30 namespace media { 31 32 class AddOnManager { 33 public: 34 AddOnManager(); 35 ~AddOnManager(); 36 37 static AddOnManager* GetInstance(); 38 39 status_t GetDecoderForFormat(entry_ref* _ref, 40 const media_format& format); 41 42 status_t GetEncoderForFormat(entry_ref* _ref, 43 const media_format& outputFormat); 44 45 status_t GetReaders(entry_ref* _ref, 46 int32* _count, int32 maxCount); 47 48 status_t GetStreamers(entry_ref* _ref, 49 int32* _count, int32 maxCount); 50 51 status_t GetEncoder(entry_ref* _ref, int32 id); 52 53 status_t GetWriter(entry_ref* _ref, 54 uint32 internalID); 55 56 status_t GetFileFormat(media_file_format* _fileFormat, 57 int32 cookie); 58 status_t GetCodecInfo(media_codec_info* _codecInfo, 59 media_format_family* _formatFamily, 60 media_format* _inputFormat, 61 media_format* _outputFormat, int32 cookie); 62 63 void RegisterAddOns(); 64 65 private: 66 67 status_t _RegisterAddOn(const entry_ref& ref); 68 status_t _UnregisterAddOn(const entry_ref& ref); 69 70 void _RegisterReader(ReaderPlugin* reader, 71 const entry_ref& ref); 72 void _RegisterDecoder(DecoderPlugin* decoder, 73 const entry_ref& ref); 74 75 void _RegisterWriter(WriterPlugin* writer, 76 const entry_ref& ref); 77 void _RegisterEncoder(EncoderPlugin* encoder, 78 const entry_ref& ref); 79 80 void _RegisterStreamer(StreamerPlugin* streamer, 81 const entry_ref& ref); 82 83 bool _FindDecoder(const media_format& format, 84 const BPath& path, 85 entry_ref* _decoderRef); 86 87 bool _FindEncoder(const media_format& format, 88 const BPath& path, 89 entry_ref* _decoderRef); 90 91 void _GetReaders(const BPath& path, 92 entry_ref* outRefs, int32* outCount, 93 int32 maxCount); 94 95 private: 96 struct reader_info { 97 entry_ref ref; 98 }; 99 struct writer_info { 100 entry_ref ref; 101 uint32 internalID; 102 }; 103 struct decoder_info { 104 entry_ref ref; 105 List<media_format> formats; 106 }; 107 struct encoder_info { 108 entry_ref ref; 109 uint32 internalID; 110 media_codec_info codecInfo; 111 media_format_family formatFamily; 112 media_format intputFormat; 113 media_format outputFormat; 114 }; 115 struct streamer_info { 116 entry_ref ref; 117 }; 118 119 BLocker fLock; 120 List<reader_info> fReaderList; 121 List<writer_info> fWriterList; 122 List<decoder_info> fDecoderList; 123 List<encoder_info> fEncoderList; 124 List<streamer_info> fStreamerList; 125 126 List<media_file_format> fWriterFileFormats; 127 128 uint32 fNextWriterFormatFamilyID; 129 uint32 fNextEncoderCodecInfoID; 130 131 static AddOnManager sInstance; 132 }; 133 134 } // namespace media 135 } // namespace BPrivate 136 137 #endif // _ADD_ON_MANAGER_H 138