00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __RIOMULTIMEDIAOBJECT_H_
00019 #define __RIOMULTIMEDIAOBJECT_H_
00020
00021 #include "CommMulticastStream.h"
00022
00023 #define INITIAL_RTT 500000
00024 #ifndef MAXPATHSIZE
00025 #define MAXPATHSIZE 255
00026 #endif
00027
00028 enum
00029 {
00030 BUFFEREMPTY,
00031 BUFFERFULL
00032 };
00033
00034 enum
00035 {
00036 BPLAY,
00037 BPAUSE,
00038 BFFORWARD,
00039 BFREWIND,
00040 STOP,
00041 PLAYING,
00042 JUMPBAR,
00043 JUMPTOPIC,
00044 REQSERV,
00045 REQCACHE,
00046 ARRIVING,
00047 QUIT
00048 };
00049
00050 class BufferStream;
00051
00052 class CRioMMObject
00053 {
00054 protected:
00055
00056 CRioObject Object;
00057 CRioStream Stream;
00058 RioAccess Access;
00059 char MMObjectName[ MAXPATHSIZE ];
00060 pthread_mutex_t PlayThreadMutex;
00061 pthread_cond_t PlayThreadCondition;
00062 CRioMMObject **Media;
00063 unsigned int nMedias;
00064 unsigned int CurMedia;
00065 int *BufferStatus;
00066 RioRequest *Request;
00067 unsigned int BlockSize;
00068 RioObjectSize ObjSize;
00069 RioBlock TotalBlocks;
00070 RioBlock CurrentBlock;
00071 RioBlock nBuffers;
00072
00073 #ifdef RIO_EMUL
00074 int *duration;
00075 #endif
00076
00077 struct timeval average_RTT;
00078 int fullBuffers;
00079 BufferStream *bufferStream;
00080
00081 public:
00082
00083 int group_block;
00084
00085
00086
00087
00088
00089 CRioMMObject( char *, unsigned int, RioBlock, struct timeval average_RTT );
00090 virtual ~CRioMMObject();
00091
00092 int Open( RioAccess, CRioStream * );
00093 bool Read( int, RioBlock, RioStreamType traffic = UNICASTTRAFFIC,
00094 int ip = 0, int port = 0 );
00095 bool MulticastRead( RioBlock block , RioStreamType traffic );
00096
00097
00098
00099
00100
00101 void Getmyaddr( int *my_address, int *my_port );
00102
00103 virtual void Prefetch( void );
00104 virtual bool WaitPrefetch( void );
00105 int CanStart( void );
00106 void AllocMedia( int );
00107 bool AddMedia( CRioMMObject * );
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120 void SetBufferStatus( RioBlock, int );
00121
00122 int GetBufferStatus( RioBlock );
00123 char *GetName( void );
00124
00125
00126 void PlayThreadMutexLock( string msg = "" );
00127 void PlayThreadMutexUnlock( string msg = "" );
00128 void PlayThreadReleaseCondition( string msg = "" );
00129 void PlayThreadWaitCondition( string msg = "" );
00130 int PlayThreadWaitCondition( struct timespec *t,
00131 string msg = "" );
00132
00133 virtual void Play( void ) = 0;
00134 virtual void Stop( void ) = 0;
00135 #ifdef RIO_EMUL
00136 virtual void Quit( void ) = 0;
00137 #endif
00138 virtual void Pause( void ) = 0;
00139 virtual void FastRewind( void ) = 0;
00140 virtual void FastForward( void ) = 0;
00141 virtual void SyncMedia( void * );
00142 virtual int Close( void );
00143 virtual void GoTo( RioBlock ) = 0;
00144
00145 virtual int init( void ) = 0;
00146 virtual RioBlock GetCurrentPosition( void ) = 0;
00147
00148 virtual RioBlock GetTotalPositions( void ) = 0;
00149
00150
00151 static void CallBack( struct RioRequest *request );
00152
00153 virtual void inputLog( int, unsigned int = 0, unsigned int = 0 );
00154 virtual unsigned int getCurrentPlayingBlock();
00155
00156 #ifdef RIO_EMUL
00157 void SetBlocksDuration( int * );
00158 int *GetBlocksDuration( );
00159 bool GetFinalizeEmul( );
00160 bool finalize_emul;
00161 #endif
00162
00163 CRioObject *GetObject();
00164 int GetNBuffers();
00165
00166
00167
00168
00169 int GetFullBuffers();
00170
00171 int GetNMedias();
00172 CRioMMObject *GetMedia( unsigned );
00173
00174 virtual int ProcessSignal( int, void * );
00175
00176 struct RTT
00177 {
00178 struct timeval initial_time;
00179 struct timeval arrived_time;
00180 int block;
00181 };
00182
00183 struct RTT calculete_RTT[30];
00184 unsigned int RTT_average;
00185 unsigned int RTT_window;
00186 struct timeval sum_RTT;
00187
00188 #ifdef RIO_DEBUG2
00189
00190
00191
00192
00193
00194
00195 void printDebug( short debugCode, string message = "" );
00196 #endif
00197 };
00198 #endif