Ticket #2418: eitsupport-premiere-rewrite2.diff

File eitsupport-premiere-rewrite2.diff, 15.9 KB (added by mythtv@…, 18 years ago)

removed wrong indents

  • libs/libmythtv/eithelper.cpp

     
    231231    for (uint i = 0; i < eit->EventCount(); i++)
    232232    {
    233233        // 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))))
    236238        {
    237239            continue;
    238240        }
     
    341343        if (content_data)
    342344        {
    343345            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            }
    346365        }
    347366
    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                }
    350387
    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));
    353401
    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());
    357419
    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        }
    365435    }
    366436}
    367437
  • libs/libmythtv/eithelper.h

     
    4747class EventInformationTable;
    4848class ExtendedTextTable;
    4949class DVBEventInformationTable;
     50class DVBPremiereEventInformationTable;
    5051
    5152class EITHelper
    5253{
  • libs/libmythtv/mpeg/dvbtables.cpp

     
    165165    // Dish Network Long Term Future Event Information for all transports
    166166    is_eit |= (TableID::DN_EITbego <= table_id &&
    167167               TableID::DN_EITendo >= table_id);
     168    // Premiere Event Information for option channels
     169    is_eit |= TableID::PR_EIT == table_id;
    168170
    169171    return is_eit;
    170172}
  • 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        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
    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/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    //       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
    16541690#endif
  • libs/libmythtv/mpeg/dvbtables.h

     
    219219    // last_section_number      8   7.0
    220220        Parse();
    221221    }
     222    virtual ~DVBEventInformationTable(){}
    222223
    223224    // service_id              16   3.0
    224     uint ServiceID(void) const { return TableIDExtension(); }
     225    virtual uint ServiceID(void) const { return TableIDExtension(); }
    225226
    226227    // transport_stream_id     16   8.0
    227     uint TSID(void) const
     228    virtual uint TSID(void) const
    228229        { return (psipdata()[0]<<8) | psipdata()[1]; }
    229230
    230231    // original_network_id     16  10.0
    231     uint OriginalNetworkID(void) const
     232    virtual uint OriginalNetworkID(void) const
    232233        { return (psipdata()[2]<<8) | psipdata()[3]; }
    233234
    234235    // segment_last_section_num 8  12.0
     
    238239    uint LastTableID(void) const
    239240        { return psipdata()[5]; }
    240241
    241     uint EventCount() const { return _ptrs.size()-1; }
     242    virtual uint EventCount() const { return _ptrs.size()-1; }
    242243
    243244    // for(i=0;i<N;i++) {
    244245    //   event_id              16   0.0+x
     
    258259    //   duration              24   7.0+x
    259260    const unsigned char *Duration(uint i) const
    260261        { return _ptrs[i]+7; }
    261     uint DurationInSeconds(uint i) const
     262    virtual uint DurationInSeconds(uint i) const
    262263    {
    263264        return ((byteBCD2int(Duration(i)[0]) * 3600) +
    264265                (byteBCD2int(Duration(i)[1]) * 60) +
     
    269270    //   free_CA_mode           1  10.3+x
    270271    bool IsScrambled(uint i) const { return bool(_ptrs[i][10] & 0x10); }
    271272    //   descriptors_loop_len  12  10.4+x
    272     uint DescriptorsLength(uint i) const
     273    virtual uint DescriptorsLength(uint i) const
    273274        { return ((_ptrs[i][10]<<8) | (_ptrs[i][11])) & 0xfff; }
    274275    //   for(i=0;i<N;i++)       y  12.0+x
    275276    //     { descriptor() }
    276     const unsigned char* Descriptors(uint i) const
     277    virtual const unsigned char* Descriptors(uint i) const
    277278        { return _ptrs[i] + 12; }
    278279    //   }
    279280    //CRC_32 32 rpchof
    280281
    281     void Parse(void) const;
     282    virtual void Parse(void) const;
    282283
    283284    static bool IsEIT(uint table_id);
    284285
     
    286287    mutable vector<const unsigned char*> _ptrs; // used to parse
    287288};
    288289
     290class 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(){}
    289309
     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};
    290336#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