Ginga  0.13.6
 All Classes Namespaces Functions Variables
EventInfo.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 EVENTINFO_H_
51 #define EVENTINFO_H_
52 
53 #include "IEventInfo.h"
54 
55 #include "util/functions.h"
56 using namespace ::br::pucrio::telemidia::util;
57 
58 #include "system/compat/SystemCompat.h"
59 using namespace ::br::pucrio::telemidia::ginga::core::system::compat;
60 
61 #include "ShortEventDescriptor.h"
62 #include "ExtendedEventDescriptor.h"
63 #include "ComponentDescriptor.h"
64 #include "ContentDescriptor.h"
65 #include "DigitalCCDescriptor.h"
66 #include "AudioComponentDescriptor.h"
67 #include "DataContentDescriptor.h"
68 #include "SeriesDescriptor.h"
69 #include "ParentalRatingDescriptor.h"
70 #include "ContentAvailabilityDescriptor.h"
71 using namespace ::br::pucrio::telemidia::ginga::core::tsparser::si::descriptors;
72 
73 #include "IMpegDescriptor.h"
74 using namespace ::br::pucrio::telemidia::ginga::core::tsparser;
75 
76 
77 #include <iostream>
78 #include <sstream>
79 //#include <time.h>
80 //#include <vector>
81 //#include <map>
82 using namespace std;
83 
84 namespace br {
85 namespace pucrio {
86 namespace telemidia {
87 namespace ginga {
88 namespace core {
89 namespace tsparser {
90 namespace si {
91  class EventInfo : public IEventInfo {
92  protected:
93  unsigned short eventId;
94  char startTimeEncoded[5];
95  char durationEncoded[3];
96  unsigned char runningStatus;
97  unsigned char freeCAMode;
98  unsigned short descriptorsLoopLength;
99  vector<IMpegDescriptor*>* descriptors;
100  map<unsigned char, IMpegDescriptor*>* desc;
101 
102  /*attention: tm_mon represents month from 0(January) to 11(December).
103  * the print function is printing month in 1(jan) to 12(dec)*/
104  struct tm startTime;
105  struct tm duration;
106  struct tm endTime;
107 
108  public:
109  EventInfo();
110  ~EventInfo();
111  void setStartTime(char* date);
112  void setDuration(char* dur);
113  struct tm calcEndTime(struct tm start, struct tm end);
114 
115  time_t getStartTimeSecs();
116  time_t getEndTimeSecs();
117  unsigned int getDurationSecs();
118 
119  virtual string getStartTimeSecsStr();
120  virtual string getEndTimeSecsStr();
121  virtual string getDurationSecsStr();
122 
123  struct tm getStartTime();
124  struct tm getDuration();
125  struct tm getEndTime();
126 
127  string getStartTimeEncoded();
128  string getDurationEncoded();
129  string getStartTimeStr();
130  string getEndTimeStr();
131  string getDurationStr();
132 
133  unsigned short getLength();
134  unsigned short getEventId();
135  string getRunningStatus();
136  string getRunningStatusDescription();
137  unsigned char getFreeCAMode();
138  unsigned short getDescriptorsLoopLength();
139 
140  vector<IMpegDescriptor*>* getDescriptors();
141  map<unsigned char, IMpegDescriptor*>* getDescriptorsMap();
142 
143  void print();
144  size_t process(char* data, size_t pos);
145 
146  protected:
147  int convertDecimaltoBCD(int dec);
148  int convertBCDtoDecimal(int bcd);
149  struct tm convertMJDtoUTC(unsigned int mjd);
150  int convertUTCtoMJD (int day, int month, int year);
151 
152  private:
153  string getFormatNumStr(int un);
154  //void clearDescriptors();
155 
156 
157  };
158 }
159 }
160 }
161 }
162 }
163 }
164 }
165 
166 #endif /*EVENTINFO_H_*/