]> git.vomp.tv Git - vompclient.git/blob - vvideorec.cc
Sleep timer
[vompclient.git] / vvideorec.cc
1 /*
2     Copyright 2004-2005 Chris Tallon
3
4     This file is part of VOMP.
5
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP; if not, write to the Free Software
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20
21 #include "vvideorec.h"
22
23 #include "command.h"
24 #include "osd.h"
25 #include "wsymbol.h"
26 #include "audio.h"
27 #include "vdr.h"
28 #include "video.h"
29 #include "timers.h"
30 #include "player.h"
31 #include "recording.h"
32 #include "vaudioselector.h"
33 #include "message.h"
34 #include "remote.h"
35 #include "boxstack.h"
36 #include "vinfo.h"
37 #include "i18n.h"
38
39 VVideoRec::VVideoRec(Recording* rec)
40 {
41   boxstack = BoxStack::getInstance();
42   vdr = VDR::getInstance();
43   video = Video::getInstance();
44   timers = Timers::getInstance();
45   vas = NULL;
46   vsummary = NULL;
47
48   player = new Player(Command::getInstance(), this);
49   player->init();
50
51   videoMode = video->getMode();
52   myRec = rec;
53
54   playing = false;
55
56   startMargin = 0;
57   endMargin = 0;
58   char* cstartMargin = vdr->configLoad("Timers", "Start margin");
59   char* cendMargin = vdr->configLoad("Timers", "End margin");
60   if (!cstartMargin)
61   {
62     startMargin = 300; // 5 mins default
63   }
64   else
65   {
66     startMargin = atoi(cstartMargin) * 60;
67     delete[] cstartMargin;
68   }
69
70   if (!cendMargin)
71   {
72     endMargin = 300; // 5 mins default
73   }
74   else
75   {
76     endMargin = atoi(cendMargin) * 60;
77     delete[] cendMargin;
78   }
79
80   Log::getInstance()->log("VVideoRec", Log::DEBUG, "SM: %u EM: %u", startMargin, endMargin);
81
82   setSize(video->getScreenWidth(), video->getScreenHeight());
83   createBuffer();
84   transparent.set(0, 0, 0, 0);
85   setBackgroundColour(transparent);
86
87   barRegion.x = 0;
88   barRegion.y = video->getScreenHeight() - 58;   // FIXME, need to be - 1? and below?
89   barRegion.w = video->getScreenWidth();
90   barRegion.h = 58;
91
92   clocksRegion.x = barRegion.x + 140;
93   clocksRegion.y = barRegion.y + 12;
94   clocksRegion.w = 170;
95   clocksRegion.h = surface->getFontHeight();
96
97
98 //  barBlue.set(0, 0, 150, 150);
99   barBlue.set(0, 0, 0, 128);
100
101   barShowing = false;
102   barGenHold = false;
103   barScanHold = false;
104   barVasHold = false;
105
106   dowss = false;
107   char* optionWSS = vdr->configLoad("General", "WSS");
108   if (optionWSS)
109   {
110     if (strstr(optionWSS, "Yes")) dowss = true;
111     delete[] optionWSS;
112   }
113   Log::getInstance()->log("VVideoRec", Log::DEBUG, "Do WSS: %u", dowss);
114
115   if (dowss)
116   {
117     wss.setFormat(video->getFormat());
118     wss.setWide(true);
119     add(&wss);
120
121     wssRegion.x = 0;
122     wssRegion.y = 0;
123     wssRegion.w = video->getScreenWidth();
124     wssRegion.h = 300;
125   }
126 }
127
128 void VVideoRec::preDelete()
129 {
130   timers->cancelTimer(this, 1);
131   timers->cancelTimer(this, 2);
132
133   if (vas)
134   {
135     boxstack->remove(vas);
136     vas = NULL;
137   }
138
139   if (vsummary) delete vsummary;
140
141   if (playing) stopPlay();
142 }
143
144 VVideoRec::~VVideoRec()
145 {
146   Log::getInstance()->log("VVideoRec", Log::DEBUG, "Entering vvideorec destructor");
147
148   video->setDefaultAspect();
149
150   // kill recInfo in case resumePoint has changed (likely)
151   myRec->dropRecInfo();
152   // FIXME - do this properly - save the resume point back to the server manually and update
153   // rec->recInfo->resumePoint - this will fix the ~10s offset problem as well
154 }
155
156 void VVideoRec::go(bool resume)
157 {
158   ULONG startFrameNum;
159   if (resume)
160     startFrameNum = myRec->recInfo->resumePoint;
161   else
162     startFrameNum = 0;
163
164   Log::getInstance()->log("VVideoRec", Log::DEBUG, "Starting stream: %s at frame: %lu", myRec->getFileName(), startFrameNum);
165   ULONG lengthFrames = 0;
166   ULLONG lengthBytes = vdr->streamRecording(myRec->getFileName(), &lengthFrames);
167   if (lengthBytes)
168   {
169     player->setLengthBytes(lengthBytes);
170     player->setLengthFrames(lengthFrames);
171     player->setStartFrame(startFrameNum);
172     player->play();
173     playing = true;
174     doBar(0);
175   }
176   else
177   {
178     stopPlay(); // clean up
179
180     if (!vdr->isConnected())
181     {
182       Command::getInstance()->connectionLost();
183       return;
184     }
185
186     Message* m = new Message();
187     m->message = Message::CLOSE_ME;
188     m->from = this;
189     m->to = boxstack;
190     Command::getInstance()->postMessageNoLock(m);
191
192     VInfo* vi = new VInfo();
193     vi->setSize(400, 150);
194     vi->createBuffer();
195     if (video->getFormat() == Video::PAL)
196       vi->setPosition(170, 200);
197     else
198       vi->setPosition(160, 150);
199     vi->setExitable();
200     vi->setBorderOn(1);
201     vi->setTitleBarOn(0);
202     vi->setOneLiner(tr("Error playing recording"));
203     vi->draw();
204
205     m = new Message();
206     m->message = Message::ADD_VIEW;
207     m->to = boxstack;
208     m->parameter = (ULONG)vi;
209     Command::getInstance()->postMessageNoLock(m);
210   }
211 }
212
213 int VVideoRec::handleCommand(int command)
214 {
215   switch(command)
216   {
217     case Remote::PLAY:
218     {
219       player->play();
220       doBar(0);
221       return 2;
222     }
223
224     case Remote::BACK:
225     {
226       if (vsummary)
227       {
228         removeSummary();
229         return 2;
230       }
231     } // DROP THROUGH
232     case Remote::STOP:
233     case Remote::MENU:
234     {
235       if (playing) stopPlay();
236
237       return 4;
238     }
239     case Remote::PAUSE:
240     {
241       player->pause();
242       doBar(0);
243       return 2;
244     }
245     case Remote::SKIPFORWARD:
246     {
247       doBar(3);
248       player->skipForward(60);
249       return 2;
250     }
251     case Remote::SKIPBACK:
252     {
253       doBar(4);
254       player->skipBackward(60);
255       return 2;
256     }
257     case Remote::FORWARD:
258     {
259       player->fastForward();
260       doBar(0);
261       return 2;
262     }
263     case Remote::REVERSE:
264     {
265       player->fastBackward();
266       doBar(0);
267       return 2;
268     }
269     case Remote::RED:
270     {
271       if (vsummary) removeSummary();
272       else doSummary();
273       return 2;
274     }
275     case Remote::GREEN:
276     {
277       doAudioSelector();
278       return 2;
279     }
280     case Remote::YELLOW:
281     {
282       if (myRec->hasMarks())
283       {
284         // skip to previous mark
285         Log* logger = Log::getInstance();
286         int currentFrame = (player->getCurrentFrameNum()); // get current Frame
287         currentFrame -= 5 * video->getFPS(); // subtrack 5 seconds, else you cannot skip more than once back ..
288
289         int prevMark = myRec->getPrevMark(currentFrame); // find previous Frame
290         if (prevMark)
291         {
292           logger->log("VVideoRec", Log::NOTICE, "jump back from pos %i to mark at %i",currentFrame,prevMark);
293           player->jumpToMark(prevMark);
294         }
295         doBar(4);
296       }
297       else
298       {
299         doBar(2);
300         player->skipBackward(10);
301       }
302       return 2;
303     }
304     case Remote::BLUE:
305     {
306       if (myRec->hasMarks())
307       {
308         // skip to next mark
309         Log* logger = Log::getInstance();
310         int currentFrame = (player->getCurrentFrameNum());
311
312         int nextMark = myRec->getNextMark(currentFrame);
313
314         if (nextMark)
315         {
316           logger->log("VVideoRec", Log::NOTICE, "jump forward from pos %i to mark at %i",currentFrame,nextMark);
317           player->jumpToMark(nextMark);
318         }
319         doBar(3);
320       }
321       else
322       {
323         doBar(1);
324         player->skipForward(10);
325       }
326       return 2;
327     }
328     case Remote::STAR:
329     {
330       doBar(2);
331       player->skipBackward(10);
332       return 2;
333     }
334     case Remote::HASH:
335     {
336       doBar(1);
337       player->skipForward(10);
338       return 2;
339     }
340     case Remote::FULL:
341     case Remote::TV:
342     {
343       toggleChopSides();
344       return 2;
345     }
346
347     case Remote::OK:
348     {
349       if (vsummary)
350       {
351         removeSummary();
352         return 2;
353       }
354       
355       if (barShowing) removeBar();
356       else doBar(0);
357       return 2;
358     }
359
360     case Remote::ZERO:  player->jumpToPercent(0);  doBar(0);  return 2;
361     case Remote::ONE:   player->jumpToPercent(10); doBar(0);  return 2;
362     case Remote::TWO:   player->jumpToPercent(20); doBar(0);  return 2;
363     case Remote::THREE: player->jumpToPercent(30); doBar(0);  return 2;
364     case Remote::FOUR:  player->jumpToPercent(40); doBar(0);  return 2;
365     case Remote::FIVE:  player->jumpToPercent(50); doBar(0);  return 2;
366     case Remote::SIX:   player->jumpToPercent(60); doBar(0);  return 2;
367     case Remote::SEVEN: player->jumpToPercent(70); doBar(0);  return 2;
368     case Remote::EIGHT: player->jumpToPercent(80); doBar(0);  return 2;
369     case Remote::NINE:  player->jumpToPercent(90); doBar(0);  return 2;
370
371 #ifdef DEV
372 //    case Remote::RED:
373 //    {
374       //Don't use RED for anything. It will eventually be recording summary
375
376       //player->test1();
377
378
379       /*
380       // for testing EPG in NTSC with a NTSC test video
381       Video::getInstance()->setMode(Video::QUARTER);
382       Video::getInstance()->setPosition(170, 5);
383       VEpg* vepg = new VEpg(NULL, 0);
384       vepg->draw();
385       BoxStack::getInstance()->add(vepg);
386       BoxStack::getInstance()->update(vepg);
387       */
388
389 //      return 2;
390 //    }
391
392 #endif
393
394   }
395
396   return 1;
397 }
398
399 void VVideoRec::processMessage(Message* m)
400 {
401   Log::getInstance()->log("VVideoRec", Log::DEBUG, "Message received");
402
403   if (m->message == Message::MOUSE_LBDOWN)
404   {
405     UINT x = (m->parameter>>16) - getScreenX();
406     UINT y = (m->parameter&0xFFFF) - getScreenY();
407
408     if (!barShowing)
409     {
410       BoxStack::getInstance()->handleCommand(Remote::OK); //simulate rok press
411     }
412     else if (barRegion.x<=x && barRegion.y<=y && (barRegion.x+barRegion.w)>=x && (barRegion.y+barRegion.h)>=y)
413     {
414       int progBarXbase = barRegion.x + 300;
415       if (myRec->hasMarks())
416       {
417         MarkList* markList = myRec->getMarkList();
418         MarkList::iterator i;
419         Mark* loopMark = NULL;
420         int posPix;
421         ULONG lengthFrames;
422         if (myRec->recInfo->timerEnd > time(NULL))
423         {
424           // chasing playback
425           // Work out an approximate length in frames (good to 1s...)
426           lengthFrames = (myRec->recInfo->timerEnd - myRec->recInfo->timerStart) * video->getFPS();
427         }
428         else
429         {
430           lengthFrames = player->getLengthFrames();
431         }
432         for(i = markList->begin(); i != markList->end(); i++)
433         {
434           loopMark = *i;
435           if (loopMark->pos)
436           {
437             posPix = 302 * loopMark->pos / lengthFrames;
438             rectangle(barRegion.x + progBarXbase + 2 + posPix, barRegion.y + 12 - 2, 3, 28, Colour::DANGER);
439             if (x>=barRegion.x + progBarXbase + 2 + posPix
440                 && x<=barRegion.x + progBarXbase + 2 + posPix+3
441                 && y>=barRegion.y + 12 - 2
442                 && y<=barRegion.y + 12 - 2+28)
443             {
444               player->jumpToMark(loopMark->pos);
445               doBar(3);
446               return;
447             }
448           }
449         }
450       }
451
452       if (x>=barRegion.x + progBarXbase + 24
453           && x<=barRegion.x + progBarXbase + 4 + 302
454           && y>=barRegion.y + 12 - 2
455           && y<=barRegion.y + 12 - 2+28)
456       {
457         int cx=x-(barRegion.x + progBarXbase + 4);
458         double percent=((double)cx)/302.*100.;
459         player->jumpToPercent(percent);
460         doBar(3);
461         return;
462         //  int progressWidth = 302 * currentFrameNum / lengthFrames;
463         //  rectangle(barRegion.x + progBarXbase + 4, barRegion.y + 16, progressWidth, 16, Colour::SELECTHIGHLIGHT);
464       }
465     }
466     else
467     {
468       BoxStack::getInstance()->handleCommand(Remote::OK); //simulate rok press
469     }
470   }
471   else if (m->from == player)
472   {
473     if (m->message != Message::PLAYER_EVENT) return;
474     switch(m->parameter)
475     {
476       case Player::CONNECTION_LOST: // connection lost detected
477       {
478         // I can't handle this, send it to command
479         Message* m2 = new Message();
480         m2->to = Command::getInstance();
481         m2->message = Message::CONNECTION_LOST;
482         Command::getInstance()->postMessageNoLock(m2);
483         break;
484       }
485       case Player::STOP_PLAYBACK:
486       {
487         // FIXME Obselete ish - improve this
488         Message* m2 = new Message(); // Must be done after this thread finishes, and must break into master mutex
489         m2->to = Command::getInstance();
490         m2->message = Message::STOP_PLAYBACK;
491         Command::getInstance()->postMessageNoLock(m2);
492         break;
493       }
494       case Player::ASPECT43:
495       {
496         if (dowss)
497         {
498           Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 43");
499           wss.setWide(false);
500           wss.draw();
501           boxstack->update(this, &wssRegion);
502         }
503         break;
504       }
505       case Player::ASPECT169:
506       {
507         if (dowss)
508         {
509           Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 169");
510           wss.setWide(true);
511           wss.draw();
512           boxstack->update(this, &wssRegion);
513         }
514         break;
515       }
516     }
517   }
518   else if (m->message == Message::AUDIO_CHANGE_CHANNEL)
519   {
520     Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received change audio channel to %i", m->parameter);
521     player->setAudioChannel(m->parameter&0xFFFF,(m->parameter&0xFF0000)>> 16 );
522   }
523   else if (m->message == Message::CHILD_CLOSE)
524   {
525     if (m->from == vas)
526     {
527       vas = NULL;
528       barVasHold = false;
529       if (!barGenHold && !barScanHold && !barVasHold) removeBar();
530     }
531   }
532 }
533
534 void VVideoRec::stopPlay()
535 {
536   Log::getInstance()->log("VVideoRec", Log::DEBUG, "Pre stopPlay");
537
538   removeBar();
539   Log::getInstance()->log("VVideoRec", Log::DEBUG, "1");
540   player->stop();
541   Log::getInstance()->log("VVideoRec", Log::DEBUG, "2");
542   vdr->stopStreaming();
543   Log::getInstance()->log("VVideoRec", Log::DEBUG, "3");
544   delete player;
545
546   playing = false;
547
548   if (!vdr->isConnected()) { Command::getInstance()->connectionLost(); return; }
549   Log::getInstance()->log("VVideoRec", Log::DEBUG, "Post stopPlay");
550 }
551
552 void VVideoRec::toggleChopSides()
553 {
554   if (video->getTVsize() == Video::ASPECT16X9) return; // Means nothing for 16:9 TVs
555
556   if (videoMode == Video::NORMAL)
557   {
558     videoMode = Video::LETTERBOX;
559     video->setMode(Video::LETTERBOX);
560   }
561   else
562   {
563     videoMode = Video::NORMAL;
564     video->setMode(Video::NORMAL);
565   }
566 }
567
568 void VVideoRec::doAudioSelector()
569 {
570   bool* availableMpegAudioChannels = player->getDemuxerMpegAudioChannels();
571   bool* availableAc3AudioChannels = 0;
572   int currentAudioChannel = player->getCurrentAudioChannel();
573   if (Audio::getInstance()->supportsAc3())
574   {
575       availableAc3AudioChannels = player->getDemuxerAc3AudioChannels();
576   }
577
578   vas = new VAudioSelector(this, availableMpegAudioChannels, availableAc3AudioChannels, currentAudioChannel, myRec->recInfo);
579   vas->setBackgroundColour(barBlue);
580   vas->setPosition(0, barRegion.y - 120);
581
582 // pal 62, ntsc 57
583
584   barVasHold = true;
585   doBar(0);
586
587   vas->draw();
588   boxstack->add(vas);
589   boxstack->update(vas);
590 }
591
592 void VVideoRec::doBar(int action)
593 {
594   barShowing = true;
595
596   rectangle(barRegion, barBlue);
597
598   /* Work out what to display - choices:
599
600   Playing  >
601   Paused   ||
602   FFwd     >>
603   FBwd     <<
604
605   Specials, informed by parameter
606
607   Skip forward 10s    >|
608   Skip backward 10s   |<
609   Skip forward 1m     >>|
610   Skip backward 1m    |<<
611
612   */
613
614   WSymbol w;
615   TEMPADD(&w);
616   w.nextSymbol = 0;
617   w.setPosition(barRegion.x + 66, barRegion.y + 16);
618
619   UCHAR playerState = 0;
620
621   if (action)
622   {
623     if (action == 1)       w.nextSymbol = WSymbol::SKIPFORWARD;
624     else if (action == 2)  w.nextSymbol = WSymbol::SKIPBACK;
625     else if (action == 3)  w.nextSymbol = WSymbol::SKIPFORWARD2;
626     else if (action == 4)  w.nextSymbol = WSymbol::SKIPBACK2;
627   }
628   else
629   {
630     playerState = player->getState();
631     if (playerState == Player::S_PAUSE_P)      w.nextSymbol = WSymbol::PAUSE;
632     else if (playerState == Player::S_PAUSE_I) w.nextSymbol = WSymbol::PAUSE;
633     else if (playerState == Player::S_FFWD)    w.nextSymbol = WSymbol::FFWD;
634     else if (playerState == Player::S_FBWD)    w.nextSymbol = WSymbol::FBWD;
635     else                                       w.nextSymbol = WSymbol::PLAY;
636   }
637
638   w.draw();
639
640   if ((playerState == Player::S_FFWD) || (playerState == Player::S_FBWD))
641   {
642     // draw blips to show how fast the scan is
643     UCHAR scanrate = player->getIScanRate();
644     if (scanrate >= 2)
645     {
646       char text[5];
647       SNPRINTF(text, 5, "%ux", scanrate);
648       drawText(text, barRegion.x + 102, barRegion.y + 12, Colour::LIGHTTEXT);
649     }
650   }
651
652   drawBarClocks();
653
654   boxstack->update(this, &barRegion);
655
656   timers->cancelTimer(this, 1);
657
658
659   if ((playerState == Player::S_FFWD) || (playerState == Player::S_FBWD)) barScanHold = true;
660   else barScanHold = false;
661
662   if (!barGenHold && !barScanHold && !barVasHold) timers->setTimerD(this, 1, 4);
663
664   timers->setTimerD(this, 2, 0, 200000000);
665 }
666
667 void VVideoRec::timercall(int clientReference)
668 {
669   switch(clientReference)
670   {
671     case 1:
672     {
673       // Remove bar
674       removeBar();
675       break;
676     }
677     case 2:
678     {
679       // Update clock
680       if (!barShowing) break;
681       drawBarClocks();
682       boxstack->update(this, &barRegion);
683       
684       timers->setTimerD(this, 2, 0, 200000000);
685       break;
686     }
687   }
688 }
689
690 void VVideoRec::drawBarClocks()
691 {
692   if (barScanHold)
693   {
694     UCHAR playerState = player->getState();
695     // sticky bar is set if we are in ffwd/fbwd mode
696     // if player has gone to S_PLAY then kill stickyBar, and run doBar(0) which
697     // will repaint all the bar (it will call this function again, but
698     // this section won't run because stickyBarF will then == false)
699
700     if ((playerState != Player::S_FFWD) && (playerState != Player::S_FBWD))
701     {
702       barScanHold = false;
703       doBar(0);
704       return; // doBar will call this function and do the rest
705     }
706   }
707
708   Log* logger = Log::getInstance();
709   logger->log("VVideoRec", Log::DEBUG, "Draw bar clocks");
710
711   // Draw RTC
712   // Blank the area first
713   rectangle(barRegion.x + 624, barRegion.y + 12, 60, 30, barBlue);
714   char timeString[20];
715   time_t t;
716   time(&t);
717   struct tm* tms = localtime(&t);
718   strftime(timeString, 19, "%H:%M", tms);
719   drawText(timeString, barRegion.x + 624, barRegion.y + 12, Colour::LIGHTTEXT);
720
721   // Draw clocks
722
723   rectangle(clocksRegion, barBlue);
724
725   ULONG currentFrameNum = player->getCurrentFrameNum();
726   ULONG lengthFrames;
727   if (myRec->recInfo->timerEnd > time(NULL))
728   {
729     // chasing playback
730     // Work out an approximate length in frames (good to 1s...)
731     lengthFrames = (myRec->recInfo->timerEnd - myRec->recInfo->timerStart) * video->getFPS();
732   }
733   else
734   {
735     lengthFrames = player->getLengthFrames();
736   }
737
738   hmsf currentFrameHMSF = video->framesToHMSF(currentFrameNum);
739   hmsf lengthHMSF = video->framesToHMSF(lengthFrames);
740
741   char buffer[100];
742   if (currentFrameNum >= lengthFrames)
743   {
744     strcpy(buffer, "-:--:-- / -:--:--");
745   }
746   else
747   {
748     SNPRINTF(buffer, 99, "%01i:%02i:%02i / %01i:%02i:%02i", currentFrameHMSF.hours, currentFrameHMSF.minutes, currentFrameHMSF.seconds, lengthHMSF.hours, lengthHMSF.minutes, lengthHMSF.seconds);
749     logger->log("VVideoRec", Log::DEBUG, buffer);
750   }
751
752   drawText(buffer, clocksRegion.x, clocksRegion.y, Colour::LIGHTTEXT);
753
754
755
756
757
758
759
760   // Draw progress bar
761   int progBarXbase = barRegion.x + 300;
762
763   rectangle(barRegion.x + progBarXbase, barRegion.y + 12, 310, 24, Colour::LIGHTTEXT);
764   rectangle(barRegion.x + progBarXbase + 2, barRegion.y + 14, 306, 20, barBlue);
765
766   if (currentFrameNum > lengthFrames) return;
767   if (lengthFrames == 0) return;
768
769   // Draw yellow portion
770   int progressWidth = 302 * currentFrameNum / lengthFrames;
771   rectangle(barRegion.x + progBarXbase + 4, barRegion.y + 16, progressWidth, 16, Colour::SELECTHIGHLIGHT);
772
773   if (myRec->recInfo->timerEnd > time(NULL)) // if chasing
774   {
775     int nrWidth = (int)(302 * ((double)(lengthFrames - player->getLengthFrames()) / lengthFrames));
776
777     Log::getInstance()->log("GVASDF", Log::DEBUG, "Length Frames: %lu", lengthFrames);
778     Log::getInstance()->log("GVASDF", Log::DEBUG, "Player lf: %lu", player->getLengthFrames());
779     Log::getInstance()->log("GVASDF", Log::DEBUG, "NR WDITH: %i", nrWidth);
780     rectangle(barRegion.x + progBarXbase + 4 + 302 - nrWidth, barRegion.y + 16, nrWidth, 16, Colour::RED);
781   }
782
783   int posPix;
784   // Now calc position for blips
785
786   if (myRec->hasMarks())
787   {
788     // Draw blips where there are cut marks
789     MarkList* markList = myRec->getMarkList();
790     MarkList::iterator i;
791     Mark* loopMark = NULL;
792
793     for(i = markList->begin(); i != markList->end(); i++)
794     {
795       loopMark = *i;
796       if (loopMark->pos)
797       {
798         logger->log("VVideoRec", Log::DEBUG, "Drawing mark at frame %i", loopMark->pos);
799         posPix = 302 * loopMark->pos / lengthFrames;
800         rectangle(barRegion.x + progBarXbase + 2 + posPix, barRegion.y + 12 - 2, 3, 28, Colour::DANGER);
801       }
802     }
803   }
804   else
805   {
806     // Draw blips where start and end margins probably are
807
808     posPix = 302 * startMargin * video->getFPS() / lengthFrames;
809
810     rectangle(barRegion.x + progBarXbase + 2 + posPix, barRegion.y + 12 - 2, 2, 2, Colour::LIGHTTEXT);
811     rectangle(barRegion.x + progBarXbase + 2 + posPix, barRegion.y + 12 + 24, 2, 2, Colour::LIGHTTEXT);
812
813     posPix = 302 * (lengthFrames - endMargin * video->getFPS()) / lengthFrames;
814
815     rectangle(barRegion.x + progBarXbase + 2 + posPix, barRegion.y + 12 - 2, 2, 2, Colour::LIGHTTEXT);
816     rectangle(barRegion.x + progBarXbase + 2 + posPix, barRegion.y + 12 + 24, 2, 2, Colour::LIGHTTEXT);
817   }
818 }
819
820 void VVideoRec::removeBar()
821 {
822   if (!barShowing) return;
823   timers->cancelTimer(this, 2);
824   barShowing = false;
825   barGenHold = false;
826   barScanHold = false;
827   barVasHold = false;
828   rectangle(barRegion, transparent);
829   boxstack->update(this, &barRegion);
830 }
831
832 void VVideoRec::doSummary()
833 {
834   vsummary = new VInfo();
835   vsummary->setTitleText(myRec->getProgName());
836   vsummary->setBorderOn(1);
837   vsummary->setExitable();
838   if (myRec->recInfo->summary) vsummary->setMainText(myRec->recInfo->summary);
839   else vsummary->setMainText(tr("Summary unavailable"));
840   if (Video::getInstance()->getFormat() == Video::PAL)
841   {
842     vsummary->setPosition(120, 130);
843   }
844   else
845   {
846     vsummary->setPosition(110, 90);
847   }
848   vsummary->setSize(510, 270);
849   add(vsummary);
850   vsummary->draw();
851
852   BoxStack::getInstance()->update(this);
853 }
854
855 void VVideoRec::removeSummary()
856 {
857   if (vsummary)
858   {
859     remove(vsummary);
860     delete vsummary;
861     vsummary = NULL;
862     draw();
863     BoxStack::getInstance()->update(this);
864   }
865 }
866