From abe5cfebd14e1e4ca95792348b16e9708c7c1370 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sat, 10 Feb 2007 16:59:57 +0000 Subject: [PATCH] New S_JUMP_PI state for cutting marks --- player.cc | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- player.h | 16 +++++----- 2 files changed, 98 insertions(+), 9 deletions(-) diff --git a/player.cc b/player.cc index 8ea268c..447a41e 100644 --- a/player.cc +++ b/player.cc @@ -282,6 +282,14 @@ void Player::jumpToMark(int mark) // unLock(); - let thread unlock this } +void Player::jumpToFrameP(int newFrame) +{ + lock(); + logger->log("Player", Log::DEBUG, "JUMP TO FRAME AND PAUSE %i", newFrame); + switchState(S_JUMP_PI, newFrame); + unLock(); +} + void Player::skipForward(int seconds) { lock(); @@ -379,6 +387,19 @@ void Player::switchState(UCHAR toState, ULONG jumpFrame) restartAtFrame(jumpFrame); return; } + case S_JUMP_PI: // to S_JUMP_PI + { + audio->systemMuteOn(); + threadStop(); + vfeed.stop(); + afeed.stop(); + demuxer->flush(); + state = S_PAUSE_I; + video->reset(); + video->play(); + restartAtFramePI(jumpFrame); + return; + } } } case S_PAUSE_P: // from S_PAUSE_P ----------------------------------- @@ -448,6 +469,20 @@ void Player::switchState(UCHAR toState, ULONG jumpFrame) restartAtFrame(jumpFrame); return; } + case S_JUMP_PI: // to S_JUMP_PI + { + audio->systemMuteOn(); + audio->unPause(); + threadStop(); + vfeed.stop(); + afeed.stop(); + demuxer->flush(); + state = S_PAUSE_I; + video->reset(); + video->play(); + restartAtFramePI(jumpFrame); + return; + } } } case S_PAUSE_I: // from S_PAUSE_I ----------------------------------- @@ -497,6 +532,11 @@ void Player::switchState(UCHAR toState, ULONG jumpFrame) restartAtFrame(jumpFrame); return; } + case S_JUMP_PI: // to S_JUMP_PI + { + restartAtFramePI(jumpFrame); + return; + } } } case S_FFWD: // from S_FFWD ----------------------------------- @@ -548,6 +588,13 @@ void Player::switchState(UCHAR toState, ULONG jumpFrame) restartAtFrame(jumpFrame); return; } + case S_JUMP_PI: // to S_JUMP_PI + { + threadStop(); + state = S_PAUSE_I; + restartAtFramePI(jumpFrame); + return; + } } } case S_FBWD: // from S_FBWD ----------------------------------- @@ -599,6 +646,13 @@ void Player::switchState(UCHAR toState, ULONG jumpFrame) restartAtFrame(jumpFrame); return; } + case S_JUMP_PI: // to S_JUMP_PI + { + threadStop(); + state = S_PAUSE_I; + restartAtFramePI(jumpFrame); + return; + } } } case S_STOP: // from S_STOP ----------------------------------- @@ -666,9 +720,14 @@ void Player::switchState(UCHAR toState, ULONG jumpFrame) { return; } + case S_JUMP_PI: // to S_JUMP_PI + { + return; + } } } - // case S_JUMP cannot be selected as a start state because it auto flips to play + // case S_JUMP cannot be a start state because it auto flips to play + // case S_JUMP_PI cannot be a start state because it auto flips to S_PAUSE_I } } @@ -718,6 +777,33 @@ void Player::restartAtFrame(ULONG newFrame) audio->doMuting(); } + +void Player::restartAtFramePI(ULONG newFrame) +{ + ULLONG filePos; + ULONG nextiframeNumber; + ULONG iframeLength; + ULONG iframeNumber; + + UCHAR* buffer; + UINT amountReceived; + UINT videoLength; + + // newFrame could be anywhere, go forwards to next I-Frame + if (!vdr->getNextIFrame(newFrame, 1, &filePos, &nextiframeNumber, &iframeLength)) return; + + // Now step back a GOP. This ensures we go to the greatest I-Frame equal to or less than the requested frame + vdr->getNextIFrame(nextiframeNumber, 0, &filePos, &iframeNumber, &iframeLength); + + buffer = vdr->getBlock(filePos, iframeLength, &amountReceived); + videoLength = demuxer->stripAudio(buffer, amountReceived); + video->displayIFrame(buffer, videoLength); + video->displayIFrame(buffer, videoLength); // If you do it twice, it works :) + free(threadBuffer); + + currentFrameNumber = iframeNumber; +} + void Player::doConnectionLost() { logger->log("Player", Log::DEBUG, "Connection lost, sending message"); @@ -1182,8 +1268,9 @@ void Player::threadPostStopCleanup() void Player::test1() { logger->log("Player", Log::DEBUG, "PLAYER TEST 1"); - video->play(); +// video->play(); // video->setAspectRatio(Video::ASPECT4X3); + jumpToFrameP(37507); } void Player::test2() diff --git a/player.h b/player.h index 4c884e8..4306cbc 100644 --- a/player.h +++ b/player.h @@ -69,6 +69,7 @@ class Player : public Thread_TYPE, public Callback void skipForward(int seconds); void skipBackward(int seconds); void jumpToMark(int mark); + void jumpToFrameP(int newFrame); UCHAR getState() { return state; } ULONG getCurrentFrameNum(); @@ -87,6 +88,7 @@ class Player : public Thread_TYPE, public Callback const static UCHAR S_FBWD = 5; const static UCHAR S_STOP = 6; const static UCHAR S_JUMP = 7; + const static UCHAR S_JUMP_PI = 8; // Jump to Pause_I mode // Player events @@ -116,6 +118,7 @@ class Player : public Thread_TYPE, public Callback void doConnectionLost(); void restartAtFrame(ULONG newFrame); + void restartAtFramePI(ULONG newFrame); MessageQueue* messageQueue; void* messageReceiver; @@ -169,6 +172,7 @@ Play -> PauseP * * -> FBwd * * -> Stop * * -> Jump * * + -> Jump_PI * * PauseP -> Play * * -> PauseI @@ -176,6 +180,7 @@ PauseP -> Play * * -> FBwd * * -> Stop * * -> Jump * * + -> Jump_PI * * PauseI -> Play * * -> PauseP @@ -183,6 +188,7 @@ PauseI -> Play * * -> FBwd * * -> Stop * * -> Jump * * + -> Jump_PI * * FFwd -> Play * * -> PauseP @@ -190,6 +196,7 @@ FFwd -> Play * * -> FBwd * * -> Stop * * -> Jump * * + -> Jump_PI * * FBwd -> Play * * -> PauseP @@ -197,6 +204,7 @@ FBwd -> Play * * -> FFwd * * -> Stop * * -> Jump * * + -> Jump_PI * * Stop -> Play * * -> PauseP @@ -204,12 +212,6 @@ Stop -> Play * * -> FFwd -> FBwd -> Jump - -Jump -> Play - -> PauseP - -> PauseI - -> FFwd - -> FBwd - -> Stop + -> Jump_PI */ -- 2.39.5