Ticket #1970: dvbrecorder_save_pidfilters.2.diff

File dvbrecorder_save_pidfilters.2.diff, 3.9 KB (added by Janne <janne-mythtv@…>, 18 years ago)

first round-robin implementation, something like HasEITPIDChanges and PMT tracking in MPEGStremData would be a better approach

  • libs/libmythtv/dvbrecorder.cpp

    old new void DVBRecorder::OpenFilter(uint pid, i 
    424424
    425425bool DVBRecorder::AdjustFilters(void)
    426426{
     427    _pmt_monitoring_pids.clear();
    427428    StopDummyVideo(); // Stop the dummy video before acquiring the lock.
    428429
    429430    QMutexLocker change_lock(&_pid_lock);
    bool DVBRecorder::AdjustFilters(void) 
    437438    add_stream_type.push_back(StreamID::PrivSec);
    438439    _stream_data->AddListeningPID(MPEG_PAT_PID);
    439440
    440     for (uint i = 0; i < _input_pat->ProgramCount(); i++)
    441     {
    442         add_pid.push_back(_input_pat->ProgramPID(i));
    443         add_stream_type.push_back(StreamID::PrivSec);
    444         _stream_data->AddListeningPID(_input_pat->ProgramPID(i));
    445     }
    446 
    447441    // Record the streams in the PMT...
    448442    bool need_pcr_pid = true;
    449443    for (uint i = 0; i < _input_pmt->StreamCount(); i++)
    bool DVBRecorder::AdjustFilters(void) 
    470464        _stream_data->AddListeningPID(_eit_pids[i]);
    471465    }
    472466
     467    for (uint i = 0; i < _input_pat->ProgramCount(); i++)
     468        _pmt_monitoring_pids.push_back(_input_pat->ProgramPID(i));
     469
    473470    // Delete filters for pids we no longer wish to monitor
    474471    PIDInfoMap::iterator it   = _pid_infos.begin();
    475472    PIDInfoMap::iterator next = it;
    bool DVBRecorder::AdjustEITPIDs(void) 
    536533    return true;
    537534}
    538535
     536void DVBRecorder::AdjustMonitoringPMTPIDs()
     537{
     538    if (_pmt_monitoring_pids.empty())
     539        return;
     540
     541    QMutexLocker change_lock(&_pid_lock);
     542
     543    while (!_pmt_listening_pids.empty())
     544    {
     545        uint pid = _pmt_listening_pids.front();
     546        if (_pid_infos.contains(pid))
     547        {
     548            _stream_data->RemoveListeningPID(pid);
     549            _stream_data->RemoveWritingPID(pid);
     550            _pid_infos[pid]->Close();
     551            delete _pid_infos[pid];
     552            _pid_infos.erase(pid);
     553        }
     554        _pmt_monitoring_pids.push_back(pid);
     555        _pmt_listening_pids.pop_front();
     556    }
     557
     558    for (unsigned int i=0; i<5 && i<_pmt_monitoring_pids.size(); ++i)
     559    {
     560        uint pid = _pmt_monitoring_pids.front();
     561        OpenFilter(pid, DMX_PES_OTHER, StreamID::PrivSec);
     562        _stream_data->AddListeningPID(pid);
     563        _pmt_listening_pids.push_back(pid);
     564        _pmt_monitoring_pids.pop_front();
     565    }
     566}
     567
    539568void DVBRecorder::StartRecording(void)
    540569{
    541570    if (!Open())
    void DVBRecorder::StartRecording(void) 
    565594    }
    566595    _drb->Start();
    567596
     597    int count = 0;
    568598    while (_request_recording && !_error)
    569599    {
    570600        if (PauseAndWait())
    void DVBRecorder::StartRecording(void) 
    602632            }
    603633        }
    604634
     635        if (count-- <= 0)
     636        {
     637            AdjustMonitoringPMTPIDs();
     638            count = 500;
     639        }
     640
    605641        ssize_t len = _drb->Read(_buffer, _buffer_size);
    606642        if (len > 0)
    607643            ProcessDataTS(_buffer, len);
  • libs/libmythtv/dvbrecorder.h

    old new  
    1010
    1111// C++ includes
    1212#include <vector>
     13#include <deque>
    1314using namespace std;
    1415
    1516// Qt includes
    class DVBRecorder : public DTVRecorder, 
    9192
    9293    bool AdjustFilters(void);
    9394    bool AdjustEITPIDs(void);
     95    void AdjustMonitoringPMTPIDs(void);
    9496    void CloseFilters(void);
    9597    void OpenFilter(uint pid, int pes_type, uint mpeg_stream_type);
    9698    int  OpenFilterFd(uint pid, int pes_type, uint stream_type);
    class DVBRecorder : public DTVRecorder, 
    132134    PIDInfoMap      _pid_infos;
    133135    uint_vec_t      _eit_pids;
    134136
     137    deque<uint>     _pmt_monitoring_pids;
     138    deque<uint>     _pmt_listening_pids;
     139
    135140    /// PAT on input side
    136141    ProgramAssociationTable *_input_pat;
    137142    /// PMT on input side