Ticket #4308: eit_component_parsing.diff
File eit_component_parsing.diff, 25.2 KB (added by , 16 years ago) |
---|
-
libs/libmythtv/eit.cpp
old new 11 11 #include "mythdbcon.h" 12 12 #include "eit.h" 13 13 #include "dvbdescriptors.h" 14 #include "programinfo.h" // for subtitle types and audio and video properties 14 15 15 16 DBPerson::DBPerson(Role _role, const QString &_name) : 16 17 role(_role), name(QDeepCopy<QString>(_name)) … … 132 133 "SELECT title, subtitle, description, " 133 134 " category, category_type, " 134 135 " starttime, endtime, " 135 " closecaptioned, subtitled,stereo, hdtv, "136 " closecaptioned, stereo, hdtv, " 136 137 " partnumber, parttotal, " 137 138 " syndicatedepisodenumber, " 138 139 " airdate, originalairdate, " … … 167 168 category_type, 168 169 query.value(5).toDateTime(), query.value(6).toDateTime(), 169 170 fixup, 170 query.value(7).toBool(), query.value(8).toBool(), 171 query.value(9).toBool(), query.value(10).toBool(), 172 QString::fromUtf8(query.value(16).toString()), 173 QString::fromUtf8(query.value(17).toString()) 171 query.value(7).toUInt(), 172 query.value(8).toUInt(), 173 query.value(9).toUInt(), 174 QString::fromUtf8(query.value(15).toString()), 175 QString::fromUtf8(query.value(16).toString()) 174 176 ); 175 177 176 prog.partnumber = query.value(1 1).toUInt();177 prog.parttotal = query.value(1 2).toUInt();178 prog.partnumber = query.value(10).toUInt(); 179 prog.parttotal = query.value(11).toUInt(); 178 180 prog.syndicatedepisodenumber = 179 QString::fromUtf8(query.value(1 3).toString());180 prog.airdate = query.value(1 4).toString();181 prog.originalairdate = query.value(1 5).toDate();181 QString::fromUtf8(query.value(12).toString()); 182 prog.airdate = query.value(13).toString(); 183 prog.originalairdate = query.value(14).toDate(); 182 184 183 prog.previouslyshown = query.value(1 6).toBool();185 prog.previouslyshown = query.value(17).toBool(); 184 186 185 187 programs.push_back(prog); 186 188 count++; … … 326 328 327 329 QString lcattype = myth_category_type_to_string(tmp); 328 330 329 bool lcc = IsCaptioned() | match.IsCaptioned(); 330 bool lstereo = IsStereo() | match.IsStereo(); 331 bool lsubtitled = IsSubtitled() | match.IsSubtitled(); 332 bool lhdtv = IsHDTV() | match.IsHDTV(); 331 unsigned char lsubtype = subtitleType | match.subtitleType; 332 unsigned char laudio = audioProps | match.audioProps; 333 unsigned char lvideo = videoProps | match.videoProps; 333 334 334 335 uint lpartnumber = 335 336 (!partnumber && match.partnumber) ? match.partnumber : partnumber; … … 349 350 " description = :DESC, " 350 351 " category = :CAT, category_type = :CATTYPE, " 351 352 " starttime = :STARTTIME, endtime = :ENDTIME, " 352 " closecaptioned = :CC, subtitled = :SUBTITLED,"353 " closecaptioned = :CC, " 353 354 " stereo = :STEREO, hdtv = :HDTV, " 354 355 " partnumber = :PARTNO, parttotal = :PARTTOTAL, " 355 356 " syndicatedepisodenumber = :SYNDICATENO, " … … 369 370 query.bindValue(":CATTYPE", lcattype.utf8()); 370 371 query.bindValue(":STARTTIME", starttime); 371 372 query.bindValue(":ENDTIME", endtime); 372 query.bindValue(":CC", lcc); 373 query.bindValue(":SUBTITLED", lsubtitled); 374 query.bindValue(":STEREO", lstereo); 375 query.bindValue(":HDTV", lhdtv); 373 query.bindValue(":CC", lsubtype); 374 query.bindValue(":STEREO", laudio); 375 query.bindValue(":HDTV", lvideo); 376 376 query.bindValue(":PARTNO", lpartnumber); 377 377 query.bindValue(":PARTTOTAL", lparttotal); 378 378 query.bindValue(":SYNDICATENO", lsyndicatedepisodenumber.utf8()); … … 504 504 " chanid, title, subtitle, description, " 505 505 " category, category_type, " 506 506 " starttime, endtime, " 507 " closecaptioned, subtitled,stereo, hdtv, "507 " closecaptioned, stereo, hdtv, " 508 508 " partnumber, parttotal, " 509 509 " syndicatedepisodenumber, " 510 510 " airdate, originalairdate,listingsource, " … … 513 513 " :CHANID, :TITLE, :SUBTITLE, :DESCRIPTION, " 514 514 " :CATEGORY, :CATTYPE, " 515 515 " :STARTTIME, :ENDTIME, " 516 " :CC, :S UBTITLED, :STEREO, :HDTV, "516 " :CC, :STEREO, :HDTV, " 517 517 " :PARTNUMBER, :PARTTOTAL, " 518 518 " :SYNDICATENO, " 519 519 " :AIRDATE, :ORIGAIRDATE, :LSOURCE, " … … 529 529 query.bindValue(":CATTYPE", cattype.utf8()); 530 530 query.bindValue(":STARTTIME", starttime); 531 531 query.bindValue(":ENDTIME", endtime); 532 query.bindValue(":CC", IsCaptioned()); 533 query.bindValue(":SUBTITLED", IsSubtitled()); 534 query.bindValue(":STEREO", IsStereo()); 535 query.bindValue(":HDTV", IsHDTV()); 532 query.bindValue(":CC", subtitleType); 533 query.bindValue(":STEREO", audioProps); 534 query.bindValue(":HDTV", videoProps); 536 535 query.bindValue(":PARTNUMBER", partnumber); 537 536 query.bindValue(":PARTTOTAL", parttotal); 538 537 query.bindValue(":SYNDICATENO", syndicatedepisodenumber.utf8()); -
libs/libmythtv/eit.h
old new 58 58 const QString &_category, uint _category_type, 59 59 const QDateTime &_start, const QDateTime &_end, 60 60 uint _fixup, 61 bool _captioned, bool _subtitled, 62 bool _stereo, bool _hdtv, 61 unsigned char _subtitleType, 62 unsigned char _audioProps, 63 unsigned char _videoProps, 63 64 const QString &_seriesId, const QString &_programId) : 64 65 title(_title), subtitle(_subtitle), 65 66 description(_desc), … … 70 71 chanid(_chanid), 71 72 partnumber(0), parttotal(0), 72 73 syndicatedepisodenumber(QString::null), 73 fixup(_fixup), flags(0), 74 fixup(_fixup), 75 subtitleType(_subtitleType), 76 audioProps(_audioProps), videoProps(_videoProps), 74 77 category_type(_category_type), 75 78 seriesId(_seriesId), 76 79 programId(_programId), 77 80 previouslyshown(false) 78 81 { 79 flags |= (_captioned) ? kCaptioned : 0;80 flags |= (_subtitled) ? kSubtitled : 0;81 flags |= (_stereo) ? kStereo : 0;82 flags |= (_hdtv) ? kHDTV : 0;83 82 } 84 83 85 84 DBEvent(uint _chanid, 86 85 const QString &_title, const QString &_desc, 87 86 const QDateTime &_start, const QDateTime &_end, 88 87 uint _fixup, 89 bool _captioned, bool _stereo) : 88 unsigned char _subtitleType, 89 unsigned char _audioProps, 90 unsigned char _videoProps) : 90 91 title(_title), subtitle(QString::null), 91 92 description(_desc), 92 93 category(QString::null), … … 96 97 chanid(_chanid), 97 98 partnumber(0), parttotal(0), 98 99 syndicatedepisodenumber(QString::null), 99 fixup(_fixup), flags(0), 100 fixup(_fixup), 101 subtitleType(_subtitleType), 102 audioProps(_audioProps), videoProps(_videoProps), 100 103 category_type(0/*kCategoryNone*/), previouslyshown(false) 101 104 { 102 flags |= (_captioned) ? kCaptioned : 0;103 flags |= (_stereo) ? kStereo : 0;104 105 } 105 106 106 107 ~DBEvent() { if (credits) delete credits; } … … 109 110 110 111 uint UpdateDB(MSqlQuery &query, int match_threshold) const; 111 112 112 bool IsCaptioned(void) const { return flags & kCaptioned; }113 bool IsSubtitled(void) const { return flags & kSubtitled; }114 bool IsStereo(void) const { return flags & kStereo; }115 bool IsHDTV(void) const { return flags & kHDTV; }116 113 bool HasCredits(void) const { return credits; } 117 114 118 115 private: … … 139 136 uint16_t parttotal; 140 137 QString syndicatedepisodenumber; 141 138 uint32_t fixup; 142 unsigned char flags; 139 unsigned char subtitleType; 140 unsigned char audioProps; 141 unsigned char videoProps; 143 142 unsigned char category_type; 144 143 QString seriesId; 145 144 QString programId; 146 145 bool previouslyshown; 147 148 static const unsigned char kCaptioned = 0x1;149 static const unsigned char kSubtitled = 0x2;150 static const unsigned char kStereo = 0x4;151 static const unsigned char kHDTV = 0x8;152 146 }; 153 147 154 148 #endif // _EIT_H_ -
libs/libmythtv/eithelper.cpp
old new 19 19 #include "dishdescriptors.h" 20 20 #include "premieredescriptors.h" 21 21 #include "util.h" 22 #include "programinfo.h" // for subtitle types and audio and video properties 22 23 23 24 const uint EITHelper::kChunkSize = 20; 24 25 EITCache *EITHelper::eitcache = new EITCache(); … … 279 280 } 280 281 281 282 static inline void parse_dvb_component_descriptors(desc_list_t list, 282 bool &hdtv,283 bool &stereo,284 bool &subtitled)283 unsigned char &subtitle_type, 284 unsigned char &audio_properties, 285 unsigned char &video_properties) 285 286 { 286 287 desc_list_t components = 287 288 MPEGDescriptor::FindAll(list, DescriptorID::component); 288 289 for (uint j = 0; j < components.size(); j++) 289 290 { 290 291 ComponentDescriptor component(components[j]); 291 hdtv |= component.IsHDTV();292 stereo |= component.IsStereo();293 subtitle d |= component.IsReallySubtitled();292 video_properties |= component.VideoProperties(); 293 audio_properties |= component.AudioProperties(); 294 subtitle_type |= component.SubtitleType(); 294 295 } 295 296 } 296 297 … … 327 328 QString description = QString::null; 328 329 QString category = QString::null; 329 330 MythCategoryType category_type = kCategoryNone; 330 bool hdtv = false, stereo = false, subtitled = false;331 unsigned char subtitle_type, audio_props, video_props; 331 332 332 333 // Parse descriptors 333 334 desc_list_t list = MPEGDescriptor::Parse( … … 358 359 title, subtitle, description); 359 360 } 360 361 361 parse_dvb_component_descriptors(list, hdtv, stereo, subtitled); 362 parse_dvb_component_descriptors(list, subtitle_type, audio_props, 363 video_props); 362 364 363 365 const unsigned char *content_data = 364 366 MPEGDescriptor::Find(list, DescriptorID::content); … … 395 397 title, subtitle, description, 396 398 category, category_type, 397 399 starttime, endtime, fix, 398 false, subtitled, 399 stereo, hdtv, 400 subtitle_type, 401 audio_props, 402 video_props, 400 403 seriesId, programId); 401 404 db_events.enqueue(event); 402 405 } … … 415 418 QString description = QString::null; 416 419 QString category = QString::null; 417 420 MythCategoryType category_type = kCategoryNone; 418 bool hdtv = false, stereo = false, subtitled = false;421 unsigned char subtitle_type, audio_props, video_props; 419 422 420 423 // Parse descriptors 421 424 desc_list_t list = MPEGDescriptor::Parse( … … 424 427 parse_dvb_event_descriptors(list, fix, languagePreferences, 425 428 title, subtitle, description); 426 429 427 parse_dvb_component_descriptors(list, hdtv, stereo, subtitled); 430 parse_dvb_component_descriptors(list, subtitle_type, audio_props, 431 video_props); 428 432 429 433 const unsigned char *content_data = 430 434 MPEGDescriptor::Find(list, DescriptorID::content); … … 495 499 title, subtitle, description, 496 500 category, category_type, 497 501 starttime, endtime, fix, 498 false, subtitled, 499 stereo, hdtv, 502 subtitle_type, 503 audio_props, 504 video_props, 500 505 "", ""); 501 506 db_events.enqueue(event); 502 507 } … … 547 552 QDateTime endtime = starttime.addSecs(event.length); 548 553 549 554 desc_list_t list = MPEGDescriptor::Parse(event.desc, event.desc_length); 550 bool captioned = MPEGDescriptor::Find(list, DescriptorID::caption_service); 551 bool stereo = false; 555 unsigned char subtitle_type = 556 MPEGDescriptor::Find(list, DescriptorID::caption_service) ? 557 SUB_HARDHEAR : SUB_UNKNOWN; 558 unsigned char audio_properties = AUD_UNKNOWN; 559 unsigned char video_properties = VID_UNKNOWN; 552 560 553 561 uint atsc_key = (atsc_major << 16) | atsc_minor; 554 562 … … 556 564 db_events.enqueue(new DBEvent(chanid, QDeepCopy<QString>(event.title), 557 565 QDeepCopy<QString>(ett), 558 566 starttime, endtime, 559 fixup[atsc_key], captioned, stereo)); 567 fixup[atsc_key], subtitle_type, 568 audio_properties, video_properties)); 560 569 } 561 570 562 571 uint EITHelper::GetChanID(uint atsc_major, uint atsc_minor) -
libs/libmythtv/mpeg/dvbdescriptors.h
old new 10 10 #include <qstring.h> 11 11 #include "mythcontext.h" 12 12 #include "mpegdescriptors.h" 13 #include "../programinfo.h" // for subtitle types and audio and video properties 13 14 14 15 using namespace std; 15 16 … … 333 334 // 334 335 // for (i=0; i<N; i++) { text_char 8 } 335 336 336 bool IsVideo(void) const { return 0x1 == StreamContent(); } 337 bool IsAudio(void) const { return 0x2 == StreamContent(); } 337 bool IsVideo(void) const 338 { 339 return 0x1 == StreamContent() || 340 0x5 == StreamContent(); 341 } 342 bool IsAudio(void) const 343 { 344 switch(StreamContent()) 345 { 346 case 0x02: 347 case 0x04: 348 case 0x06: 349 case 0x07: 350 return true; 351 default: 352 return false; 353 } 354 } 338 355 bool IsSubtitle(void) const { return 0x3 == StreamContent(); } 339 356 340 bool IsHDTV(void) const357 unsigned char VideoProperties(void) const 341 358 { 342 return IsVideo() && 0x9 <= ComponentType() && ComponentType() <= 0x10; 359 if (0x1 == StreamContent()) 360 return MPEG2Properties(); 361 if (0x5 == StreamContent()) 362 return VID_AVC || AVCProperties(); 363 364 return VID_UNKNOWN; 343 365 } 344 366 345 bool IsStereo(void) const367 unsigned char MPEG2Properties(void) const 346 368 { 347 return IsAudio() && 348 ((0x3 == ComponentType()) || (0x5 == ComponentType())); 369 switch(ComponentType()) 370 { 371 case 0x2 ... 0x4: 372 case 0x6 ... 0x8: 373 return VID_WIDESCREEN; 374 case 0x09: 375 case 0x0D: 376 return VID_HDTV; 377 case 0x0A ... 0x0C: 378 case 0x0E ... 0x10: 379 return VID_WIDESCREEN | VID_HDTV; 380 default: 381 return VID_UNKNOWN; 382 } 349 383 } 350 384 351 bool IsReallySubtitled(void) const 385 unsigned char AVCProperties(void) const 386 { 387 switch(ComponentType()) 388 { 389 case 0x3 ... 0x4: 390 case 0x7 ... 0x8: 391 return VID_WIDESCREEN; 392 case 0x0B ... 0x0C: 393 case 0x0F ... 0x10: 394 return VID_WIDESCREEN | VID_HDTV; 395 default: 396 return VID_UNKNOWN; 397 } 398 } 399 400 unsigned char AudioProperties(void) const 401 { 402 switch (StreamContent()) 403 { 404 case 0x2: 405 return MP2Properties(); 406 case 0x04: 407 return AC3Properties(); 408 case 0x06: 409 return HEAACProperties(); 410 default: 411 return AUD_UNKNOWN; 412 } 413 } 414 415 unsigned char MP2Properties(void) const 416 { 417 switch (ComponentType()) 418 { 419 case 0x1: 420 return AUD_MONO; 421 case 0x3: 422 return AUD_STEREO; 423 case 0x5: 424 return AUD_SURROUND; 425 case 0x40: 426 return AUD_VISUALIMPAIR; 427 case 0x41: 428 return AUD_HARDHEAR; 429 default: 430 return AUD_UNKNOWN; 431 } 432 } 433 434 unsigned char AC3Properties(void) const 435 { 436 unsigned char properties = AUD_UNKNOWN; 437 438 switch (ComponentType() & 0x7) 439 { 440 case 0x0: 441 properties |= AUD_MONO; 442 break; 443 case 0x2: 444 properties |= AUD_STEREO; 445 break; 446 case 0x3: 447 properties |= AUD_DOLBY; 448 break; 449 case 0x4 ... 0x5: 450 properties |= AUD_SURROUND; 451 break; 452 } 453 454 if ((ComponentType() >> 3) & 0x7 == 0x2) 455 properties |= AUD_VISUALIMPAIR; 456 457 if ((ComponentType() >> 3) & 0x7 == 0x3) 458 properties |= AUD_HARDHEAR; 459 460 return properties; 461 } 462 463 unsigned char HEAACProperties(void) const 464 { 465 switch (ComponentType()) 466 { 467 case 0x1: 468 return AUD_MONO; 469 case 0x3: 470 case 0x43: 471 return AUD_STEREO; 472 case 0x5: 473 return AUD_SURROUND; 474 case 0x40: 475 case 0x44: 476 return AUD_VISUALIMPAIR; 477 case 0x41: 478 case 0x45: 479 return AUD_HARDHEAR; 480 default: 481 return AUD_UNKNOWN; 482 } 483 } 484 485 unsigned char SubtitleType(void) const 352 486 { 353 487 if (!IsSubtitle()) 354 return false; 488 return SUB_UNKNOWN; 489 355 490 switch (ComponentType()) 356 491 { 357 492 case 0x1: 358 493 case 0x3: 359 494 case 0x10 ... 0x13: 495 return SUB_NORMAL; 360 496 case 0x20 ... 0x23: 361 return true;497 return SUB_HARDHEAR; 362 498 default: 363 return false;499 return SUB_UNKNOWN; 364 500 } 365 501 } 366 502 367 QString toString() const { return QString("ComponentDescriptor(stub)"); } 503 QString toString() const { return QString("ComponentDescriptor(stream_content: 0x%1, " 504 "component_type: 0x%2)").arg(StreamContent(), 0, 16) 505 .arg(ComponentType(), 0, 16); } 368 506 }; 369 507 370 508 typedef enum -
libs/libmythtv/programinfo.h
old new 62 62 AUD_STEREO = 0x01, 63 63 AUD_MONO = 0x02, 64 64 AUD_SURROUND = 0x04, 65 AUD_DOLBY = 0x08 65 AUD_DOLBY = 0x08, 66 AUD_HARDHEAR = 0x10, 67 AUD_VISUALIMPAIR = 0x20, 66 68 }; 67 69 68 70 enum VideoProps { 69 71 VID_UNKNOWN = 0x00, // For backwards compatibility do not change 0 or 1 70 72 VID_HDTV = 0x01, 71 VID_WIDESCREEN = 0x02 73 VID_WIDESCREEN = 0x02, 74 VID_AVC = 0x04, 72 75 }; 73 76 74 77 enum SubtitleTypes { -
libs/libmythtv/eitfixup.cpp
old new 2 2 #include "mythcontext.h" 3 3 #include "dvbdescriptors.h" // for MythCategoryType 4 4 5 #include "programinfo.h" // for subtitle types and audio and video properties 6 5 7 /*------------------------------------------------------------------------ 6 8 * Event Fix Up Scripts - Turned on by entry in dtv_privatetype table 7 9 *------------------------------------------------------------------------*/ … … 117 119 } 118 120 119 121 if (kFixHDTV & event.fixup) 120 event. flags |= DBEvent::kHDTV;122 event.videoProps |= VID_HDTV; 121 123 122 124 if (kFixBell & event.fixup) 123 125 FixBellExpressVu(event); … … 237 239 position = event.description.find("(CC)"); 238 240 if (position != -1) 239 241 { 240 event. flags |= DBEvent::kCaptioned;242 event.subtitleType |= SUB_HARDHEAR; 241 243 event.description = event.description.replace("(CC)", ""); 242 244 } 243 245 … … 245 247 position = event.description.find("(Stereo)"); 246 248 if (position != -1) 247 249 { 248 event. flags |= DBEvent::kStereo;250 event.audioProps |= AUD_STEREO; 249 251 event.description = event.description.replace("(Stereo)", ""); 250 252 } 251 253 … … 261 263 if (position != -1) 262 264 { 263 265 event.title = event.title.replace(m_bellPPVTitleHD, ""); 264 event. flags |= DBEvent::kHDTV;266 event.videoProps |= VID_HDTV; 265 267 } 266 268 267 269 // Check for subtitle "All Day (... Eastern)" in the subtitle … … 347 349 position1 = event.description.find(m_ukSubtitle); 348 350 if (position1 != -1) 349 351 { 350 event. flags |= DBEvent::kSubtitled;352 event.subtitleType |= SUB_NORMAL; 351 353 event.description.remove(m_ukSubtitle); 352 354 } 353 355 … … 545 547 for (it = captures.begin(); it != captures.end(); ++it) 546 548 { 547 549 if (*it == "S") 548 event. flags |= DBEvent::kSubtitled;550 event.subtitleType |= SUB_NORMAL; 549 551 } 550 552 } 551 553 else if ((position1 = tmpUKCC.search(event.subtitle)) != -1) … … 554 556 for (it = captures.begin(); it != captures.end(); ++it) 555 557 { 556 558 if (*it == "S") 557 event. flags |= DBEvent::kSubtitled;559 event.subtitleType |= SUB_NORMAL; 558 560 } 559 561 560 562 // We remove [AD,S] from the subtitle. … … 790 792 int position = event.description.find(m_comHemTT); 791 793 if (position != -1) 792 794 { 793 event. flags |= DBEvent::kSubtitled;795 event.subtitleType |= SUB_NORMAL; 794 796 } 795 797 796 798 // Try to findout if this is a rerun and if so the date. … … 917 919 position = event.description.find(m_mcaCC); 918 920 if (position > 0) 919 921 { 920 event. flags |= DBEvent::kCaptioned;922 event.subtitleType |= SUB_HARDHEAR; 921 923 event.description.replace(m_mcaCC, ""); 922 924 } 923 925 … … 925 927 position = event.description.find(m_mcaDD); 926 928 if ((position > 0) && (position > (int) (event.description.length() - 7))) 927 929 { 928 event. flags |= DBEvent::kStereo;930 event.audioProps |= AUD_STEREO; 929 931 dd = true; 930 932 event.description.replace(m_mcaDD, ""); 931 933 } … … 1081 1083 position = event.description.find(m_Stereo); 1082 1084 if (position != -1) 1083 1085 { 1084 event. flags |= DBEvent::kStereo;1086 event.audioProps |= AUD_STEREO; 1085 1087 event.description = event.description.replace(m_Stereo, ""); 1086 1088 } 1087 1089 } … … 1214 1216 int position; 1215 1217 if ((position = fullinfo.find(m_nlStereo)) != -1) 1216 1218 { 1217 event. flags |= DBEvent::kStereo;1219 event.audioProps |= AUD_STEREO; 1218 1220 fullinfo = fullinfo.replace("stereo", "."); 1219 1221 } 1220 1222 … … 1233 1235 // Get teletext subtitle info 1234 1236 if ((position = fullinfo.find(m_nlTxt)) != -1) 1235 1237 { 1236 event. flags |= DBEvent::kSubtitled;1238 event.subtitleType |= SUB_NORMAL; 1237 1239 fullinfo = fullinfo.replace("txt", "."); 1238 1240 } 1239 1241 1240 1242 // Get HDTV information 1241 1243 if ((position = event.title.find(m_nlHD)) != -1) 1242 1244 { 1243 event. flags |= DBEvent::kHDTV;1245 event.videoProps |= VID_HDTV; 1244 1246 event.title = event.title.replace(m_nlHD, ""); 1245 1247 } 1246 1248