Skip to content

Commit

Permalink
DTVRecorder: buffer up each payload until we know if the payload is a
Browse files Browse the repository at this point in the history
keyframe.

Especially with H.264, we can be several packets into a payload before we
know if it is a keyframe or just a frame or something else.  Always buffer
the packets of a payload until we know what we are doing with the payload.

If we need to switch ringbuffers, we now do it so the new file will start at
the beginning of the payload holding a keyframe.  Each file will also start
with a PAT/PMT if the "recorder" calls for it.
(cherry picked from commit 87a15e1)

Signed-off-by: Taylor Ralph <tralph@mythtv.org>
  • Loading branch information
jpoet authored and tralph committed Mar 3, 2013
1 parent 947bb60 commit 71ad653
Show file tree
Hide file tree
Showing 13 changed files with 227 additions and 167 deletions.
15 changes: 9 additions & 6 deletions mythtv/libs/libmythtv/asirecorder.cpp
Expand Up @@ -62,6 +62,14 @@ void ASIRecorder::SetOption(const QString &name, int value)
DTVRecorder::SetOption(name, value);
}

void ASIRecorder::StartNewFile(void)
{
// Make sure the first things in the file are a PAT & PMT
HandleSingleProgramPAT(_stream_data->PATSingleProgram(), true);
HandleSingleProgramPMT(_stream_data->PMTSingleProgram(), true);
}


void ASIRecorder::run(void)
{
if (!Open())
Expand Down Expand Up @@ -99,12 +107,7 @@ void ASIRecorder::run(void)
if (m_channel && (m_channel->GetSIStandard() == "dvb"))
_stream_data->AddListeningPID(DVB_TDT_PID);

// Make sure the first things in the file are a PAT & PMT
bool tmp = _wait_for_keyframe_option;
_wait_for_keyframe_option = false;
HandleSingleProgramPAT(_stream_data->PATSingleProgram());
HandleSingleProgramPMT(_stream_data->PMTSingleProgram());
_wait_for_keyframe_option = tmp;
StartNewFile();

_stream_data->AddAVListener(this);
_stream_data->AddWritingListener(this);
Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmythtv/asirecorder.h
Expand Up @@ -68,6 +68,7 @@ class ASIRecorder : public DTVRecorder
bool Open(void);
bool IsOpen(void) const;
void Close(void);
void StartNewFile(void);

private:
ASIChannel *m_channel;
Expand Down
14 changes: 8 additions & 6 deletions mythtv/libs/libmythtv/cetonrecorder.cpp
Expand Up @@ -46,6 +46,13 @@ void CetonRecorder::Close(void)
LOG(VB_RECORD, LOG_INFO, LOC + "Close() -- end");
}

void CetonRecorder::StartNewFile(void)
{
// Make sure the first things in the file are a PAT & PMT
HandleSingleProgramPAT(_stream_data->PATSingleProgram(), true);
HandleSingleProgramPMT(_stream_data->PMTSingleProgram(), true);
}

void CetonRecorder::run(void)
{
LOG(VB_RECORD, LOG_INFO, LOC + "run -- begin");
Expand All @@ -65,12 +72,7 @@ void CetonRecorder::run(void)
recordingWait.wakeAll();
}

// Make sure the first things in the file are a PAT & PMT
bool tmp = _wait_for_keyframe_option;
_wait_for_keyframe_option = false;
HandleSingleProgramPAT(_stream_data->PATSingleProgram());
HandleSingleProgramPMT(_stream_data->PMTSingleProgram());
_wait_for_keyframe_option = tmp;
StartNewFile();

_stream_data->AddAVListener(this);
_stream_data->AddWritingListener(this);
Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmythtv/cetonrecorder.h
Expand Up @@ -26,6 +26,7 @@ class CetonRecorder : public DTVRecorder

bool Open(void);
void Close(void);
void StartNewFile(void);

bool IsOpen(void) const { return _stream_handler; }

Expand Down

0 comments on commit 71ad653

Please sign in to comment.