Ticket #5530: csat-eit.diff

File csat-eit.diff, 33.6 KB (added by eallaud@…, 16 years ago)

full diff based on trunk

  • mythtv/libs/libmythtv/mpeg/csatcaraibesdescriptors.cpp

    diff -uN mythtv/libs/libmythtv/mpeg/csatcaraibesdescriptors.cpp ../release-0-21-fixes-work/mythtv/libs/libmythtv/mpeg/csatcaraibesdescriptors.cpp
    old new  
     1#include "mpegdescriptors.h"
     2#include "csatcaraibesdescriptors.h"
     3
     4/****************** Schedule *******************************/
     5
     6void CSatCaraibesChannelsDescriptor::Parse(void)
     7{
     8    const unsigned char * p = _data+2;
     9
     10    for (uint i = DescriptorLength();i >= 4;)
     11    {
     12        uint key = p[0] << 8 + p[1];
     13        /* MSBit of LSByte seems to be 1 when it is a radio
     14         * and MSByte seems to be 0 always
     15         */
     16
     17        uint index = p[3] << 8 + p[4];
     18        channels_indexes.insert(key, index);
     19        i -= 4;
     20        p += 4;
     21    }
     22}
  • mythtv/libs/libmythtv/mpeg/csatcaraibesdescriptors.h

    diff -uN mythtv/libs/libmythtv/mpeg/csatcaraibesdescriptors.h ../release-0-21-fixes-work/mythtv/libs/libmythtv/mpeg/csatcaraibesdescriptors.h
    old new  
     1// -*- Mode: c++ -*-
     2#ifndef _CSATCAR_DESCRIPTORS_H_
     3#define _CSATCAR_DESCRIPTORS_H_
     4
     5#include <stdint.h>
     6#include <inttypes.h>
     7
     8#include <qstring.h>
     9#include <qdatetime.h>
     10
     11#include "dvbdescriptors.h"
     12
     13class CSatCaraibesChannelsDescriptor : public MPEGDescriptor
     14{
     15    public:
     16        CSatCaraibesChannelsDescriptor(const unsigned char* data) : MPEGDescriptor(data)
     17        {
     18            assert(DescriptorID::csat_channels_ind == DescriptorTag());
     19            Parse();
     20        }
     21
     22        void Parse(void);
     23        const QMap<uint,uint>& GetIndexes() const
     24        {
     25            return channels_indexes;
     26        }
     27
     28    private:
     29        /* Maps a Program ID to an index used by the EIT */
     30        QMap<uint,uint> channels_indexes;
     31};
     32
     33#endif // _CSATCAR_DESCRIPTORS_H_
  • mythtv/libs/libmythtv/mpeg/csatcaraibestables.cpp

    diff -uN mythtv/libs/libmythtv/mpeg/csatcaraibestables.cpp ../release-0-21-fixes-work/mythtv/libs/libmythtv/mpeg/csatcaraibestables.cpp
    old new  
     1#include "csatcaraibesdescriptors.h"
     2#include "csatcaraibestables.h"
     3
     4/************** Channels *********************************/
     5
     6void CSatCaraibesChannelsTable::Parse()
     7{
     8    int pos = 0;
     9
     10    /* FIXME: There is for sure a clean way to do this
     11       Lookup a 00 01 sequence*
     12    */
     13
     14    while ((pos<SectionLength()) && ((psipdata()[pos]!=0) || (psipdata()[pos+1]!=1))) pos++;
     15
     16    assert(pos<SectionLength());
     17
     18    /* skip 4 bytes */
     19    pos += 4;
     20    while (pos<SectionLength()) {
     21        _ptrs.push_back(psipdata()[pos]*256+psipdata()[pos+1]);
     22        pos += 14;
     23    }
     24}
     25
     26/******************* Schedule ******************************/
     27
     28void CSatCaraibesScheduleTable::Parse()
     29{
     30    uint nb_titles, i;
     31    unsigned char * pos;
     32
     33    /* Skip section length */
     34    nb_titles = psipdata()[1];
     35    pos = psipdata() + 2;
     36    for (i = 0;i < nb_titles;i++) {
     37        _ptrs.push_back(pos);
     38        /* Skip titles */
     39        pos += *pos+1;
     40        /* Skip 4 bytes per showing */
     41        pos += ((*pos >> 4) & 0x07)*4;
     42    }
     43}
     44
     45void CSatCaraibesScheduleTable::GetSchedules(vector<CSatCaraibesSchedule>& schedules) const
     46{
     47    QDateTime date = QDateTime::currentDateTime();
     48    QDate today = QDate::currentDate();
     49
     50    for (uint i = 0;i < NbSchedules();i++) {
     51        const unsigned char * p = _ptrs[i];
     52        CSatCaraibesSchedule schedule;
     53        uint j;
     54
     55        schedule.title = QString::fromLatin1((const char *) (p+1), *p);
     56        p += p[0];
     57        /* 0x85 at the end means incomplete, so add dots */
     58        if (*p==0x85)
     59            schedule.title.append("...");
     60        p++;
     61        if (*p & 0x80) schedule.key = 0;
     62        else schedule.key = Section() << 12 + (_ptrs[i]-psipdata());
     63        /* Get corresponding showings */
     64        j = (*p & 0x70) >> 4;
     65        schedule.duration = ( (p[0] & 0x0F)*256 + p[1] ) * 60;
     66        schedule.theme = (p[2] >> 4) & 0x0F;
     67        p += 3;
     68        for (;j > 0;j--) {
     69            CSatCaraibesShowing s;
     70
     71            s.channel_index = *p & 0x7F;
     72            p++;
     73            s.Start = QDateTime(today).addDays(*p >> 3)
     74                .addSecs(((p[0] & 0x07)*256+p[1])*60);
     75            schedule.showings.push_back(s);
     76        }
     77        schedules.push_back(schedule);
     78    }
     79}
     80 
     81/******************* Summaries *******************************/
     82
     83uint CSatCaraibesSummaryTable::TitleKey() const
     84{
     85    uint sched_off = (psipdata()[0] &0x0F)*256+psipdata()[1];
     86    uint sched_sect = psipdata()[5];
     87    return (sched_off + sched_sect << 12);
     88}
     89
     90/* FIXME: this is a bit crude. Eg \0x0a chars are used
     91   to break lines, we should escape them
     92   Also there is sometimes a second part of the summary
     93   that we do not use here
     94*/
     95QString CSatCaraibesSummaryTable::toString() const
     96{
     97    uint len = psipdata()[8];
     98 
     99    return QString::fromLatin1((const char*)(psipdata()+15), len);
     100}
     101
     102/******************* Themes **************************/
     103
     104static MythCategoryType ConvertTheme(const QString& str)
     105{
     106    if (str == "CINEMA") return string_to_myth_category_type("movies");
     107    if (str == "SPORT") return string_to_myth_category_type("sports");
     108    if (str == "SERIE") return string_to_myth_category_type("series");
     109    return kCategoryNone;
     110}
     111
     112void CSatCaraibesThemesTable::GetThemes(vector<CSatCaraibesTheme>& v) const
     113{
     114    CSatCaraibesTheme t;
     115    /* Points on themes string */
     116    const unsigned char * p = psipdata() + 0x109;
     117    for (int i = 9;i < 0x100;i += 0x10) {
     118        /* A zero length is possible */
     119        if (psipdata()[i] & 0x7F) {
     120            t.theme = QString::fromAscii((const char *)p, psipdata()[i] & 0x7F);
     121            t.category = ConvertTheme(t.theme);
     122            p += psipdata()[i] & 0x7F;
     123        } else {
     124            t.theme = QString::null;
     125            t.category = kCategoryNone;
     126        }
     127        v.push_back(t);
     128    }
     129}
     130
     131/************** Information table ******************/
     132
     133void CSatCaraibesInformationTable::AddSummary(const CSatCaraibesSummaryTable& t)
     134{
     135    summaries.insert(t.TitleKey(), t.toString());
     136}
     137
     138bool CSatCaraibesInformationTable::HasScheduleSection(uint section) const
     139{
     140    for (uint i = 0; i < sections.size();i++)
     141        if (section == sections[i]) return true;
     142    return false;
     143}
     144
     145void CSatCaraibesInformationTable::AddSchedules(const CSatCaraibesScheduleTable& t)
     146{
     147    if (!HasScheduleSection(t.Section())) {
     148        /* Record section */
     149        sections.push_back(t.Section());
     150        /* Get all schedules */
     151        t.GetSchedules(schedules);
     152        nb_sections = t.LastSection()+1;
     153    }
     154}
     155
     156void CSatCaraibesInformationTable::AddChannelsInfo(const BouquetAssociationTable * bat)
     157{
     158    for (uint i = 0; i < bat->NBTransports();i++)
     159    {
     160        desc_list_t desc =
     161            MPEGDescriptor::Parse(bat->TransportDescriptors(i),
     162                                  bat->TransportDescriptorsLoopLength(i));
     163        const unsigned char * private_data =
     164            MPEGDescriptor::Find(desc, DescriptorID::private_data_specifier);
     165
     166        /* Check if this looks like CanalSat private table
     167           Canal+ is 0x000000c0
     168        */
     169        if (!private_data || (MPEGDescriptor(private_data).DescriptorLength()!=4)
     170            || ((uint32_t)*(private_data+4)!=0x000000c0))
     171            continue;
     172        private_data = MPEGDescriptor::Find(desc, DescriptorID::csat_channels_ind);
     173        if (private_data) {
     174            CSatCaraibesChannelsDescriptor csat(private_data);
     175
     176            const QMap<uint,uint>& indexes = csat.GetIndexes();
     177            CSatCaraibesChannelInfo info;
     178            QMap<uint,uint>::const_iterator it = indexes.begin();
     179
     180            info.tsid = bat->TSID(i);
     181            info.orignetworkid = bat->OriginalNetworkID(i);
     182            VERBOSE(VB_SIPARSER,QString("TSID %1 OrigNetworkid %2").arg(info.tsid).arg(info.orignetworkid));
     183            for (;it != indexes.end();it++) {
     184                info.serviceid = it.key();
     185                channels.insert(it.data(), info);
     186                VERBOSE(VB_SIPARSER,
     187                        QString("Index %1 Serviceid %2").arg(it.data()).arg(it.key()));
     188            }
     189        }
     190    }
     191}
  • mythtv/libs/libmythtv/mpeg/csatcaraibestables.h

    diff -uN mythtv/libs/libmythtv/mpeg/csatcaraibestables.h ../release-0-21-fixes-work/mythtv/libs/libmythtv/mpeg/csatcaraibestables.h
    old new  
     1// -*- Mode: c++ -*-
     2#ifndef _CSATCARAIBES_TABLES_H_
     3#define _CSATCARAIBES_TABLES_H_
     4
     5#include <qstring.h>
     6#include <qmap.h>
     7#include <stdint.h>  // uint32_t
     8#include "mpegtables.h"
     9#include "dvbdescriptors.h"
     10#include "dvbtables.h"
     11#include "mpegtables.h"
     12
     13/* Parses the channels table which contains the program number
     14   in a certain order. The index in this table is used by
     15   the other tables to refer to the channel (I dont know why
     16   this indirection is needed, but well)
     17   This class is not directly used to emit EIT events.
     18*/
     19
     20class CSatCaraibesChannelsTable : public PSIPTable
     21{
     22    public:
     23        CSatCaraibesChannelsTable(const PSIPTable & table) : PSIPTable(table)
     24        {
     25            if (IsValid()) Parse();
     26        }
     27
     28        bool IsValid() const {
     29            return TableID()==TableID::CSATCARAIBES_CHANNELS;
     30        }
     31        void Parse();
     32        uint ChannelByIndex(uint index) const {
     33            assert(index<_ptrs.size());
     34            return _ptrs[index];
     35        }
     36        const vector<uint>& Channels() const {
     37            return _ptrs;
     38        }
     39    private:
     40        mutable vector<uint> _ptrs;
     41};
     42
     43typedef struct CSatCaraibesShowing
     44{
     45        QDateTime Start;
     46        uint channel_index;
     47};
     48
     49typedef struct CSatCaraibesSchedule {
     50        QString title;
     51        uint duration; /* In minutes */
     52        uint key; /* Key that links it to its summary; ==0 means no summary */
     53        short unsigned int theme;
     54        vector<CSatCaraibesShowing> showings;
     55};
     56
     57class CSatCaraibesScheduleTable : public PSIPTable
     58{
     59    public:
     60        CSatCaraibesScheduleTable(const PSIPTable& table) : PSIPTable(table)
     61        {
     62        }
     63
     64        void Parse();
     65        bool IsValid() {
     66            return TableID()==TableID::CSATCARAIBES_SCHED;
     67        }
     68        void GetSchedules(vector<CSatCaraibesSchedule>& schedules) const;
     69        uint GetKey(uint i) const
     70        {
     71            return Section() << 12 + (_ptrs[i]-psipdata());
     72        }
     73        uint NbSchedules() const
     74        {
     75            return _ptrs.size();
     76        }
     77 
     78    private:
     79 
     80        mutable vector<const unsigned char *> _ptrs;
     81};
     82
     83class CSatCaraibesSummaryTable : public PSIPTable
     84{
     85    public:
     86        CSatCaraibesSummaryTable(const PSIPTable & table) : PSIPTable(table)
     87        {
     88        }
     89
     90        bool IsValid() {
     91            return TableID()==TableID::CSATCARAIBES_SUMMARIES;
     92        }
     93        QString toString() const;
     94        uint TitleKey() const;
     95};
     96
     97typedef struct CSatCaraibesTheme {
     98        QString theme;
     99        MythCategoryType category;
     100};
     101
     102class CSatCaraibesThemesTable : public PSIPTable
     103{
     104    public:
     105        CSatCaraibesThemesTable(const PSIPTable & table) : PSIPTable(table)
     106        {
     107        }
     108 
     109        void GetThemes(vector<CSatCaraibesTheme>&) const;
     110};
     111
     112/* This struct holds all the needed info to find the chanid
     113   of the channel
     114*/
     115
     116typedef struct CSatCaraibesChannelInfo {
     117        uint tsid, orignetworkid, serviceid;
     118};
     119
     120class CSatCaraibesInformationTable
     121{
     122    public:
     123        CSatCaraibesInformationTable() {}
     124
     125        void Reset() {
     126            themes.clear();
     127            channels.clear();
     128            summaries.clear();
     129            schedules.clear();
     130        }
     131        bool HasThemes() const
     132        {
     133            return themes.empty();
     134        }
     135        bool HasChannels() const
     136        {
     137            return channels.empty();
     138        }
     139        void AddThemes(const CSatCaraibesThemesTable& t)
     140        {
     141            t.GetThemes(themes);
     142        }
     143        /*  void AddChannels(const CSatCaraibesChannelsTable& c) {
     144            channels = c.Channels();
     145            }*/
     146        void AddSummary(const CSatCaraibesSummaryTable& s);
     147        void AddSchedules(const CSatCaraibesScheduleTable& t);
     148        bool HasSeenAllSchedules(void)
     149        {
     150            if (schedules.empty()) return false;
     151            return (nb_sections == schedules.size());
     152        }
     153        bool HasScheduleSection(uint section) const;
     154
     155        /* Returns true when the channels, themes, and at least
     156           one schedule and one summaries table has been gathered */
     157        bool IsReady() const
     158        {
     159            /* Summaries can be empty */
     160            return !(themes.empty() || channels.empty() ||
     161                     schedules.empty());
     162        }
     163        uint NbSchedules() const
     164        { return schedules.size(); }
     165        const CSatCaraibesSchedule & GetSchedule(uint i) const
     166        {
     167            return schedules[i];
     168        }
     169        void AddChannelsInfo(const BouquetAssociationTable *);
     170        const CSatCaraibesChannelInfo& GetChannelInfoFromIndex(uint index)
     171        {
     172            return channels[index];
     173        }
     174        /* Returns true if summary is found and then it points to it
     175           else returns false */
     176        bool GetSummary(uint i, QMap<uint,QString>::const_iterator& it) const
     177        {
     178            it = summaries.find(schedules[i].key);
     179            return it!=summaries.end();
     180        }
     181
     182    private:
     183        mutable vector<CSatCaraibesTheme> themes;
     184
     185        /* Maps the index to the channel info */
     186        mutable QMap<uint, CSatCaraibesChannelInfo> channels;
     187        mutable vector<CSatCaraibesSchedule> schedules;
     188        /* Maps the key (see summary) to the description */
     189        mutable QMap<uint,QString> summaries;
     190
     191        /* Used to check if the sections have been seen */
     192        mutable vector<uint> sections;
     193        /* Number of sections needed to make up the whole schedules */
     194        uint nb_sections;
     195};
     196
     197#endif // _CSATCARAIBES_TABLES_H_
  • mythtv/libs/libmythtv/mpeg/dvbdescriptors.h

    diff -uN mythtv/libs/libmythtv/mpeg/dvbdescriptors.h ../release-0-21-fixes-work/mythtv/libs/libmythtv/mpeg/dvbdescriptors.h
    old new  
    18121812        QString toString() const { return QString("DVBContentIdentifierDescriptor(stub)"); }
    18131813};
    18141814
     1815/* Used by Canal+ (French Sat provider) in the BAT
     1816   For Canal+: data is 4 bytes, equal to 0x000000C0
     1817*/
     1818class DVBPrivateDataSpecifierDescriptor : public MPEGDescriptor
     1819{
     1820    public:
     1821        DVBPrivateDataSpecifierDescriptor(const unsigned char * data) : MPEGDescriptor(data)
     1822        {
     1823            assert(DescriptorID::private_data_specifier == DescriptorTag());
     1824        }
     1825};
    18151826
    18161827#endif
  • mythtv/libs/libmythtv/mpeg/dvbstreamdata.cpp

    diff -uN mythtv/libs/libmythtv/mpeg/dvbstreamdata.cpp ../release-0-21-fixes-work/mythtv/libs/libmythtv/mpeg/dvbstreamdata.cpp
    old new  
    1716    : MPEGStreamData(desired_program, cacheTables),
    1817      _desired_netid(desired_netid), _desired_tsid(desired_tsid),
    1918      _dvb_eit_dishnet_long(false),
     19      _dvb_eit_csatcaraibes(true),
    2020      _nit_version(-2), _nito_version(-2)
    2121{
    2222    SetVersionNIT(-1,0);
     
    243245
    244246            return true;
    245247        }
     248        case TableID::BAT:
     249        {
     250            BouquetAssociationTable bat(psip);
     251            /* For now we use the BAT only for Canal Satellite
     252             * Caraibes (French provider)
     253             */
     254            if (bat.BouquetName()=="CanalSatellite Caraibes") {
     255                VERBOSE(VB_SIPARSER,"Bat processed to get channels info, CanalSat Caraibes");
     256                _csat_info.AddChannelsInfo(&bat);
     257            }
     258            else VERBOSE(VB_SIPARSER,"BAT but not canalsat");
     259            return true;
     260        }
    246261        case TableID::SDT:
    247262        {
    248263            uint tsid = psip.TableIDExtension();
     
    370385        return true;
    371386    }
    372387
     388    if (CSATCARAIBES_EIT_PID1 == pid) {
     389        switch (psip.TableID())
     390        {
     391            /*case TableID::CSATCARAIBES_CHANNELS:
     392              if (_csat_info.HasChannels()) return true;
     393              _csat_info.AddChannels(psip);*/
     394            break;
     395            case TableID::CSATCARAIBES_THEMES:
     396                if (_csat_info.HasThemes()) return true;
     397                _csat_info.AddThemes(psip);
     398                break;
     399            case TableID::CSATCARAIBES_SCHED:
     400                if (_csat_info.HasSeenAllSchedules()) return true;
     401                _csat_info.AddSchedules(psip);
     402                break;
     403            case TableID::CSATCARAIBES_SUMMARIES:
     404            {
     405                CSatCaraibesSummaryTable summary(psip);
     406                if (!(summary.IsValid())) return false;
     407                _csat_info.AddSummary(summary);
     408                break;
     409            }
     410            default:
     411                return false;
     412        }
     413        if (_eit_helper)
     414            _eit_helper->AddEIT(&_csat_info);
     415    }
    373416    return false;
    374417}
    375418
     
    416459            add_pids.push_back(DVB_DNLONG_EIT_PID);
    417460        }
    418461
     462        if (_dvb_eit_csatcaraibes &&
     463            find(cur_pids.begin(), cur_pids.end(),
     464                 (uint) CSATCARAIBES_EIT_PID1) == cur_pids.end())
     465        {
     466            add_pids.push_back(CSATCARAIBES_EIT_PID1);
     467            VERBOSE(VB_EIT,"Added CSAT PID!");
     468        }
     469
    419470        if (_desired_netid == PREMIERE_ONID &&
    420471            find(cur_pids.begin(), cur_pids.end(),
    421472                 (uint) PREMIERE_EIT_DIREKT_PID) == cur_pids.end())
     
    451496            del_pids.push_back(DVB_DNLONG_EIT_PID);
    452497        }
    453498
     499        if (_dvb_eit_csatcaraibes &&
     500            find(cur_pids.begin(), cur_pids.end(),
     501                 (uint) CSATCARAIBES_EIT_PID1) == cur_pids.end())
     502        {
     503            del_pids.push_back(CSATCARAIBES_EIT_PID1);
     504        }
    454505        if (_desired_netid == PREMIERE_ONID &&
    455506            find(cur_pids.begin(), cur_pids.end(),
    456507                 (uint) PREMIERE_EIT_DIREKT_PID) != cur_pids.end())
  • mythtv/libs/libmythtv/mpeg/dvbstreamdata.h

    diff -uN mythtv/libs/libmythtv/mpeg/dvbstreamdata.h ../release-0-21-fixes-work/mythtv/libs/libmythtv/mpeg/dvbstreamdata.h
    old new  
    44#define DVBSTREAMDATA_H_
    55
    66#include "mpegstreamdata.h"
     7#include "csatcaraibestables.h"
    78
    89typedef NetworkInformationTable* nit_ptr_t;
    910typedef vector<const NetworkInformationTable*>  nit_vec_t;
    1011typedef QMap<uint, nit_ptr_t>    nit_cache_t; // section->sdts
     
    193191   
    194192        /// Decode DishNet's long-term DVB EIT
    195193        bool                      _dvb_eit_dishnet_long;
     194        /// Decode Canal Satellite Caraibes DVB EIT
     195        bool                        _dvb_eit_csatcaraibes;
    196196        /// Tell us if the DVB service has EIT
    197197        dvb_has_eit_t             _dvb_has_eit;
    198198
     
    217217        sections_t                _nito_section_seen;
    218218        sections_map_t            _sdto_section_seen;
    219219
     220        // Canal Satellite Caraibes private information table
     221        CSatCaraibesInformationTable _csat_info;
     222
    220223        // Caching
    221224        nit_cache_t               _cached_nit;  // section -> sdt
    222225        sdt_cache_t               _cached_sdts; // tsid+section -> sdt
  • mythtv/libs/libmythtv/mpeg/dvbtables.cpp

    diff -uN mythtv/libs/libmythtv/mpeg/dvbtables.cpp ../release-0-21-fixes-work/mythtv/libs/libmythtv/mpeg/dvbtables.cpp
    old new  
    148148        return false;
    149149}
    150150
     151void BouquetAssociationTable::Parse(void)
     152{
     153    const unsigned char * p = psipdata()+8;
     154    uint looplen, len = (p[0] & 0x0F) << 8 + p[1]; // Name descriptor length
     155    desc_list_t desc;
     156    p += 2;
     157    desc = MPEGDescriptor::ParseOnlyInclude(p, len, DescriptorID::bouquet_name);
     158    if (desc.empty())
     159        VERBOSE(VB_SIPARSER,"Curious: BAT without bouquet name!");
     160    else
     161        bouquet_name = QString::fromLatin1((const char*)(desc[0]+2),
     162                                           MPEGDescriptor(desc[0]).DescriptorLength());
     163    p += len;
     164    looplen = (p[0] & 0x0F) << 8 + p[1];
     165    p += 2; // Now point on first TS desc
     166    while (looplen) {
     167        _ptrs.push_back(p);    // Add first TS position
     168        p += 4;                // Skip TS and network ID
     169        len = (p[0] & 0x0F) << 8 + p[1];    // Get length of descriptors
     170        p += 2;
     171        looplen -= 6;
     172        p += len;
     173        looplen -= len;
     174    }
     175}
     176
    151177void DVBEventInformationTable::Parse(void) const
    152178{
    153179    _ptrs.clear();
     
    177203    // Dish Network Long Term Future Event Information for all transports
    178204    is_eit |= (TableID::DN_EITbego <= table_id &&
    179205               TableID::DN_EITendo >= table_id);
     206    // Canal Satellite long term EIT for all transports
     207    is_eit |= (table_id == TableID::CSATCARAIBES_CHANNELS ||
     208               table_id == TableID::CSATCARAIBES_THEMES ||
     209               table_id == TableID::CSATCARAIBES_SCHED ||
     210               table_id == TableID::CSATCARAIBES_SUMMARIES);
    180211
    181212    return is_eit;
    182213}
  • mythtv/libs/libmythtv/mpeg/dvbtables.h

    diff -uN mythtv/libs/libmythtv/mpeg/dvbtables.h ../release-0-21-fixes-work/mythtv/libs/libmythtv/mpeg/dvbtables.h
    old new  
    164164        mutable vector<const unsigned char*> _ptrs; // used to parse
    165165};
    166166
     167/** \class BouquetAssociationTable
     168 *  \brief Tells what channels can be found on each transponder
     169 *  for one bouquet (a bunch of channels from one provider)
     170 *  Note: French Provider Canal+ uses this to associate channels
     171 *  with an index used in their proprietary EIT
     172 */
     173
     174class BouquetAssociationTable : public PSIPTable
     175{
     176    public:
     177        BouquetAssociationTable(const PSIPTable& table) : PSIPTable(table)
     178        {
     179            assert(TableID::BAT == TableID());
     180            Parse();
     181        }
     182        ~BouquetAssociationTable() { ; }
     183
     184        // table_id                 8   0.0       0x4a
     185        // section_syntax_indicator 1   1.0          1
     186        // reserved_future_use      1   1.1          1
     187        // reserved                 2   1.2          3
     188        // section_length          12   1.4          0
     189        // Bouquet ID              16   3.0          0
     190        // reserved                 2   5.0          3
     191        // version_number           5   5.2          0
     192        // current_next_indicator   1   5.7          1
     193        // section_number           8   6.0       0x00
     194        // last_section_number      8   7.0       0x00
     195        // reserved                 4   8         0x0d
     196        // Bouquet descriptors len 12   8.4
     197        // for (i=0;i<N;i++)
     198        // Descriptor();
     199        // reserved                4 10+N.0
     200        // Transport stream loop len 12
     201        // for (i=0;i<N;i++) {
     202        //   transport_stream_id    16
     203        //   original_network_id    16
     204        //   reserved                4
     205        //   transport descriptor len 12
     206        //   for (j=0;j<N;j++)
     207        //     Descriptor();
     208        //  }
     209        //  crc                     32
     210        uint TSID(uint i) const
     211        { return _ptrs[i][0] << 8 + _ptrs[i][1]; }
     212
     213        /// original_network_id    16   8.0
     214        uint OriginalNetworkID(uint i) const
     215        { return _ptrs[i][2] << 8 + _ptrs[i][3]; }
     216
     217        /* Returns a pointer to the first descriptor following
     218           the TS and Network ID, and the loop length */
     219        const unsigned char * TransportDescriptors(uint i) const
     220        { return _ptrs[i]+6; }
     221        uint TransportDescriptorsLoopLength(uint i) const
     222        { return (_ptrs[i][4] &0x0F)<< 8 + _ptrs[i][5]; }
     223        void Parse(void);
     224        uint NBTransports() const
     225        {
     226            return _ptrs.size();
     227        }
     228        QString BouquetName() const
     229        { return bouquet_name; }
     230
     231    private:
     232        /* point on the transport descriptors */
     233        mutable vector<const unsigned char*> _ptrs;
     234        mutable QString bouquet_name;
     235};
     236
    167237class DiscontinuityInformationTable : public PSIPTable
    168238{
    169239        DiscontinuityInformationTable(const PSIPTable& table) : PSIPTable(table)
  • mythtv/libs/libmythtv/mpeg/mpegdescriptors.h

    diff -uN mythtv/libs/libmythtv/mpeg/mpegdescriptors.h ../release-0-21-fixes-work/mythtv/libs/libmythtv/mpeg/mpegdescriptors.h
    old new  
    123112
    124113            // ATSC
    125114            atsc_stuffing               = 0x80,
     115            /* Seems to be used also for user-defined
     116               For CanalSat Caraibes this is used in
     117               the BAT to provide channel indexes */
    126118            audio_stream                = 0x81,
     119            csat_channels_ind           = 0x81,
    127120            caption_service             = 0x86,
    128121            content_advisory            = 0x87,
    129122
  • mythtv/libs/libmythtv/mpeg/mpegtables.h

    diff -uN mythtv/libs/libmythtv/mpeg/mpegtables.h ../release-0-21-fixes-work/mythtv/libs/libmythtv/mpeg/mpegtables.h
    old new  
    191191    PREMIERE_EIT_DIREKT_PID = 0x0b11,
    192192    PREMIERE_EIT_SPORT_PID  = 0x0b12,
    193193
     194    // Canal Sat longterm EIT is on pid 0x114 and 0x153
     195    CSATCARAIBES_EIT_PID1 = 0x114,
     196    //    CSATCARAIBES_EIT_PID2 = 0x153,
     197
    194198    ATSC_PSIP_PID = 0x1ffb,
    195199};
    196200
     
    241245            DN_EITbego = 0x80, // always on pid 0x300
    242246            DN_EITendo = 0xfe, // always on pid 0x300
    243247
     248            // Canal Sat Caraibes Longterm EIT data
     249            CSATCARAIBES_CHANNELS = 0x90, // always on pid 0x114
     250            CSATCARAIBES_SCHED = 0x92,    // always on pid 0x114
     251            CSATCARAIBES_SUMMARIES = 0x94, //always on pid 0x114
     252            CSATCARAIBES_THEMES = 0x91,    //always on pid 0x114
     253
    244254            // ARIB
    245255            ARIBbeg  = 0x80,
    246256            ARIBend  = 0x8f,
  • mythtv/libs/libmythtv/mpeg/streamlisteners.h

    diff -uN mythtv/libs/libmythtv/mpeg/streamlisteners.h ../release-0-21-fixes-work/mythtv/libs/libmythtv/mpeg/streamlisteners.h
    old new  
    3131class DirectedChannelChangeSelectionCodeTable;
    3232
    3333class NetworkInformationTable;
     34class BouquetAssociationTable;
    3435class ServiceDescriptionTable;
    3536class TimeDateTable;
    3637class DVBEventInformationTable;
     
    143144    public:
    144145        virtual void HandleEIT(const DVBEventInformationTable*) = 0;
    145146        virtual void HandleEIT(const PremiereContentInformationTable*) = 0;
     147        virtual void HandleBAT(const BouquetAssociationTable*)=0;
    146148};
    147149
    148150
  • mythtv/libs/libmythtv/dtvsignalmonitor.h

    old new  
    100105        void HandleTDT(const TimeDateTable*);
    101106        void HandleNIT(const NetworkInformationTable*);
    102107        void HandleSDT(uint, const ServiceDescriptionTable*);
     108        void HandleBAT(const BouquetAssociationTable*);
    103109
    104110        void IgnoreEncrypted(bool ignore) { ignore_encrypted = ignore; }
    105111
  • mythtv/libs/libmythtv/dtvsignalmonitor.cpp

    old new  
    469476        AddFlags(kDTVSigMon_CryptMatch);
    470477}
    471478
     479void DTVSignalMonitor::HandleBAT(const BouquetAssociationTable * bat)
     480{
     481    VERBOSE(VB_SIPARSER,"BAT detected");
     482 
     483}
     484
    472485ATSCStreamData *DTVSignalMonitor::GetATSCStreamData()
    473486{
    474487    return dynamic_cast<ATSCStreamData*>(stream_data);
  • mythtv/libs/libmythtv/eithelper.h

    old new  
    5348class ExtendedTextTable;
    5449class DVBEventInformationTable;
    5550class PremiereContentInformationTable;
     51class CSatCaraibesInformationTable;
    5652
    5753class EITHelper
    5854{
     
    7773                    const ExtendedTextTable     *ett);
    7874        void AddEIT(const DVBEventInformationTable *eit);
    7975        void AddEIT(const PremiereContentInformationTable *eit);
     76        void AddEIT(CSatCaraibesInformationTable *eit);
    8077#else // if !USING_BACKEND
    8178        void AddEIT(uint, uint, const EventInformationTable*) {}
    8279        void AddETT(uint, uint, const ExtendedTextTable*) {}
    8380        void AddEIT(const DVBEventInformationTable*) {}
    8481        void AddEIT(const PremiereContentInformationTable*) {}
     82        void AddEIT(const CSatCaraibesInformationTable*) {}
    8583#endif // !USING_BACKEND
    8684
    8785        // EIT cache handling
  • mythtv/libs/libmythtv/eithelper.cpp

    old new  
    2019#include "atsctables.h"
    2120#include "dvbtables.h"
    2221#include "premieretables.h"
     22#include "csatcaraibestables.h"
    2323#include "dishdescriptors.h"
    2424#include "premieredescriptors.h"
    2525#include "util.h"
     
    513512    }
    514513}
    515514
     515// This function gets special eit data from the French provider
     516// Canal Satellite Caraibes. It probably applies to this provider
     517// in France. This EIT is available for all channels for 7-10 days                   
     518void EITHelper::AddEIT(CSatCaraibesInformationTable *cit)
     519{
     520    QString title         = QString::null;
     521    QString subtitle      = QString::null;
     522    QString description   = QString::null;
     523    QString category      = QString::null;
     524    MythCategoryType category_type = kCategoryNone;
     525    unsigned char subtitle_type=0, audio_props=0, video_props=0;
     526    uint fix = fixup[ 601LL << 32 | 1 << 16 |  0 ] | EITFixUp::kFixGenericDVB;
     527    if (!cit->IsReady()) {
     528        VERBOSE(VB_EIT,LOC+"CSAT EIT NOT READY YET");
     529        return;
     530    }
     531    for (uint i = 0;i < cit->NbSchedules();i++) {
     532        const CSatCaraibesSchedule& schedule = cit->GetSchedule(i);
     533        QString title = schedule.title;
     534        const vector<CSatCaraibesShowing>& showings = schedule.showings;
     535        QMap<uint, QString>::const_iterator sum;
     536        bool sum_available = false;
     537
     538        if (schedule.key) {
     539            /* If the summary is not there we go on with the next schedule */
     540            if (!(cit->GetSummary(i, sum))) continue;
     541            sum_available = true;
     542        }
     543        for (vector<CSatCaraibesShowing>::const_iterator it = showings.begin();
     544             it != showings.end();it++) {
     545            QDateTime starttime = (*it).Start;
     546            //    EITFixUp::TimeFix(starttime);
     547            QDateTime endtime   = starttime.addSecs(schedule.duration*60);
     548            uint chanid;
     549            DBEvent *event;
     550            const CSatCaraibesChannelInfo& info = cit->GetChannelInfoFromIndex((*it).channel_index);
     551            chanid = GetChanID(info.tsid,info.serviceid,info.orignetworkid);
     552            VERBOSE(VB_EIT, LOC +
     553                    QString("CSATCARAIBES EIT for NIT %1, TID %2, SID %3, "
     554                            "T: %4, Start: %5, Dur: %6 Thm: %7, summ: %8")
     555                    .arg(info.orignetworkid).arg(info.tsid).arg(info.serviceid)
     556                    .arg(title).arg(starttime.toString()).arg(schedule.duration)
     557                    .arg(schedule.theme).arg((sum_available ? *sum :"No summary")));
     558     
     559            if (!chanid)
     560            {
     561                VERBOSE(VB_EIT, LOC +
     562                        QString("CSATCARAIBES EIT for NIT %1, TID %2, SID %3, "
     563                                "title: %4. Channel not found!")
     564                        .arg(info.orignetworkid).arg(info.tsid).arg(info.serviceid)
     565                        .arg(title));
     566                continue;
     567            }
     568     
     569            /*      event = new DBEvent(chanid,
     570                    title, QString::null, sum_available ? (*sum).value():"",
     571                    category,  category_type,
     572                    starttime, endtime, fix,
     573                    subtitle_type,
     574                    audio_props,
     575                    video_props,
     576                    "",  "");
     577                    db_events.enqueue(event);*/
     578        }
     579    }
     580}
    516581
    517582void EITHelper::PruneEITCache(uint timestamp)
    518583{
     
    856907        fix[ 1094LL << 32 | 1 << 16 | 17028 ] = // NT1
    857908        fix[ 1100LL << 32 | 1 << 16 |  8710 ] = // NRJ 12
    858909        EITFixUp::kEFixForceISO8859_15;
     910
     911    // IntelSat 903 DVB-S french channels (CanalSat Caraibes)
     912    // The original network id is the same as the previous one
     913    // at least transport ids are different
     914    // For now all channels are marked as needing fixup
     915    fix[   601LL << 32 | 1 << 16 |  0 ] =
     916        fix[ 602LL << 32 | 1 << 16 |  0 ] =
     917        fix[ 603LL << 32 | 1 << 16 |  0 ] =
     918        fix[ 604LL << 32 | 1 << 16 |  0 ] =
     919        EITFixUp::kEFixForceISO8859_15;
    859920}
    860921
    861922static int calc_eit_utc_offset(void)