2 Copyright 2004-2005 Chris Tallon
4 This file is part of VOMP.
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "vvideorec.h"
23 VVideoRec::VVideoRec(Recording* rec)
25 player = new PlayerVideo(Command::getInstance(), 1, 0); // say 0 for radio because buffering will work anyway
27 vdr = VDR::getInstance();
28 video = Video::getInstance();
29 timers = Timers::getInstance();
31 videoMode = video->getMode();
34 create(video->getScreenWidth(), video->getScreenHeight());
35 transparent.set(0, 0, 0, 0);
36 setBackgroundColour(transparent);
39 barRegion.y = video->getScreenHeight() - 66; // FIXME, need to be - 1? and below?
40 barRegion.w = video->getScreenWidth();
43 clocksRegion.x = barRegion.x + 180;
44 clocksRegion.y = barRegion.y + 12;
46 clocksRegion.h = surface->getFontHeight();
48 barBlue.set(0, 0, 150, 150);
53 VVideoRec::~VVideoRec()
55 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Pre delete player");
57 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Post delete player");
58 Video::getInstance()->setDefaultAspect();
60 timers->cancelTimer(this, 1);
61 timers->cancelTimer(this, 2);
64 void VVideoRec::draw()
69 void VVideoRec::go(ULLONG startPosition)
71 ULLONG recLength = vdr->streamRecording(myRec);
75 player->setLength(recLength);
76 player->setPosition(startPosition);
81 ViewMan* viewman = ViewMan::getInstance();
83 Message* m = new Message();
84 m->message = Message::CLOSE_ME;
87 viewman->postMessage(m);
89 VInfo* vi = new VInfo();
91 if (Video::getInstance()->getFormat() == Video::PAL)
92 vi->setScreenPos(170, 200);
94 vi->setScreenPos(160, 150);
98 vi->setOneLiner(tr("Error playing recording"));
102 m->message = Message::ADD_VIEW;
104 m->parameter = (ULONG)vi;
105 viewman->postMessage(m);
109 int VVideoRec::handleCommand(int command)
115 player->play(); // do resync
123 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Pre player stop");
125 // FIXME work out a better soln for this
126 // Fix a problem to do with thread sync here
127 // because the bar gets a timer every 0.2s and it seems to take up to 0.1s,
128 // (or maybe just the wrong thread being selected?) for the main loop to lock and process
129 // the video stop message it is possible for a bar message to stack up after a stop message
130 // when the bar message is finally processed the prog crashes because this is deleted by then
135 vdr->stopStreaming();
137 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Post player stop");
142 player->togglePause();
146 case Remote::SKIPFORWARD:
149 player->skipForward(60);
152 case Remote::SKIPBACK:
155 player->skipBackward(60);
158 case Remote::FORWARD:
160 player->toggleFastForward();
167 player->skipBackward(10);
173 player->skipForward(10);
190 // case Remote::REVERSE:
192 // player->toggleFastBackward();
196 case Remote::ZERO: player->jumpToPercent(0); return 2;
197 case Remote::ONE: player->jumpToPercent(10); return 2;
198 case Remote::TWO: player->jumpToPercent(20); return 2;
199 case Remote::THREE: player->jumpToPercent(30); return 2;
200 case Remote::FOUR: player->jumpToPercent(40); return 2;
201 case Remote::FIVE: player->jumpToPercent(50); return 2;
202 case Remote::SIX: player->jumpToPercent(60); return 2;
203 case Remote::SEVEN: player->jumpToPercent(70); return 2;
204 case Remote::EIGHT: player->jumpToPercent(80); return 2;
205 case Remote::NINE: player->jumpToPercent(90); return 2;
213 // for testing EPG in NTSC with a NTSC test video
214 Video::getInstance()->setMode(Video::QUARTER);
215 Video::getInstance()->setPosition(170, 5);
216 VEpg* vepg = new VEpg(NULL, 0);
218 ViewMan::getInstance()->add(vepg);
219 ViewMan::getInstance()->updateView(vepg);
236 void VVideoRec::toggleChopSides()
238 if (video->getTVsize() == Video::ASPECT16X9) return; // Means nothing for 16:9 TVs
240 if (videoMode == Video::NORMAL)
242 videoMode = Video::LETTERBOX;
243 video->setMode(Video::LETTERBOX);
247 videoMode = Video::NORMAL;
248 video->setMode(Video::NORMAL);
252 void VVideoRec::doBar(int action)
256 rectangle(barRegion, barBlue);
258 /* Work out what to display - choices:
265 Specials, informed by parameter
275 w.setSurface(surface);
277 w.setSurfaceOffset(76, barRegion.y + 16);
281 if (action == 1) w.nextSymbol = WSymbol::SKIPFORWARD;
282 else if (action == 2) w.nextSymbol = WSymbol::SKIPBACK;
283 else if (action == 3) w.nextSymbol = WSymbol::SKIPFORWARD2;
284 else if (action == 4) w.nextSymbol = WSymbol::SKIPBACK2;
288 if (player->isPaused()) w.nextSymbol = WSymbol::PAUSE;
289 else if (player->isFfwd()) w.nextSymbol = WSymbol::FFWD;
290 else if (player->isFbwd()) w.nextSymbol = WSymbol::FBWD;
291 else w.nextSymbol = WSymbol::PLAY;
298 ViewMan::getInstance()->updateView(this, &barRegion);
299 timers->setTimer(this, 1, (struct timespec){4, 0});
300 timers->setTimer(this, 2, (struct timespec){0, 200000000});
303 void VVideoRec::timercall(int clientReference)
305 switch(clientReference)
316 if (!barShowing) break;
318 ViewMan::getInstance()->updateView(this, &barRegion);
319 timers->setTimer(this, 2, (struct timespec){0, 200000000});
325 void VVideoRec::drawBarClocks()
327 Log::getInstance()->log("VVideoRec", Log::DEBUG, "Draw bar clocks");
329 rectangle(clocksRegion, barBlue);
331 ULONG currentTS = (player->getPositionTS() / 90000);
332 int chours = currentTS / 3600;
333 int cminutes = (currentTS - (chours * 3600)) / 60;
334 int cseconds = currentTS - (chours * 3600) - (cminutes * 60);
336 ULONG endTS = (player->getEndTS() / 90000);
337 int ehours = endTS / 3600;
338 int eminutes = (endTS - (ehours * 3600)) / 60;
339 int eseconds = endTS - (ehours * 3600) - (eminutes * 60);
342 if ((currentTS > 95441) // it's at the 33bit rollover point where the calc doesn't work because of the 1s diff
343 // between demuxer values and video chip return values ... ?
344 || (!endTS)) // No values yet
346 strcpy(buffer, "-:--:-- / -:--:--");
350 snprintf(buffer, 99, "%01i:%02i:%02i / %01i:%02i:%02i", chours, cminutes, cseconds, ehours, eminutes, eseconds);
353 drawText(buffer, barRegion.x + 180, barRegion.y + 12, Colour::LIGHTTEXT);
356 void VVideoRec::removeBar()
358 timers->cancelTimer(this, 2);
360 rectangle(barRegion, transparent);
361 ViewMan::getInstance()->updateView(this, &barRegion);