From aed81816e73763ac3f8f26d4823d831c2e847fdf Mon Sep 17 00:00:00 2001
From: Adam Williamson <awilliam@redhat.com>
Date: Sat, 30 Aug 2014 14:33:08 -0700
Subject: [PATCH] firewirerecorder: use DTVRecorder for TS processing (fixes
 MPEG-4)

This fixes https://code.mythtv.org/trac/ticket/10080 and reduces
code duplication into the bargain. I couldn't find a way to
factor out FirewireRecorder::ProcessTSPacket entirely, but this
turns it into a fairly thin wrapper around the
ProcessAudioTSPacket and ProcessVideoTSPacket functions in
DTVRecorder. ProcessVideoTSPacket handles MPEG-4 just fine. This
also seems to speed up initial lock. Tested with a DCX3400 on
Shaw (Vancouver) - both MPEG-2 and MPEG-4 channels work.
---
 .../libs/libmythtv/recorders/firewirerecorder.cpp  | 29 ++++++++--------------
 1 file changed, 10 insertions(+), 19 deletions(-)

diff --git a/mythtv/libs/libmythtv/recorders/firewirerecorder.cpp b/mythtv/libs/libmythtv/recorders/firewirerecorder.cpp
index d7c6ae6..adff37f 100644
--- a/mythtv/libs/libmythtv/recorders/firewirerecorder.cpp
+++ b/mythtv/libs/libmythtv/recorders/firewirerecorder.cpp
@@ -154,26 +154,17 @@ bool FirewireRecorder::ProcessTSPacket(const TSPacket &tspacket)
     if (tspacket.HasAdaptationField())
         GetStreamData()->HandleAdaptationFieldControl(&tspacket);
 
-    if (tspacket.HasPayload())
-    {
-        const unsigned int lpid = tspacket.PID();
+    if (GetStreamData()->IsVideoPID(tspacket.PID()))
+        return ProcessVideoTSPacket(tspacket);
 
-        // Pass or reject packets based on PID, and parse info from them
-        if (lpid == GetStreamData()->VideoPIDSingleProgram())
-        {
-            _buffer_packets = !FindMPEG2Keyframes(&tspacket);
-            BufferedWrite(tspacket);
-        }
-        else if (GetStreamData()->IsAudioPID(lpid))
-        {
-            _buffer_packets = !FindAudioKeyframes(&tspacket);
-            BufferedWrite(tspacket);
-        }
-        else if (GetStreamData()->IsListeningPID(lpid))
-            GetStreamData()->HandleTSTables(&tspacket);
-        else if (GetStreamData()->IsWritingPID(lpid))
-            BufferedWrite(tspacket);
-    }
+    if (GetStreamData()->IsAudioPID(tspacket.PID()))
+        return ProcessAudioTSPacket(tspacket);
+
+    if (GetStreamData()->IsWritingPID(tspacket.PID()))
+        BufferedWrite(tspacket);
+
+    if (GetStreamData()->IsListeningPID(tspacket.PID()) && tspacket.HasPayload())
+        GetStreamData()->HandleTSTables(&tspacket);
 
     return true;
 }
-- 
2.1.0

