]> git.vomp.tv Git - vompclient.git/blob - vvideolive.cc
NTSC support, needs testing
[vompclient.git] / vvideolive.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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20
21 #include "vvideolive.h"
22
23 VVideoLive::VVideoLive(List* tchanList)
24 {
25   player = new Player(NULL);
26   player->init();
27   vdr = VDR::getInstance();
28   chanList = tchanList;
29   currentChannel = 0;
30
31   setDimensions(Osd::getInstance()->getScreenHeight(), Osd::getInstance()->getScreenWidth());
32   Colour transparent(0, 0, 0, 0);
33   setBackgroundColour(transparent);
34 }
35
36 VVideoLive::~VVideoLive()
37 {
38   delete player;
39 }
40
41 void VVideoLive::draw()
42 {
43   View::draw();
44 }
45
46 int VVideoLive::handleCommand(int command)
47 {
48   switch(command)
49   {
50     case Remote::PLAY:
51     {
52       player->play(); // do resync
53       return 2;
54     }
55
56     case Remote::STOP:
57     case Remote::BACK:
58     case Remote::MENU:
59     {
60       player->stop();
61       vdr->stopStreaming();
62       return 4;
63     }
64     case Remote::UP:
65     {
66       player->stop();
67       vdr->stopStreaming();
68       upChannel();
69       doBanner();
70       vdr->streamChannel(currentChannel);
71       player->play();
72       return 2;
73     }
74     case Remote::DOWN:
75     {
76       player->stop();
77       vdr->stopStreaming();
78       downChannel();
79       doBanner();
80       vdr->streamChannel(currentChannel);
81       player->play();
82       return 2;
83     }
84     case Remote::OK:
85     {
86       doBanner();
87       return 2;
88     }
89
90     case Remote::ZERO ... Remote::NINE:
91     {
92       VChannelSelect* v = new VChannelSelect(this, command);
93       ViewMan::getInstance()->addNoLock(v);
94 //      ViewMan::getInstance()->timedDelete(v, 4, 0);
95       v->draw();
96       v->show();
97     }
98   }
99
100   return 1;
101 }
102
103 void VVideoLive::processMessage(Message* m)
104 {
105   if (m->message == Message::CHANNEL_CHANGE)
106   {
107     // check channel number is valid
108     Channel* channel;
109     for(chanList->reset(); (channel = (Channel*)chanList->getCurrent()); chanList->next())
110     {
111       if (channel->number == m->parameter)
112       {
113         player->stop();
114         vdr->stopStreaming();
115         setChannel(channel->number);
116       }
117     }
118   }
119 }
120
121 void VVideoLive::doBanner()
122 {
123   VLiveBanner* v = new VLiveBanner();
124   ViewMan::getInstance()->addNoLock(v);
125   ViewMan::getInstance()->timedDelete(v, 4, 0);
126   v->draw();
127   v->show();
128 }
129
130 void VVideoLive::setChannel(int number)
131 {
132   currentChannel = number;
133 //  doBanner();
134   vdr->streamChannel(currentChannel);
135   player->play();
136 }
137
138 void VVideoLive::upChannel()
139 {
140   Channel* channel;
141   for(chanList->reset(); (channel = (Channel*)chanList->getCurrent()); chanList->next())
142   {
143     if (channel->number == currentChannel)
144     {
145       chanList->next();
146       channel = (Channel*)chanList->getCurrent();
147       if (!channel) return;
148       currentChannel = channel->number;
149     }
150   }
151 }
152
153 void VVideoLive::downChannel()
154 {
155   Channel* channel;
156   Channel* prevChannel = NULL;
157   for(chanList->reset(); (channel = (Channel*)chanList->getCurrent()); chanList->next())
158   {
159     if (channel->number == currentChannel)
160     {
161       if (!prevChannel) return;
162       currentChannel = prevChannel->number;
163     }
164     prevChannel = channel;
165   }
166 }