Index: libs/libmythtv/firewirechannel.cpp
===================================================================
--- libs/libmythtv/firewirechannel.cpp	(revision 9365)
+++ libs/libmythtv/firewirechannel.cpp	(working copy)
@@ -44,8 +44,8 @@
 
 FirewireChannel::FirewireChannel(FireWireDBOptions firewire_opts,
                                  TVRec *parent)
-    : ChannelBase(parent), fw_opts(firewire_opts),
-      fwhandle(NULL),      isopen(false)
+    : FirewireChannelBase(parent), fw_opts(firewire_opts),
+      fwhandle(NULL)
 {
 }
 
@@ -54,16 +54,8 @@
     Close();
 }
 
-bool FirewireChannel::SetChannelByString(const QString &chan)
+bool FirewireChannel::SetChannelByNumber(int channel)
 {
-    inputs[currentInputID]->startChanNum = chan;
-    curchannelname = chan;
-
-    InputMap::const_iterator it = inputs.find(currentInputID);
-
-    if (!(*it)->externalChanger.isEmpty())
-        return ChangeExternalChannel(chan);
-
     // Change channel using internal changer
 
     if (!is_supported(fw_opts.model))
@@ -74,10 +66,6 @@
         return false;
     }
 
-    if (!isopen)
-        return false;
-
-    int channel = chan.toInt();
     int dig[3];
     dig[0] = (channel % 1000) / 100;
     dig[1] = (channel % 100)  / 10;
@@ -138,15 +126,8 @@
     return true;
 }
 
