playing = false;
ffwd = false;
fbwd = false;
- streamLength = 0;
+ lengthBytes = 0;
+ lengthFrames = 0;
feedPosition = 0;
feedMode = MODE_NORMAL;
lastRescan = 0;
feedPosition = position;
}
-void Player::setLength(ULLONG length)
+void Player::setLengthBytes(ULLONG length)
{
lastRescan = time(NULL);
- streamLength = length;
- logger->log("Player", Log::DEBUG, "Player has received length of %llu", streamLength);
+ lengthBytes = length;
+ logger->log("Player", Log::DEBUG, "Player has received length bytes of %llu", lengthBytes);
+}
+
+void Player::setLengthFrames(ULONG length)
+{
+ lengthFrames = length;
+ logger->log("Player", Log::DEBUG, "Player has received length frames of %lu", lengthFrames);
}
ULLONG Player::getEndTS() // used internally (jump to percent)
logger->log("Player", Log::DEBUG, "Setting end TS");
#ifndef NEW_DEMUXER
UINT thisRead;
- UCHAR* tempBuffer = VDR::getInstance()->getBlock((streamLength - 100000), 100000, &thisRead);
+ UCHAR* tempBuffer = VDR::getInstance()->getBlock((lengthBytes - 100000), 100000, &thisRead);
if (!tempBuffer && !VDR::getInstance()->isConnected()) { doConnectionLost(); return; }
if (!tempBuffer) return;
if (thisRead) demuxer->findVideoPTS(tempBuffer, thisRead, &endTS);
free(tempBuffer);
#else //The replacement code relias completely on VDRs timecode and not the pts
endTS=video->frameNumberToTimecode(
- VDR::getInstance()->frameNumberFromPosition((streamLength - 100000)));
+ VDR::getInstance()->frameNumberFromPosition((lengthBytes - 100000)));
#endif
logger->log("Player", Log::DEBUG, "Set end TS");
}
// If we havn't rescanned for a while..
if (isRecording && ((lastRescan + 60) < time(NULL)))
{
- streamLength = vdr->rescanRecording();
+ lengthBytes = vdr->rescanRecording(&lengthFrames);
if (!vdr->isConnected()) { doConnectionLost(); return; }
- logger->log("Player", Log::DEBUG, "Rescanned and reset length: %llu", streamLength);
+ logger->log("Player", Log::DEBUG, "Rescanned and reset length: %llu", lengthBytes);
lastRescan = time(NULL);
setEndTS();
}
- if (streamLength) // is playing a recording
+ if (lengthBytes) // is playing a recording
{
- if (feedPosition >= streamLength) break; // finished playback
+ if (feedPosition >= lengthBytes) break; // finished playback
if (startup)
{
- if (startupBlockSize > streamLength)
- askFor = streamLength; // is a very small recording!
+ if (startupBlockSize > lengthBytes)
+ askFor = lengthBytes; // is a very small recording!
else
askFor = startupBlockSize; // normal, but a startup sized block to detect all the audio streams
}
else
{
- if ((feedPosition + blockSize) > streamLength) // last block of recording
- askFor = streamLength - feedPosition;
+ if ((feedPosition + blockSize) > lengthBytes) // last block of recording
+ askFor = lengthBytes - feedPosition;
else // normal
askFor = blockSize;
}
threadCheckExit();
Message* m = new Message(); // Must be done after this thread finishes, and must break into master mutex
- if (streamLength) m->message = Message::STOP_PLAYBACK; // recording
+ if (lengthBytes) m->message = Message::STOP_PLAYBACK; // recording
else m->message = Message::STREAM_END; // live
logger->log("Player", Log::DEBUG, "Posting message to %p...", commandMessageQueue);
commandMessageQueue->postMessage(m);
return toReturn;
}
-ULLONG VDR::streamRecording(char* fileName)
+ULLONG VDR::streamRecording(char* fileName, ULONG* totalFrames)
{
unsigned long totalLength = 8 + strlen(fileName) + 1;
UCHAR* buffer = new UCHAR[totalLength];
return 0;
}
- ULLONG recordingLength = extractULLONG();
+ ULLONG lengthBytes = extractULLONG();
+ ULONG lengthFrames = extractULONG();
freePacket();
MUTEX_UNLOCK(&mutex);
- Log::getInstance()->log("VDR", Log::DEBUG, "VDR said length is: %llu", recordingLength);
+ Log::getInstance()->log("VDR", Log::DEBUG, "VDR said length is: %llu %lu", lengthBytes, lengthFrames);
- return recordingLength;
+ *totalFrames = lengthFrames;
+ return lengthBytes;
}
-ULLONG VDR::rescanRecording()
+ULLONG VDR::rescanRecording(ULONG* totalFrames)
{
unsigned long totalLength = 8;
UCHAR* buffer = new UCHAR[totalLength];
return 0;
}
- ULLONG recordingLength = extractULLONG();
+ ULLONG lengthBytes = extractULLONG();
+ ULONG lengthFrames = extractULONG();
freePacket();
MUTEX_UNLOCK(&mutex);
- Log::getInstance()->log("VDR", Log::DEBUG, "VDR said length is: %llu", recordingLength);
+ Log::getInstance()->log("VDR", Log::DEBUG, "VDR said length is: %llu %lu", lengthBytes, lengthFrames);
- return recordingLength;
+ *totalFrames = lengthFrames;
+ return lengthBytes;
}
ULLONG VDR::positionFromFrameNumber(ULONG frameNumber)
void VVideoRec::go(ULLONG startPosition)
{
Log::getInstance()->log("VVideoRec", Log::DEBUG, "Starting stream: %s", myRec->getFileName());
- ULLONG recLength = vdr->streamRecording(myRec->getFileName());
- if (recLength)
+ ULONG lengthFrames = 0;
+ ULLONG lengthBytes = vdr->streamRecording(myRec->getFileName(), &lengthFrames);
+ if (lengthBytes)
{
doBar(0);
- player->setLength(recLength);
+ player->setLengthBytes(lengthBytes);
+ player->setLengthFrames(lengthFrames);
player->setPosition(startPosition);
player->play();
playing = true;