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(List* tchanList, ULONG tstreamType)
25 vdr = VDR::getInstance();
26 viewman = ViewMan::getInstance();
28 currentChannel = NULL;
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->getScreenHeight(), video->getScreenWidth());
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);
79 if (unavailable) showUnavailable(0);
88 if (unavailable) showUnavailable(0);
96 if (!unavailable) doBanner();
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 = channelFromNumber(m->parameter);
119 if (!currentChannel) return; // this should never happen
120 if (unavailable) showUnavailable(0);
126 void VVideoLive::doBanner()
128 VLiveBanner* v = new VLiveBanner(currentChannel);
129 viewman->timedDelete(v, 4, 0);
131 Message* m = new Message();
134 m->message = Message::ADD_VIEW;
135 m->parameter = (ULONG)v;
137 viewman->postMessage(m);
140 void VVideoLive::showUnavailable(int active)
142 if (active == unavailable) return;
148 unavailableView = new VInfo();
149 unavailableView->setDimensions(200, 400);
150 if (Video::getInstance()->getFormat() == Video::PAL)
152 unavailableView->setScreenPos(170, 200);
156 unavailableView->setScreenPos(160, 150);
158 unavailableView->setTitleText(currentChannel->name);
159 unavailableView->setMainText("\n Channel unavailable");
160 unavailableView->setDropThrough();
162 Message* m = new Message();
165 m->message = Message::ADD_VIEW;
166 m->parameter = (ULONG)unavailableView;
168 viewman->postMessage(m);
173 ViewMan::getInstance()->removeView(unavailableView, 1);
174 unavailableView = NULL;
178 void VVideoLive::setChannel(int number)
180 currentChannel = channelFromNumber(number);
181 if (!currentChannel) return; // should never happen
185 void VVideoLive::play()
189 int available = vdr->streamChannel(currentChannel->number);
202 void VVideoLive::stop()
204 if (unavailable) return;
206 vdr->stopStreaming();
209 void VVideoLive::upChannel()
212 for(chanList->reset(); (channel = (Channel*)chanList->getCurrent()); chanList->next())
214 if (channel == currentChannel)
217 channel = (Channel*)chanList->getCurrent();
218 if (!channel) return;
219 currentChannel = channel;
224 void VVideoLive::downChannel()
227 Channel* prevChannel = NULL;
228 for(chanList->reset(); (channel = (Channel*)chanList->getCurrent()); chanList->next())
230 if (channel == currentChannel)
232 if (!prevChannel) return;
233 currentChannel = prevChannel;
235 prevChannel = channel;
239 Channel* VVideoLive::channelFromNumber(int number)
242 for(chanList->reset(); (channel = (Channel*)chanList->getCurrent()); chanList->next())
244 if (channel->number == (UINT)number) return channel;