Ticket #5866: hdpvr-livetv.patch

File hdpvr-livetv.patch, 3.7 KB (added by jppoet@…, 11 years ago)

Fix LiveTV for the HD-PVR

  • libs/libmythtv/mpegrecorder.cpp

    old new void MpegRecorder::StartRecording(void) 
    11091109
    11101110    if (driver == "hdpvr")
    11111111    {
     1112        if (curRecording->recgroup == "LiveTV")
     1113        {
     1114            // Don't bother checking resolution, always use best bitrate
     1115            int maxbitrate = std::max(high_mpeg4peakbitrate,
     1116                                      high_mpeg4avgbitrate);
     1117            SetBitrate(high_mpeg4avgbitrate, maxbitrate, "LiveTV");
     1118        }
     1119
    11121120        int progNum = 1;
    11131121        MPEGStreamData *sd = new MPEGStreamData(progNum, true);
    11141122        sd->SetRecordingType(_recording_type);
    bool MpegRecorder::StartEncoding(int fd) 
    15531561    memset(&command, 0, sizeof(struct v4l2_encoder_cmd));
    15541562    command.cmd = V4L2_ENC_CMD_START;
    15551563
    1556     if (driver == "hdpvr")
     1564    if (driver == "hdpvr" && curRecording->recgroup != "LiveTV")
    15571565        HandleResolutionChanges();
    15581566
    15591567    VERBOSE(VB_RECORD, LOC + "StartEncoding");
    bool MpegRecorder::WaitFor_HDPVR(void) 
    17551763    return false;
    17561764}
    17571765
     1766void MpegRecorder::SetBitrate(int bitrate, int maxbitrate,
     1767                              const QString & reason)
     1768{
     1769    if (maxbitrate == bitrate)
     1770    {
     1771        VERBOSE(VB_RECORD, LOC + QString("%1 bitrate %2 kbps CBR")
     1772                .arg(reason).arg(bitrate));
     1773    }
     1774    else
     1775    {
     1776        VERBOSE(VB_RECORD, LOC + QString("%1 bitrate %2/%3 kbps VBR")
     1777                .arg(reason).arg(bitrate).arg(maxbitrate));
     1778    }
     1779
     1780    vector<struct v4l2_ext_control> ext_ctrls;
     1781    add_ext_ctrl(ext_ctrls, V4L2_CID_MPEG_VIDEO_BITRATE_MODE,
     1782                 (maxbitrate == bitrate) ?
     1783                 V4L2_MPEG_VIDEO_BITRATE_MODE_CBR :
     1784                 V4L2_MPEG_VIDEO_BITRATE_MODE_VBR);
     1785
     1786    add_ext_ctrl(ext_ctrls, V4L2_CID_MPEG_VIDEO_BITRATE,
     1787                 bitrate * 1000);
     1788
     1789    add_ext_ctrl(ext_ctrls, V4L2_CID_MPEG_VIDEO_BITRATE_PEAK,
     1790                 maxbitrate * 1000);
     1791
     1792    set_ctrls(readfd, ext_ctrls);
     1793}
     1794
    17581795void MpegRecorder::HandleResolutionChanges(void)
    17591796{
    17601797    VERBOSE(VB_RECORD, LOC + "Checking Resolution");
    void MpegRecorder::HandleResolutionChang 
    18191856                    .arg(old_avg).arg(old_max));
    18201857        }
    18211858
    1822         if (maxbitrate == bitrate)
    1823         {
    1824             VERBOSE(VB_RECORD, LOC + QString("New bitrate %1 kbps CBR")
    1825                     .arg(bitrate));
    1826         }
    1827         else
    1828         {
    1829             VERBOSE(VB_RECORD, LOC + QString("New bitrate %1/%2 kbps VBR")
    1830                     .arg(bitrate).arg(maxbitrate));
    1831         }
    1832 
    1833         vector<struct v4l2_ext_control> ext_ctrls;
    1834         add_ext_ctrl(ext_ctrls, V4L2_CID_MPEG_VIDEO_BITRATE_MODE,
    1835                      (maxbitrate == bitrate) ?
    1836                      V4L2_MPEG_VIDEO_BITRATE_MODE_CBR :
    1837                      V4L2_MPEG_VIDEO_BITRATE_MODE_VBR);
    1838 
    1839         add_ext_ctrl(ext_ctrls, V4L2_CID_MPEG_VIDEO_BITRATE,
    1840                      bitrate * 1000);
    1841 
    1842         add_ext_ctrl(ext_ctrls, V4L2_CID_MPEG_VIDEO_BITRATE_PEAK,
    1843                      maxbitrate * 1000);
    1844 
    1845         set_ctrls(readfd, ext_ctrls);
    1846 
     1859        SetBitrate(bitrate, maxbitrate, "New");
    18471860    }
    18481861}
     1862
  • libs/libmythtv/mpegrecorder.h

    old new class MpegRecorder : public DTVRecorder, 
    8787    void ResetForNewFile(void);
    8888
    8989    bool WaitFor_HDPVR(void);
     90    void SetBitrate(int bitrate, int maxbitrate, const QString & reason);
    9091    void HandleResolutionChanges(void);
    9192
    9293    inline bool CheckCC(uint pid, uint cc);