Ginga  0.13.6
 All Classes Namespaces Functions Variables
Tuner.h
1 /******************************************************************************
2 Este arquivo eh parte da implementacao do ambiente declarativo do middleware
3 Ginga (Ginga-NCL).
4 
5 Direitos Autorais Reservados (c) 1989-2007 PUC-Rio/Laboratorio TeleMidia
6 
7 Este programa eh software livre; voce pode redistribui-lo e/ou modificah-lo sob
8 os termos da Licenca Publica Geral GNU versao 2 conforme publicada pela Free
9 Software Foundation.
10 
11 Este programa eh distribuido na expectativa de que seja util, porem, SEM
12 NENHUMA GARANTIA; nem mesmo a garantia implicita de COMERCIABILIDADE OU
13 ADEQUACAO A UMA FINALIDADE ESPECIFICA. Consulte a Licenca Publica Geral do
14 GNU versao 2 para mais detalhes.
15 
16 Voce deve ter recebido uma copia da Licenca Publica Geral do GNU versao 2 junto
17 com este programa; se nao, escreva para a Free Software Foundation, Inc., no
18 endereco 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
19 
20 Para maiores informacoes:
21 ncl @ telemidia.puc-rio.br
22 http://www.ncl.org.br
23 http://www.ginga.org.br
24 http://www.telemidia.puc-rio.br
25 ******************************************************************************
26 This file is part of the declarative environment of middleware Ginga (Ginga-NCL)
27 
28 Copyright: 1989-2007 PUC-RIO/LABORATORIO TELEMIDIA, All Rights Reserved.
29 
30 This program is free software; you can redistribute it and/or modify it under
31 the terms of the GNU General Public License version 2 as published by
32 the Free Software Foundation.
33 
34 This program is distributed in the hope that it will be useful, but WITHOUT ANY
35 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
36 PARTICULAR PURPOSE. See the GNU General Public License version 2 for more
37 details.
38 
39 You should have received a copy of the GNU General Public License version 2
40 along with this program; if not, write to the Free Software
41 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
42 
43 For further information contact:
44 ncl @ telemidia.puc-rio.br
45 http://www.ncl.org.br
46 http://www.ginga.org.br
47 http://www.telemidia.puc-rio.br
48 *******************************************************************************/
49 
50 #ifndef __TUNER_H__
51 #define __TUNER_H__
52 
53 #include "system/thread/Thread.h"
54 using namespace ::br::pucrio::telemidia::ginga::core::system::thread;
55 
56 #include "system/compat/SystemCompat.h"
57 using namespace ::br::pucrio::telemidia::ginga::core::system::compat;
58 
59 #include "mb/interface/IInputEventListener.h"
60 using namespace ::br::pucrio::telemidia::ginga::core::mb;
61 
62 #include "mb/interface/CodeMap.h"
63 using namespace ::br::pucrio::telemidia::ginga::core::mb;
64 
65 #include "ITuner.h"
66 #include "providers/Channel.h"
67 #include "NetworkInterface.h"
68 #include "ITunerListener.h"
69 #include "providers/IProviderListener.h"
70 
71 #include <fstream>
72 #include <string>
73 #include <iostream>
74 #include <cstdio>
75 #include <set>
76 #include <map>
77 using namespace std;
78 
79 namespace br {
80 namespace pucrio {
81 namespace telemidia {
82 namespace ginga {
83 namespace core {
84 namespace tuning {
85  class Tuner : public ITuner, public IInputEventListener, public ITProviderListener, public Thread {
86  private:
87  bool receiving;
88  ITunerListener* listener;
89  ITunerListener* loopListener;
90  map<int, INetworkInterface*> interfaces;
91  int currentInterface;
92  bool firstTune;
93  int skipSize;
94  unsigned char packetSize;
95  string currentSpec;
96  GingaScreenID screenId;
97 
98  public:
99  Tuner(
100  GingaScreenID screenId,
101  string network = "",
102  string protocol = "",
103  string address = "");
104 
105  virtual ~Tuner();
106 
107  void setLoopListener(ITunerListener* loopListener);
108  bool userEventReceived(IInputEvent* ev);
109 
110  private:
111  void clearInterfaces();
112  void receiveSignal(short signalCode);
113  void initializeInterface(string niSpec);
114  void initializeInterfaces();
115  void createInterface(
116  string network, string protocol, string address);
117 
118  bool listenInterface(INetworkInterface* nInterface);
119  void receiveInterface(INetworkInterface* nInterface);
120 
121  public:
122  void setSpec(string ni, string ch);
123  void tune();
124  INetworkInterface* getCurrentInterface();
125  void channelUp();
126  void channelDown();
127  void changeChannel(int factor);
128  bool hasSignal();
129  void setSkipSize(int size);
130  void setPacketSize(unsigned char size);
131 
132  public:
133  void setTunerListener(ITunerListener* listener);
134 
135  private:
136  void notifyData(char* buff, unsigned int val);
137  void notifyStatus(short newStatus, IChannel* channel);
138  virtual void run();
139  };
140 }
141 }
142 }
143 }
144 }
145 }
146 
147 #endif //__TUNER_H__
Definition: DataProcessor.h:88