Ticket #1095: copy-caption-descriptor-from-vct.patch

File copy-caption-descriptor-from-vct.patch, 2.9 KB (added by danielk, 18 years ago)

Terrestrial ATSC is not required to have a caption descriptor in the PMT, this copies it over from the VCT when it isn't in the PMT.

  • libs/libmythtv/dvbrecorder.cpp

     
    5757#include "mpegtables.h"
    5858#include "iso639.h"
    5959#include "atscstreamdata.h"
     60#include "atsctables.h"
    6061#include "cardutil.h"
    6162#include "tv_rec.h"
    6263
     
    723724    SetOutputPAT(pat);
    724725}
    725726
     727desc_list_t extract_atsc_desc(const tvct_vec_t &tvct, const cvct_vec_t &cvct,
     728                              uint pnum)
     729{
     730    desc_list_t desc;
     731
     732    vector<const VirtualChannelTable*> vct;
     733
     734    for (uint i = 0; i < tvct.size(); i++)
     735        vct.push_back(tvct[i]);
     736    for (uint i = 0; i < cvct.size(); i++)
     737        vct.push_back(cvct[i]);
     738
     739    for (uint i = 0; i < tvct.size(); i++)
     740    {
     741        for (uint j = 0; j < vct[i]->ChannelCount(); j++)
     742        {
     743            if (vct[i]->ProgramNumber(j) == pnum)
     744            {
     745                desc_list_t ldesc = MPEGDescriptor::ParseOnlyInclude(
     746                    vct[i]->Descriptors(j), vct[i]->DescriptorsLength(j),
     747                    DescriptorID::caption_service);
     748
     749                if (ldesc.size())
     750                    desc.insert(desc.end(), ldesc.begin(), ldesc.end());
     751            }
     752        }
     753
     754        if (0 != vct[i]->GlobalDescriptorsLength())
     755        {
     756            desc_list_t vdesc = MPEGDescriptor::ParseOnlyInclude(
     757                vct[i]->GlobalDescriptors(),
     758                vct[i]->GlobalDescriptorsLength(),
     759                DescriptorID::caption_service);
     760
     761            if (vdesc.size())
     762                desc.insert(desc.end(), vdesc.begin(), vdesc.end());
     763        }
     764    }
     765
     766    return desc;
     767}
     768
    726769void DVBRecorder::CreatePMT(void)
    727770{
    728771    QMutexLocker read_lock(&_pid_lock);
     
    737780        _input_pmt->ProgramInfo(), _input_pmt->ProgramInfoLength(),
    738781        DescriptorID::conditional_access);
    739782
     783    // If there is no caption descriptor in PMT, copy any caption
     784    // descriptor found in VCT to global descriptors...
     785    ATSCStreamData *sd = dynamic_cast<ATSCStreamData*>(GetStreamData());
     786    tvct_vec_t tvct;
     787    cvct_vec_t cvct;
     788    if (sd && !MPEGDescriptor::Find(gdesc, DescriptorID::caption_service))
     789    {
     790        tvct = sd->GetAllCachedTVCTs();
     791        cvct = sd->GetAllCachedCVCTs();
     792
     793        desc_list_t vdesc = extract_atsc_desc(
     794            tvct, cvct, _input_pmt->ProgramNumber());
     795
     796        if (vdesc.size())
     797            gdesc.insert(gdesc.end(), vdesc.begin(), vdesc.end());
     798    }
     799
    740800    vector<uint> pids;
    741801    vector<uint> types;
    742802    vector<desc_list_t> pdesc;
     
    781841        _next_pmt_version, gdesc,
    782842        pids, types, pdesc);
    783843
     844    // Return any TVCT & CVCT tables, once we've copied any descriptors.
     845    if (sd)
     846    {
     847        sd->ReturnCachedTVCTTables(tvct);
     848        sd->ReturnCachedCVCTTables(cvct);
     849    }
     850
    784851    // Set the continuity counter...
    785852    if (_pmt)
    786853    {