Ticket #2418: eitsupport-premiere.diff

File eitsupport-premiere.diff, 14.6 KB (added by mythtv@…, 6 years ago)
  • libs/libmythtv/eithelper.cpp

     
    346346    } 
    347347} 
    348348 
     349// This function gets special eit data from the german provider Premiere  
     350// for the option channels Premiere Sport and Premiere Direct  
     351// Because the passive eit scan looks only on the channel with the lowest 
     352// channum per transponder, you have to make sure that both portal channels 
     353// have the lowest channel number 
     354void EITHelper::AddEIT(const DVBPremiereEventInformationTable *eit) 
     355{ 
     356    // set fixup for Premiere 
     357    uint fix = fixup[133 << 16]; 
     358    fix |= EITFixUp::kFixGenericDVB; 
     359 
     360    QString title         = QString::null; 
     361    QString subtitle      = QString::null; 
     362    QString description   = QString::null; 
     363    QString category      = QString::null; 
     364    MythCategoryType category_type = kCategoryNone; 
     365    bool hdtv = false, stereo = false, subtitled = false; 
     366     
     367    // Parse descriptors 
     368    desc_list_t list = MPEGDescriptor::Parse( 
     369        eit->Descriptors(), eit->DescriptorsLength()); 
     370     
     371    const unsigned char *bestShortEvent = 
     372        MPEGDescriptor::FindBestMatch( 
     373            list, DescriptorID::short_event, languagePreferences); 
     374 
     375    unsigned char enc_ch[1] = { 0x05 }; 
     376    const unsigned char *enc = 
     377        (fix & EITFixUp::kEFixPro7Sat) ? enc_ch : NULL; 
     378 
     379    if (bestShortEvent) 
     380    { 
     381        ShortEventDescriptor sed(bestShortEvent); 
     382        if (enc) 
     383        { 
     384            title    = sed.EventName(enc, 1); 
     385            subtitle = sed.Text(enc, 1); 
     386        } 
     387        else 
     388        { 
     389            title    = sed.EventName(); 
     390            subtitle = sed.Text(); 
     391        } 
     392    } 
     393 
     394    vector<const unsigned char*> bestExtendedEvents = 
     395        MPEGDescriptor::FindBestMatches( 
     396            list, DescriptorID::extended_event, languagePreferences); 
     397 
     398    description = ""; 
     399    for (uint j = 0; j < bestExtendedEvents.size(); j++) 
     400    { 
     401        if (!bestExtendedEvents[j]) 
     402        { 
     403            description = ""; 
     404            break; 
     405        } 
     406 
     407        ExtendedEventDescriptor eed(bestExtendedEvents[j]); 
     408        if (enc) 
     409            description += eed.Text(enc, 1); 
     410        else 
     411            description += eed.Text(); 
     412    } 
     413 
     414    desc_list_t components = 
     415        MPEGDescriptor::FindAll(list, DescriptorID::component); 
     416    for (uint j = 0; j < components.size(); j++) 
     417    { 
     418        ComponentDescriptor component(components[j]); 
     419        hdtv      |= component.IsHDTV(); 
     420        stereo    |= component.IsStereo(); 
     421        subtitled |= component.IsReallySubtitled(); 
     422    } 
     423 
     424    const unsigned char *content_data = 
     425        MPEGDescriptor::Find(list, DescriptorID::content); 
     426    if (content_data) 
     427    { 
     428        ContentDescriptor content(content_data); 
     429        // fix events without real content data 
     430        if (content.Nibble(0)==0x00){  
     431            if(content.UserNibble(0)==0x1)  
     432            { 
     433                category_type = kCategoryMovie; 
     434            } 
     435            else if(content.UserNibble(0)==0x0)  
     436            { 
     437                category_type = kCategorySports; 
     438                category = QObject::tr("Sports"); 
     439            } 
     440        } 
     441        else  
     442        {    
     443          category_type = content.GetMythCategory(0); 
     444          category      = content.GetDescription(0); 
     445        } 
     446    } 
     447 
     448    // Find Transmissions 
     449    desc_list_t transmissions = 
     450        MPEGDescriptor::FindAll(list, DescriptorID::pr_event_transmission); 
     451    for(uint j=0; j< transmissions.size(); j++) 
     452    { 
     453        PremiereTransmissionDescriptor transmission(transmissions[j]); 
     454        uint networkid = transmission.OriginalNetworkID(); 
     455        uint tsid      = transmission.TSID(); 
     456        uint serviceid = transmission.ServiceID(); 
     457         
     458        // Fix wrong channel information  
     459        if     (tsid==0x03 && serviceid==0xf0) { tsid=0x02; serviceid=0xe0; }  
     460        else if(tsid==0x03 && serviceid==0xf1) { tsid=0x02; serviceid=0xe1; }  
     461        else if(tsid==0x03 && serviceid==0xf5) { tsid=0x03; serviceid=0xdc; }  
     462        else if(tsid==0x04 && serviceid==0xd2) { tsid=0x11; serviceid=0xe2; }  
     463        else if(tsid==0x11 && serviceid==0xd3) { tsid=0x11; serviceid=0xe3; }  
     464         
     465        uint chanid = GetChanID(serviceid, networkid, tsid); 
     466 
     467        if (!chanid) 
     468        { 
     469            VERBOSE(VB_GENERAL, LOC + QString("NIT %1 TID %2 SID %3 COUNT %4 NOT FOUND").arg(networkid).arg(tsid).arg(serviceid).arg(transmission.TransmissionCount())); 
     470            continue; 
     471        } 
     472 
     473        unsigned char startdate[5]; 
     474        memcpy(startdate, transmission.StartDate(), 2); 
     475        for (uint k=0; k<transmission.TransmissionCount(); k+=3) 
     476        { 
     477            memcpy(&startdate[2], transmission.StartTime(k), 3); 
     478            QDateTime starttime = MythUTCToLocal(dvbdate2qt(startdate)); 
     479            EITFixUp::TimeFix(starttime); 
     480            QDateTime endtime   = starttime.addSecs(eit->DurationInSeconds()); 
     481 
     482            DBEvent *event = new DBEvent(chanid, 
     483                                         title,     subtitle,      description, 
     484                                         category,  category_type, 
     485                                         starttime, endtime,       fix, 
     486                                         false,     subtitled, 
     487                                         stereo,    hdtv); 
     488            db_events.enqueue(event); 
     489             
     490        } 
     491    } 
     492} 
     493 
    349494void EITHelper::PruneCache(uint timestamp) 
    350495{ 
    351496    eitcache->PruneOldEntries(timestamp); 
  • libs/libmythtv/eithelper.h

     
    4747class EventInformationTable; 
    4848class ExtendedTextTable; 
    4949class DVBEventInformationTable; 
     50class DVBPremiereEventInformationTable; 
    5051 
    5152class EITHelper 
    5253{ 
     
    7071    void AddETT(uint atsc_major, uint atsc_minor, 
    7172                const ExtendedTextTable     *ett); 
    7273    void AddEIT(const DVBEventInformationTable *eit); 
     74    void AddEIT(const DVBPremiereEventInformationTable *eit); 
    7375#else // if !USING_BACKEND 
    7476    void AddEIT(uint, uint, const EventInformationTable*) {} 
    7577    void AddETT(uint, uint, const ExtendedTextTable*) {} 
    7678    void AddEIT(const DVBEventInformationTable*) {} 
     79    void AddEIT(const DVBPremiereEventInformationTable*) {} 
    7780#endif // !USING_BACKEND 
    7881 
    7982    void PruneCache(uint timestamp); 
  • libs/libmythtv/mpeg/dvbtables.cpp

     
    186186    return secsSince1970; 
    187187} 
    188188 
     189bool DVBPremiereEventInformationTable::IsEIT(uint table_id) 
     190{ 
     191    bool is_eit = false; 
     192 
     193    // Premiere Event Information for option channels 
     194    is_eit |= TableID::PR_EIT == table_id; 
     195 
     196    return is_eit; 
     197} 
     198 
    189199/** \fn dvbdate2qt(const unsigned char*) 
    190200 *  \return UTC time 
    191201 */ 
  • libs/libmythtv/mpeg/dvbstreamdata.cpp

     
    137137        is_eit |= (TableID::DN_EITbego <= table_id && 
    138138                   TableID::DN_EITendo >= table_id); 
    139139    } 
     140    if (DVB_PR_SPORT_EIT_PID == pid || DVB_PR_DIRECT_EIT_PID == pid) 
     141    { 
     142        is_eit |= TableID::PR_EIT == table_id; 
     143    } 
    140144    if (is_eit) 
    141145    { 
    142146        uint service_id = psip.TableIDExtension(); 
     
    292296        return true; 
    293297    } 
    294298 
     299    if ((DVB_PR_SPORT_EIT_PID || DVB_PR_DIRECT_EIT_PID) && 
     300        DVBPremiereEventInformationTable::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 
    295320    return false; 
    296321} 
    297322 
     
    337362        { 
    338363            add_pids.push_back(DVB_DNLONG_EIT_PID); 
    339364        } 
     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        } 
    340375    } 
    341376    else 
    342377    { 
     
    352387        { 
    353388            del_pids.push_back(DVB_DNLONG_EIT_PID); 
    354389        } 
     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        } 
    355400    } 
    356401 
    357402    return add_pids.size() || del_pids.size(); 
  • libs/libmythtv/mpeg/mpegtables.h

     
    186186    // Dishnet longterm EIT is on pid 0x300 
    187187    DVB_DNLONG_EIT_PID = 0x0300, 
    188188 
     189    // Premiere EIT for Direct/Sport PPV 
     190    DVB_PR_DIRECT_EIT_PID = 0x0b11, 
     191    DVB_PR_SPORT_EIT_PID = 0x0b12, 
     192 
    189193    ATSC_PSIP_PID = 0x1ffb, 
    190194}; 
    191195 
     
    231235        // Dishnet Longterm EIT data 
    232236        DN_EITbego = 0x80, // always on pid 0x300 
    233237        DN_EITendo = 0xfe, // always on pid 0x300 
     238         
     239        // Premiere Eit for Direct and Sport 
     240        PR_EIT     = 0xA0, 
    234241 
    235242        // ATSC 
    236243        STUFFING = 0x80, 
  • libs/libmythtv/mpeg/streamlisteners.h

     
    3232class NetworkInformationTable; 
    3333class ServiceDescriptionTable; 
    3434class DVBEventInformationTable; 
     35class DVBPremiereEventInformationTable; 
    3536 
    3637class MPEGStreamListener 
    3738{ 
     
    108109    virtual ~DVBEITStreamListener() {} 
    109110  public: 
    110111    virtual void HandleEIT(const DVBEventInformationTable*) = 0; 
     112    virtual void HandleEIT(const DVBPremiereEventInformationTable*) = 0; 
    111113}; 
    112114 
    113115 
  • libs/libmythtv/mpeg/dvbdescriptors.h

     
    16511651    QString toString() const { return QString("UKChannelListDescriptor(stub)"); } 
    16521652}; 
    16531653 
     1654class PremiereTransmissionDescriptor : public MPEGDescriptor 
     1655{ 
     1656  public: 
     1657    PremiereTransmissionDescriptor(const unsigned char* data) : MPEGDescriptor(data) 
     1658    { 
     1659//        assert(DescriptorID::transmission == DescriptorTag()); 
     1660    } 
     1661 
     1662    // event_id                 8   0.0 
     1663    uint EventID() const 
     1664        { return (_data[0]); } 
     1665    // transmission_length      8   1.0 
     1666    uint TransmissionLength() const 
     1667        { return (_data[1]); } 
     1668    // transport id            16   2.0 
     1669    uint TSID() const 
     1670        { return (_data[2] << 8) | _data[3]; } 
     1671    // network id              16   4.0 
     1672    uint OriginalNetworkID() const 
     1673        { return (_data[4] << 8) | _data[5]; } 
     1674    // service id              16   6.0 
     1675    uint ServiceID() const 
     1676        { return (_data[6] << 8) | _data[7]; } 
     1677 
     1678    // start date              16   8.0 
     1679    const unsigned char* StartDate() const 
     1680        { return &_data[8]; }   
     1681    // transmission count       8  10.0 
     1682    uint TransmissionCount() const 
     1683        { return (_data[10]); } 
     1684    // for(i=0;i<N;i++)  
     1685    //   start_time            24  11.0+x 
     1686    const unsigned char* StartTime(uint j) const 
     1687        { return &_data[11 + j];  } 
     1688       
     1689    QString toString() const { return QString("TransmissionDescriptor(stub)"); } 
     1690}; 
     1691 
     1692 
    16541693#endif 
  • libs/libmythtv/mpeg/dvbtables.h

     
    286286    mutable vector<const unsigned char*> _ptrs; // used to parse 
    287287}; 
    288288 
     289class DVBPremiereEventInformationTable : public PSIPTable 
     290{ 
     291  public: 
     292    DVBPremiereEventInformationTable(const PSIPTable& table) : PSIPTable(table) 
     293    { 
     294    // table_id                 8   0.0       0xA0 
     295        assert(IsEIT(TableID())); 
     296    // section_syntax_indicator 1   1.0          1 
     297    // private_indicator        1   1.1          1 
     298    // reserved                 2   1.2          3 
     299    // section_length          12   1.4 
     300    // reserved                 2   5.0          3 
     301    // version_number           5   5.2 
     302    // current_next_indicator   1   5.7          1 
     303    // section_number           8   6.0 
     304    // last_section_number      8   7.0 
     305    } 
    289306 
     307    // content_id              32   0.0 
     308    uint ContentID(void) const 
     309        { return (psipdata()[0]<<24) | (psipdata()[1]<<16) | (psipdata()[2]<<8) | psipdata()[3]; } 
     310 
     311    // event_duration          24   4.0 
     312    uint DurationInSeconds() const  
     313        { return ((byteBCD2int(psipdata()[4]) * 3600) + 
     314                  (byteBCD2int(psipdata()[5]) * 60) + 
     315                  (byteBCD2int(psipdata()[6]))); } 
     316    // descriptor length        8   8.0 
     317    uint DescriptorsLength() const 
     318        { return ((psipdata()[7] & 0x0F) << 8) | psipdata()[8]; } 
     319 
     320    uint EventCount(void) const 
     321        { return 1; } 
     322     
     323    // descriptor length        x   9.0 
     324    const unsigned char* Descriptors() const 
     325        { return &psipdata()[9]; } 
     326 
     327    static bool IsEIT(uint table_id); 
     328     
     329  private: 
     330    mutable vector<const unsigned char*> _ptrs; // used to parse 
     331}; 
    290332#endif // _DVB_TABLES_H_ 
  • libs/libmythtv/mpeg/mpegdescriptors.h

     
    129129        DCC_arriving_request        = 0xA9, 
    130130        DRM_control                 = 0xAA, 
    131131        atsc_content_identifier     = 0xB6, 
     132 
     133        // PREMIERE 
     134        pr_event_transmission       = 0xF2, 
    132135    }; 
    133136}; 
    134137