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