Debian Codegraph @

src/lib/tsreader/PidTable.cpp

raw
1 /*
2 * Copyright (C) 2006-2009 Team MediaPortal
3 * http://www.team-mediaportal.com
4 *
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
8 * any later version.
9 *
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with GNU Make; see the file COPYING. If not, write to
17 * the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
18 * MA 02110-1335 USA
19 * http://www.gnu.org/copyleft/gpl.html
20 *
21 */
22
23 #include "PidTable.h"
24 #include <kodi/General.h> //for kodi::Log
25 #include "utils.h"
26
27 namespace MPTV
28 {
29 CPidTable::CPidTable(const CPidTable& pids)
30 {
31 Copy(pids);
32 }
33
34
35 CPidTable::CPidTable(void)
36 {
37 Reset();
38 }
39
40
41 CPidTable::~CPidTable(void)
42 {
43 }
44
45
46 bool CPidTable::operator ==(const CPidTable& other) const
47 {
48 // Not all members are compared, this is how DeMultiplexer class has
49 // been comparing "PMTs" to detect channel changes.
50 if (subtitlePids != other.subtitlePids
51 || audioPids != other.audioPids
52 || videoPids != other.videoPids
53 || PcrPid != other.PcrPid
54 || PmtPid != other.PmtPid)
55 {
56 return false;
57 }
58 else
59 {
60 return true;
61 }
62 }
63
64
65 void CPidTable::Reset()
66 {
67 //kodi::Log(ADDON_LOG_DEBUG, "Pid table reset");
68 PcrPid = 0;
69 PmtPid = 0;
70 ServiceId = -1;
71
72 videoPids.clear();
73 audioPids.clear();
74 subtitlePids.clear();
75
76 TeletextPid = 0;
77 // no reason to reset TeletextSubLang
78 }
79
80
81 CPidTable& CPidTable::operator = (const CPidTable &pids)
82 {
83 if (&pids == this)
84 {
85 return *this;
86 }
87 Copy(pids);
88 return *this;
89 }
90
91
92 void CPidTable::Copy(const CPidTable &pids)
93 {
94 //kodi::Log(ADDON_LOG_DEBUG, "Pid table copy");
95 ServiceId = pids.ServiceId;
96
97 PcrPid = pids.PcrPid;
98 PmtPid = pids.PmtPid;
99
100 videoPids = pids.videoPids;
101 audioPids = pids.audioPids;
102 subtitlePids = pids.subtitlePids;
103
104 TeletextPid = pids.TeletextPid;
105 //TeletextInfo=pids.TeletextInfo;
106 }
107
108
109 bool CPidTable::HasTeletextPageInfo(int UNUSED(page))
110 { //MG: todo
111 //std::vector<TeletextServiceInfo>::iterator vit = TeletextInfo.begin();
112 //while(vit != TeletextInfo.end())
113 //{ // is the page already registrered
114 // TeletextServiceInfo& info = *vit;
115 // if(info.page == page)
116 // {
117 // return true;
118 // break;
119 // }
120 // else vit++;
121 //}
122 return false;
123 }
124
125 void CPidTable::LogPIDs()
126 {
127 kodi::Log(ADDON_LOG_DEBUG, " pcr pid: %4x ", PcrPid);
128 kodi::Log(ADDON_LOG_DEBUG, " pmt pid: %4x ", PmtPid);
129
130 // Log all video streams (Blu-ray can have multiple video streams)
131 for (unsigned int i(0); i < videoPids.size(); i++)
132 {
133 kodi::Log(ADDON_LOG_DEBUG, " video pid: %4x type: %s",
134 videoPids[i].Pid,
135 StreamFormatAsString(videoPids[i].VideoServiceType));
136 }
137
138 // Log all audio streams
139 for (unsigned int i(0); i < audioPids.size(); i++)
140 {
141 kodi::Log(ADDON_LOG_DEBUG, " audio pid: %4x language: %3s type: %s",
142 audioPids[i].Pid,
143 audioPids[i].Lang,
144 StreamFormatAsString(audioPids[i].AudioServiceType));
145 }
146
147 // Log all subtitle streams
148 for (unsigned int i(0); i < subtitlePids.size(); i++)
149 {
150 kodi::Log(ADDON_LOG_DEBUG, " Subtitle pid: %4x language: %3s type: %s",
151 subtitlePids[i].Pid,
152 subtitlePids[i].Lang,
153 StreamFormatAsString(subtitlePids[i].SubtitleServiceType));
154 }
155 }
156
157
158 const char* CPidTable::StreamFormatAsString(int streamType)
159 {
160 switch (streamType)
161 {
162 case 0x01:
163 return "MPEG1";
164 case 0x02:
165 return "MPEG2";
166 case 0x03:
167 return "MPEG1 - audio";
168 case 0x04:
169 return "MPEG2 - audio";
170 case 0x05:
171 return "DVB subtitle 1";
172 case 0x06:
173 return "DVB subtitle 2";
174 case 0x10:
175 return "MPEG4";
176 case 0x1B:
177 return "H264";
178 case 0xEA:
179 return "VC1";
180 case 0x80:
181 return "LPCM";
182 case 0x81:
183 return "AC3";
184 case 0x82:
185 return "DTS";
186 case 0x83:
187 return "MLP";
188 case 0x84:
189 return "DD+";
190 case 0x85:
191 return "DTS-HD";
192 case 0x86:
193 return "DTS-HD Master Audio";
194 case 0x0f:
195 return "AAC";
196 case 0x11:
197 return "LATM AAC";
198 case 0xA1:
199 return "DD+";
200 case 0xA2:
201 return "DTS-HD";
202 case 0x90:
203 return "PGS";
204 case 0x91:
205 return "IG";
206 case 0x92:
207 return "Text";
208 default:
209 return "Unknown";
210 }
211 }
212 }