-#/*
+/*
Copyright 2004-2005 Chris Tallon
This file is part of VOMP.
lastRescan = 0;
startTS = 0;
endTS = 0;
+ startup = 1;
threadBuffer = NULL;
if (isRadio)
video->blank();
audio->stop();
- startup = 0;
initted = 1;
return 1;
}
audio->reset();
video->reset();
demuxer.reset();
- startup = 1;
// ------------------------ This one works, but doesn't allow any pre-buffering.
threadStart();
ULLONG PlayerVideo::getPositionTS()
{
+ if (startup) return 0ULL;
long long currentTS = video->getCurrentTimestamp() - startTS;
- if (currentTS < 0) currentTS += 7776000000ULL;
+ if (currentTS < 0) currentTS += 8589934592ULL;
return (ULLONG)currentTS;
}
ULLONG PlayerVideo::getEndTS()
{
long long rendTS = endTS - startTS;
- if (rendTS < 0) rendTS += 7776000000ULL;
+ if (rendTS < 0) rendTS += 8589934592ULL;
return (ULLONG)rendTS;
}
demuxer.setAudioStream(a_stream);
Log::getInstance()->log("Player", Log::DEBUG, "Startup Audio stream chosen %x", a_stream);
- demuxer.findVideoPTS(threadBuffer, thisRead, &startTS);
+ setStartTS(thisRead);
+
if (isRecording) setEndTS();
startup = 0;
}
}
+void PlayerVideo::setStartTS(UINT dataInBuffer)
+{
+ if (isRecording && feedPosition) // (feedPosition != 0)
+ {
+ // FIXME find out how much data need to get to find a TS
+ // Need to get the actual start of the recording
+
+ UINT thisRead;
+ UCHAR* tempBuffer = VDR::getInstance()->getBlock(0, 100000, &thisRead);
+ if (!tempBuffer) return;
+ if (thisRead) demuxer.findVideoPTS(tempBuffer, thisRead, &startTS);
+ free(tempBuffer);
+ }
+ else
+ {
+ demuxer.findVideoPTS(threadBuffer, dataInBuffer, &startTS);
+ }
+}
+
void PlayerVideo::setEndTS()
{
Log::getInstance()->log("Player", Log::DEBUG, "Setting end TS");
player->init();
vdr = VDR::getInstance();
video = Video::getInstance();
+ timers = Timers::getInstance();
videoMode = video->getMode();
myRec = rec;
barRegion.w = video->getScreenWidth();
barRegion.h = 66;
+ clocksRegion.x = barRegion.x + 180;
+ clocksRegion.y = barRegion.y + 12;
+ clocksRegion.w = 200;
+ clocksRegion.h = surface->getFontHeight();
+
barBlue.set(0, 0, 150, 150);
+
+ barShowing = false;
}
VVideoRec::~VVideoRec()
Log::getInstance()->log("VVideoRec", Log::DEBUG, "Post delete player");
Video::getInstance()->setDefaultAspect();
- Timers::getInstance()->cancelTimer(this, 1);
+ timers->cancelTimer(this, 1);
+ timers->cancelTimer(this, 2);
}
void VVideoRec::draw()
case Remote::MENU:
{
Log::getInstance()->log("VVideoRec", Log::DEBUG, "Pre player stop");
+
+ // FIXME work out a better soln for this
+ // Fix a problem to do with thread sync here
+ // because the bar gets a timer every 0.2s and it seems to take up to 0.1s,
+ // (or maybe just the wrong thread being selected?) for the main loop to lock and process
+ // the video stop message it is possible for a bar message to stack up after a stop message
+ // when the bar message is finally processed the prog crashes because this is deleted by then
+ removeBar();
+ //
+
player->stop();
vdr->stopStreaming();
+
Log::getInstance()->log("VVideoRec", Log::DEBUG, "Post player stop");
return 4;
}
void VVideoRec::doBar(int action)
{
+ barShowing = true;
+
rectangle(barRegion, barBlue);
/* Work out what to display - choices:
w.draw();
+ drawBarClocks();
+
+ ViewMan::getInstance()->updateView(this, &barRegion);
+ timers->setTimer(this, 1, (struct timespec){4, 0});
+ timers->setTimer(this, 2, (struct timespec){0, 200000000});
+}
+
+void VVideoRec::timercall(int clientReference)
+{
+ switch(clientReference)
+ {
+ case 1:
+ {
+ // Remove bar
+ removeBar();
+ break;
+ }
+ case 2:
+ {
+ // Update clock
+ if (!barShowing) break;
+ drawBarClocks();
+ ViewMan::getInstance()->updateView(this, &barRegion);
+ timers->setTimer(this, 2, (struct timespec){0, 200000000});
+ break;
+ }
+ }
+}
+
+void VVideoRec::drawBarClocks()
+{
+ Log::getInstance()->log("VVideoRec", Log::DEBUG, "Draw bar clocks");
+
+ rectangle(clocksRegion, barBlue);
+
ULONG currentTS = (player->getPositionTS() / 90000);
int chours = currentTS / 3600;
int cminutes = (currentTS - (chours * 3600)) / 60;
int eseconds = endTS - (ehours * 3600) - (eminutes * 60);
char buffer[100];
- snprintf(buffer, 99, "%01i:%02i:%02i / %01i:%02i:%02i", chours, cminutes, cseconds, ehours, eminutes, eseconds);
+ if ((currentTS > 95441) // it's at the 33bit rollover point where the calc doesn't work because of the 1s diff
+ // between demuxer values and video chip return values ... ?
+ || (!endTS)) // No values yet
+ {
+ strcpy(buffer, "-:--:-- / -:--:--");
+ }
+ else
+ {
+ snprintf(buffer, 99, "%01i:%02i:%02i / %01i:%02i:%02i", chours, cminutes, cseconds, ehours, eminutes, eseconds);
+ }
drawText(buffer, barRegion.x + 180, barRegion.y + 12, Colour::LIGHTTEXT);
-
- ViewMan::getInstance()->updateView(this, &barRegion);
- Timers::getInstance()->setTimer(this, 1, (struct timespec){4, 0});
}
-void VVideoRec::timercall(int clientReference)
+void VVideoRec::removeBar()
{
- switch(clientReference)
- {
- case 1:
- {
- // Remove bar
- rectangle(barRegion, transparent);
- ViewMan::getInstance()->updateView(this, &barRegion);
- break;
- }
- }
+ timers->cancelTimer(this, 2);
+ barShowing = false;
+ rectangle(barRegion, transparent);
+ ViewMan::getInstance()->updateView(this, &barRegion);
}