vdr
1.7.27
|
00001 /*************************************************************************** 00002 * Copyright (c) 2003 by Marcel Wiesweg * 00003 * * 00004 * This program is free software; you can redistribute it and/or modify * 00005 * it under the terms of the GNU General Public License as published by * 00006 * the Free Software Foundation; either version 2 of the License, or * 00007 * (at your option) any later version. * 00008 * * 00009 * $Id: section.c 2.0 2006/04/14 10:53:44 kls Exp $ 00010 * * 00011 ***************************************************************************/ 00012 00013 #include "section.h" 00014 #include <stdio.h> 00015 00016 namespace SI { 00017 00018 /*********************** PAT ***********************/ 00019 00020 void PAT::Parse() { 00021 int offset=0; 00022 data.setPointerAndOffset<const pat>(s, offset); 00023 associationLoop.setData(data+offset, getLength()-offset-4); 00024 } 00025 00026 int PAT::getTransportStreamId() const { 00027 return HILO(s->transport_stream_id); 00028 } 00029 00030 int PAT::Association::getServiceId() const { 00031 return HILO(s->program_number); 00032 } 00033 00034 int PAT::Association::getPid() const { 00035 return HILO(s->network_pid); 00036 } 00037 00038 void PAT::Association::Parse() { 00039 s=data.getData<pat_prog>(); 00040 } 00041 00042 /*********************** CAT ***********************/ 00043 00044 void CAT::Parse() { 00045 loop.setData(data+sizeof(cat), getLength()-sizeof(cat)-4); 00046 } 00047 00048 /*********************** PMT ***********************/ 00049 00050 void PMT::Parse() { 00051 int offset=0; 00052 data.setPointerAndOffset<const pmt>(s, offset); 00053 commonDescriptors.setDataAndOffset(data+offset, HILO(s->program_info_length), offset); 00054 streamLoop.setData(data+offset, getLength()-offset-4); 00055 } 00056 00057 int PMT::getServiceId() const { 00058 return HILO(s->program_number); 00059 } 00060 00061 int PMT::getPCRPid() const { 00062 return HILO(s->PCR_PID); 00063 } 00064 00065 int PMT::Stream::getPid() const { 00066 return HILO(s->elementary_PID); 00067 } 00068 00069 int PMT::Stream::getStreamType() const { 00070 return s->stream_type; 00071 } 00072 00073 void PMT::Stream::Parse() { 00074 int offset=0; 00075 data.setPointerAndOffset<const pmt_info>(s, offset); 00076 streamDescriptors.setData(data+offset, HILO(s->ES_info_length)); 00077 } 00078 00079 /*********************** TSDT ***********************/ 00080 00081 void TSDT::Parse() { 00082 int offset=0; 00083 data.setPointerAndOffset<const tsdt>(s, offset); 00084 transportStreamDescriptors.setDataAndOffset(data+offset, getLength()-offset-4, offset); 00085 } 00086 00087 /*********************** NIT ***********************/ 00088 00089 int NIT::getNetworkId() const { 00090 return HILO(s->network_id); 00091 } 00092 00093 void NIT::Parse() { 00094 int offset=0; 00095 data.setPointerAndOffset<const nit>(s, offset); 00096 commonDescriptors.setDataAndOffset(data+offset, HILO(s->network_descriptor_length), offset); 00097 const nit_mid *mid; 00098 data.setPointerAndOffset<const nit_mid>(mid, offset); 00099 transportStreamLoop.setData(data+offset, HILO(mid->transport_stream_loop_length)); 00100 } 00101 00102 int NIT::TransportStream::getTransportStreamId() const { 00103 return HILO(s->transport_stream_id); 00104 } 00105 00106 int NIT::TransportStream::getOriginalNetworkId() const { 00107 return HILO(s->original_network_id); 00108 } 00109 00110 void NIT::TransportStream::Parse() { 00111 int offset=0; 00112 data.setPointerAndOffset<const ni_ts>(s, offset); 00113 transportStreamDescriptors.setData(data+offset, HILO(s->transport_descriptors_length)); 00114 } 00115 00116 /*********************** SDT ***********************/ 00117 00118 void SDT::Parse() { 00119 int offset=0; 00120 data.setPointerAndOffset<const sdt>(s, offset); 00121 serviceLoop.setData(data+offset, getLength()-offset-4); //4 is for CRC 00122 } 00123 00124 int SDT::getTransportStreamId() const { 00125 return HILO(s->transport_stream_id); 00126 } 00127 00128 int SDT::getOriginalNetworkId() const { 00129 return HILO(s->original_network_id); 00130 } 00131 00132 int SDT::Service::getServiceId() const { 00133 return HILO(s->service_id); 00134 } 00135 00136 int SDT::Service::getEITscheduleFlag() const { 00137 return s->eit_schedule_flag; 00138 } 00139 00140 int SDT::Service::getEITpresentFollowingFlag() const { 00141 return s->eit_present_following_flag; 00142 } 00143 00144 RunningStatus SDT::Service::getRunningStatus() const { 00145 return (RunningStatus)s->running_status; 00146 } 00147 00148 int SDT::Service::getFreeCaMode() const { 00149 return s->free_ca_mode; 00150 } 00151 00152 void SDT::Service::Parse() { 00153 int offset=0; 00154 data.setPointerAndOffset<const sdt_descr>(s, offset); 00155 serviceDescriptors.setData(data+offset, HILO(s->descriptors_loop_length)); 00156 } 00157 00158 /*********************** EIT ***********************/ 00159 00160 int EIT::getServiceId() const { 00161 return HILO(s->service_id); 00162 } 00163 00164 int EIT::getTransportStreamId() const { 00165 return HILO(s->transport_stream_id); 00166 } 00167 00168 int EIT::getOriginalNetworkId() const { 00169 return HILO(s->original_network_id); 00170 } 00171 00172 int EIT::getSegmentLastSectionNumber() const { 00173 return s->segment_last_section_number; 00174 } 00175 00176 int EIT::getLastTableId() const { 00177 return s->last_table_id; 00178 } 00179 00180 bool EIT::isPresentFollowing() const { 00181 return getTableId() == TableIdEIT_presentFollowing || getTableId() == TableIdEIT_presentFollowing_other; 00182 } 00183 00184 bool EIT::isActualTS() const { 00185 return 00186 (getTableId() ==TableIdEIT_presentFollowing) 00187 || (TableIdEIT_schedule_first <= getTableId() && getTableId() <= TableIdEIT_schedule_last); 00188 } 00189 00190 void EIT::Parse() { 00191 int offset=0; 00192 data.setPointerAndOffset<const eit>(s, offset); 00193 //printf("%d %d %d %d %d\n", getServiceId(), getTransportStreamId(), getOriginalNetworkId(), isPresentFollowing(), isActualTS()); 00194 eventLoop.setData(data+offset, getLength()-offset-4); //4 is for CRC 00195 } 00196 00197 time_t EIT::Event::getStartTime() const { 00198 return DVBTime::getTime(s->mjd_hi, s->mjd_lo, s->start_time_h, s->start_time_m, s->start_time_s); 00199 } 00200 00201 time_t EIT::Event::getDuration() const { 00202 return DVBTime::getDuration(s->duration_h, s->duration_m, s->duration_s); 00203 } 00204 00205 int EIT::Event::getEventId() const { 00206 return HILO(s->event_id); 00207 } 00208 00209 int EIT::Event::getMJD() const { 00210 return HILO(s->mjd); 00211 } 00212 00213 int EIT::Event::getStartTimeHour() const { 00214 return DVBTime::bcdToDec(s->start_time_h); 00215 } 00216 00217 int EIT::Event::getStartTimeMinute() const { 00218 return DVBTime::bcdToDec(s->start_time_m); 00219 } 00220 00221 int EIT::Event::getStartTimeSecond() const { 00222 return DVBTime::bcdToDec(s->start_time_s); 00223 } 00224 00225 int EIT::Event::getDurationHour() const { 00226 return DVBTime::bcdToDec(s->duration_h); 00227 } 00228 00229 int EIT::Event::getDurationMinute() const { 00230 return DVBTime::bcdToDec(s->duration_m); 00231 } 00232 00233 int EIT::Event::getDurationSecond() const { 00234 return DVBTime::bcdToDec(s->duration_s); 00235 } 00236 00237 RunningStatus EIT::Event::getRunningStatus() const { 00238 return (RunningStatus)s->running_status; 00239 } 00240 00241 int EIT::Event::getFreeCaMode() const { 00242 return s->free_ca_mode; 00243 } 00244 00245 void EIT::Event::Parse() { 00246 int offset=0; 00247 data.setPointerAndOffset<const eit_event>(s, offset); 00248 //printf("%d %d %d\n", getStartTime(), getDuration(), getRunningStatus()); 00249 eventDescriptors.setData(data+offset, HILO(s->descriptors_loop_length)); 00250 } 00251 00252 /*********************** TDT ***********************/ 00253 00254 time_t TDT::getTime() const { 00255 return DVBTime::getTime(s->utc_mjd_hi, s->utc_mjd_lo, s->utc_time_h, s->utc_time_m, s->utc_time_s); 00256 } 00257 00258 void TDT::Parse() { 00259 s=data.getData<const tdt>(); 00260 } 00261 00262 /*********************** TOT ***********************/ 00263 00264 time_t TOT::getTime() const { 00265 return DVBTime::getTime(s->utc_mjd_hi, s->utc_mjd_lo, s->utc_time_h, s->utc_time_m, s->utc_time_s); 00266 } 00267 00268 void TOT::Parse() { 00269 int offset=0; 00270 data.setPointerAndOffset<const tot>(s, offset); 00271 descriptorLoop.setData(data+offset, getLength()-offset-4); 00272 } 00273 00274 /*********************** RST ***********************/ 00275 00276 void RST::Parse() { 00277 int offset=0; 00278 const rst *s; 00279 data.setPointerAndOffset<const rst>(s, offset); 00280 infoLoop.setData(data+offset, getLength()-offset); 00281 } 00282 00283 int RST::RunningInfo::getTransportStreamId() const { 00284 return HILO(s->transport_stream_id); 00285 } 00286 00287 int RST::RunningInfo::getOriginalNetworkId() const { 00288 return HILO(s->original_network_id); 00289 } 00290 00291 int RST::RunningInfo::getServiceId() const { 00292 return HILO(s->service_id); 00293 } 00294 00295 int RST::RunningInfo::getEventId() const { 00296 return HILO(s->event_id); 00297 } 00298 00299 RunningStatus RST::RunningInfo::getRunningStatus() const { 00300 return (RunningStatus)s->running_status; 00301 } 00302 00303 void RST::RunningInfo::Parse() { 00304 s=data.getData<const rst_info>(); 00305 } 00306 00307 /*********************** AIT ***********************/ 00308 00309 int AIT::getApplicationType() const { 00310 return HILO(first->application_type); 00311 } 00312 00313 int AIT::getAITVersion() const { 00314 return first->version_number; 00315 } 00316 00317 void AIT::Parse() { 00318 int offset=0; 00319 data.setPointerAndOffset<const ait>(first, offset); 00320 commonDescriptors.setDataAndOffset(data+offset, HILO(first->common_descriptors_length), offset); 00321 const ait_mid *mid; 00322 data.setPointerAndOffset<const ait_mid>(mid, offset); 00323 applicationLoop.setData(data+offset, HILO(mid->application_loop_length)); 00324 } 00325 00326 long AIT::Application::getOrganisationId() const { 00327 return data.FourBytes(0); 00328 } 00329 00330 int AIT::Application::getApplicationId() const { 00331 return HILO(s->application_id); 00332 } 00333 00334 int AIT::Application::getControlCode() const { 00335 return s->application_control_code; 00336 } 00337 00338 void AIT::Application::Parse() { 00339 int offset=0; 00340 data.setPointerAndOffset<const ait_app>(s, offset); 00341 applicationDescriptors.setData(data+offset, HILO(s->application_descriptors_length)); 00342 } 00343 00344 /******************* PremiereCIT *******************/ 00345 00346 void PremiereCIT::Parse() { 00347 int offset=0; 00348 data.setPointerAndOffset<const pcit>(s, offset); 00349 eventDescriptors.setData(data+offset, HILO(s->descriptors_loop_length)); 00350 } 00351 00352 int PremiereCIT::getContentId() const { 00353 return (HILO(s->contentId_hi) << 16) | HILO(s->contentId_lo); 00354 } 00355 00356 time_t PremiereCIT::getDuration() const { 00357 return DVBTime::getDuration(s->duration_h, s->duration_m, s->duration_s); 00358 } 00359 00360 } //end of namespace