예제 #1
0
파일: channel.cpp 프로젝트: gdenning/mythtv
DTC::ChannelInfo* Channel::GetChannelInfo( int nChanID )
{
    if (nChanID == 0)
        throw( QString("Channel ID appears invalid."));

    DTC::ChannelInfo *pChannelInfo = new DTC::ChannelInfo();

    QString channum = ChannelUtil::GetChanNum(nChanID);
    uint sourceid = ChannelUtil::GetSourceIDForChannel(nChanID);
    QString format, modulation, freqtable, freqid, dtv_si_std,
            xmltvid, default_authority, icon;
    int finetune, program_number;
    uint64_t frequency;
    uint atscmajor, atscminor, transportid, networkid, mplexid;
    bool commfree = false;
    bool eit = false;
    bool visible = true;

    if (ChannelUtil::GetExtendedChannelData( sourceid, channum, format, modulation,
                            freqtable, freqid, finetune, frequency,
                            dtv_si_std, program_number, atscmajor,
                            atscminor, transportid, networkid, mplexid,
                            commfree, eit, visible, xmltvid, default_authority, icon ))
    {
        pChannelInfo->setChanId(nChanID);
        pChannelInfo->setChanNum(channum);
        pChannelInfo->setCallSign(ChannelUtil::GetCallsign(nChanID));
        pChannelInfo->setIconURL(icon);
        pChannelInfo->setChannelName(ChannelUtil::GetServiceName(nChanID));
        pChannelInfo->setMplexId(mplexid);
        pChannelInfo->setServiceId(program_number);
        pChannelInfo->setATSCMajorChan(atscmajor);
        pChannelInfo->setATSCMinorChan(atscminor);
        pChannelInfo->setFormat(format);
        pChannelInfo->setModulation(modulation);
        pChannelInfo->setFrequencyTable(freqtable);
        pChannelInfo->setFineTune(finetune);
        pChannelInfo->setFrequency((long)frequency);
        pChannelInfo->setFrequencyId(freqid);
        pChannelInfo->setSIStandard(dtv_si_std);
        pChannelInfo->setTransportId(transportid);
        pChannelInfo->setNetworkId(networkid);
        pChannelInfo->setChanFilters(ChannelUtil::GetVideoFilters(sourceid, channum));
        pChannelInfo->setSourceId(sourceid);
        pChannelInfo->setCommFree(commfree);
        pChannelInfo->setUseEIT(eit);
        pChannelInfo->setVisible(visible);
        pChannelInfo->setXMLTVID(xmltvid);
        pChannelInfo->setDefaultAuth(default_authority);
    }
    else
        throw( QString("Channel ID appears invalid."));

    return pChannelInfo;
}
예제 #2
0
파일: channel.cpp 프로젝트: gdenning/mythtv
DTC::ChannelInfoList* Channel::GetChannelInfoList( int nSourceID,
                                                   int nStartIndex,
                                                   int nCount )
{
    vector<uint> chanList;

    chanList = ChannelUtil::GetChanIDs(nSourceID);

    // ----------------------------------------------------------------------
    // Build Response
    // ----------------------------------------------------------------------

    DTC::ChannelInfoList *pChannelInfos = new DTC::ChannelInfoList();

    nStartIndex   = min( nStartIndex, (int)chanList.size() );
    nCount        = (nCount > 0) ? min( nCount, (int)chanList.size() ) : chanList.size();
    int nEndIndex = min((nStartIndex + nCount), (int)chanList.size() );

    for( int n = nStartIndex; n < nEndIndex; n++)
    {
        DTC::ChannelInfo *pChannelInfo = pChannelInfos->AddNewChannelInfo();

        int chanid = chanList.at(n);
        QString channum = ChannelUtil::GetChanNum(chanid);
        QString format, modulation, freqtable, freqid, dtv_si_std,
                xmltvid, default_authority, icon;
        int finetune, program_number;
        uint64_t frequency;
        uint atscmajor, atscminor, transportid, networkid, mplexid;
        bool commfree = false;
        bool eit = false;
        bool visible = true;

        if (ChannelUtil::GetExtendedChannelData( nSourceID, channum, format, modulation,
                            freqtable, freqid, finetune, frequency,
                            dtv_si_std, program_number, atscmajor,
                            atscminor, transportid, networkid, mplexid,
                            commfree, eit, visible, xmltvid, default_authority, icon ))
        {
            pChannelInfo->setChanId(chanid);
            pChannelInfo->setChanNum(channum);
            pChannelInfo->setCallSign(ChannelUtil::GetCallsign(chanid));
            pChannelInfo->setIconURL(icon);
            pChannelInfo->setChannelName(ChannelUtil::GetServiceName(chanid));
            pChannelInfo->setMplexId(mplexid);
            pChannelInfo->setServiceId(program_number);
            pChannelInfo->setATSCMajorChan(atscmajor);
            pChannelInfo->setATSCMinorChan(atscminor);
            pChannelInfo->setFormat(format);
            pChannelInfo->setModulation(modulation);
            pChannelInfo->setFrequencyTable(freqtable);
            pChannelInfo->setFineTune(finetune);
            pChannelInfo->setFrequency((long)frequency);
            pChannelInfo->setFrequencyId(freqid);
            pChannelInfo->setSIStandard(dtv_si_std);
            pChannelInfo->setTransportId(transportid);
            pChannelInfo->setNetworkId(networkid);
            pChannelInfo->setChanFilters(ChannelUtil::GetVideoFilters(nSourceID, channum));
            pChannelInfo->setSourceId(nSourceID);
            pChannelInfo->setCommFree(commfree);
            pChannelInfo->setUseEIT(eit);
            pChannelInfo->setVisible(visible);
            pChannelInfo->setXMLTVID(xmltvid);
            pChannelInfo->setDefaultAuth(default_authority);
        }
    }

    int curPage = 0, totalPages = 0;
    if (nCount == 0)
        totalPages = 1;
    else
        totalPages = (int)ceil((float)chanList.size() / nCount);

    if (totalPages == 1)
        curPage = 1;
    else
    {
        curPage = (int)ceil((float)nStartIndex / nCount) + 1;
    }

    pChannelInfos->setStartIndex    ( nStartIndex     );
    pChannelInfos->setCount         ( nCount          );
    pChannelInfos->setCurrentPage   ( curPage         );
    pChannelInfos->setTotalPages    ( totalPages      );
    pChannelInfos->setTotalAvailable( chanList.size() );
    pChannelInfos->setAsOf          ( QDateTime::currentDateTime() );
    pChannelInfos->setVersion       ( MYTH_BINARY_VERSION );
    pChannelInfos->setProtoVer      ( MYTH_PROTO_VERSION  );

    return pChannelInfos;
}