Ticket #6612: DTV_StartNewFile_debug.diff

File DTV_StartNewFile_debug.diff, 4.4 KB (added by Shane Shrybman, 11 years ago)

Implement StartNewFile?() for DTV recorders (Writes first PAT/PMT to file)

  • mythtv/libs/libmythtv/RingBuffer.cpp

    int RingBuffer::Write(const void *buf, uint count) 
    12611261    if (!tfw)
    12621262        return ret;
    12631263
     1264    if (writepos < 1)
     1265    {
     1266        VERBOSE(VB_RECORD, LOC + "RB:: first write");
     1267    }
     1268
    12641269    pthread_rwlock_rdlock(&rwlock);
    12651270
    12661271    ret = tfw->Write(buf, count);
  • mythtv/libs/libmythtv/dtvrecorder.cpp

    void DTVRecorder::ResetForNewFile(void) 
    162162    _payload_buffer.clear();
    163163}
    164164
     165void DTVRecorder::StartNewFile(void)
     166{
     167    MPEGStreamData *sd = GetStreamData();
     168
     169    VERBOSE(VB_RECORD, LOC + "StartNewFile(void)"
     170            " (Writing first PAT/PMT) sd: "<<sd);
     171   
     172    if (sd)
     173    {
     174        bool tmp = _wait_for_keyframe_option;
     175        _wait_for_keyframe_option = false;
     176        HandleSingleProgramPAT(sd->PATSingleProgram());
     177        HandleSingleProgramPMT(sd->PMTSingleProgram());
     178        _wait_for_keyframe_option = tmp;
     179    }
     180}
     181
    165182// documented in recorderbase.h
    166183void DTVRecorder::Reset(void)
    167184{
    168185    VERBOSE(VB_RECORD, LOC + "Reset(void)");
    169186    ResetForNewFile();
     187    StartNewFile();
    170188
    171189    _start_code = 0xffffffff;
    172190
    void DTVRecorder::BufferedWrite(const TSPacket &tspacket) 
    180198    if (_wait_for_keyframe_option && _first_keyframe<0)
    181199        return;
    182200
     201    if (_first_keyframe<0)
     202    {
     203        VERBOSE(VB_RECORD, LOC + QString(
     204                "BufferedWrite(): Waiting for first Keyframe.  RB::written: %1"
     205                " buffered: %2").arg(ringBuffer ? ringBuffer->GetWritePosition():0)
     206                .arg(_payload_buffer.size()));
     207    }
     208
    183209    // Do we have to buffer the packet for exact keyframe detection?
    184210    if (_buffer_packets)
    185211    {
  • mythtv/libs/libmythtv/dtvrecorder.h

    using namespace std; 
    1919
    2020class MPEGStreamData;
    2121class TSPacket;
     22class ProgramAssociationTable;
     23class ProgramMapTable;
    2224class QTime;
    2325
    2426class DTVRecorder: public RecorderBase
    class DTVRecorder: public RecorderBase 
    4749    virtual void Reset();
    4850
    4951  protected:
     52    // MPEG Single Program Stream Listener
     53    virtual void HandleSingleProgramPAT(ProgramAssociationTable *pat) = 0;
     54    virtual void HandleSingleProgramPMT(ProgramMapTable*) = 0;
     55
    5056    void FinishRecording(void);
    5157    void ResetForNewFile(void);
     58    void StartNewFile(void);
    5259
    5360    void HandleKeyframe(uint64_t extra = 0);
    5461
  • mythtv/libs/libmythtv/dvbrecorder.cpp

    void DVBRecorder::StartRecording(void) 
    385385        _stream_data->AddListeningPID(DVB_TDT_PID);
    386386
    387387    // Make sure the first things in the file are a PAT & PMT
    388     bool tmp = _wait_for_keyframe_option;
    389     _wait_for_keyframe_option = false;
    390     HandleSingleProgramPAT(_stream_data->PATSingleProgram());
    391     HandleSingleProgramPMT(_stream_data->PMTSingleProgram());
    392     _wait_for_keyframe_option = tmp;
     388    StartNewFile();
    393389
    394390    _stream_data->AddAVListener(this);
    395391    _stream_data->AddWritingListener(this);
  • mythtv/libs/libmythtv/mpegrecorder.cpp

    void MpegRecorder::StartRecording(void) 
    10531053        sd->SetRecordingType(_recording_type);
    10541054        SetStreamData(sd);
    10551055
     1056        StartNewFile();
     1057
    10561058        _stream_data->AddAVListener(this);
    10571059        _stream_data->AddWritingListener(this);
    1058 
    1059         // Make sure the first things in the file are a PAT & PMT
    1060         _wait_for_keyframe_option = false;
    1061         HandleSingleProgramPAT(_stream_data->PATSingleProgram());
    1062         HandleSingleProgramPMT(_stream_data->PMTSingleProgram());
    1063         _wait_for_keyframe_option = true;
    10641060    }
    10651061
    10661062    encoding = true;