Esempio n. 1
0
bool DVBChannel::Tune(const DTVMultiplex &tuning, QString inputname)
{
    int inputid = inputname.isEmpty() ? m_currentInputID : GetInputByName(inputname);
    if (inputid < 0)
    {
        VERBOSE(VB_IMPORTANT, LOC_ERR + QString("Tune(): Invalid input '%1'.")
                .arg(inputname));
        return false;
    }
    return Tune(tuning, inputid, false, false);
}
Esempio n. 2
0
bool DVBChannel::SwitchToInput(const QString &inputname, const QString &chan)
{
    int input = GetInputByName(inputname);

    bool ok = false;
    if (input >= 0)
    {
        m_currentInputID = input;
        ok = SetChannelByString(chan);
    }
    else
    {
        LOG(VB_GENERAL, LOG_ERR, LOC +
            QString("DVBChannel: Could not find input: %1 on card when "
                    "setting channel %2\n").arg(inputname).arg(chan));
    }
    return ok;
}
Esempio n. 3
0
bool DVBChannel::SelectInput(const QString &inputname, const QString &chan,
                             bool use_sm)
{
    int input = GetInputByName(inputname);

    if (input >= 0)
    {
        nextInputID = input;
        SelectChannel(chan, use_sm);
    }
    else
    {
        VERBOSE(VB_IMPORTANT,
                QString("DVBChannel: Could not find input: %1 on card when "
                        "setting channel %2\n").arg(inputname).arg(chan));
        return false;
    }
    return true;
}
Esempio n. 4
0
bool DVBChannel::SetChannelByString(const QString &channum)
{
    QString tmp     = QString("SetChannelByString(%1): ").arg(channum);
    QString loc     = LOC + tmp;
    QString loc_err = LOC_ERR + tmp;

    VERBOSE(VB_CHANNEL, loc);

    if (!IsOpen())
    {
        VERBOSE(VB_IMPORTANT, loc_err + "Channel object "
                "will not open, cannot change channels.");

        ClearDTVInfo();
        return false;
    }

    ClearDTVInfo();

    QString inputName;
    if (!CheckChannel(channum, inputName))
    {
        VERBOSE(VB_IMPORTANT, loc_err +
                "CheckChannel failed.\n\t\t\tPlease verify the channel "
                "in the 'mythtv-setup' Channel Editor.");

        return false;
    }

    // If CheckChannel filled in the inputName we need to change inputs.
    if (!inputName.isEmpty() && (nextInputID == m_currentInputID))
        nextInputID = GetInputByName(inputName);

    // Get the input data for the channel
    int inputid = (nextInputID >= 0) ? nextInputID : m_currentInputID;
    InputMap::const_iterator it = m_inputs.find(inputid);
    if (it == m_inputs.end())
        return false;

    uint mplexid_restriction;
    if (!IsInputAvailable(inputid, mplexid_restriction))
    {
        VERBOSE(VB_IMPORTANT, loc_err + "Input is not available");
        return false;
    }

    // Get the input data for the channel
    QString tvformat, modulation, freqtable, freqid, si_std;
    int finetune;
    uint64_t frequency;
    int mpeg_prog_num;
    uint atsc_major, atsc_minor, mplexid, tsid, netid;

    if (!ChannelUtil::GetChannelData(
        (*it)->sourceid, channum,
        tvformat, modulation, freqtable, freqid,
        finetune, frequency,
        si_std, mpeg_prog_num, atsc_major, atsc_minor, tsid, netid,
        mplexid, m_commfree))
    {
        VERBOSE(VB_IMPORTANT, loc_err +
                "Unable to find channel in database.");

        return false;
    }

    if (mplexid_restriction && (mplexid != mplexid_restriction))
    {
        VERBOSE(VB_IMPORTANT, loc_err + "Multiplex is not available");
        return false;
    }

    // Initialize basic the tuning parameters
    DTVMultiplex tuning;
    if (!mplexid || !tuning.FillFromDB(tunerType, mplexid))
    {
        VERBOSE(VB_IMPORTANT, loc_err +
                "Failed to initialize multiplex options");

        return false;
    }

    SetDTVInfo(atsc_major, atsc_minor, netid, tsid, mpeg_prog_num);

    // Try to fix any problems with the multiplex
    CheckOptions(tuning);

    if (!Tune(tuning, inputid))
    {
        VERBOSE(VB_IMPORTANT, loc_err + "Tuning to frequency.");

        ClearDTVInfo();
        return false;
    }

    QString tmpX = channum; tmpX.detach();
    m_curchannelname = tmpX;

    VERBOSE(VB_CHANNEL, loc + "Tuned to frequency.");

    m_currentInputID = nextInputID;
    QString tmpY = m_curchannelname; tmpY.detach();
    m_inputs[m_currentInputID]->startChanNum = tmpY;

    return true;
}