Ginga  0.13.6
 All Classes Namespaces Functions Variables
Pat.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 PAT_H_
51 #define PAT_H_
52 
53 #include "Pmt.h"
54 #include "TransportSection.h"
55 
56 #include <map>
57 #include <vector>
58 #include <iostream>
59 using namespace std;
60 
61 namespace br {
62 namespace pucrio {
63 namespace telemidia {
64 namespace ginga {
65 namespace core {
66 namespace tsparser {
67 namespace si {
68  class Pat : public TransportSection {
69  private:
70  static int defaultProgramNumber;
71  static int defaultProgramPid;
72 
73  protected:
74  unsigned int currentPid;
75  unsigned int currentCarouselId;
76  unsigned int carouselComponentTag;
77  unsigned int tsPid;
78 
79  //Program association table (pmt pid x program number)
80  // if i->first == 0 i->second = networkPid
81  map<unsigned int, unsigned int> pat;
82 
83  vector<unsigned int> unprocessedPmts;
84 
85  //PMT Pid TO PMT
86  map<unsigned int, Pmt*> programs;
87 
88  char* stream;
89 
90  public:
91  Pat();
92  virtual ~Pat();
93 
94  bool hasStreamType(short streamType);
95  int getPidByStreamType(short streamType);
96  unsigned int getNextPid();
97  unsigned int getNextCarouselId();
98  unsigned int getCarouselComponentTag();
99  bool hasProgramNumber(unsigned int programNumber);
100  bool hasPid(unsigned int pid);
101  Pmt* getPmtByProgramNumber(unsigned int programNumber);
102  unsigned int getTSId();
103  void setTSId(unsigned int newTSId);
104  unsigned int getNumOfPrograms();
105  void addProgram(unsigned int pid, unsigned int programNumber);
106  void addPmt(Pmt* program);
107  void replacePmt(unsigned int pid, Pmt* newPmt);
108  unsigned int getFirstProgramNumber();
109  unsigned int getProgramNumberByPid(unsigned int pid);
110  short getStreamType(unsigned int pid);
111  bool isSectionType(unsigned int pid);
112 
113  static void resetPayload(char* payload, int size);
114 
115  bool processSectionPayload();
116  bool hasUnprocessedPmt();
117  vector<unsigned int>* getUnprocessedPmtPids();
118  map<unsigned int, Pmt*>* getProgramsInfo();
119  void checkConsistency();
120  unsigned int getDefaultProgramPid();
121  unsigned int getDefaultMainVideoPid();
122  unsigned int getDefaultMainAudioPid();
123  unsigned int getDefaultMainCarouselPid();
124 
125  unsigned short createPatStreamByProgramPid(unsigned short pid, char** dataStream);
126 
127  void print();
128  };
129 }
130 }
131 }
132 }
133 }
134 }
135 }
136 
137 #endif /*PAT_H_*/