From 3c2d65ab3f9641f66744b382fab8c8fec6ae2d36 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sun, 2 Dec 2007 22:49:41 +0000 Subject: [PATCH] Live TV updates --- playerlivetv.cc | 112 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 95 insertions(+), 17 deletions(-) diff --git a/playerlivetv.cc b/playerlivetv.cc index 806a5bd..f6dad3c 100644 --- a/playerlivetv.cc +++ b/playerlivetv.cc @@ -208,9 +208,6 @@ void PlayerLiveTV::call(void* caller) void PlayerLiveTV::streamReceive(void* data, ULONG len) { - logger->log("PlayerLiveTV", Log::DEBUG, "Got data, %p, %lu", data, len); - - if (streamChunks.size() < 11) { StreamChunk s; @@ -220,11 +217,10 @@ void PlayerLiveTV::streamReceive(void* data, ULONG len) threadSignalNoLock(); } else - { // Too many chunks in streamChunks, drop this chunk free(data); - logger->log("PlayerLiveTV", Log::DEBUG, "Dropped chunk"); + logger->log("PlayerLiveTV", Log::WARN, "Dropped chunk"); } } @@ -243,9 +239,9 @@ void PlayerLiveTV::chunkToDemuxer() { StreamChunk s = streamChunks.front(); streamChunks.pop(); - logger->log("PlayerLiveTV", Log::DEBUG, "About to call demuxer with %p %lu", s.data, s.len); - int a = demuxer->put((UCHAR*)s.data, s.len); - logger->log("PlayerLiveTV", Log::DEBUG, "put %i to demuxer", a); + //logger->log("PlayerLiveTV", Log::DEBUG, "About to call demuxer with %p %lu", 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); } @@ -299,11 +295,55 @@ void PlayerLiveTV::switchState(UCHAR newState) { case S_PREBUFFERING: { - logger->log("PlayerLiveTV", Log::DEBUG, "doing ss to ss2"); vfeed.release(); state = newState; return; } + + case S_VIDEOSTARTUP: + { + vdr->stopStreaming(); + clearStreamChunks(); + vfeed.stop(); + afeed.stop(); + + video->blank(); + video->reset(); + video->sync(); + video->play(); + video->pause(); + + audio->stop(); + audio->unPause(); + audio->reset(); + audio->setStreamType(Audio::MPEG2_PES); + audio->sync(); + audio->play(); + audio->pause(); + + demuxer->reset(); + demuxer->seek(); + + afeed.start(); + vfeed.start(); + + state = newState; + return; + } + case S_STOP: + { + vdr->stopStreaming(); + clearStreamChunks(); + vfeed.stop(); + afeed.stop(); + video->stop(); + video->blank(); + audio->stop(); + audio->reset(); + video->reset(); + state = newState; + return; + } default: { logger->log("PlayerLiveTV", Log::EMERG, "Thread called state %u to state %u which is not supported", state, newState); @@ -319,12 +359,56 @@ void PlayerLiveTV::switchState(UCHAR newState) { case S_PLAY: { - logger->log("PlayerLiveTV", Log::DEBUG, "doing ss2 to ss3"); audio->unPause(); video->unPause(); state = newState; return; } + case S_VIDEOSTARTUP: + { + vdr->stopStreaming(); + clearStreamChunks(); + vfeed.stop(); + afeed.stop(); + video->stop(); + video->blank(); + audio->stop(); + audio->unPause(); + audio->reset(); + + video->reset(); + video->sync(); + video->play(); + video->pause(); + + audio->setStreamType(Audio::MPEG2_PES); + audio->sync(); + audio->play(); + audio->pause(); + + demuxer->reset(); + demuxer->seek(); + + afeed.start(); + vfeed.start(); + + state = newState; + return; + } + case S_STOP: + { + vdr->stopStreaming(); + clearStreamChunks(); + vfeed.stop(); + afeed.stop(); + video->stop(); + video->blank(); + audio->stop(); + audio->reset(); + video->reset(); + state = newState; + return; + } default: { logger->log("PlayerLiveTV", Log::EMERG, "Thread called state %u to state %u which is not supported", state, newState); @@ -334,7 +418,6 @@ void PlayerLiveTV::switchState(UCHAR newState) } } - case S_PLAY: // FROM S_PLAY { switch(newState) @@ -348,7 +431,6 @@ void PlayerLiveTV::switchState(UCHAR newState) video->stop(); video->blank(); audio->stop(); - audio->unPause(); audio->reset(); video->reset(); state = newState; @@ -398,8 +480,6 @@ void PlayerLiveTV::switchState(UCHAR newState) void PlayerLiveTV::threadMethod() { - logger->log("PlayerLiveTV", Log::DEBUG, "Thread started"); - while(1) { if (videoStartup) // we are in S_VIDEOSTARTUP, afeed has signalled that it has written some data @@ -448,8 +528,7 @@ void PlayerLiveTV::threadMethod() chunkToDemuxer(); if (state == S_PREBUFFERING) - { - logger->log("PlayerLiveTV", Log::DEBUG, "video startup2 buffering..."); + { if (++videoStartup2Counter == 3) { switchState(S_PLAY); @@ -461,7 +540,6 @@ void PlayerLiveTV::threadMethod() threadWaitForSignal(); // unlocks and waits for signal threadUnlock(); - logger->log("PlayerLiveTV", Log::DEBUG, "Woken"); } logger->log("PlayerLiveTV", Log::DEBUG, "End of thread"); -- 2.39.2