2 Copyright 2004-2005 Chris Tallon
\r
4 This file is part of VOMP.
\r
6 VOMP is free software; you can redistribute it and/or modify
\r
7 it under the terms of the GNU General Public License as published by
\r
8 the Free Software Foundation; either version 2 of the License, or
\r
9 (at your option) any later version.
\r
11 VOMP is distributed in the hope that it will be useful,
\r
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 GNU General Public License for more details.
\r
16 You should have received a copy of the GNU General Public License
\r
17 along with VOMP; if not, write to the Free Software
\r
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
\r
23 #include "vvideorec.h"
\r
24 #include "vteletextview.h"
\r
26 #include "command.h"
\r
28 #include "wsymbol.h"
\r
34 #include "recording.h"
\r
35 #include "vaudioselector.h"
\r
36 #include "message.h"
\r
38 #include "boxstack.h"
\r
42 #include "recinfo.h"
\r
44 #include "channel.h"
\r
46 VVideoRec::VVideoRec(Recording* rec, bool ish264)
\r
48 boxstack = BoxStack::getInstance();
\r
49 vdr = VDR::getInstance();
\r
50 video = Video::getInstance();
\r
51 timers = Timers::getInstance();
\r
55 videoMode = video->getMode();
\r
58 video->seth264mode(ish264);
\r
60 player = new Player(Command::getInstance(), this, this);
\r
61 player->init(myRec->IsPesRecording,myRec->recInfo->fps);
\r
67 char* cstartMargin = vdr->configLoad("Timers", "Start margin");
\r
68 char* cendMargin = vdr->configLoad("Timers", "End margin");
\r
71 startMargin = 300; // 5 mins default
\r
75 startMargin = atoi(cstartMargin) * 60;
\r
76 delete[] cstartMargin;
\r
81 endMargin = 300; // 5 mins default
\r
85 endMargin = atoi(cendMargin) * 60;
\r
86 delete[] cendMargin;
\r
89 Log::getInstance()->log("VVideoRec", Log::DEBUG, "SM: %u EM: %u", startMargin, endMargin);
\r
91 setSize(video->getScreenWidth(), video->getScreenHeight());
\r
93 transparent.set(0, 0, 0, 0);
\r
94 setBackgroundColour(transparent);
\r
97 barRegion.y = video->getScreenHeight() - 58; // FIXME, need to be - 1? and below?
\r
98 barRegion.w = video->getScreenWidth();
\r
101 clocksRegion.x = barRegion.x + 140;
\r
102 clocksRegion.y = barRegion.y + 12;
\r
103 clocksRegion.w = 170;
\r
104 clocksRegion.h = getFontHeight();
\r
105 // barBlue.set(0, 0, 150, 150);
\r
106 barBlue.set(0, 0, 0, 128);
\r
108 barShowing = false;
\r
109 barGenHold = false;
\r
110 barScanHold = false;
\r
111 barVasHold = false;
\r
114 char* optionWSS = vdr->configLoad("General", "WSS");
\r
117 if (strstr(optionWSS, "Yes")) dowss = true;
\r
118 delete[] optionWSS;
\r
120 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Do WSS: %u", dowss);
\r
124 wss.setFormat(video->getFormat());
\r
130 wssRegion.w = video->getScreenWidth();
\r
136 void VVideoRec::preDelete()
\r
138 timers->cancelTimer(this, 1);
\r
139 timers->cancelTimer(this, 2);
\r
143 boxstack->remove(vas);
\r
147 if (vsummary) delete vsummary;
\r
149 if (playing) stopPlay();
\r
152 VVideoRec::~VVideoRec()
\r
154 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Entering vvideorec destructor");
\r
156 video->setDefaultAspect();
\r
158 // kill recInfo in case resumePoint has changed (likely)
\r
159 myRec->dropRecInfo();
\r
160 // FIXME - do this properly - save the resume point back to the server manually and update
\r
161 // rec->recInfo->resumePoint - this will fix the ~10s offset problem as well
\r
164 void VVideoRec::go(bool resume)
\r
166 ULONG startFrameNum;
\r
168 startFrameNum = myRec->recInfo->resumePoint;
\r
172 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Starting stream: %s at frame: %lu", myRec->getFileName(), startFrameNum);
\r
173 ULONG lengthFrames = 0;
\r
174 bool isPesRecording;
\r
175 ULLONG lengthBytes = vdr->streamRecording(myRec->getFileName(), &lengthFrames, &isPesRecording);
\r
176 myRec->IsPesRecording = isPesRecording;
\r
179 player->setLengthBytes(lengthBytes);
\r
180 player->setLengthFrames(lengthFrames);
\r
181 player->setStartFrame(startFrameNum);
\r
188 stopPlay(); // clean up
\r
190 if (!vdr->isConnected())
\r
192 Command::getInstance()->connectionLost();
\r
196 Message* m = new Message();
\r
197 m->message = Message::CLOSE_ME;
\r
200 Command::getInstance()->postMessageNoLock(m);
\r
202 VInfo* vi = new VInfo();
\r
203 vi->setSize(400, 150);
\r
204 vi->createBuffer();
\r
205 if (video->getFormat() == Video::PAL)
\r
206 vi->setPosition(170, 200);
\r
208 vi->setPosition(160, 150);
\r
210 vi->setBorderOn(1);
\r
211 vi->setTitleBarOn(0);
\r
212 vi->setOneLiner(tr("Error playing recording"));
\r
216 m->message = Message::ADD_VIEW;
\r
218 m->parameter = (ULONG)vi;
\r
219 Command::getInstance()->postMessageNoLock(m);
\r
223 int VVideoRec::handleCommand(int command)
\r
235 case Remote::PLAYPAUSE:
\r
237 player->playpause();
\r
253 if (playing) stopPlay();
\r
258 case Remote::PAUSE:
\r
264 case Remote::SKIPFORWARD:
\r
267 player->skipForward(60);
\r
270 case Remote::SKIPBACK:
\r
273 player->skipBackward(60);
\r
277 case Remote::FORWARD:
\r
279 player->fastForward();
\r
284 case Remote::REVERSE:
\r
286 player->fastBackward();
\r
292 if (vsummary) removeSummary();
\r
296 case Remote::GREEN:
\r
301 case Remote::YELLOW:
\r
303 if (myRec->hasMarks())
\r
305 // skip to previous mark
\r
306 Log* logger = Log::getInstance();
\r
307 int currentFrame = (player->getCurrentFrameNum()); // get current Frame
\r
308 currentFrame -= 5. * myRec->recInfo->fps; // subtrack 5 seconds, else you cannot skip more than once back ..
\r
310 int prevMark = myRec->getPrevMark(currentFrame); // find previous Frame
\r
313 logger->log("VVideoRec", Log::NOTICE, "jump back from pos %i to mark at %i",currentFrame,prevMark);
\r
314 player->jumpToMark(prevMark);
\r
321 player->skipBackward(10);
\r
327 if (myRec->hasMarks())
\r
329 // skip to next mark
\r
330 Log* logger = Log::getInstance();
\r
331 int currentFrame = (player->getCurrentFrameNum());
\r
333 int nextMark = myRec->getNextMark(currentFrame);
\r
337 logger->log("VVideoRec", Log::NOTICE, "jump forward from pos %i to mark at %i",currentFrame,nextMark);
\r
338 player->jumpToMark(nextMark);
\r
345 player->skipForward(10);
\r
352 player->skipBackward(10);
\r
358 player->skipForward(10);
\r
376 if (barShowing) removeBar();
\r
381 case Remote::ZERO: player->jumpToPercent(0); doBar(0); return 2;
\r
382 case Remote::ONE: player->jumpToPercent(10); doBar(0); return 2;
\r
383 case Remote::TWO: player->jumpToPercent(20); doBar(0); return 2;
\r
384 case Remote::THREE: player->jumpToPercent(30); doBar(0); return 2;
\r
385 case Remote::FOUR: player->jumpToPercent(40); doBar(0); return 2;
\r
386 case Remote::FIVE: player->jumpToPercent(50); doBar(0); return 2;
\r
387 case Remote::SIX: player->jumpToPercent(60); doBar(0); return 2;
\r
388 case Remote::SEVEN: player->jumpToPercent(70); doBar(0); return 2;
\r
389 case Remote::EIGHT: player->jumpToPercent(80); doBar(0); return 2;
\r
390 case Remote::NINE: player->jumpToPercent(90); doBar(0); return 2;
\r
392 case Remote::RECORD: player->toggleSubtitles(); return 2;
\r
394 // case Remote::RED:
\r
396 //Don't use RED for anything. It will eventually be recording summary
\r
402 // for testing EPG in NTSC with a NTSC test video
\r
403 Video::getInstance()->setMode(Video::QUARTER);
\r
404 Video::getInstance()->setPosition(170, 5);
\r
405 VEpg* vepg = new VEpg(NULL, 0);
\r
407 BoxStack::getInstance()->add(vepg);
\r
408 BoxStack::getInstance()->update(vepg);
\r
421 void VVideoRec::doTeletext()
\r
427 // Draw the teletxt
\r
428 VTeletextView *vtxv=player->getTeletextDecoder()->getTeletxtView();
\r
430 vtxv= new VTeletextView((player)->getTeletextDecoder(),this);
\r
431 (player)->getTeletextDecoder()->registerTeletextView(vtxv);
\r
434 vtxv->setSubtitleMode(true);
\r
439 BoxStack::getInstance()->add(vtxv);
\r
441 BoxStack::getInstance()->update(this);
\r
442 BoxStack::getInstance()->update(vtxv);
\r
445 void VVideoRec::processMessage(Message* m)
\r
447 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Message received");
\r
449 if (m->message == Message::MOUSE_LBDOWN)
\r
451 UINT x = (m->parameter>>16) - getScreenX();
\r
452 UINT y = (m->parameter&0xFFFF) - getScreenY();
\r
456 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate rok press
\r
458 else if (barRegion.x<=x && barRegion.y<=y && (barRegion.x+barRegion.w)>=x && (barRegion.y+barRegion.h)>=y)
\r
460 int progBarXbase = barRegion.x + 300;
\r
461 if (myRec->hasMarks())
\r
463 MarkList* markList = myRec->getMarkList();
\r
464 MarkList::iterator i;
\r
465 Mark* loopMark = NULL;
\r
467 ULONG lengthFrames;
\r
468 if (myRec->recInfo->timerEnd > time(NULL))
\r
470 // chasing playback
\r
471 // Work out an approximate length in frames (good to 1s...)
\r
472 lengthFrames = (ULONG)((double)(myRec->recInfo->timerEnd - myRec->recInfo->timerStart) * myRec->recInfo->fps);
\r
476 lengthFrames = player->getLengthFrames();
\r
478 for(i = markList->begin(); i != markList->end(); i++)
\r
483 posPix = 302 * loopMark->pos / lengthFrames;
\r
484 rectangle(barRegion.x + progBarXbase + 2 + posPix, barRegion.y + 12 - 2, 3, 28, DrawStyle::DANGER);
\r
485 if (x>=barRegion.x + progBarXbase + 2 + posPix
\r
486 && x<=barRegion.x + progBarXbase + 2 + posPix+3
\r
487 && y>=barRegion.y + 12 - 2
\r
488 && y<=barRegion.y + 12 - 2+28)
\r
490 player->jumpToMark(loopMark->pos);
\r
498 if (x>=barRegion.x + progBarXbase + 24
\r
499 && x<=barRegion.x + progBarXbase + 4 + 302
\r
500 && y>=barRegion.y + 12 - 2
\r
501 && y<=barRegion.y + 12 - 2+28)
\r
503 int cx=x-(barRegion.x + progBarXbase + 4);
\r
504 double percent=((double)cx)/302.*100.;
\r
505 player->jumpToPercent(percent);
\r
508 // int progressWidth = 302 * currentFrameNum / lengthFrames;
\r
509 // rectangle(barRegion.x + progBarXbase + 4, barRegion.y + 16, progressWidth, 16, DrawStyle::SELECTHIGHLIGHT);
\r
514 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate rok press
\r
517 else if (m->from == player)
\r
519 if (m->message != Message::PLAYER_EVENT) return;
\r
520 switch(m->parameter)
\r
522 case Player::CONNECTION_LOST: // connection lost detected
\r
524 // I can't handle this, send it to command
\r
525 Message* m2 = new Message();
\r
526 m2->to = Command::getInstance();
\r
527 m2->message = Message::CONNECTION_LOST;
\r
528 Command::getInstance()->postMessageNoLock(m2);
\r
531 case Player::STOP_PLAYBACK:
\r
533 // FIXME Obselete ish - improve this
\r
534 Message* m2 = new Message(); // Must be done after this thread finishes, and must break into master mutex
\r
535 m2->to = Command::getInstance();
\r
536 m2->message = Message::STOP_PLAYBACK;
\r
537 Command::getInstance()->postMessageNoLock(m2);
\r
540 case Player::ASPECT43:
\r
545 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 43");
\r
546 wss.setWide(false);
\r
548 boxstack->update(this, &wssRegion);
\r
553 case Player::ASPECT169:
\r
558 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 169");
\r
561 boxstack->update(this, &wssRegion);
\r
568 else if (m->message == Message::AUDIO_CHANGE_CHANNEL)
\r
570 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received change audio channel to %i", m->parameter);
\r
571 player->setAudioChannel(m->parameter&0xFFFF,(m->parameter&0xFF0000)>> 16,(m->parameter&0xFF000000)>> 24 );
\r
573 else if (m->message == Message::SUBTITLE_CHANGE_CHANNEL)
\r
575 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received change subtitle channel to %i", m->parameter);
\r
576 int type=((m->parameter & 0xFF0000)>>16);
\r
578 case 0x10: { //dvbsubtitle
\r
579 player->setSubtitleChannel((m->parameter & 0xFFFF));
\r
580 player->turnSubtitlesOn(true);
\r
581 VTeletextView *vtxt=((Player*)player)->getTeletextDecoder()->getTeletxtView();
\r
582 if (vtxt && vtxt->isInSubtitleMode()) {
\r
583 BoxStack::getInstance()->remove(vtxt);
\r
586 case 0xFF: { //nosubtitles
\r
588 player->turnSubtitlesOn(false);
\r
589 VTeletextView *vtxt=((Player*)player)->getTeletextDecoder()->getTeletxtView();
\r
590 if (vtxt && vtxt->isInSubtitleMode()) {
\r
591 BoxStack::getInstance()->remove(vtxt);
\r
595 case 0x11: { //videotext
\r
596 player->turnSubtitlesOn(false);
\r
598 ((Player*)player)->getTeletextDecoder()->setPage((m->parameter & 0xFFFF));
\r
602 BoxStack::getInstance()->update(vas);
\r
604 BoxStack::getInstance()->update(this);
\r
608 else if (m->message == Message::CHILD_CLOSE)
\r
610 if (m->from == vas)
\r
613 barVasHold = false;
\r
614 if (!barGenHold && !barScanHold && !barVasHold) removeBar();
\r
619 void VVideoRec::stopPlay()
\r
621 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Pre stopPlay");
\r
624 Log::getInstance()->log("VVideoRec", Log::DEBUG, "1");
\r
626 Log::getInstance()->log("VVideoRec", Log::DEBUG, "2");
\r
627 vdr->stopStreaming();
\r
628 Log::getInstance()->log("VVideoRec", Log::DEBUG, "3");
\r
633 if (!vdr->isConnected()) { Command::getInstance()->connectionLost(); return; }
\r
634 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Post stopPlay");
\r
637 void VVideoRec::toggleChopSides()
\r
639 if (video->getTVsize() == Video::ASPECT16X9) return; // Means nothing for 16:9 TVs
\r
641 if (videoMode == Video::NORMAL)
\r
643 videoMode = Video::LETTERBOX;
\r
644 video->setMode(Video::LETTERBOX);
\r
648 videoMode = Video::NORMAL;
\r
649 video->setMode(Video::NORMAL);
\r
653 void VVideoRec::doAudioSelector()
\r
655 int subtitleChannel=player->getCurrentSubtitleChannel();
\r
656 int subtitleType=0x10;
\r
657 if (!(player)->isSubtitlesOn()) {
\r
658 if ((player)->getTeletextDecoder()->getTeletxtView() &&
\r
659 (player)->getTeletextDecoder()->getTeletxtView()->isInSubtitleMode()
\r
661 subtitleChannel=(player)->getTeletextDecoder()->getPage();
\r
665 subtitleType=0xFF; //turnedOff
\r
669 if (player->isPesRecording()) {
\r
670 bool* availableMpegAudioChannels = player->getDemuxerMpegAudioChannels();
\r
671 bool* availableAc3AudioChannels = NULL;
\r
672 bool* availableSubtitleChannels = player->getDemuxerSubtitleChannels();
\r
673 int *availableTTxtpages = player->getTeletxtSubtitlePages();
\r
674 int currentAudioChannel = player->getCurrentAudioChannel();
\r
675 if (Audio::getInstance()->supportsAc3())
\r
677 availableAc3AudioChannels = player->getDemuxerAc3AudioChannels();
\r
680 vas = new VAudioSelector(this, availableMpegAudioChannels, availableAc3AudioChannels, currentAudioChannel,availableSubtitleChannels, availableTTxtpages,
\r
681 subtitleChannel, subtitleType, myRec->recInfo);
\r
683 // Draw the selector
\r
684 Channel *temp_channel=player->getDemuxerChannel();
\r
685 // RecInfo *cur_info= myRec->recInfo;
\r
686 /* unsigned char numchan_recinfo = cur_info->numComponents;
\r
687 unsigned char numchan_subtitles_siz = temp_channel.numSPids;
\r
688 ULONG mp_audcounter = 0;
\r
689 ULONG ac3_counter = 0;
\r
690 int dvb_subcounter = 1;*/
\r
693 /*unsigned char type;
\r
696 for (i = 0; i < numchan_recinfo; i++)
\r
699 type = cur_info->types[i];
\r
700 lang = cur_info->languages[i];
\r
701 description = cur_info->descriptions[i];
\r
704 if (cur_info->streams[i] == 2) {
\r
707 case 1: //mpaudio mono
\r
708 case 3: //mpaudio stereo
\r
709 if (mp_audcounter < temp_channel.numAPids) ac = &temp_channel.apids[mp_audcounter];
\r
714 if (ac3_counter < temp_channel.numDPids) ac = &temp_channel.dpids[ac3_counter];
\r
718 } else if (cur_info->streams[i] == 3){
\r
719 if (dvb_subcounter < numchan_subtitles_siz) ac = &temp_channel.spids[dvb_subcounter];
\r
720 } else continue; //neither audio nor subtitle
\r
723 if (description && (strlen(description) > 0))
\r
725 ac->name = new char[strlen(description) + 1];
\r
726 strcpy(ac->name, description);
\r
728 } else if (lang && strlen(lang) > 0)
\r
730 ac->name = new char[strlen(lang) + 1];
\r
731 strcpy(ac->name, lang);
\r
736 for (i=0;i<temp_channel->numAPids;i++) {
\r
737 apid *ac=&temp_channel->apids[i];
\r
738 if (ac->desc[0]==0) {
\r
739 strncpy(ac->desc, tr("unknown"),9);
\r
742 for (i=0;i<temp_channel->numDPids;i++) {
\r
743 apid *ac=&temp_channel->dpids[i];
\r
744 if (ac->desc[0]==0) {
\r
745 strncpy(ac->desc, tr("unknown"),9);
\r
748 for (i=0;i<temp_channel->numSPids;i++) {
\r
749 apid *ac=&temp_channel->spids[i];
\r
750 if (ac->desc[0]==0) {
\r
751 strncpy(ac->desc, tr("unknown"),9);
\r
755 vas = new VAudioSelector(this,temp_channel , (player)->getCurrentAudioChannel(),
\r
756 subtitleType,subtitleChannel,player->getTeletxtSubtitlePages());
\r
757 /* for (i=0;i<temp_channel.numAPids;i++) {
\r
758 apid *ac=&temp_channel.apids[i];
\r
762 for (i=0;i<temp_channel.numDPids;i++) {
\r
763 apid *ac=&temp_channel.dpids[i];
\r
767 for (i=0;i<temp_channel.numSPids;i++) {
\r
768 apid *ac=&temp_channel.spids[i];
\r
775 vas->setBackgroundColour(barBlue);
\r
776 vas->setPosition(0, barRegion.y - 120);
\r
784 boxstack->add(vas);
\r
785 boxstack->update(vas);
\r
788 void VVideoRec::doBar(int action)
\r
792 rectangle(barRegion, barBlue);
\r
794 /* Work out what to display - choices:
\r
801 Specials, informed by parameter
\r
803 Skip forward 10s >|
\r
804 Skip backward 10s |<
\r
805 Skip forward 1m >>|
\r
806 Skip backward 1m |<<
\r
813 w.setPosition(barRegion.x + 66, barRegion.y + 16);
\r
815 UCHAR playerState = 0;
\r
819 if (action == 1) w.nextSymbol = WSymbol::SKIPFORWARD;
\r
820 else if (action == 2) w.nextSymbol = WSymbol::SKIPBACK;
\r
821 else if (action == 3) w.nextSymbol = WSymbol::SKIPFORWARD2;
\r
822 else if (action == 4) w.nextSymbol = WSymbol::SKIPBACK2;
\r
826 playerState = player->getState();
\r
827 if (playerState == Player::S_PAUSE_P) w.nextSymbol = WSymbol::PAUSE;
\r
828 else if (playerState == Player::S_PAUSE_I) w.nextSymbol = WSymbol::PAUSE;
\r
829 else if (playerState == Player::S_FFWD) w.nextSymbol = WSymbol::FFWD;
\r
830 else if (playerState == Player::S_FBWD) w.nextSymbol = WSymbol::FBWD;
\r
831 else w.nextSymbol = WSymbol::PLAY;
\r
836 if ((playerState == Player::S_FFWD) || (playerState == Player::S_FBWD))
\r
838 // draw blips to show how fast the scan is
\r
839 UCHAR scanrate = player->getIScanRate();
\r
843 SNPRINTF(text, 5, "%ux", scanrate);
\r
844 drawText(text, barRegion.x + 102, barRegion.y + 12, DrawStyle::LIGHTTEXT);
\r
850 boxstack->update(this, &barRegion);
\r
852 timers->cancelTimer(this, 1);
\r
855 if ((playerState == Player::S_FFWD) || (playerState == Player::S_FBWD)) barScanHold = true;
\r
856 else barScanHold = false;
\r
858 if (!barGenHold && !barScanHold && !barVasHold) timers->setTimerD(this, 1, 4);
\r
860 timers->setTimerD(this, 2, 0, 200000000);
\r
863 void VVideoRec::timercall(int clientReference)
\r
865 switch(clientReference)
\r
876 if (!barShowing) break;
\r
878 boxstack->update(this, &barRegion);
\r
880 timers->setTimerD(this, 2, 0, 200000000);
\r
886 hmsf VVideoRec::framesToHMSF(ULONG frames)
\r
891 double fps=myRec->recInfo->fps;
\r
892 ret.frames= int(modf((frames + 0.5) / fps, &Seconds) * fps + 1);
\r
893 int s = int(Seconds);
\r
894 ret.seconds=s % 60;
\r
895 ret.minutes = s / 60 % 60;
\r
896 ret.hours = s / 3600;
\r
902 void VVideoRec::drawBarClocks()
\r
906 UCHAR playerState = player->getState();
\r
907 // sticky bar is set if we are in ffwd/fbwd mode
\r
908 // if player has gone to S_PLAY then kill stickyBar, and run doBar(0) which
\r
909 // will repaint all the bar (it will call this function again, but
\r
910 // this section won't run because stickyBarF will then == false)
\r
912 if ((playerState != Player::S_FFWD) && (playerState != Player::S_FBWD))
\r
914 barScanHold = false;
\r
916 return; // doBar will call this function and do the rest
\r
920 Log* logger = Log::getInstance();
\r
921 logger->log("VVideoRec", Log::DEBUG, "Draw bar clocks");
\r
924 // Blank the area first
\r
925 rectangle(barRegion.x + 624, barRegion.y + 12, 60, 30, barBlue);
\r
926 char timeString[20];
\r
929 struct tm* tms = localtime(&t);
\r
930 strftime(timeString, 19, "%H:%M", tms);
\r
931 drawText(timeString, barRegion.x + 624, barRegion.y + 12, DrawStyle::LIGHTTEXT);
\r
935 rectangle(clocksRegion, barBlue);
\r
937 ULONG currentFrameNum = player->getCurrentFrameNum();
\r
938 ULONG lengthFrames;
\r
939 if (myRec->recInfo->timerEnd > time(NULL))
\r
941 // chasing playback
\r
942 // Work out an approximate length in frames (good to 1s...)
\r
943 lengthFrames =(ULONG) ((double)(myRec->recInfo->timerEnd - myRec->recInfo->timerStart) * myRec->recInfo->fps);
\r
947 lengthFrames = player->getLengthFrames();
\r
950 hmsf currentFrameHMSF = framesToHMSF(currentFrameNum);
\r
951 hmsf lengthHMSF = framesToHMSF(lengthFrames);
\r
954 if (currentFrameNum >= lengthFrames)
\r
956 strcpy(buffer, "-:--:-- / -:--:--");
\r
960 SNPRINTF(buffer, 99, "%01i:%02i:%02i / %01i:%02i:%02i", currentFrameHMSF.hours, currentFrameHMSF.minutes, currentFrameHMSF.seconds, lengthHMSF.hours, lengthHMSF.minutes, lengthHMSF.seconds);
\r
961 logger->log("VVideoRec", Log::DEBUG, buffer);
\r
964 drawText(buffer, clocksRegion.x, clocksRegion.y, DrawStyle::LIGHTTEXT);
\r
972 // Draw progress bar
\r
973 int progBarXbase = barRegion.x + 300;
\r
975 rectangle(barRegion.x + progBarXbase, barRegion.y + 12, 310, 24, DrawStyle::LIGHTTEXT);
\r
976 rectangle(barRegion.x + progBarXbase + 2, barRegion.y + 14, 306, 20, barBlue);
\r
978 if (currentFrameNum > lengthFrames) return;
\r
979 if (lengthFrames == 0) return;
\r
981 // Draw yellow portion
\r
982 int progressWidth = 302 * currentFrameNum / lengthFrames;
\r
983 rectangle(barRegion.x + progBarXbase + 4, barRegion.y + 16, progressWidth, 16, DrawStyle::SELECTHIGHLIGHT);
\r
985 if (myRec->recInfo->timerEnd > time(NULL)) // if chasing
\r
987 int nrWidth = (int)(302 * ((double)(lengthFrames - player->getLengthFrames()) / lengthFrames));
\r
989 Log::getInstance()->log("GVASDF", Log::DEBUG, "Length Frames: %lu", lengthFrames);
\r
990 Log::getInstance()->log("GVASDF", Log::DEBUG, "Player lf: %lu", player->getLengthFrames());
\r
991 Log::getInstance()->log("GVASDF", Log::DEBUG, "NR WDITH: %i", nrWidth);
\r
992 rectangle(barRegion.x + progBarXbase + 4 + 302 - nrWidth, barRegion.y + 16, nrWidth, 16, DrawStyle::RED);
\r
996 // Now calc position for blips
\r
998 if (myRec->hasMarks())
\r
1000 // Draw blips where there are cut marks
\r
1001 MarkList* markList = myRec->getMarkList();
\r
1002 MarkList::iterator i;
\r
1003 Mark* loopMark = NULL;
\r
1005 for(i = markList->begin(); i != markList->end(); i++)
\r
1008 if (loopMark->pos)
\r
1010 logger->log("VVideoRec", Log::DEBUG, "Drawing mark at frame %i", loopMark->pos);
\r
1011 posPix = 302 * loopMark->pos / lengthFrames;
\r
1012 rectangle(barRegion.x + progBarXbase + 2 + posPix, barRegion.y + 12 - 2, 3, 28, DrawStyle::DANGER);
\r
1018 // Draw blips where start and end margins probably are
\r
1020 posPix =(int) (302. * myRec->recInfo->fps * ((double)startMargin) /((double) lengthFrames));
\r
1022 rectangle(barRegion.x + progBarXbase + 2 + posPix, barRegion.y + 12 - 2, 2, 2, DrawStyle::LIGHTTEXT);
\r
1023 rectangle(barRegion.x + progBarXbase + 2 + posPix, barRegion.y + 12 + 24, 2, 2, DrawStyle::LIGHTTEXT);
\r
1025 posPix = (int)(302. * ((double)lengthFrames - ((double)endMargin) * myRec->recInfo->fps) / ((double)lengthFrames));
\r
1027 rectangle(barRegion.x + progBarXbase + 2 + posPix, barRegion.y + 12 - 2, 2, 2, DrawStyle::LIGHTTEXT);
\r
1028 rectangle(barRegion.x + progBarXbase + 2 + posPix, barRegion.y + 12 + 24, 2, 2, DrawStyle::LIGHTTEXT);
\r
1032 void VVideoRec::removeBar()
\r
1034 if (!barShowing) return;
\r
1035 timers->cancelTimer(this, 2);
\r
1036 barShowing = false;
\r
1037 barGenHold = false;
\r
1038 barScanHold = false;
\r
1039 barVasHold = false;
\r
1040 rectangle(barRegion, transparent);
\r
1041 boxstack->update(this, &barRegion);
\r
1044 void VVideoRec::doSummary()
\r
1046 vsummary = new VInfo();
\r
1047 vsummary->setTitleText(myRec->getProgName());
\r
1048 vsummary->setBorderOn(1);
\r
1049 vsummary->setExitable();
\r
1050 if (myRec->recInfo->summary) vsummary->setMainText(myRec->recInfo->summary);
\r
1051 else vsummary->setMainText(tr("Summary unavailable"));
\r
1052 if (Video::getInstance()->getFormat() == Video::PAL)
\r
1054 vsummary->setPosition(120, 130);
\r
1058 vsummary->setPosition(110, 90);
\r
1060 vsummary->setSize(510, 270);
\r
1064 BoxStack::getInstance()->update(this);
\r
1067 void VVideoRec::removeSummary()
\r
1075 BoxStack::getInstance()->update(this);
\r
1079 void VVideoRec::drawOSDBitmap(UINT posX, UINT posY, const Bitmap& bm, const DisplayRegion& region)
\r
1081 drawBitmap(posX, posY, bm, region);
\r
1083 r.x = posX; r.y = posY; r.w = bm.getWidth(); r.h = bm.getHeight();
\r
1084 boxstack->update(this, &r);
\r
1087 void VVideoRec::clearOSD()
\r
1089 rectangle(area, transparent);
\r
1090 boxstack->update(this, &area);
\r
1093 void VVideoRec::clearOSDArea(UINT posX, UINT posY, UINT width, UINT height, const DisplayRegion& region)
\r
1096 r.x = posX+region.windowx; r.y = posY+region.windowy; r.w = width; r.h = height;
\r
1097 //now convert to our display
\r
1098 float scalex=720.f/((float) (region.framewidth+1));
\r
1099 float scaley=576.f/((float) (region.frameheight+1));
\r
1100 r.x=floor(scalex*((float)r.x));
\r
1101 r.y=floor(scaley*((float)r.y));
\r
1102 r.w=ceil(scalex*((float)r.w));
\r
1103 r.h=ceil(scaley*((float)r.h));
\r
1105 rectangle(r, transparent);
\r
1106 boxstack->update(this, &r);
\r