Ticket #2708: preferMythProto.patch

File preferMythProto.patch, 6.4 KB (added by anonymous, 19 years ago)

Slight update to fix doxygen

  • libs/libmythtv/jobqueue.cpp

     
    17761776        ChangeJobStatus(jobID, JOB_STARTING);
    17771777        program_info->SetTranscoded(TRANSCODING_RUNNING);
    17781778
    1779         QString filename = program_info->GetPlaybackURL();
     1779        // I need to get the filesize,
     1780        // // so we need to use the file (RW=true)
     1781        QString filename = program_info->GetPlaybackURL(true);
    17801782
    17811783        origfilesize = 0;
    17821784        filesize = 0;
     
    18391841                // Clear the pathname to force rechecking the DB in case
    18401842                // mythtranscode renamed the file.
    18411843                program_info->pathname = "";
    1842                 filename = program_info->GetPlaybackURL();
     1844                // I need to get the filesize,
     1845                // so we need to use the file (RW=true)
     1846                filename = program_info->GetPlaybackURL(true);
    18431847
    18441848                if (stat(filename.ascii(), &st) == 0)
    18451849                {
  • libs/libmythtv/previewgenerator.cpp

     
    6969    if (!QFileInfo(localFN).exists())
    7070    {
    7171        // GetPlaybackURL tries to return a local filename if one exists
    72         localFN = programInfo.GetPlaybackURL();
     72        localFN = programInfo.GetPlaybackURL(true);
    7373        if (!(localFN.left(1) == "/" && QFileInfo(localFN).exists()))
    7474            return; // didn't find file locally, must use remote backend
    7575    }
  • libs/libmythtv/RingBuffer.cpp

     
    168168    if ((filename.left(7) == "myth://") &&
    169169        (filename.length() > 7 ))
    170170    {
    171         QString local_pathname = gContext->GetSetting("RecordFilePrefix");
    172         int hostlen = filename.find(QRegExp("/"), 7);
    173 
    174         if (hostlen != -1)
     171        //If we don't prefer the myth proto, check to see if the file is
     172        //availible locally
     173        if (!gContext->GetSetting("PreferMythProto") )
    175174        {
    176             local_pathname += filename.right(filename.length() - hostlen);
     175            QString local_pathname = gContext->GetSetting("RecordFilePrefix");
     176            int hostlen = filename.find(QRegExp("/"), 7);
    177177
    178             QFile checkFile(local_pathname);
    179             if (checkFile.exists())
     178            if (hostlen != -1)
    180179            {
    181                 is_local = true;
    182                 filename = local_pathname;
     180                local_pathname += filename.right(filename.length() - hostlen);
     181
     182                QFile checkFile(local_pathname);
     183                if (checkFile.exists())
     184                {
     185                    is_local = true;
     186                    filename = local_pathname;
     187                }
    183188            }
    184189        }
     190
    185191    }
    186192#ifdef USING_FRONTEND
    187193    else if (filename.left(4) == "dvd:")
  • libs/libmythtv/programinfo.h

     
    160160    bool SetRecordBasename(QString basename);
    161161    QString GetRecordBasename(bool fromDB = false) const;
    162162    QString GetRecordFilename(const QString &prefix, bool fromDB = false) const;
    163     QString GetPlaybackURL(QString playbackHost = "") const;
     163    QString GetPlaybackURL(bool needRW = false) const;
    164164    QString MakeUniqueKey(void) const;
    165165    int CalculateLength(void) const;
    166166    int SecsTillStart() const;
  • libs/libmythtv/programinfo.cpp

     
    14671467    return QString("%1/%2").arg(prefix).arg(GetRecordBasename(fromDB));
    14681468}               
    14691469
    1470 /** \fn ProgramInfo::GetPlaybackURL(QString) const
     1470/** \fn ProgramInfo::GetPlaybackURL(bool) const
    14711471 *  \brief Returns URL to where %MythTV would stream the
    14721472 *         this program from, were it to be streamed.
     1473 *  \param needRW boolean to request that file needs to be
     1474 *         writeable or otherwise not a mythstream (default =
     1475 *         false)
    14731476 */
    1474 QString ProgramInfo::GetPlaybackURL(QString playbackHost) const
     1477QString ProgramInfo::GetPlaybackURL(bool needRW) const
    14751478{
    14761479    QString tmpURL;
    14771480    QString m_hostname = gContext->GetHostName();
    14781481
    1479     if (playbackHost == "")
    1480         playbackHost = m_hostname;
    1481 
    14821482    tmpURL = GetRecordFilename(gContext->GetSettingOnHost("RecordFilePrefix",
    14831483                                                          hostname));
     1484    bool preferMythProto = gContext->GetSettingOnHost("PreferMythProtocol",
     1485                                                          m_hostname);
    14841486
    1485     if (playbackHost == hostname)
     1487    //If this is local, use the file path
     1488    if (m_hostname == hostname)
    14861489        return tmpURL;
    14871490
    1488     if (playbackHost == m_hostname)
     1491    // I'd rather not use the mythproto, or I need to Read & Write
     1492    // Check my local recording dir, see if this recording is there
     1493    if (!preferMythProto || needRW)
    14891494    {
    14901495        QFile checkFile(tmpURL);
    14911496
     
    15001505            return tmpURL;
    15011506    }
    15021507
     1508    //Otherwise I prefer the myth protocol, or the file is not avail locally
     1509    //so stream the file
    15031510    tmpURL = QString("myth://") +
    15041511             gContext->GetSettingOnHost("BackendServerIP", hostname) + ":" +
    15051512             gContext->GetSettingOnHost("BackendServerPort", hostname) + "/" +
  • programs/mythtranscode/main.cpp

     
    395395            return TRANSCODE_EXIT_NO_RECORDING_DATA;
    396396        }
    397397
    398         infile = pginfo->GetPlaybackURL();
     398        // We can't transcode if we can't write
     399        infile = pginfo->GetPlaybackURL(true);
    399400    }
    400401    else
    401402    {
     
    584585        return;
    585586    }
    586587
    587     QString filename = pginfo->GetPlaybackURL();
     588    // We need to write the new file, so we need RW
     589    QString filename = pginfo->GetPlaybackURL(true);
    588590
    589591    if (status == JOB_STOPPING)
    590592    {