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