Ticket #2418: eitsupport-premiere-rewrite.diff
File eitsupport-premiere-rewrite.diff, 15.9 KB (added by , 17 years ago) |
---|
-
libs/libmythtv/eithelper.cpp
231 231 for (uint i = 0; i < eit->EventCount(); i++) 232 232 { 233 233 // Skip event if we have already processed it before... 234 if (!eitcache->IsNewEIT(networkid, tsid, serviceid, tableid, version, 235 eit->EventID(i), eit->EndTimeUnixUTC(i))) 234 // don't skip for Premiere EIT sid,tid are not known at this point 235 if ((tableid != TableID::PR_EIT) 236 && (!eitcache->IsNewEIT(networkid, tsid, serviceid, tableid, version, 237 eit->EventID(i), eit->EndTimeUnixUTC(i)))) 236 238 { 237 239 continue; 238 240 } … … 341 343 if (content_data) 342 344 { 343 345 ContentDescriptor content(content_data); 344 category = content.GetDescription(0); 345 category_type = content.GetMythCategory(0); 346 347 // fix events without real content data for Premiere EIT 348 if ((tableid == TableID::PR_EIT) && (content.Nibble(0)==0x00)){ 349 if(content.UserNibble(0)==0x1) 350 { 351 category_type = kCategoryMovie; 352 subtitle.length() < 2 ? category = QObject::tr("Movie") : category = subtitle; 353 } 354 else if(content.UserNibble(0)==0x0) 355 { 356 category_type = kCategorySports; 357 subtitle.length() < 2 ? category = QObject::tr("Sports") : category = subtitle; 358 } 359 } 360 else 361 { 362 category = content.GetDescription(0); 363 category_type = content.GetMythCategory(0); 364 } 346 365 } 347 366 348 uint chanid = GetChanID( 349 eit->ServiceID(), eit->OriginalNetworkID(), eit->TSID()); 367 if (tableid == TableID::PR_EIT) 368 { 369 // Find all transmission descriptors for this event 370 desc_list_t transmissions = 371 MPEGDescriptor::FindAll(list, DescriptorID::pr_event_transmission); 372 for(uint j=0; j<transmissions.size(); j++) 373 { 374 PremiereTransmissionDescriptor transmission(transmissions[j]); 375 uint descriptor_length = transmission.DescriptorLength(); 376 uint networkid = transmission.OriginalNetworkID(); 377 uint tsid = transmission.TSID(); 378 uint serviceid = transmission.ServiceID(); 379 380 uint chanid = GetChanID(serviceid, networkid, tsid); 381 382 if (!chanid) 383 { 384 VERBOSE(VB_GENERAL, LOC + QString("No channid for NIT:%1 TID:%2 SID:%3. Possible new feed channel or wrong eit data").arg(networkid).arg(tsid).arg(serviceid)); 385 continue; 386 } 350 387 351 if (!chanid) 352 continue; 388 uint pos = 0; 389 // find all transmissions for this event 390 while (pos<descriptor_length-6) 391 { 392 unsigned char startdate[5]; 393 memcpy(startdate, transmission.StartDate(pos), 2); 394 // get all start times on this day 395 for (uint k=0; k<transmission.TransmissionCount(pos); k+=3) 396 { 397 memcpy(&startdate[2], transmission.StartTime(pos+k), 3); 398 QDateTime starttime = MythUTCToLocal(dvbdate2qt(startdate)); 399 EITFixUp::TimeFix(starttime); 400 QDateTime endtime = starttime.addSecs(eit->DurationInSeconds(i)); 353 401 354 QDateTime starttime = MythUTCToLocal(eit->StartTimeUTC(i)); 355 EITFixUp::TimeFix(starttime); 356 QDateTime endtime = starttime.addSecs(eit->DurationInSeconds(i)); 402 DBEvent *event = new DBEvent(chanid, 403 title, subtitle, description, 404 category, category_type, 405 starttime, endtime, fix, 406 false, subtitled, 407 stereo, hdtv); 408 db_events.enqueue(event); 409 } 410 // set pos to next transmission 411 pos += 3 + transmission.TransmissionCount(pos); 412 } 413 } 414 } 415 else 416 { 417 uint chanid = GetChanID( 418 eit->ServiceID(), eit->OriginalNetworkID(), eit->TSID()); 357 419 358 DBEvent *event = new DBEvent(chanid, 359 title, subtitle, description, 360 category, category_type, 361 starttime, endtime, fix, 362 false, subtitled, 363 stereo, hdtv); 364 db_events.enqueue(event); 420 if (!chanid) 421 continue; 422 423 QDateTime starttime = MythUTCToLocal(eit->StartTimeUTC(i)); 424 EITFixUp::TimeFix(starttime); 425 QDateTime endtime = starttime.addSecs(eit->DurationInSeconds(i)); 426 427 DBEvent *event = new DBEvent(chanid, 428 title, subtitle, description, 429 category, category_type, 430 starttime, endtime, fix, 431 false, subtitled, 432 stereo, hdtv); 433 db_events.enqueue(event); 434 } 365 435 } 366 436 } 367 437 -
libs/libmythtv/eithelper.h
47 47 class EventInformationTable; 48 48 class ExtendedTextTable; 49 49 class DVBEventInformationTable; 50 class DVBPremiereEventInformationTable; 50 51 51 52 class EITHelper 52 53 { -
libs/libmythtv/mpeg/dvbtables.cpp
165 165 // Dish Network Long Term Future Event Information for all transports 166 166 is_eit |= (TableID::DN_EITbego <= table_id && 167 167 TableID::DN_EITendo >= table_id); 168 // Premiere Event Information for option channels 169 is_eit |= TableID::PR_EIT == table_id; 168 170 169 171 return is_eit; 170 172 } -
libs/libmythtv/mpeg/dvbstreamdata.cpp
137 137 is_eit |= (TableID::DN_EITbego <= table_id && 138 138 TableID::DN_EITendo >= table_id); 139 139 } 140 if (DVB_PR_SPORT_EIT_PID == pid || DVB_PR_DIRECT_EIT_PID == pid) 141 { 142 is_eit |= TableID::PR_EIT == table_id; 143 } 140 144 if (is_eit) 141 145 { 142 146 uint service_id = psip.TableIDExtension(); … … 292 296 return true; 293 297 } 294 298 299 if ((DVB_PR_SPORT_EIT_PID || DVB_PR_DIRECT_EIT_PID) && 300 DVBEventInformationTable::IsEIT(psip.TableID())) 301 { 302 QMutexLocker locker(&_listener_lock); 303 if (!_dvb_eit_listeners.size() && !_eit_helper) 304 return true; 305 306 uint service_id = psip.TableIDExtension(); 307 SetVersionEIT(psip.TableID(), service_id, psip.Version()); 308 SetEITSectionSeen(psip.TableID(), service_id, psip.Section()); 309 310 DVBPremiereEventInformationTable eit(psip); 311 for (uint i = 0; i < _dvb_eit_listeners.size(); i++) 312 _dvb_eit_listeners[i]->HandleEIT(&eit); 313 314 if (_eit_helper) 315 _eit_helper->AddEIT(&eit); 316 317 return true; 318 } 319 295 320 return false; 296 321 } 297 322 … … 337 362 { 338 363 add_pids.push_back(DVB_DNLONG_EIT_PID); 339 364 } 365 if (find(cur_pids.begin(), cur_pids.end(), 366 (uint) DVB_PR_SPORT_EIT_PID) == cur_pids.end()) 367 { 368 add_pids.push_back(DVB_PR_SPORT_EIT_PID); 369 } 370 if (find(cur_pids.begin(), cur_pids.end(), 371 (uint) DVB_PR_DIRECT_EIT_PID) == cur_pids.end()) 372 { 373 add_pids.push_back(DVB_PR_DIRECT_EIT_PID); 374 } 340 375 } 341 376 else 342 377 { … … 352 387 { 353 388 del_pids.push_back(DVB_DNLONG_EIT_PID); 354 389 } 390 if (find(cur_pids.begin(), cur_pids.end(), 391 (uint) DVB_PR_SPORT_EIT_PID) != cur_pids.end()) 392 { 393 del_pids.push_back(DVB_PR_SPORT_EIT_PID); 394 } 395 if (find(cur_pids.begin(), cur_pids.end(), 396 (uint) DVB_PR_DIRECT_EIT_PID) != cur_pids.end()) 397 { 398 del_pids.push_back(DVB_PR_DIRECT_EIT_PID); 399 } 355 400 } 356 401 357 402 return add_pids.size() || del_pids.size(); -
libs/libmythtv/mpeg/mpegtables.h
186 186 // Dishnet longterm EIT is on pid 0x300 187 187 DVB_DNLONG_EIT_PID = 0x0300, 188 188 189 // Premiere EIT for Direct/Sport PPV 190 DVB_PR_DIRECT_EIT_PID = 0x0b11, 191 DVB_PR_SPORT_EIT_PID = 0x0b12, 192 189 193 ATSC_PSIP_PID = 0x1ffb, 190 194 }; 191 195 … … 231 235 // Dishnet Longterm EIT data 232 236 DN_EITbego = 0x80, // always on pid 0x300 233 237 DN_EITendo = 0xfe, // always on pid 0x300 238 239 // Premiere Eit for Direct and Sport 240 PR_EIT = 0xA0, 234 241 235 242 // ATSC 236 243 STUFFING = 0x80, -
libs/libmythtv/mpeg/dvbdescriptors.h
1651 1651 QString toString() const { return QString("UKChannelListDescriptor(stub)"); } 1652 1652 }; 1653 1653 1654 class PremiereTransmissionDescriptor : public MPEGDescriptor 1655 { 1656 public: 1657 PremiereTransmissionDescriptor(const unsigned char* data) : MPEGDescriptor(data) 1658 { 1659 // Name bits loc expected value 1660 // descriptor_tag 8 0.0 0xF2 1661 assert(DescriptorID::pr_event_transmission == DescriptorTag()); 1662 // descriptor_length 8 1.0 1663 } 1664 1665 // transport id 16 2.0 1666 uint TSID() const 1667 { return (_data[2] << 8) | _data[3]; } 1668 // network id 16 4.0 1669 uint OriginalNetworkID() const 1670 { return (_data[4] << 8) | _data[5]; } 1671 // service id 16 6.0 1672 uint ServiceID() const 1673 { return (_data[6] << 8) | _data[7]; } 1674 1675 // for(i=0;i<N;i+=2+1+count) 1676 // start date 16 8.0 1677 const unsigned char* StartDate(uint i) const 1678 { return &_data[8 + i]; } 1679 // transmission count 8 10.0 1680 uint TransmissionCount(uint i) const 1681 { return (_data[10 + i]); } 1682 // start_time 24 11.0+x 1683 const unsigned char* StartTime(uint i) const 1684 { return &_data[11 + i]; } 1685 1686 QString toString() const { return QString("TransmissionDescriptor(stub)"); } 1687 }; 1688 1689 1654 1690 #endif -
libs/libmythtv/mpeg/dvbtables.h
219 219 // last_section_number 8 7.0 220 220 Parse(); 221 221 } 222 virtual ~DVBEventInformationTable(){} 222 223 223 224 // service_id 16 3.0 224 uint ServiceID(void) const { return TableIDExtension(); }225 virtual uint ServiceID(void) const { return TableIDExtension(); } 225 226 226 227 // transport_stream_id 16 8.0 227 uint TSID(void) const228 virtual uint TSID(void) const 228 229 { return (psipdata()[0]<<8) | psipdata()[1]; } 229 230 230 231 // original_network_id 16 10.0 231 uint OriginalNetworkID(void) const232 virtual uint OriginalNetworkID(void) const 232 233 { return (psipdata()[2]<<8) | psipdata()[3]; } 233 234 234 235 // segment_last_section_num 8 12.0 … … 238 239 uint LastTableID(void) const 239 240 { return psipdata()[5]; } 240 241 241 uint EventCount() const { return _ptrs.size()-1; }242 virtual uint EventCount() const { return _ptrs.size()-1; } 242 243 243 244 // for(i=0;i<N;i++) { 244 245 // event_id 16 0.0+x … … 258 259 // duration 24 7.0+x 259 260 const unsigned char *Duration(uint i) const 260 261 { return _ptrs[i]+7; } 261 uint DurationInSeconds(uint i) const262 virtual uint DurationInSeconds(uint i) const 262 263 { 263 264 return ((byteBCD2int(Duration(i)[0]) * 3600) + 264 265 (byteBCD2int(Duration(i)[1]) * 60) + … … 269 270 // free_CA_mode 1 10.3+x 270 271 bool IsScrambled(uint i) const { return bool(_ptrs[i][10] & 0x10); } 271 272 // descriptors_loop_len 12 10.4+x 272 uint DescriptorsLength(uint i) const273 virtual uint DescriptorsLength(uint i) const 273 274 { return ((_ptrs[i][10]<<8) | (_ptrs[i][11])) & 0xfff; } 274 275 // for(i=0;i<N;i++) y 12.0+x 275 276 // { descriptor() } 276 const unsigned char* Descriptors(uint i) const277 virtual const unsigned char* Descriptors(uint i) const 277 278 { return _ptrs[i] + 12; } 278 279 // } 279 280 //CRC_32 32 rpchof 280 281 281 v oid Parse(void) const;282 virtual void Parse(void) const; 282 283 283 284 static bool IsEIT(uint table_id); 284 285 … … 286 287 mutable vector<const unsigned char*> _ptrs; // used to parse 287 288 }; 288 289 290 class DVBPremiereEventInformationTable : public DVBEventInformationTable 291 { 292 public: 293 DVBPremiereEventInformationTable(const DVBEventInformationTable& table) : DVBEventInformationTable(table) 294 { 295 // table_id 8 0.0 0xA0 296 assert(IsEIT(TableID())); 297 // section_syntax_indicator 1 1.0 1 298 // private_indicator 1 1.1 1 299 // reserved 2 1.2 3 300 // section_length 12 1.4 301 // reserved 2 5.0 3 302 // version_number 5 5.2 303 // current_next_indicator 1 5.7 1 304 // section_number 8 6.0 305 // last_section_number 8 7.0 306 Parse(); 307 } 308 ~DVBPremiereEventInformationTable(){} 289 309 310 // content_id 32 0.0 311 uint ContentID(void) const 312 { return (psipdata()[0]<<24) | (psipdata()[1]<<16) | (psipdata()[2]<<8) | psipdata()[3]; } 313 314 // return dummy values for compatitbility 315 uint ServiceID(void) const { return 18; } 316 uint OriginalNetworkID(void) const { return 133; } 317 uint TSID(void) const { return 4; } 318 uint EventCount(void) const { return 1; } 319 320 // event_duration 24 4.0 321 uint DurationInSeconds(uint i) const 322 { return ((byteBCD2int(psipdata()[4]) * 3600) + 323 (byteBCD2int(psipdata()[5]) * 60) + 324 (byteBCD2int(psipdata()[6]))); } 325 326 // descriptor length 7 8.0 327 uint DescriptorsLength(uint i) const 328 { return ((psipdata()[7] & 0x0F) << 8) | psipdata()[8]; } 329 330 // descriptor length x 9.0 331 const unsigned char* Descriptors(uint i) const 332 { return &psipdata()[9]; } 333 334 void Parse(void) const {}; 335 }; 290 336 #endif // _DVB_TABLES_H_ -
libs/libmythtv/mpeg/mpegdescriptors.h
129 129 DCC_arriving_request = 0xA9, 130 130 DRM_control = 0xAA, 131 131 atsc_content_identifier = 0xB6, 132 133 // PREMIERE 134 pr_event_transmission = 0xF2, 132 135 }; 133 136 }; 134 137