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)
25 player = new Player(NULL);
27 vdr = VDR::getInstance();
28 viewman = ViewMan::getInstance();
30 currentChannel = NULL;
32 unavailableView = NULL;
34 Video* video = Video::getInstance();
35 setDimensions(video->getScreenHeight(), video->getScreenWidth());
36 Colour transparent(0, 0, 0, 0);
37 setBackgroundColour(transparent);
40 VVideoLive::~VVideoLive()
45 void VVideoLive::draw()
50 int VVideoLive::handleCommand(int command)
56 if (!unavailable) player->play(); // do resync
64 if (unavailable) showUnavailable(0);
71 if (unavailable) showUnavailable(0);
80 if (unavailable) showUnavailable(0);
88 if (!unavailable) doBanner();
92 case Remote::ZERO ... Remote::NINE:
94 VChannelSelect* v = new VChannelSelect(this, command);
95 viewman->addNoLock(v);
96 // ViewMan::getInstance()->timedDelete(v, 4, 0);
105 void VVideoLive::processMessage(Message* m)
107 if (m->message == Message::CHANNEL_CHANGE)
109 // check channel number is valid
110 currentChannel = channelFromNumber(m->parameter);
111 if (!currentChannel) return; // this should never happen
112 if (unavailable) showUnavailable(0);
118 void VVideoLive::doBanner()
120 VLiveBanner* v = new VLiveBanner(currentChannel);
121 viewman->timedDelete(v, 4, 0);
123 Message* m = new Message();
126 m->message = Message::ADD_VIEW;
127 m->parameter = (ULONG)v;
129 viewman->postMessage(m);
132 void VVideoLive::showUnavailable(int active)
134 if (active == unavailable) return;
140 unavailableView = new VInfo();
141 unavailableView->setDimensions(200, 400);
142 if (Video::getInstance()->getFormat() == Video::PAL)
144 unavailableView->setScreenPos(170, 200);
148 unavailableView->setScreenPos(160, 150);
150 unavailableView->setTitleText(currentChannel->name);
151 unavailableView->setMainText("\n Channel unavailable");
152 unavailableView->setDropThrough();
154 Message* m = new Message();
157 m->message = Message::ADD_VIEW;
158 m->parameter = (ULONG)unavailableView;
160 viewman->postMessage(m);
165 ViewMan::getInstance()->removeView(unavailableView, 1);
166 unavailableView = NULL;
170 void VVideoLive::setChannel(int number)
172 currentChannel = channelFromNumber(number);
173 if (!currentChannel) return; // should never happen
177 void VVideoLive::play()
181 int available = vdr->streamChannel(currentChannel->number);
194 void VVideoLive::stop()
196 if (unavailable) return;
198 vdr->stopStreaming();
201 void VVideoLive::upChannel()
204 for(chanList->reset(); (channel = (Channel*)chanList->getCurrent()); chanList->next())
206 if (channel == currentChannel)
209 channel = (Channel*)chanList->getCurrent();
210 if (!channel) return;
211 currentChannel = channel;
216 void VVideoLive::downChannel()
219 Channel* prevChannel = NULL;
220 for(chanList->reset(); (channel = (Channel*)chanList->getCurrent()); chanList->next())
222 if (channel == currentChannel)
224 if (!prevChannel) return;
225 currentChannel = prevChannel;
227 prevChannel = channel;
231 Channel* VVideoLive::channelFromNumber(int number)
234 for(chanList->reset(); (channel = (Channel*)chanList->getCurrent()); chanList->next())
236 if (channel->number == (UINT)number) return channel;