vdr = VDR::getInstance();
initted = false;
-// videoStartup = false;
-// preBuffering = false;
+ videoStartup = false;
stopNow = false;
state = 1;
i.instruction = 1;
i.channelIndex = index;
instructions.push(i);
-
threadStart();
}
void PlayerLiveTV::setChannel(ULONG index)
{
-// demuxer->setVID(Vpid);
-// demuxer->setAID(Apid);
-// play();
logger->log("PlayerLiveTV", Log::DEBUG, "setChannel");
-
struct PLTVInstruction i;
i.instruction = 1;
i.channelIndex = index;
instructions.push(i);
-
threadSignalNoLock();
}
void PlayerLiveTV::stop()
{
logger->log("PlayerLiveTV", Log::DEBUG, "stop");
-
struct PLTVInstruction i;
i.instruction = 2;
instructions.push(i);
-
- logger->log("PlayerLiveTV", Log::DEBUG, "Pushed instruction");
-
threadSignal();
-
- logger->log("PlayerLiveTV", Log::DEBUG, "Signal sent");
-
threadStop();
-
- logger->log("PlayerLiveTV", Log::DEBUG, "Stop returning");
}
// ----------------------------------- Callback
{
logger->log("PlayerLiveTV", Log::DEBUG, "Demuxer said video is something else... ignoring");
}
-
}
- else
+ else if (caller == &afeed)
{
- if (videoStartup)
+ if (state == S_VIDEOSTARTUP)
{
- logger->log("PlayerLiveTV", Log::DEBUG, "Video startup");
- videoStartup = false;
- video->reset();
- video->play();
- video->sync();
- vfeed.release();
+ logger->log("PlayerLiveTV", Log::DEBUG, "afeed video startup");
+ videoStartup = true;
+ threadSignalNoLock();
+ }
+ }
+ /*
+ else if (caller == &vfeed)
+ {
+ if (videoStartup2)
+ {
+ logger->log("PlayerLiveTV", Log::DEBUG, "Video startup %i", videoStartup2count);
+
+ if (++videoStartup2count == 2)
+ {
+ videoStartup2 = false;
+
+ video->unPause();
+ audio->unPause();
+
+ audio->systemMuteOff();
+ }
}
threadSignalNoLock();
}
+*/
}
// -----------------------------------
StreamChunk s = streamChunks.front();
streamChunks.pop();
logger->log("PlayerLiveTV", Log::DEBUG, "About to call demuxer with %p %lu", s.data, s.len);
- demuxer->put((UCHAR*)s.data, s.len);
+ int a = demuxer->put((UCHAR*)s.data, s.len);
+ logger->log("PlayerLiveTV", Log::DEBUG, "put %i to demuxer", a);
free(s.data);
}
{
switch(newState)
{
- case S_STOP:
- {
- abort();
- }
case S_PREBUFFERING:
{
- break;
- }
- case S_PLAY:
- {
- abort();
+ video->blank();
+ audio->stop();
+ audio->unPause();
+ audio->reset();
+
+ audio->setStreamType(Audio::MPEG2_PES);
+ audio->systemMuteOff();
+ video->reset();
+ demuxer->reset();
+ demuxer->seek();
+ state = newState;
+ return;
}
}
- break;
}
case S_PREBUFFERING: // FROM S_PREBUFFERING
{
vdr->stopStreaming();
clearStreamChunks();
- break;
+ state = newState;
+ return;
}
case S_PREBUFFERING:
{
vdr->stopStreaming();
clearStreamChunks();
- break;
+ state = newState;
+ return;
}
- case S_PLAY:
+ case S_VIDEOSTARTUP:
{
- videoStartup = true;
+ logger->log("PlayerLiveTV", Log::DEBUG, "doing ss to videostartup");
- audio->reset();
- audio->setStreamType(Audio::MPEG2_PES);
- audio->systemMuteOff();
- video->reset();
- demuxer->reset();
- demuxer->seek();
-
audio->sync();
audio->play();
+ //audio->systemMuteOn();
video->sync();
video->pause();
afeed.start();
vfeed.start();
- break;
+ state = newState;
+ return;
+ }
+ }
+ }
+
+ case S_VIDEOSTARTUP: // FROM S_VIDEOSTARTUP
+ {
+ switch(newState)
+ {
+ case S_PLAY:
+ {
+ logger->log("PlayerLiveTV", Log::DEBUG, "doing ss to play");
+ video->reset();
+ video->play();
+ video->sync();
+ vfeed.release();
+ state = newState;
+ return;
}
}
- break;
}
case S_PLAY: // FROM S_PLAY
video->blank();
audio->stop();
audio->unPause();
+ audio->reset();
video->reset();
- break;
+ state = newState;
+ return;
}
case S_PREBUFFERING:
{
video->blank();
audio->stop();
audio->unPause();
+ audio->reset();
+
+ audio->setStreamType(Audio::MPEG2_PES);
+ // audio->systemMuteOn();
video->reset();
demuxer->reset();
- break;
- }
- case S_PLAY:
- {
- abort();
+ demuxer->seek();
+ state = newState;
+ return;
}
}
- break;
}
}
- state = newState;
+ logger->log("PlayerLiveTV", Log::EMERG, "Thread called state %u to state %u which is not supported", state, newState);
+ abort();
}
void PlayerLiveTV::threadMethod()
while(1)
{
+ if (videoStartup) // we are in S_VIDEOSTARTUP, afeed has signalled that it has written some data
+ {
+ switchState(S_PLAY);
+ videoStartup = false;
+ }
+
while(!instructions.empty())
{
struct PLTVInstruction i = instructions.front();
{
if (state == S_PREBUFFERING)
{
- if (streamChunks.size() > 4)
+ if (streamChunks.size() > 9)
{
while(streamChunks.size()) chunkToDemuxer();
- switchState(S_PLAY);
+ switchState(S_VIDEOSTARTUP);
}
}
- else if (state == S_PLAY)
+ else if (state == S_PLAY || state == S_VIDEOSTARTUP)
{
while(streamChunks.size()) chunkToDemuxer();
}
logger->log("PlayerLiveTV", Log::DEBUG, "End of thread");
}
-void PlayerLiveTV::threadPostStopCleanup()
-{
- logger->log("PlayerLiveTV", Log::DEBUG, "Post stop cleanup");
-}
-
-// ----------------------------------- Dev
-
-#ifdef DEV
-void PlayerLiveTV::test1()
-{
- logger->log("PlayerLiveTV", Log::DEBUG, "PLAYER TEST 1");
-}
-
-void PlayerLiveTV::test2()
-{
- logger->log("PlayerLiveTV", Log::DEBUG, "PLAYER TEST 2");
-}
-#endif
-