2 Copyright 2004-2006 Chris Tallon, Andreas Vogel
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
36 #include "messagequeue.h"
40 #include "timerreceiver.h"
44 #include "threadwin.h"
57 class PlayerMedia : public Thread_TYPE, public Callback, public TimerReceiver
60 PlayerMedia(Boxx *frontend);
61 virtual ~PlayerMedia();
62 //start the player thread
65 //is the player still running?
66 bool isPlayerRunning();
70 //each of the commands works as a request
71 //only after getSequence returned the same sequence as those commands this is
72 //handled by the player and getError is valid
73 int playNew(ULONG mediaChannel,ULLONG lengthBytes, ULLONG lengthFrames=0);
74 //stop the player without shutting it down
81 int jumpToPercent(double percent);
82 int skipForward(int sec);
83 int skipBackward(int sec);
85 //wait for a particular sequence to be handled
86 //timeout in s, returnes current sequence, -1 on timeout
87 int waitForSequence(int timeout, int sequence);
92 //get current position in s
93 ULONG getCurrentTimes();
97 ULLONG getLengthFrames();
98 ULLONG getLengthBytes();
100 virtual void call(void * caller);
104 const static UCHAR S_PLAY = 1;
105 const static UCHAR S_PAUSE = 2;
106 const static UCHAR S_POSITION = 3;
107 const static UCHAR S_DONE=5;
108 const static UCHAR S_STOP = 6;
109 const static UCHAR S_ERROR = 8;
110 const static UCHAR S_FF = 9;
111 const static UCHAR S_BACK = 10;
112 const static UCHAR S_SEEK = 11;
115 //message parameters for frontend messages
116 const static ULONG CONNECTION_LOST=1;
117 const static ULONG STREAM_END=2;
118 const static ULONG STREAM_ERR=3;
119 const static ULONG STATUS_CHANGE=4; //some info has been changed
120 const static ULONG SHORT_UPDATE=6; //timer info update
121 const static ULONG ASPECT43 = 7;
122 const static ULONG ASPECT169 = 8;
124 virtual void timercall(int reference);
125 void setAudioChannel(int channel);
126 bool * getDemuxerMpegAudioChannels();
127 bool * getDemuxerAc3AudioChannels();
128 int getCurrentAudioChannel();
129 ULLONG getCurrentPTS();
131 char * getInfo(); //return some info about the played file,caller has to destroy buffer
135 void threadPostStopCleanup();
144 DemuxerMedia *demuxer;
149 const static int FEEDER_START=1;
150 const static int FEEDER_STOP=2;
151 const static int FEEDER_PAUSE=3;
152 const static int FEEDER_UNPAUSE=4;
153 void controlFeeder(int action) ;
156 //synchronized get/set methods for states
157 int setRequestedState(UCHAR st);
158 void setState(UCHAR st);
160 //to be called from within the thread
163 //variables used by the thread
167 bool onStartup; //set for the firts chunk to find the audio channel
174 ULLONG requestedStreampos;
176 //the buffer len in bytes
177 const static int BUFLEN=100000;
178 const static int STARTBUFLEN=250000;
181 int requestedSequence;
185 void sendFrontendMessage(ULONG para);
188 void waitTimed(int ms);
190 //get the current average bitrate by using PTS compared to streampos
191 ULLONG getBytesPerSecond();
196 ULLONG appDestinationPTS; //if we are moving set the PTS to the destination
197 //for display at the bar, take this if !=0
198 bool playingStarted; //did we ever start to play?