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 "vvideolive.h"
23 VVideoLive::VVideoLive(ChannelList* tchanList, ULONG tstreamType)
25 vdr = VDR::getInstance();
26 viewman = ViewMan::getInstance();
30 unavailableView = NULL;
31 streamType = tstreamType;
32 if (streamType == VDR::VIDEO)
34 player = new PlayerVideo(NULL, 0);
38 player = new PlayerRadio();
42 Video* video = Video::getInstance();
43 setDimensions(video->getScreenWidth(), video->getScreenHeight());
44 Colour transparent(0, 0, 0, 0);
45 setBackgroundColour(transparent);
48 VVideoLive::~VVideoLive()
53 void VVideoLive::draw()
58 int VVideoLive::handleCommand(int command)
64 if (!unavailable) player->play(); // do resync
72 if (unavailable) showUnavailable(0);
77 case Remote::CHANNELUP:
79 if (unavailable) showUnavailable(0);
86 case Remote::CHANNELDOWN:
88 if (unavailable) showUnavailable(0);
100 case Remote::ZERO ... Remote::NINE:
102 VChannelSelect* v = new VChannelSelect(this, command);
103 viewman->addNoLock(v);
104 // ViewMan::getInstance()->timedDelete(v, 4, 0);
113 void VVideoLive::processMessage(Message* m)
115 if (m->message == Message::CHANNEL_CHANGE)
117 // check channel number is valid
118 currentChannel = channelIndexFromNumber(m->parameter);
119 if (unavailable) showUnavailable(0);
123 else if (m->message == Message::CHANNEL_UP)
126 if (unavailable) showUnavailable(0);
130 vlb->setChannel((*chanList)[currentChannel]);
134 else if (m->message == Message::CHANNEL_DOWN)
137 if (unavailable) showUnavailable(0);
141 vlb->setChannel((*chanList)[currentChannel]);
148 void VVideoLive::doBanner()
150 vlb = new VLiveBanner(this, (*chanList)[currentChannel]);
151 viewman->timedDelete(vlb, 4, 0);
153 Message* m = new Message();
156 m->message = Message::ADD_VIEW;
157 m->parameter = (ULONG)vlb;
159 viewman->postMessage(m);
162 void VVideoLive::showUnavailable(int active)
164 if (active == unavailable) return;
170 unavailableView = new VInfo();
171 unavailableView->setDimensions(400, 200);
172 if (Video::getInstance()->getFormat() == Video::PAL)
174 unavailableView->setScreenPos(170, 200);
178 unavailableView->setScreenPos(160, 150);
180 unavailableView->setTitleText((*chanList)[currentChannel]->name);
181 unavailableView->setMainText("\n Channel unavailable");
182 unavailableView->setDropThrough();
184 Message* m = new Message();
187 m->message = Message::ADD_VIEW;
188 m->parameter = (ULONG)unavailableView;
190 viewman->postMessage(m);
195 ViewMan::getInstance()->removeView(unavailableView, 1);
196 unavailableView = NULL;
200 void VVideoLive::setChannel(int number)
202 currentChannel = channelIndexFromNumber(number);
206 void VVideoLive::play(int noShowVLB)
210 int available = vdr->streamChannel((*chanList)[currentChannel]->number);
215 if (!noShowVLB) doBanner();
219 if (!noShowVLB) doBanner();
224 void VVideoLive::stop(int noRemoveVLB)
226 if (unavailable) return;
227 if (!noRemoveVLB) viewman->removeView(vlb, 1, 1); // if live banner is present, remove it. won't cause damage if its not present
230 vdr->stopStreaming();
233 int VVideoLive::upChannel()
235 if (currentChannel == (chanList->size() - 1)) return 0; // at the end
241 int VVideoLive::downChannel()
243 if (currentChannel == 0) return 0; // at the start
249 UINT VVideoLive::channelIndexFromNumber(int number)
251 for(UINT i = 0; i < chanList->size(); i++)
253 if ((*chanList)[i]->number == (UINT)number) return i;