00001 /* 00002 * Copyright (C) 2009, Edmundo Albuquerque de Souza e Silva. 00003 * 00004 * This file may be distributed under the terms of the Q Public License 00005 * as defined by Trolltech AS of Norway and appearing in the file 00006 * LICENSE.QPL included in the packaging of this file. 00007 * 00008 * THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING 00009 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00010 * PURPOSE. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, 00011 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING 00012 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 00013 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 00014 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 00015 * 00016 */ 00017 00018 #ifndef __RIOMMMP3_H_ 00019 #define __RIOMMMP3_H_ 00020 00021 #ifndef MaxPipeDataSize 00022 #define MaxPipeDataSize 1024 00023 #endif 00024 00025 class RioMMInterface; 00026 00027 class CRioMMMp3 : public CRioMMObject 00028 { 00029 int pipe_mpg123[2]; // pipe used to send data to mpg123 player 00030 pid_t pid; // mpg123 Process id 00031 RioBlock NextRequestBlock; // Ptr to the next block to be fetched 00032 unsigned int PlayBuffer; 00033 pthread_t PlayThreadID; 00034 bool Paused; 00035 pthread_mutex_t PlayPause; 00036 RioMMInterface *riomminterface; 00037 00038 void StartMpg123( void ); 00039 00040 /*** Request next block to the server. The block returned by the server will 00041 placed in slot index of Request buffer. This function returns true if 00042 the requested block exists in server, i. e., if it is lesser than the 00043 total blocks stored on server, otherwise it returns true. 00044 */ 00045 bool ReadNextBlock( unsigned int ); 00046 00047 static void *PlayThread( void * ); 00048 static void PlayThreadCleanup( void * ); 00049 00050 public: 00051 CRioMMMp3( char *, unsigned int, RioBlock , struct timeval RTT_average, RioMMInterface* ); 00052 ~CRioMMMp3(); 00053 00054 void PlayBlock( int, int ); 00055 void FastForward( void ); 00056 void FastRewind( void ); 00057 void GoTo( RioBlock ); 00058 void Play( void ); 00059 void Pause( void ); 00060 void Stop( void ); 00061 int init( void ); 00062 void WaitEndOfVideo( void ); 00063 RioBlock GetCurrentPosition( void ); /*Returns the current block being played*/ 00064 RioBlock GetTotalPositions( void ); /* Returns the total of blocks*/ 00065 }; 00066 00067 #endif