Ginga  0.13.6
 All Classes Namespaces Functions Variables
ISDBTProvider.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 ISDBTPROVIDER_H_
51 #define ISDBTPROVIDER_H_
52 
53 #define INPUT_BUFFER_SIZE 4096
54 
55 extern "C" {
56  #include <sys/types.h>
57  #include <stdio.h>
58  #include <errno.h>
59  #include <poll.h>
60  #include <stdint.h>
61  #include <unistd.h>
62  #include <linux/dvb/version.h>
63  #include <linux/dvb/frontend.h>
64  #include <linux/dvb/dmx.h>
65 
66 
67 // Latin America channel assignments for ISDB-T International
68  static uint64_t tv_channels_list[] =
69  {
70  /* 0 */ 0, /* index placeholders... */
71  /* 1 */ 0, // never used for broadcasting
72  /* 2 */ 0, // what to do?
73  /* 3 */ 0, // what to do?
74  /* 4 */ 0, // what to do?
75  /* 5 */ 0, // future allocation for radio broadcasting
76  /* 6 */ 0, // future allocation for radio broadcasting
77  /* 7 */ 177142000,
78  /* 8 */ 183142000,
79  /* 9 */ 189142000,
80  /* 10 */ 195142000,
81  /* 11 */ 201142000,
82  /* 12 */ 207142000,
83  /* 13 */ 213142000,
84  /* 14 */ 473142000,
85  /* 15 */ 479142000,
86  /* 16 */ 485142000,
87  /* 17 */ 491142000,
88  /* 18 */ 497142000,
89  /* 19 */ 503142000,
90  /* 20 */ 509142000,
91  /* 21 */ 515142000,
92  /* 22 */ 521142000,
93  /* 23 */ 527142000,
94  /* 24 */ 533142000,
95  /* 25 */ 539142000,
96  /* 26 */ 545142000,
97  /* 27 */ 551142000,
98  /* 28 */ 557142000,
99  /* 29 */ 563142000,
100  /* 30 */ 569142000,
101  /* 31 */ 575142000,
102  /* 32 */ 581142000,
103  /* 33 */ 587142000,
104  /* 34 */ 593142000,
105  /* 35 */ 599142000,
106  /* 36 */ 605142000,
107  /* 37 */ 611142000, // radio astronomy reserved (we are in rx mode anyway, so no harm here...
108  /* 38 */ 617142000,
109  /* 39 */ 623142000,
110  /* 40 */ 629142000,
111  /* 41 */ 635142000,
112  /* 42 */ 641142000,
113  /* 43 */ 647142000,
114  /* 44 */ 653142000,
115  /* 45 */ 659142000,
116  /* 46 */ 665142000,
117  /* 47 */ 671142000,
118  /* 48 */ 677142000,
119  /* 49 */ 683142000,
120  /* 50 */ 689142000,
121  /* 51 */ 695142000,
122  /* 52 */ 701142000,
123  /* 53 */ 707142000,
124  /* 54 */ 713142000,
125  /* 55 */ 719142000,
126  /* 56 */ 725142000,
127  /* 57 */ 731142000,
128  /* 58 */ 737142000,
129  /* 59 */ 743142000,
130  /* 60 */ 749142000,
131  /* 61 */ 755142000,
132  /* 62 */ 761142000,
133  /* 63 */ 767142000,
134  /* 64 */ 773142000,
135  /* 65 */ 779142000,
136  /* 66 */ 785142000,
137  /* 67 */ 791142000,
138  /* 68 */ 797142000,
139  /* 69 */ 803142000,
140  };
141 
142 
143 }
144 
145 #include "system/compat/SystemCompat.h"
146 using namespace ::br::pucrio::telemidia::ginga::core::system::compat;
147 
148 #include "../../IDataProvider.h"
149 #include "../../Channel.h"
150 
151 #include "ISDBTFrontend.h"
152 #include "RingBuffer.h"
153 
154 #include <fstream>
155 #include <string>
156 #include <iostream>
157 using namespace std;
158 
159 namespace br {
160 namespace pucrio {
161 namespace telemidia {
162 namespace ginga {
163 namespace core {
164 namespace tuning {
165 
166  class ISDBTProvider : public IDataProvider {
167  protected:
168  string fileName;
169  int feDescriptor;
170  int initialFrequency;
171  static const string iniFileName;
172  ISDBTFrontend* frontend;
173  vector<IChannel*>* channels;
174  vector<IChannel*>::iterator currentChannel;
175  short capabilities;
176  ITProviderListener* listener;
177 
178  // thread and ring buffer variables...
179  int keep_reading;
180  pthread_t output_thread_id;
181  pthread_mutex_t output_mutex;
182  pthread_cond_t output_cond;
183  struct ring_buffer output_buffer;
184  static void *output_thread(void *nothing);
185  public:
186  ISDBTProvider(long freq);
187  virtual ~ISDBTProvider();
188 
189  short getCaps();
190  void setListener(ITProviderListener* listener);
191  void attachFilter(IFrontendFilter* filter);
192  void removeFilter(IFrontendFilter* filter);
193 
194  private:
195  bool scanChannels();
196  void initializeChannels();
197 
198  public:
199  bool tune();
200  IChannel* getCurrentChannel();
201  bool getSTCValue(uint64_t* stc, int* valueType);
202  bool changeChannel(int factor);
203  bool setChannel(string channelValue);
204  int createPesFilter(int pid, int pesType, bool compositeFiler);
205  string getPesFilterOutput();
206  void close();
207  int receiveData(char* buff, int skipSize, unsigned char packetSize);
208 
209 
210 
211  };
212 }
213 }
214 }
215 }
216 }
217 }
218 
219 #endif /*FILESYSTEMPROVIDER_H_*/
Definition: RingBuffer.h:20