00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #if ! defined ( KDENSERVER_HH )
00037 #define KDENSERVER_HH
00038
00039
00040 #include <sys/types.h>
00041 #include <sys/socket.h>
00042 #include <netinet/in.h>
00043 #include <arpa/inet.h>
00044 #include <unistd.h>
00045
00046
00047 #include <iostream>
00048 #include <string>
00049 #include <algorithm>
00050 #include <functional>
00051 #include <list>
00052
00053
00054 #include "server.hh"
00055 #include "libpiave/piave_base.hh"
00056 #include "libpiave/storybase.hh"
00057 #include "libpiave/player.hh"
00058 #include "libpiave/ringbuffer.hh"
00059 #include "libpiave/VEML.hh"
00060
00061 namespace PIAVE {
00062
00067 class KdenLiveServer : public Server
00068 {
00069
00070 private:
00071
00072 struct CommandQueue
00073 {
00074 enum AccessMode { block, non_block };
00075 PtrRingBuffer< VEMLCmnd > dropQ;
00076 PtrRingBuffer< VEMLCmnd > stdQ;
00077 pthread_mutex_t lock;
00078 pthread_cond_t notempty;
00079 pthread_cond_t notfull;
00080 CommandQueue() {
00081 pthread_mutex_init( &lock, NULL );
00082 pthread_cond_init( ¬empty, NULL );
00083 pthread_cond_init( ¬full, NULL );
00084 }
00085 void kick();
00086 void push( const VEMLCmnd * c );
00087 const VEMLCmnd * pop( AccessMode a );
00088 };
00089
00090 public:
00091 KdenLiveServer( unsigned short port );
00092 virtual ~KdenLiveServer();
00093
00094
00095
00096
00097 void setStoryBoard( StoryBoard * s ) { _theStoryBoard = s; }
00098
00099
00100
00101 void printAllVEML( std::ostream & o ) const ;
00102
00103
00104 void inc_seek_pos();
00105 void dec_seek_pos();
00106 void push_cmnd( const std::string & c );
00107
00108
00109 bool _listenForSDLEvents;
00110
00111 protected:
00112
00113
00114 void startProcessCommandsLoop();
00115
00116 private:
00117
00118
00119
00120 static void * _listen_for_commands( void * );
00121 static void * _listen_for_SDL_events( void * );
00122 static void * _process_commands( void * );
00123
00124
00125
00126
00127 virtual void listenForCommands();
00128 virtual void listenForSDLEvents();
00129 virtual void processCommands();
00130
00131
00132
00133
00135 virtual PropertyNode * veml_createVideoXWindow( const VEMLCmnd * cmd );
00136 virtual PropertyNode * veml_closeVideoXWindow( const VEMLCmnd * cmd );
00137 virtual PropertyNode * veml_seek( const VEMLCmnd * cmd );
00138 virtual PropertyNode * veml_play( const VEMLCmnd * cmd );
00139 virtual PropertyNode * veml_quit( const VEMLCmnd * cmd );
00140 virtual PropertyNode * veml_stop( const VEMLCmnd * cmd );
00141 virtual PropertyNode * veml_getFileProperties( const VEMLCmnd * cmd );
00142 virtual PropertyNode * veml_render( const VEMLCmnd * cmd );
00143 virtual PropertyNode * veml_ping( const VEMLCmnd * cmd );
00144 virtual PropertyNode * veml_setSceneList( const VEMLCmnd * cmd );
00145 virtual PropertyNode * veml_getCapabilities( const VEMLCmnd * cmd );
00146
00147
00148
00149
00150 private:
00152 OutAVStreamIFace * _screenOut;
00154 OutAudioStreamIFace * _audioOut;
00155
00157 StoryBoard * _theStoryBoard;
00158
00159
00160
00161
00162
00163 VEMLCmndMap _allVEMLCommands;
00164
00165
00166
00167
00168 CommandQueue _q;
00169
00171 Player _player;
00172 Time _seek_pos;
00173
00174
00175 pthread_t _main_thread;
00176 pthread_t _listen_thread;
00177 pthread_t _listen_SDL_thread;
00178 pthread_t _process_thread;
00179
00180 };
00181 };
00182
00183 #endif