Ticket #361: mpegscan.diff
File mpegscan.diff, 16.6 KB (added by , 19 years ago) |
---|
-
libs/libmythtv/channelutil.cpp
442 442 return query.value(0).toInt(); 443 443 } 444 444 445 QString ChannelUtil::GetChan Num(int chan_id)445 QString ChannelUtil::GetChannelStringField(int chan_id, const QString &field) 446 446 { 447 447 if (chan_id < 0) 448 448 return QString::null; 449 449 450 450 MSqlQuery query(MSqlQuery::InitCon()); 451 query.prepare(QString("SELECT channumFROM channel "452 "WHERE chanid=%1").arg(chan_id));451 query.prepare(QString("SELECT %1 FROM channel " 452 "WHERE chanid=%2").arg(field).arg(chan_id)); 453 453 if (!query.exec() || !query.isActive()) 454 454 { 455 455 MythContext::DBError("Selecting channel/dtv_multiplex 1", query); … … 462 462 return query.value(0).toString(); 463 463 } 464 464 465 QString ChannelUtil::GetChanNum(int chan_id) 466 { 467 return GetChannelStringField(chan_id, QString("channum")); 468 } 469 470 QString ChannelUtil::GetCallsign(int chan_id) 471 { 472 return GetChannelStringField(chan_id, QString("callsign")); 473 } 474 475 QString ChannelUtil::GetServiceName(int chan_id) 476 { 477 return GetChannelStringField(chan_id, QString("name")); 478 } 479 465 480 int ChannelUtil::GetSourceID(int db_mplexid) 466 481 { 467 482 MSqlQuery query(MSqlQuery::InitCon()); … … 666 681 query.bindValue(":CHANID", new_channel_id); 667 682 query.bindValue(":CHANNUM", chan_num); 668 683 query.bindValue(":SOURCEID", db_sourceid); 669 query.bindValue(":CALLSIGN", callsign );670 query.bindValue(":NAME", service_name );684 query.bindValue(":CALLSIGN", callsign.utf8()); 685 query.bindValue(":NAME", service_name.utf8()); 671 686 query.bindValue(":XMLTVID", xmltvid); 672 687 query.bindValue(":FREQID", freqid); 673 688 query.bindValue(":TVFORMAT", tvformat); … … 684 699 bool ChannelUtil::CreateChannel(uint db_mplexid, 685 700 uint db_sourceid, 686 701 uint new_channel_id, 702 const QString &callsign, 687 703 const QString &service_name, 688 704 const QString &chan_num, 689 705 uint service_id, … … 714 730 query.bindValue(":CHANID", new_channel_id); 715 731 query.bindValue(":CHANNUM", chanNum); 716 732 query.bindValue(":SOURCEID", db_sourceid); 717 query.bindValue(":CALLSIGN", service_name.utf8());733 query.bindValue(":CALLSIGN", callsign.utf8()); 718 734 query.bindValue(":NAME", service_name.utf8()); 719 735 720 736 query.bindValue(":MPLEXID", db_mplexid); … … 739 755 bool ChannelUtil::UpdateChannel(uint db_mplexid, 740 756 uint source_id, 741 757 uint channel_id, 758 const QString &callsign, 742 759 const QString &service_name, 743 760 const QString &chan_num, 744 761 uint service_id, … … 761 778 query.bindValue(":MPLEXID", db_mplexid); 762 779 query.bindValue(":SERVICEID", service_id); 763 780 query.bindValue(":ATSCSRCID", atsc_src_id); 764 query.bindValue(":CALLSIGN", service_name.utf8());781 query.bindValue(":CALLSIGN", callsign.utf8()); 765 782 query.bindValue(":NAME", service_name.utf8()); 766 783 query.bindValue(":SOURCEID", source_id); 767 784 query.bindValue(":CHANID", channel_id); -
libs/libmythtv/mpeg/mpegstreamdata.cpp
593 593 _cache_lock.lock(); 594 594 DeleteCachedTable(_cached_pat); 595 595 _cached_pat = pat; 596 for (uint i = 0; i < pat->ProgramCount(); i++) 597 AddListeningPID(pat->ProgramPID(i)); 596 598 _cache_lock.unlock(); 597 599 } 598 600 -
libs/libmythtv/mpeg/atscdescriptors.cpp
225 225 return QString("TODO huffman 2"); 226 226 } 227 227 228 ExtendedChannelNameDescriptor::ExtendedChannelNameDescriptor( 229 const unsigned char *data) : 230 MPEGDescriptor(data) 231 { 232 assert(DescriptorTag() == DescriptorID::extended_channel_name); 233 } 234 235 MultipleStringStructure ExtendedChannelNameDescriptor::LongChannelName() const 236 { 237 return MultipleStringStructure(_data + 2); 238 } 239 240 QString ExtendedChannelNameDescriptor::LongChannelNameString() const 241 { 242 QString str; 243 MultipleStringStructure mstr = LongChannelName(); 244 245 for (int i = 0; i < mstr.StringCount(); i++) 246 { 247 for (uint j = 0; j < mstr.SegmentCount(i); j++) 248 str.append(mstr.CompressedString(i,j)); 249 } 250 251 return str; 252 } -
libs/libmythtv/mpeg/atscdescriptors.h
285 285 // content_identifier v 4.0 286 286 }; 287 287 288 /** 289 * \brief Provides the long channel name for the virtual channel containing 290 * this descriptor. 291 * 292 * See ATSC A/65B section 6.9.5. 293 * When used, this descriptor must be in the Virtual Channel Table. 294 */ 295 class ExtendedChannelNameDescriptor : public MPEGDescriptor 296 { 297 public: 298 /** 299 * \brief Creates a new ExtendedChannelNameDescriptor. 300 * 301 * \param data the raw data representing this descriptor 302 */ 303 ExtendedChannelNameDescriptor(const unsigned char *data); 304 305 /** 306 * \brief Returns a MultipleStringStructure representing the 307 * long name of the associated channel. 308 */ 309 MultipleStringStructure LongChannelName() const; 310 311 /** 312 * \brief Convenience function that returns a QString comprising a 313 * concatenation of all the segments in the LongChannelName() value. 314 */ 315 QString LongChannelNameString() const; 316 }; 317 288 318 #endif -
libs/libmythtv/mpeg/mpegtables.cpp
157 157 #endif 158 158 } 159 159 160 bool ProgramMapTable::IsStillPicture(void) const 161 { 162 static const unsigned char STILL_PICTURE_FLAG = 0x01; 163 164 for (uint i = 0; i < StreamCount(); i++) 165 { 166 if (IsVideo(i)) 167 return StreamInfoLength(i) > 2 && 168 (StreamInfo(i)[2] & STILL_PICTURE_FLAG); 169 } 170 return false; 171 } 172 173 160 174 /** \fn ProgramMapTable::FindPIDs(uint type, vector<uint>& pids) const 161 175 * \brief Finds all pids matching type. 162 176 * \param pids vector pids will be added to -
libs/libmythtv/mpeg/mpegtables.h
440 440 bool IsAudio(uint i) const; 441 441 /// Returns true iff PMT contains CA descriptor. 442 442 bool IsEncrypted(void) const; 443 /** 444 * Returns true iff PMT contains a video stream with the 445 * still-picture flag. 446 */ 447 bool IsStillPicture(void) const; 443 448 /// Returns a string representation of type at stream index i 444 449 const QString StreamTypeString(uint i) const; 445 450 uint FindPIDs(uint type, vector<uint>& pids) const; -
libs/libmythtv/channelutil.h
55 55 static bool CreateChannel(uint db_mplexid, 56 56 uint db_sourceid, 57 57 uint new_channel_id, 58 const QString &callsign, 58 59 const QString &service_name, 59 60 const QString &chan_num, 60 61 uint service_id, … … 67 68 static bool UpdateChannel(uint db_mplexid, 68 69 uint source_id, 69 70 uint channel_id, 71 const QString &callsign, 70 72 const QString &service_name, 71 73 const QString &chan_num, 72 74 uint service_id, … … 81 83 static int GetServiceVersion(int mplexid); 82 84 83 85 // Misc 86 /** 87 * \brief Returns the channel-number string of the given channel. 88 * \param chanid primary key for channel record 89 */ 84 90 static QString GetChanNum(int chanid); 91 /** 92 * \brief Returns the callsign of the given channel. 93 * \param chanid primary key for channel record 94 */ 95 static QString GetCallsign(int chanid); 96 /** 97 * \brief Returns the service name of the given channel. 98 * \param chanid primary key for channel record 99 */ 100 static QString GetServiceName(int chanid); 85 101 static int GetSourceID(int mplexid); 86 102 static QString GetInputName(int sourceid); 87 103 static QString GetDTVPrivateType(uint networkid, const QString &key, 88 104 const QString sitype = "dvb"); 105 106 private: 107 static QString GetChannelStringField(int chanid, const QString &field); 89 108 }; 90 109 91 110 #endif // CHANUTIL_H -
libs/libmythtv/siscan.h
38 38 class DTVSignalMonitor; 39 39 class DVBSignalMonitor; 40 40 class ProgramAssociationTable; 41 class ProgramMapTable; 41 42 class ServiceDescriptionTable; 42 43 class NetworkInformationTable; 43 44 class VirtualChannelTable; … … 52 53 TRANSPORT_LIST, ///< Actively scan for channels 53 54 } SCANMODE; 54 55 56 /// PMTs by PID 57 typedef QMap<uint, const ProgramMapTable *> QMap_PMTs; 58 55 59 class SIScan : public QObject 56 60 { 57 61 Q_OBJECT … … 126 130 void HandleMPEGDBInsertion(const ScanStreamData *sd, bool wait); 127 131 void UpdatePATinDB(int mplexid, 128 132 const ProgramAssociationTable*, 133 const QMap_PMTs &, 129 134 bool force_update); 130 135 131 136 void HandleATSCDBInsertion(const ScanStreamData *sd, bool wait); -
libs/libmythtv/siscan.cpp
345 345 const ProgramAssociationTable *pat = sd->GetCachedPAT(); 346 346 if (pat) 347 347 { 348 UpdatePATinDB((*current).mplexid, pat, true); 348 QMap_PMTs pmt_map; 349 pmt_vec_t pmt_vector = sd->GetCachedPMTs(); 350 for (pmt_vec_t::iterator mi = pmt_vector.begin(); mi != pmt_vector.end(); mi++) 351 pmt_map[(*mi)->tsheader()->PID()] = *mi; 352 UpdatePATinDB((*current).mplexid, pat, pmt_map, true); 353 sd->ReturnCachedTables(pmt_vector); 349 354 sd->ReturnCachedTable(pat); 350 355 } 351 356 … … 936 941 // ///////////////////// DB STUFF ///////////////////// 937 942 // ///////////////////// DB STUFF ///////////////////// 938 943 939 /** \fn UpdatePATinDB(int, const ProgramAssociationTable*, bool)944 /** \fn UpdatePATinDB(int, const ProgramAssociationTable*, const QMap_PMTs &, bool) 940 945 */ 941 946 void SIScan::UpdatePATinDB(int tid_db, 942 947 const ProgramAssociationTable *pat, 948 const QMap_PMTs &pmt_map, 943 949 bool) 944 950 { 945 951 SISCAN(QString("UpdatePATinDB(): mplex: %1:%2") … … 959 965 960 966 for (uint i = 0; i < pat->ProgramCount(); i++) 961 967 { 968 const ProgramMapTable *pmt = pmt_map[pat->ProgramPID(i)]; 969 VERBOSE(VB_SIPARSER, 970 tr("UpdatePATinDB(): Prog %1 PID %2: PMT @ %3") 971 .arg(pat->ProgramNumber(i)) 972 .arg(pat->ProgramPID(i)) 973 .arg((long long unsigned int)pmt)); 974 //TODO: user preference for still picture? 975 // For now we just ignore still-picture services such as 976 // music channels; Myth can't play them properly anyway. 977 // Eventually we might want to add a preference flag 978 // to the UI. 979 if (! pmt || // adding undefined services is rarely a good idea 980 ignoreEncryptedServices && pmt->IsEncrypted() || 981 pmt->IsStillPicture()) 982 { 983 continue; 984 } 985 962 986 // See if service already in database based on program number 963 987 int chanid = ChannelUtil::GetChanID( 964 988 db_mplexid, -1, 0, 0, pat->ProgramNumber(i)); … … 969 993 chan_num = QString("%1#%2") 970 994 .arg((freqid) ? freqid : db_mplexid).arg(i); 971 995 } 996 997 QString callsign = ChannelUtil::GetCallsign(chanid); 998 if (callsign == QString::null || callsign == "") 999 callsign = tr("C%1", "Synthesized callsign").arg(chan_num); 972 1000 973 QString service_name = QString("Unknown %1").arg(chan_num); 1001 QString service_name = ChannelUtil::GetServiceName(chanid); 1002 if (service_name == QString::null || service_name == "") 1003 service_name = callsign; 974 1004 975 1005 QString common_status_info = tr("%1 %2-%3 as %4 on %5 (%6)") 976 1006 .arg(service_name) … … 985 1015 chanid = ChannelUtil::CreateChanID(db_source_id, chan_num); 986 1016 ChannelUtil::CreateChannel( 987 1017 db_mplexid, db_source_id, chanid, 1018 callsign, 988 1019 service_name, 989 1020 chan_num, 990 1021 pat->ProgramNumber(i), … … 999 1030 db_mplexid, 1000 1031 db_source_id, 1001 1032 chanid, 1033 callsign, 1002 1034 service_name, 1003 1035 chan_num, 1004 1036 pat->ProgramNumber(i), … … 1078 1110 .arg(vct->MinorChannel(i)); 1079 1111 } 1080 1112 1113 // try to find an extended channel name 1114 QString extendedChannelName = vct->ShortChannelName(i); // fallback 1115 if (vct->DescriptorsLength(i) > 0) 1116 { 1117 vector<const unsigned char*> descVec = 1118 MPEGDescriptor::Parse(vct->Descriptors(i), vct->DescriptorsLength(i)); 1119 for (uint j = 0; j < descVec.size(); j++) 1120 { 1121 if (MPEGDescriptor(descVec[j]).DescriptorTag() == 1122 DescriptorID::extended_channel_name) 1123 { 1124 QString longName = 1125 ExtendedChannelNameDescriptor(descVec[j]).LongChannelNameString(); 1126 SISCAN(QString("UpdateVCTinDB(): chan index %1 has long name \"%2\"") 1127 .arg(i).arg(longName)); 1128 if (! longName.isEmpty()) 1129 extendedChannelName = longName; 1130 break; 1131 } 1132 } 1133 } 1134 1081 1135 QString common_status_info = tr("%1 %2-%3 as %4 on %5 (%6)") 1082 1136 .arg(vct->ShortChannelName(i)) 1083 1137 .arg(vct->MajorChannel(i)).arg(vct->MinorChannel(i)) … … 1096 1150 db_source_id, 1097 1151 chanid, 1098 1152 vct->ShortChannelName(i), 1153 extendedChannelName, 1099 1154 chan_num, 1100 1155 vct->ProgramNumber(i), 1101 1156 vct->MajorChannel(i), vct->MinorChannel(i), … … 1113 1168 db_source_id, 1114 1169 chanid, 1115 1170 vct->ShortChannelName(i), 1171 extendedChannelName, 1116 1172 chan_num, 1117 1173 vct->ProgramNumber(i), 1118 1174 vct->MajorChannel(i), vct->MinorChannel(i), … … 1232 1288 ChannelUtil::CreateChannel( 1233 1289 db_mplexid, db_source_id, chanid, 1234 1290 service_name, 1291 service_name, 1235 1292 chan_num, 1236 1293 sdt->ServiceID(i), 1237 1294 0, 0, … … 1248 1305 db_source_id, 1249 1306 chanid, 1250 1307 service_name, 1308 service_name, 1251 1309 chan_num, 1252 1310 sdt->ServiceID(i), 1253 1311 0, 0, … … 1436 1494 db_source_id, 1437 1495 chanid, 1438 1496 (*s).ServiceName, 1497 (*s).ServiceName, 1439 1498 chan_num, 1440 1499 (*s).ServiceID, 1441 1500 atsc_major, atsc_minor, … … 1452 1511 db_source_id, 1453 1512 chanid, 1454 1513 (*s).ServiceName, 1514 (*s).ServiceName, 1455 1515 chan_num, 1456 1516 (*s).ServiceID, 1457 1517 (*s).ChanNum / 10, (*s).ChanNum % 10,