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