Exemplo n.º 1
0
QString ScanStreamData::GetSIStandard(QString guess) const
{
    if (HasCachedMGT())
        return "atsc";

    if (HasCachedAnyNIT())
        return "dvb";

    QMutexLocker locker(&_cache_lock);

    pmt_cache_t::const_iterator it = _cached_pmts.begin();
    for (; it != _cached_pmts.end(); ++it)
    {
        ProgramMapTable *pmt = *it;

        for (uint i = 0; (guess != "dvb") && (i < pmt->StreamCount()); i++)
        {
            if (StreamID::OpenCableVideo == pmt->StreamType(i))
                return "opencable";
        }

        desc_list_t descs = MPEGDescriptor::ParseOnlyInclude(
            pmt->ProgramInfo(), pmt->ProgramInfoLength(),
            DescriptorID::registration);

        for (uint i = 0; i < descs.size(); i++)
        {
            RegistrationDescriptor reg(descs[i]);
            if (reg.FormatIdentifierString() == "SCTE")
                return "opencable";
        }
    }

    return "mpeg";
}
Exemplo n.º 2
0
cCiCaPmt CreateCAPMT(const ProgramMapTable &pmt,
                     const unsigned short *casids,
                     uint cplm)
{
    cCiCaPmt capmt(pmt.ProgramNumber(), cplm);

    // Add CA descriptors for the service
    desc_list_t gdesc = MPEGDescriptor::ParseOnlyInclude(
        pmt.ProgramInfo(), pmt.ProgramInfoLength(),
        DescriptorID::conditional_access);

    process_desc(capmt, casids, gdesc);

    // Add elementary streams + CA descriptors
    for (uint i = 0; i < pmt.StreamCount(); i++)
    {
        LOG(VB_DVBCAM, LOG_INFO,
            QString("DVBCam: Adding elementary stream: %1, pid(0x%2)")
                .arg(pmt.StreamDescription(i, "dvb"))
                .arg(pmt.StreamPID(i),0,16));

        capmt.AddElementaryStream(pmt.StreamType(i), pmt.StreamPID(i));

        desc_list_t desc = MPEGDescriptor::ParseOnlyInclude(
            pmt.StreamInfo(i), pmt.StreamInfoLength(i),
            DescriptorID::conditional_access);

        process_desc(capmt, casids, desc);
    }
    return capmt;
}
Exemplo n.º 3
0
bool IPTVRecorder::ProcessTSPacket(const TSPacket& tspacket)
{
    if (!_stream_data)
        return true;

    if (tspacket.TransportError() || tspacket.Scrambled())
        return true;

    if (tspacket.HasAdaptationField())
        _stream_data->HandleAdaptationFieldControl(&tspacket);

    if (tspacket.HasPayload())
    {
        const unsigned int lpid = tspacket.PID();

        // Pass or reject packets based on PID, and parse info from them
        if (lpid == _stream_data->VideoPIDSingleProgram())
        {
            ProgramMapTable *pmt = _stream_data->PMTSingleProgram();
            uint video_stream_type = pmt->StreamType(pmt->FindPID(lpid));

            if (video_stream_type == StreamID::H264Video)
                _buffer_packets = !FindH264Keyframes(&tspacket);
            else if (StreamID::IsVideo(video_stream_type))
                _buffer_packets = !FindMPEG2Keyframes(&tspacket);

            if ((video_stream_type != StreamID::H264Video) || _seen_sps)
                BufferedWrite(tspacket);
        }
        else if (_stream_data->IsAudioPID(lpid))
        {
            _buffer_packets = !FindAudioKeyframes(&tspacket);
            BufferedWrite(tspacket);
        }
        else if (_stream_data->IsListeningPID(lpid))
            _stream_data->HandleTSTables(&tspacket);
        else if (_stream_data->IsWritingPID(lpid))
            BufferedWrite(tspacket);
    }

    return true;
}
Exemplo n.º 4
0
/*
 * Send a CA_PMT object to the CAM (see EN50221, section 8.4.3.4)
 */
void DVBCam::SendPMT(const ProgramMapTable &pmt, uint cplm)
{
    bool success = false;

    for (uint s = 0; s < (uint)ciHandler->NumSlots(); s++)
    {
        const unsigned short *casids = ciHandler->GetCaSystemIds(s);

        if (!casids)
        {
            LOG(success ? VB_DVBCAM : VB_GENERAL, LOG_ERR,
                LOC + "GetCaSystemIds returned NULL! " +
                QString("(Slot #%1)").arg(s));
            continue;
        }

        if (!casids[0])
        {
            LOG(success ? VB_DVBCAM : VB_GENERAL, LOG_ERR,
                LOC + "CAM supports no CA systems! " +
                QString("(Slot #%1)").arg(s));
            continue;
        }

        LOG(VB_DVBCAM, LOG_INFO, LOC +
            QString("Creating CA_PMT, ServiceID = %1")
                .arg(pmt.ProgramNumber()));

        cCiCaPmt capmt = CreateCAPMT(pmt, casids, cplm);

        LOG(VB_DVBCAM, LOG_INFO, LOC +
            QString("Sending CA_PMT with %1 to CI slot #%2")
                .arg(cplm_info[cplm]).arg(s));

        if (!ciHandler->SetCaPmt(capmt, s))
            LOG(success ? VB_DVBCAM : VB_GENERAL, LOG_ERR,
                LOC + "CA_PMT send failed!");
        else
            success = true;
    }
}