Skip to content

Commit

Permalink
Support MPTS recordings on HDHomeRun
Browse files Browse the repository at this point in the history
The channel scan option 'Add full Transport Stream Channels' creates
additionally the MPTS channels, one per transport stream, using
which the full, unaltered, transport stream can be recorded.
This is now also possible with HDHomeRun devices.
Previously, mythbackend crashed with a segfault when such
a recording was attempted.
  • Loading branch information
kmdewaal committed Feb 22, 2020
1 parent 66b7dd2 commit ebbb3bb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
33 changes: 27 additions & 6 deletions mythtv/libs/libmythtv/recorders/hdhrrecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// MythTV includes
#include "hdhrstreamhandler.h"
#include "atscstreamdata.h"
#include "tsstreamdata.h"
#include "hdhrrecorder.h"
#include "hdhrchannel.h"
#include "ringbuffer.h"
Expand All @@ -30,6 +31,15 @@ bool HDHRRecorder::Open(void)

ResetForNewFile();

if (m_channel->GetFormat().compare("MPTS") == 0)
{
// MPTS only. Use TSStreamData to write out unfiltered data.
LOG(VB_RECORD, LOG_INFO, LOC + "Using TSStreamData");
SetStreamData(new TSStreamData(m_tvrec ? m_tvrec->GetInputId() : -1));
m_recordMptsOnly = true;
m_recordMpts = false;
}

m_streamHandler = HDHRStreamHandler::Get(m_channel->GetDevice(),
m_channel->GetInputID(),
m_channel->GetMajorID());
Expand All @@ -52,12 +62,15 @@ void HDHRRecorder::Close(void)

void HDHRRecorder::StartNewFile(void)
{
if (m_recordMpts)
m_streamHandler->AddNamedOutputFile(m_ringBuffer->GetFilename());
if (!m_recordMptsOnly)
{
if (m_recordMpts)
m_streamHandler->AddNamedOutputFile(m_ringBuffer->GetFilename());

// Make sure the first things in the file are a PAT & PMT
HandleSingleProgramPAT(m_streamData->PATSingleProgram(), true);
HandleSingleProgramPMT(m_streamData->PMTSingleProgram(), true);
// Make sure the first things in the file are a PAT & PMT
HandleSingleProgramPAT(m_streamData->PATSingleProgram(), true);
HandleSingleProgramPMT(m_streamData->PMTSingleProgram(), true);
}
}

void HDHRRecorder::run(void)
Expand All @@ -79,6 +92,14 @@ void HDHRRecorder::run(void)
m_recordingWait.wakeAll();
}

// Listen for time table on DVB standard streams
if (m_channel && (m_channel->GetSIStandard() == "dvb"))
m_streamData->AddListeningPID(DVB_TDT_PID);

// Gives errors about invalid PID but it does work...
if (m_recordMptsOnly)
m_streamData->AddListeningPID(0x2000);

StartNewFile();

m_streamData->AddAVListener(this);
Expand All @@ -102,7 +123,7 @@ void HDHRRecorder::run(void)
m_unpauseWait.wait(&m_pauseLock, 100);
}

if (!m_inputPmt)
if (!m_inputPmt && !m_recordMptsOnly)
{
LOG(VB_GENERAL, LOG_WARNING, LOC +
"Recording will not commence until a PMT is set.");
Expand Down
8 changes: 6 additions & 2 deletions mythtv/libs/libmythtv/recorders/hdhrstreamhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,12 @@ QString HDHRStreamHandler::TunerSet(
{
if (print_error)
{
LOG(VB_GENERAL, LOG_ERR, LOC + QString("DeviceSet(%1 %2): %3")
.arg(name).arg(val).arg(error));
// Skip error messages from MPTS recordings
if (!(val.contains("0x2000") && strstr(error, "ERROR: invalid pid filter")))
{
LOG(VB_GENERAL, LOG_ERR, LOC + QString("DeviceSet(%1 %2): %3")
.arg(name).arg(val).arg(error));
}
}

return QString();
Expand Down

0 comments on commit ebbb3bb

Please sign in to comment.