1*218a8c03SAugustin Cavalier /* 2*218a8c03SAugustin Cavalier * Copyright 2004-2009, Haiku, Inc. All rights reserved. 3*218a8c03SAugustin Cavalier * Distributed under the terms of the MIT license. 4*218a8c03SAugustin Cavalier * 5*218a8c03SAugustin Cavalier * Authors: 6*218a8c03SAugustin Cavalier * Axel Dörfler 7*218a8c03SAugustin Cavalier * Marcus Overhagen 8*218a8c03SAugustin Cavalier */ 9*218a8c03SAugustin Cavalier #ifndef _FORMAT_MANAGER_H 10*218a8c03SAugustin Cavalier #define _FORMAT_MANAGER_H 11*218a8c03SAugustin Cavalier 12*218a8c03SAugustin Cavalier 13*218a8c03SAugustin Cavalier #include <Locker.h> 14*218a8c03SAugustin Cavalier #include <ObjectList.h> 15*218a8c03SAugustin Cavalier #include <pthread.h> 16*218a8c03SAugustin Cavalier 17*218a8c03SAugustin Cavalier #include "MetaFormat.h" 18*218a8c03SAugustin Cavalier 19*218a8c03SAugustin Cavalier 20*218a8c03SAugustin Cavalier class FormatManager { 21*218a8c03SAugustin Cavalier public: 22*218a8c03SAugustin Cavalier ~FormatManager(); 23*218a8c03SAugustin Cavalier 24*218a8c03SAugustin Cavalier void GetFormats(bigtime_t lastUpdate, BMessage& reply); 25*218a8c03SAugustin Cavalier status_t MakeFormatFor( 26*218a8c03SAugustin Cavalier const media_format_description* descriptions, 27*218a8c03SAugustin Cavalier int32 descriptionCount, 28*218a8c03SAugustin Cavalier media_format& format, uint32 flags, 29*218a8c03SAugustin Cavalier void* _reserved); 30*218a8c03SAugustin Cavalier void RemoveFormat(const media_format& format); 31*218a8c03SAugustin Cavalier 32*218a8c03SAugustin Cavalier static FormatManager* GetInstance(); 33*218a8c03SAugustin Cavalier 34*218a8c03SAugustin Cavalier private: 35*218a8c03SAugustin Cavalier FormatManager(); 36*218a8c03SAugustin Cavalier static void CreateInstance(); 37*218a8c03SAugustin Cavalier private: 38*218a8c03SAugustin Cavalier typedef BPrivate::media::meta_format meta_format; 39*218a8c03SAugustin Cavalier 40*218a8c03SAugustin Cavalier BObjectList<meta_format> fList; 41*218a8c03SAugustin Cavalier BLocker fLock; 42*218a8c03SAugustin Cavalier bigtime_t fLastUpdate; 43*218a8c03SAugustin Cavalier int32 fNextCodecID; 44*218a8c03SAugustin Cavalier 45*218a8c03SAugustin Cavalier static FormatManager* sInstance; 46*218a8c03SAugustin Cavalier static pthread_once_t sInitOnce; 47*218a8c03SAugustin Cavalier }; 48*218a8c03SAugustin Cavalier 49*218a8c03SAugustin Cavalier #endif // _FORMAT_MANAGER_H 50