Rev Author Line No. Line
23 ovan 1 /************************************************************************************
2 This source file is part of the Theora Video Playback Library
3 For latest info, see http://libtheoraplayer.sourceforge.net/
4 *************************************************************************************
5 Copyright (c) 2008-2010 Kresimir Spes (kreso@cateia.com)
6 This program is free software; you can redistribute it and/or modify it under
7 the terms of the BSD license: http://www.opensource.org/licenses/bsd-license.php
8 *************************************************************************************/
9  
10 #ifndef _TheoraVideoManager_h
11 #define _TheoraVideoManager_h
12  
13 #include <vector>
14 #include <string>
15 #include "TheoraExport.h"
16 #include "TheoraVideoClip.h"
17 #ifdef _WIN32
18 #pragma warning( disable: 4251 ) // MSVC++
19 #endif
20 // forward class declarations
21 class TheoraWorkerThread;
22 class TheoraMutex;
23 class TheoraDataSource;
24 class TheoraAudioInterfaceFactory;
25 /**
26         This is the main singleton class that handles all playback/sync operations
27 */
28 class TheoraPlayerExport TheoraVideoManager
29 {
30 protected:
31         friend class TheoraWorkerThread;
32         typedef std::vector<TheoraVideoClip*> ClipList;
33         typedef std::vector<TheoraWorkerThread*> ThreadList;
34  
35         //! stores pointers to worker threads which are decoding video and audio
36         ThreadList mWorkerThreads;
37         //! stores pointers to created video clips
38         ClipList mClips;
39         int mDefaultNumPrecachedFrames;
40  
41         TheoraMutex* mWorkMutex;
42         TheoraAudioInterfaceFactory* mAudioFactory;
43  
44         void createWorkerThreads(int n);
45         void destroyWorkerThreads();
46  
47         /**
48          * Called by TheoraWorkerThread to request a TheoraVideoClip instance to work on decoding
49          */
50         TheoraVideoClip* requestWork(TheoraWorkerThread* caller);
51 public:
52         TheoraVideoManager(int num_worker_threads=1);
53         virtual ~TheoraVideoManager();
54  
55         //! get the global reference to the manager instance
56         static TheoraVideoManager& getSingleton();
57         //! get the global pointer to the manager instance
58         static TheoraVideoManager* getSingletonPtr();
59  
60         //! search registered clips by name
61         TheoraVideoClip* getVideoClipByName(std::string name);
62  
63         TheoraVideoClip* createVideoClip(std::string filename,TheoraOutputMode output_mode=TH_RGB,int numPrecachedOverride=0,bool usePower2Stride=0);
64         TheoraVideoClip* createVideoClip(TheoraDataSource* data_source,TheoraOutputMode output_mode=TH_RGB,int numPrecachedOverride=0,bool usePower2Stride=0);
65  
66         void update(float time_increase);
67  
68         void destroyVideoClip(TheoraVideoClip* clip);
69  
70         void setAudioInterfaceFactory(TheoraAudioInterfaceFactory* factory);
71         TheoraAudioInterfaceFactory* getAudioInterfaceFactory();
72  
73         int getNumWorkerThreads();
74         void setNumWorkerThreads(int n);
75  
76         void setDefaultNumPrecachedFrames(int n) { mDefaultNumPrecachedFrames=n; }
77         int getDefaultNumPrecachedFrames() { return mDefaultNumPrecachedFrames; }
78  
79         //! used by libtheoraplayer functions
80         void logMessage(std::string msg);
81  
82         /**
83                 \brief you can set your own log function to recieve theora's log calls
84  
85                 This way you can integrate libtheoraplayer's log messages in your own
86                 logging system, prefix them, mute them or whatever you want
87          */
88         static void setLogFunction(void (*fn)(std::string));
89  
90         //! get nicely formated version string
91         std::string getVersionString();
92         /**
93             \brief get version numbers
94  
95                 if c is negative, it means it's a release candidate -c
96          */
97         void getVersion(int* a,int* b,int* c);
98 };
99 #endif
100