-bool FirewireChannel::Open(void)
+bool FirewireChannel::OpenFirewire(void)
 {
-    if (!InitializeInputs())
-        return false;
-
-    InputMap::const_iterator it = inputs.find(currentInputID);
-    if (!(*it)->externalChanger.isEmpty())
-        return true;
-
     if (!is_supported(fw_opts.model))
     {
         VERBOSE(VB_IMPORTANT, LOC_ERR +
@@ -167,28 +148,11 @@
     VERBOSE(VB_CHANNEL, LOC + "Allocated raw1394 handle " +
             QString("for port %1").arg(fw_opts.port));
 
-    isopen = true;
     return true;
 }
 
-void FirewireChannel::Close(void)
+void FirewireChannel::CloseFirewire(void)
 {
-    // Close channel
-    if (isopen)
-    {
-        VERBOSE(VB_CHANNEL, LOC + "Releasing raw1394 handle");
-        raw1394_destroy_handle(fwhandle);
-        isopen = false;
-    }
+    VERBOSE(VB_CHANNEL, LOC + "Releasing raw1394 handle");
+    raw1394_destroy_handle(fwhandle);
 }
-
-bool FirewireChannel::SwitchToInput(const QString &input, const QString &chan)
-{
-    int inputNum = GetInputByName(input);
-    if (inputNum < 0)
-        return false;
-
-    // input switching code would go here
-
-    return SetChannelByString(chan);
-}
Index: libs/libmythtv/firewirerecorderbase.h
===================================================================
--- libs/libmythtv/firewirerecorderbase.h	(revision 9365)
+++ libs/libmythtv/firewirerecorderbase.h	(working copy)
@@ -8,10 +8,12 @@
 #define FIREWIRERECORDERBASE_H_
 
 #include "dtvrecorder.h"
+#include "tsstats.h"
 #include "mpeg/tspacket.h"
-#include <time.h>
 
-#define FIREWIRE_TIMEOUT 15
+class MPEGStreamData;
+class ProgramAssociationTable;
+class ProgramMapTable;
 
 /** \class FirewireRecorderBase
  *  \brief This is a specialization of DTVRecorder used to
@@ -21,38 +23,47 @@
  */
 class FirewireRecorderBase : public DTVRecorder
 {
+  Q_OBJECT
+    friend class MPEGStreamData;
+    friend class TSPacketProcessor;
+
   public:
-    FirewireRecorderBase(TVRec *rec, char const* name) :
-        DTVRecorder(rec, name),
-        lastpacket(0) 
-    {;}
-        
+    FirewireRecorderBase(TVRec *rec, char const* name);
+   ~FirewireRecorderBase();
+
+    // Commands
     void StartRecording(void);
     void ProcessTSPacket(const TSPacket &tspacket);
+    bool PauseAndWait(int timeout = 100);
+
+    // Sets
     void SetOptionsFromProfile(RecordingProfile *profile,
                                const QString &videodev,
                                const QString &audiodev,
                                const QString &vbidev);
+    void SetStreamData(MPEGStreamData*);
 
-    bool PauseAndWait(int timeout = 100);
+    // Gets
+    MPEGStreamData* StreamData(void) { return _mpeg_stream_data; }
 
   public slots:
     void deleteLater(void);
+    void WritePAT(ProgramAssociationTable*);
+    void WritePMT(ProgramMapTable*);
 
- protected:
-    static int read_tspacket (
-        unsigned char *tspacket, int len, uint dropped, void *callback_data);
+  private:
 
- private:
     virtual void Close() = 0;
-
     virtual void start() = 0;
     virtual void stop() = 0;
     virtual bool grab_frames() = 0;
-    virtual void no_data() = 0;
 
-  private:
-    time_t lastpacket;
+    MPEGStreamData  *_mpeg_stream_data;
+    TSStats          _ts_stats;  
+
+  protected:
+    static const int  kTimeoutInSeconds;
+
 };
 
 #endif
Index: libs/libmythtv/firewirechannelbase.h
===================================================================
--- libs/libmythtv/firewirechannelbase.h	(revision 9365)
+++ libs/libmythtv/firewirechannelbase.h	(working copy)
@@ -23,20 +23,19 @@
 class FirewireChannelBase : public ChannelBase
 {
   public:
-    FirewireChannelBase(TVRec *parent);
-    ~FirewireChannelBase();
+    FirewireChannelBase(TVRec *parent)  
+        : ChannelBase(parent), isopen(false) { }
+    ~FirewireChannelBase() { Close(); }
 
     bool Open(void);
     void Close(void);
 
     // Sets
     bool SetChannelByString(const QString &chan);
-    void SetExternalChanger(void);    
     virtual bool SetChannelByNumber(int channel) = 0;
 
     // Gets
     bool IsOpen(void) const { return isopen; }
-//    QString GetDevice(void) const;
 
     // Commands
     bool SwitchToInput(const QString &inputname, const QString &chan);
@@ -48,7 +47,6 @@
     virtual void CloseFirewire() = 0;
 
   protected:
-    bool UseExternalChanger();
     bool isopen;
 };
 
Index: libs/libmythtv/libmythtv.pro
===================================================================
--- libs/libmythtv/libmythtv.pro	(revision 9365)
+++ libs/libmythtv/libmythtv.pro	(working copy)
@@ -288,11 +288,26 @@
         DEFINES += USING_V4L
     }
 
-    # Support for cable boxes that provide Firewire out on Linux
-    using_firewire:HEADERS += firewirerecorder.h   firewirechannel.h
-    using_firewire:SOURCES += firewirerecorder.cpp firewirechannel.cpp
-    using_firewire:DEFINES += USING_FIREWIRE
+    # Support for cable boxes that provide Firewire out
+    using_firewire {
+        HEADERS += firewirerecorderbase.h       firewirechannelbase.h
+        SOURCES += firewirerecorderbase.cpp     firewirechannelbase.cpp
 
+#       macx {
+#          HEADERS += darwinfirewirechannel.h   darwinfirewirerecorder.h
+#          SOURCES += darwinfirewirechannel.cpp darwinfirewirerecorder.cpp
+#          HEADERS += selectavcdevice.h
+#          SOURCES += selectavcdevice.cpp
+#       }
+
+        linux {
+            HEADERS += firewirechannel.h        firewirerecorder.h
+            SOURCES += firewirechannel.cpp      firewirerecorder.cpp
+        }
+
+        DEFINES += USING_FIREWIRE
+    }
+
     # Support for set top boxes (Nokia DBox2 etc.)
     using_dbox2:SOURCES += dbox2recorder.cpp dbox2channel.cpp dbox2epg.cpp
     using_dbox2:HEADERS += dbox2recorder.h dbox2channel.h dbox2epg.h
Index: libs/libmythtv/darwinfirewirerecorder.cpp
===================================================================
--- libs/libmythtv/darwinfirewirerecorder.cpp	(revision 9365)
+++ libs/libmythtv/darwinfirewirerecorder.cpp	(working copy)
@@ -113,18 +113,7 @@
 {
     for (UInt32 i = 0; i < tsPacketCount; ++i)
     {
-        void* packet = ppBuf[i];
-        int ok = FirewireRecorderBase::read_tspacket( 
-            static_cast<unsigned char *>(packet), 
-              AVS::kMPEG2TSPacketSize,
-              0, // dropped
-              pRefCon);
-
-        // This is based on knowledge of what read_tspacket does --
-        // the only way it fails is with a NULL callback_data
-        // argument.
-        if (!ok)
-            return kIOReturnBadArgument;
+        ProcessTSPacket(*(reinterpret_cast<TSPacket*>(ppBuf[i])));
     }
     
     return 0;
Index: libs/libmythtv/firewirerecorderbase.cpp
===================================================================
--- libs/libmythtv/firewirerecorderbase.cpp	(revision 9365)
+++ libs/libmythtv/firewirerecorderbase.cpp	(working copy)
@@ -7,35 +7,37 @@
 // MythTV includes
 #include "firewirerecorderbase.h"
 #include "mythcontext.h"
-#include "tspacket.h"
+#include "mpegtables.h"
+#include "mpegstreamdata.h"
 #include "tv_rec.h"
 
-// callback function for libiec61883
-int FirewireRecorderBase::read_tspacket (unsigned char *tspacket, int /*len*/,
-                   uint dropped, void *callback_data)
-{
-    FirewireRecorderBase *fw = (FirewireRecorderBase*) callback_data;
+#define LOC QString("FireRecBase: ")
+#define LOC_ERR QString("FireRecBase, Error: ")
 
-    if (!fw)
-        return 0;
+const int FirewireRecorderBase::kTimeoutInSeconds = 15;
 
-    if (dropped)
-    {
-        VERBOSE(VB_RECORD,
-                QString("Firewire: %1 packet(s) dropped.").arg(dropped));
-    }
+FirewireRecorderBase::FirewireRecorderBase(TVRec *rec, char const* name) 
+    : DTVRecorder(rec, name),
+      _mpeg_stream_data(NULL)
+{
+    _mpeg_stream_data = new MPEGStreamData(1, true);
+    connect(_mpeg_stream_data,
+            SIGNAL(UpdatePATSingleProgram(ProgramAssociationTable*)),
+            this, SLOT(WritePAT(ProgramAssociationTable*)));
+    connect(_mpeg_stream_data,
+            SIGNAL(UpdatePMTSingleProgram(ProgramMapTable*)),
+            this, SLOT(WritePMT(ProgramMapTable*)));
+}
 
-    if (SYNC_BYTE != tspacket[0])
-    {
-        VERBOSE(VB_IMPORTANT, "Firewire: Got out of sync TS Packet");
-        return 1;
-    }
+FirewireRecorderBase::~FirewireRecorderBase()
+{
+   if (_mpeg_stream_data)
+   {
+       delete _mpeg_stream_data;
+       _mpeg_stream_data = NULL;
+   }
+}
 
-    fw->ProcessTSPacket(*(reinterpret_cast<TSPacket*>(tspacket)));
-
-    return 1;
-}
- 
 void FirewireRecorderBase::deleteLater(void)
 {
     Close();
@@ -44,7 +46,7 @@
 
 void FirewireRecorderBase::StartRecording(void) {
   
-    VERBOSE(VB_RECORD, QString("StartRecording"));
+    VERBOSE(VB_RECORD, LOC + "StartRecording");
 
     if (!Open()) {
         _error = true;        
@@ -54,28 +56,20 @@
     _request_recording = true;
     _recording = true;
    
-    this->start();
+    start();
 
-    lastpacket = time(NULL);
     while(_request_recording) {
        if (PauseAndWait())
            continue;
 
-       if (time(NULL) - lastpacket > FIREWIRE_TIMEOUT) {
-           this->no_data();
-           this->stop();
-           _error = true;
-           return;
-       }
-
-       if (!this->grab_frames())
+       if (!grab_frames())
        {
            _error = true;
            return;
        }
     }        
     
-    this->stop();
+    stop();
     FinishRecording();
 
     _recording = false;
@@ -83,9 +77,36 @@
 
 void FirewireRecorderBase::ProcessTSPacket(const TSPacket &tspacket)
 {
-    lastpacket = time(NULL);
-    _buffer_packets = !FindKeyframes(&tspacket);
-    BufferedWrite(tspacket);
+   if (tspacket.TransportError())
+        return;
+
+    if (tspacket.ScramplingControl())
+        return;
+
+    if (tspacket.HasAdaptationField())
+        StreamData()->HandleAdaptationFieldControl(&tspacket);
+
+    if (tspacket.HasPayload())
+    {
+        const unsigned int lpid = tspacket.PID();
+
+        // Pass or reject packets based on PID, and parse info from them
+        if (lpid == StreamData()->VideoPIDSingleProgram())
+        {
+            _buffer_packets = !FindKeyframes(&tspacket);
+            BufferedWrite(tspacket);
+        }
+        else if (StreamData()->IsAudioPID(lpid))
+            BufferedWrite(tspacket);
+        else if (StreamData()->IsListeningPID(lpid))
+            StreamData()->HandleTSTables(&tspacket);
+        else if (StreamData()->IsWritingPID(lpid))
+            BufferedWrite(tspacket);
+    }
+
+    _ts_stats.IncrTSPacketCount();
+    if (0 == _ts_stats.TSPacketCount()%1000000)
+        VERBOSE(VB_RECORD, _ts_stats.toString());
 }
 
 void FirewireRecorderBase::SetOptionsFromProfile(RecordingProfile *profile,
@@ -106,7 +127,7 @@
     {
         if (!paused)
         {
-            this->stop();
+            stop();
             paused = true;
             pauseWait.wakeAll();
             if (tvrec)
@@ -116,8 +137,39 @@
     }
     if (!request_pause && paused)
     {
-        this->start();
+        start();
         paused = false;
     }
     return paused;
 }
+
+void FirewireRecorderBase::SetStreamData(MPEGStreamData *stream_data)
+{
+    if (stream_data == _mpeg_stream_data)
+        return;
+
+    MPEGStreamData *old_data = _mpeg_stream_data;
+    _mpeg_stream_data = stream_data;
+    if (old_data)
+        delete old_data;
+}
+
+void FirewireRecorderBase::WritePAT(ProgramAssociationTable *pat)
+{
+    if (!pat)
+        return;
+
+    int next = (pat->tsheader()->ContinuityCounter()+1)&0xf;
+    pat->tsheader()->SetContinuityCounter(next);
+    BufferedWrite(*(reinterpret_cast<const TSPacket*>(pat->tsheader())));
+}
+
+void FirewireRecorderBase::WritePMT(ProgramMapTable *pmt)
+{
+    if (!pmt)
+        return;
+
+    int next = (pmt->tsheader()->ContinuityCounter()+1)&0xf;
+    pmt->tsheader()->SetContinuityCounter(next);
+    BufferedWrite(*(reinterpret_cast<const TSPacket*>(pmt->tsheader())));
+}
Index: libs/libmythtv/firewirerecorder.cpp
===================================================================
--- libs/libmythtv/firewirerecorder.cpp	(revision 9365)
+++ libs/libmythtv/firewirerecorder.cpp	(working copy)
@@ -22,10 +22,10 @@
 #define LOC QString("FireRec: ")
 #define LOC_ERR QString("FireRec, Error: ")
 
-const int FirewireRecorder::kBroadcastChannel    = 63;
-const int FirewireRecorder::kTimeoutInSeconds    = 15;
-const int FirewireRecorder::kConnectionP2P       = 0;
-const int FirewireRecorder::kConnectionBroadcast = 1;
+const int  FirewireRecorder::kBroadcastChannel    = 63;
+const int  FirewireRecorder::kConnectionP2P       = 0;
+const int  FirewireRecorder::kConnectionBroadcast = 1;
+const uint FirewireRecorder::kMaxBufferedPackets  = 8000;
 
 // callback function for libiec61883
 int fw_tspacket_handler(unsigned char *tspacket, int /*len*/,
@@ -59,47 +59,11 @@
     return QString("%1Mbps").arg(speeds[speed]);
 }
 
-FirewireRecorder::FirewireRecorder(TVRec *rec)
-    : DTVRecorder(rec, "FirewireRecorder"),
-      fwport(-1),     fwchannel(-1), fwspeed(-1),   fwbandwidth(-1),
-      fwfd(-1),       fwconnection(kConnectionP2P),
-      fwoplug(-1),    fwiplug(-1),   fwmodel(""),   fwnode(0),
-      fwhandle(NULL), fwmpeg(NULL),  isopen(false), lastpacket(0),
-      _mpeg_stream_data(NULL)
-{
-    _mpeg_stream_data = new MPEGStreamData(1, true);
-    connect(_mpeg_stream_data,
-            SIGNAL(UpdatePATSingleProgram(ProgramAssociationTable*)),
-            this, SLOT(WritePAT(ProgramAssociationTable*)));
-    connect(_mpeg_stream_data,
-            SIGNAL(UpdatePMTSingleProgram(ProgramMapTable*)),
-            this, SLOT(WritePMT(ProgramMapTable*)));
-}
-
-FirewireRecorder::~FirewireRecorder()
-{
-   Close();
-   if (_mpeg_stream_data)
-   {
-       delete _mpeg_stream_data;
-       _mpeg_stream_data = NULL;
-   }
-}
-
-void FirewireRecorder::deleteLater(void)
-{
-    Close();
-    DTVRecorder::deleteLater();
-}
-
 bool FirewireRecorder::Open(void)
 {
      if (isopen)
          return true;
 
-     if (!_mpeg_stream_data)
-         return false;
-
      VERBOSE(VB_RECORD, LOC +
              QString("Initializing Port: %1, Node: %2, Speed: %3")
              .arg(fwport).arg(fwnode).arg(speed_to_string(fwspeed)));
@@ -157,12 +121,14 @@
          return false;
      }
 
-     // Set buffer size
+     // Set buffered packets size
      size_t buffer_size = gContext->GetNumSetting("HDRingbufferSize",
                                                   50 * TSPacket::SIZE);
-     iec61883_mpeg2_set_buffers(fwmpeg, buffer_size / 2);
+     size_t buffered_packets = min(buffer_size / 4, kMaxBufferedPackets);
+     iec61883_mpeg2_set_buffers(fwmpeg, buffered_packets);
      VERBOSE(VB_IMPORTANT, LOC +
-             QString("Buffer size %1 KB").arg(buffer_size));
+             QString("Buffered packets %1 (%2 KB)").
+             arg(buffered_packets).arg(buffered_packets * 4));
 
      // Set speed if needed.
      // Probably shouldn't even allow user to set,
@@ -188,17 +154,6 @@
      return isopen = true;
 }
 
-void FirewireRecorder::SetStreamData(MPEGStreamData *stream_data)
-{
-    if (stream_data == _mpeg_stream_data)
-        return;
-
-    MPEGStreamData *old_data = _mpeg_stream_data;
-    _mpeg_stream_data = stream_data;
-    if (old_data)
-        delete old_data;
-}
-
 void FirewireRecorder::Close(void)
 {
     if (!isopen)
@@ -223,146 +178,35 @@
     raw1394_destroy_handle(fwhandle);
 }
 
-void FirewireRecorder::StartRecording(void)
+bool FirewireRecorder::grab_frames()
 {
     struct timeval tv;
     fd_set rfds;
 
-    VERBOSE(VB_RECORD, LOC + "StartRecording");
+    FD_ZERO(&rfds);
+    FD_SET(fwfd, &rfds);
+    tv.tv_sec = kTimeoutInSeconds;
+    tv.tv_usec = 0;
 
-    if (!Open())
+    if (select(fwfd + 1, &rfds, NULL, NULL, &tv)  <= 0)
     {
-        _error = true;
-        return;
+        VERBOSE(VB_IMPORTANT, LOC +
+                QString("No Input in %1 seconds [P:%2 N:%3] (select)")
+                .arg(kTimeoutInSeconds).arg(fwport).arg(fwnode));
+        return false;
     }
 
-    _request_recording = true;
-    _recording = true;
-
-    iec61883_mpeg2_recv_start(fwmpeg,fwchannel);
-    lastpacket = time(NULL);
-    while (_request_recording)
+    int ret = raw1394_loop_iterate(fwhandle);
+    if (ret)
     {
-       if (PauseAndWait())
-           continue;
-
-       if (time(NULL) - lastpacket > kTimeoutInSeconds)
-       {
-            VERBOSE(VB_IMPORTANT, LOC +
-                    QString("No Input in %1 seconds [P:%2 N:%3] (time)")
-                    .arg(kTimeoutInSeconds).arg(fwport).arg(fwnode));
-
-            iec61883_mpeg2_recv_stop(fwmpeg);
-            _error = true;
-            return;
-       }
-
-       FD_ZERO(&rfds);
-       FD_SET(fwfd, &rfds);
-       tv.tv_sec = kTimeoutInSeconds;
-       tv.tv_usec = 0;
-
-       if (select(fwfd + 1, &rfds, NULL, NULL, &tv) > 0)
-       {
-           int ret = raw1394_loop_iterate(fwhandle);
-           if (ret)
-           {
-               VERBOSE(VB_IMPORTANT, LOC_ERR + "libraw1394_loop_iterate() " +
-                       QString("returned %1").arg(ret));
-
-               iec61883_mpeg2_recv_stop(fwmpeg);
-               _error = true;
-               return;	
-           }
-       }
-       else
-       {
-           VERBOSE(VB_IMPORTANT, LOC +
-                   QString("No Input in %1 seconds [P:%2 N:%3] (select)")
-                   .arg(kTimeoutInSeconds).arg(fwport).arg(fwnode));
-
-           iec61883_mpeg2_recv_stop(fwmpeg);
-           // to bad setting _error does nothing once recording has started..
-           _error = true;
-           return;
-       }
+        VERBOSE(VB_IMPORTANT, LOC_ERR + "libraw1394_loop_iterate() " +
+                QString("returned %1").arg(ret));
+        return false;
     }
-
-    iec61883_mpeg2_recv_stop(fwmpeg);
-
-    VERBOSE(VB_IMPORTANT, QString("Firewire: Total dropped packets %1")
-            .arg(iec61883_mpeg2_get_dropped(fwmpeg)));
-
-    FinishRecording();
-    _recording = false;
+  
+    return true;
 }
 
-void FirewireRecorder::WritePAT(ProgramAssociationTable *pat)
-{
-    if (!pat)
-        return;
-
-    int next = (pat->tsheader()->ContinuityCounter()+1)&0xf;
-    pat->tsheader()->SetContinuityCounter(next);
-    BufferedWrite(*(reinterpret_cast<const TSPacket*>(pat->tsheader())));
-}
-
-void FirewireRecorder::WritePMT(ProgramMapTable *pmt)
-{
-    if (!pmt)
-        return;
-
-    int next = (pmt->tsheader()->ContinuityCounter()+1)&0xf;
-    pmt->tsheader()->SetContinuityCounter(next);
-    BufferedWrite(*(reinterpret_cast<const TSPacket*>(pmt->tsheader())));
-}
-
-void FirewireRecorder::ProcessTSPacket(const TSPacket &tspacket)
-{
-    if (tspacket.TransportError())
-        return;
-
-    if (tspacket.ScramplingControl())
-        return;
-
-    if (tspacket.HasAdaptationField())
-        StreamData()->HandleAdaptationFieldControl(&tspacket);
-
-    if (tspacket.HasPayload())
-    {
-        const unsigned int lpid = tspacket.PID();
-
-        // Pass or reject packets based on PID, and parse info from them
-        if (lpid == StreamData()->VideoPIDSingleProgram())
-        {
-            _buffer_packets = !FindKeyframes(&tspacket);
-            BufferedWrite(tspacket);
-        }
-        else if (StreamData()->IsAudioPID(lpid))
-            BufferedWrite(tspacket);
-        else if (StreamData()->IsListeningPID(lpid))
-            StreamData()->HandleTSTables(&tspacket);
-        else if (StreamData()->IsWritingPID(lpid))
-            BufferedWrite(tspacket);
-    }
-
-    lastpacket = time(NULL);
-    _ts_stats.IncrTSPacketCount();
-    if (0 == _ts_stats.TSPacketCount()%1000000)
-        VERBOSE(VB_RECORD, _ts_stats.toString());
-}
-
-void FirewireRecorder::SetOptionsFromProfile(RecordingProfile *profile,
-                                             const QString &videodev,
-                                             const QString &audiodev,
-                                             const QString &vbidev)
-{
-    (void)videodev;
-    (void)audiodev;
-    (void)vbidev;
-    (void)profile;
-}
-
 void FirewireRecorder::SetOption(const QString &name, const QString &value)
 {
     if (name == "model")
@@ -403,28 +247,3 @@
 	fwconnection = value;
     }
 }
-
-// documented in recorderbase.cpp
-bool FirewireRecorder::PauseAndWait(int timeout)
-{
-    if (request_pause)
-    {
-        if (!paused)
-        {
-            iec61883_mpeg2_recv_stop(fwmpeg);
-            paused = true;
-            pauseWait.wakeAll();
-            if (tvrec)
-                tvrec->RecorderPaused();
-        }
-        unpauseWait.wait(timeout);
-    }
-
-    if (!request_pause && paused)
-    {
-        iec61883_mpeg2_recv_start(fwmpeg, fwchannel);
-        paused = false;
-    }
-
-    return paused;
-}
Index: libs/libmythtv/firewirerecorder.h
===================================================================
--- libs/libmythtv/firewirerecorder.h	(revision 9365)
+++ libs/libmythtv/firewirerecorder.h	(working copy)
@@ -7,58 +7,41 @@
 #ifndef FIREWIRERECORDER_H_
 #define FIREWIRERECORDER_H_
 
-#include "dtvrecorder.h"
+#include "firewirerecorderbase.h"
 #include "tsstats.h"
 #include <libraw1394/raw1394.h>
 #include <libiec61883/iec61883.h>
-#include <time.h>
 
-class MPEGStreamData;
-class ProgramAssociationTable;
-class ProgramMapTable;
-
 /** \class FirewireRecorder
- *  \brief This is a specialization of DTVRecorder used to
- *         handle DVB and ATSC streams from a firewire input.
+ *  \brief Linux FirewireRecorder
  *
- *  \sa DTVRecorder
+ *  \sa FirewireRecorderBase
  */
-class FirewireRecorder : public DTVRecorder
+class FirewireRecorder : public FirewireRecorderBase
 {
-  Q_OBJECT
-    friend class MPEGStreamData;
-    friend class TSPacketProcessor;
     friend int fw_tspacket_handler(unsigned char*,int,uint,void*);
 
   public:
-    FirewireRecorder(TVRec *rec);
-   ~FirewireRecorder();
+    FirewireRecorder(TVRec *rec)
+        : FirewireRecorderBase(rec, "FirewireRecorder"),
+        fwport(-1),     fwchannel(-1), fwspeed(-1),   fwbandwidth(-1),
+        fwfd(-1),       fwconnection(kConnectionP2P),
+        fwoplug(-1),    fwiplug(-1),   fwmodel(""),   fwnode(0),
+        fwhandle(NULL), fwmpeg(NULL),  isopen(false) { }
+   ~FirewireRecorder() { Close(); }
 
     // Commands
-    void StartRecording(void);
     bool Open(void); 
-    bool PauseAndWait(int timeout = 100);
 
     // Sets
-    void SetOptionsFromProfile(RecordingProfile *profile,
-                               const QString &videodev,
-                               const QString &audiodev,
-                               const QString &vbidev);
     void SetOption(const QString &name, const QString &value);
     void SetOption(const QString &name, int value);
-    void SetStreamData(MPEGStreamData*);
 
-    // Gets
-    MPEGStreamData* StreamData(void) { return _mpeg_stream_data; }
-
-  public slots:
-    void deleteLater(void);
-    void WritePAT(ProgramAssociationTable*);
-    void WritePMT(ProgramMapTable*);
-        
   private:
     void Close(void);
-    void ProcessTSPacket(const TSPacket &tspacket);
+    void start() { iec61883_mpeg2_recv_start(fwmpeg, fwchannel); }
+    void stop() { iec61883_mpeg2_recv_stop(fwmpeg); }
+    bool grab_frames();
 
   private:
     int              fwport;
@@ -74,14 +57,11 @@
     raw1394handle_t  fwhandle;
     iec61883_mpeg2_t fwmpeg;
     bool             isopen;
-    time_t           lastpacket;
-    MPEGStreamData  *_mpeg_stream_data;
-    TSStats          _ts_stats;  
 
-    static const int kBroadcastChannel;
-    static const int kTimeoutInSeconds;
-    static const int kConnectionP2P;
-    static const int kConnectionBroadcast;
+    static const int  kBroadcastChannel;
+    static const int  kConnectionP2P;
+    static const int  kConnectionBroadcast;
+    static const uint kMaxBufferedPackets;
 };
 
 #endif
Index: libs/libmythtv/firewirechannel.h
===================================================================
--- libs/libmythtv/firewirechannel.h	(revision 9365)
+++ libs/libmythtv/firewirechannel.h	(working copy)
@@ -11,39 +11,34 @@
 
 #include <qstring.h>
 #include "tv_rec.h"
-#include "channelbase.h"
+#include "firewirechannelbase.h"
 #include <libavc1394/avc1394.h>
 
 using namespace std;
 
-class FirewireChannel : public ChannelBase
+class FirewireChannel : public FirewireChannelBase
 {
   public:
     FirewireChannel(FireWireDBOptions firewire_opts, TVRec *parent);
     ~FirewireChannel(void);
 
-    bool Open(void);
-    void Close(void);
+    bool OpenFirewire(void);
+    void CloseFirewire(void);
 
     // Sets
-    bool SetChannelByString(const QString &chan);
-    void SetExternalChanger(void);    
+    void SetExternalChanger(void);
+    bool SetChannelByNumber(int channel);
 
     // Gets
     bool IsOpen(void) const { return isopen; }
     QString GetDevice(void) const
         { return QString("%1:%2").arg(fw_opts.port).arg(fw_opts.node); }
 
-    // Commands
-    bool SwitchToInput(const QString &inputname, const QString &chan);
-    bool SwitchToInput(int newcapchannel, bool setstarting)
-        { (void)newcapchannel; (void)setstarting; return false; }
 
   private:
     FireWireDBOptions  fw_opts;
     nodeid_t           fwnode;
     raw1394handle_t    fwhandle;
-    bool               isopen;
 };
 
 #endif
Index: libs/libmythtv/firewirechannelbase.cpp
===================================================================
--- libs/libmythtv/firewirechannelbase.cpp	(revision 9365)
+++ libs/libmythtv/firewirechannelbase.cpp	(working copy)
@@ -9,68 +9,48 @@
 #include "mythcontext.h"
 #include "firewirechannelbase.h"
 
-bool FirewireChannelBase::UseExternalChanger()
-{ 
-    return !externalChanger[currentcapchannel].isEmpty(); 
-}
-
-FirewireChannelBase::FirewireChannelBase(TVRec *parent)
-  : ChannelBase(parent), isopen(false)
+bool FirewireChannelBase::SetChannelByString(const QString &chan)
 {
-	
-    isopen = false;
-    channelnames[0] = "MPEG2TS";
-}
+    inputs[currentInputID]->startChanNum = chan;
+    curchannelname = chan;
 
-FirewireChannelBase::~FirewireChannelBase(void)
-{
-    this->Close();
-}
+    InputMap::const_iterator it = inputs.find(currentInputID);   
 
-bool FirewireChannelBase::SetChannelByString(const QString &chan)
-{
-     inputChannel[currentcapchannel] = chan;
-     curchannelname = chan;
+    if (!(*it)->externalChanger.isEmpty())
+        return ChangeExternalChannel(chan);
 
-     if (this->UseExternalChanger())
-         return ChangeExternalChannel(chan);
-     else
-         return isopen && SetChannelByNumber(chan.toInt());
+    return isopen && SetChannelByNumber(chan.toInt());
 }
 
 bool FirewireChannelBase::Open()
 {
-    if (this->UseExternalChanger())
-    {
-        this->SetExternalChanger();
+    if (!InitializeInputs())
+        return false;
+
+    InputMap::const_iterator it = inputs.find(currentInputID);
+    if (!(*it)->externalChanger.isEmpty())
         return true;
-    }
-    else
+
+    if (!isopen)
     {
-        if (!this->isopen)
-            this->isopen = this->OpenFirewire();
-        return this->isopen;
+        isopen = OpenFirewire();
+        return isopen;
     }
+    return true;
 }
 
 void FirewireChannelBase::Close()
 {
-    if (this->isopen)
+    if (isopen)
         CloseFirewire();
-    this->isopen = false;
+    isopen = false;
 }
     
 bool FirewireChannelBase::SwitchToInput(const QString &input, const QString &chan)
 {
-    currentcapchannel = 0;
-    if (channelnames.empty())
-       channelnames[currentcapchannel] = input;
+    int inputNum = GetInputByName(input);
+    if (inputNum < 0)
+        return false;
 
     return SetChannelByString(chan);
 }
-
-void FirewireChannelBase::SetExternalChanger(void)
-{	
-    RetrieveInputChannels(inputChannel, inputTuneTo,
-                          externalChanger, sourceid);
-}
