Ticket #1648: firewire-sm-v15.patch
File firewire-sm-v15.patch, 47.3 KB (added by , 17 years ago) |
---|
-
libs/libmythtv/firewirechannel.cpp
1 1 /** 2 2 * FirewireChannel 3 3 * Copyright (c) 2005 by Jim Westfall 4 * SA3250HD support Copyright (c) 2005 by Matt Porter5 * SA4200HD/Alternate 3250 support Copyright (c) 2006 by Chris Ingrassia6 4 * Distributed as part of MythTV under GPL v2 and later. 7 5 */ 8 6 9 10 #include <iostream> 7 // MythTV headers 11 8 #include "mythcontext.h" 12 9 #include "firewirechannel.h" 10 #include "linuxfirewiredevice.h" 13 11 14 12 class TVRec; 15 13 16 #define LOC QString("FireChan: ") 17 #define LOC_ERR QString("FireChan, Error: ") 14 #define LOC QString("FireChan(%1): ").arg(GetDevice()) 15 #define LOC_WARN QString("FireChan(%1), Warning: ").arg(GetDevice()) 16 #define LOC_ERR QString("FireChan(%1), Error: ").arg(GetDevice()) 18 17 19 #ifndef AVC1394_PANEL_COMMAND_PASS_THROUGH 20 #define AVC1394_PANEL_COMMAND_PASS_THROUGH 0x000007C00 21 #endif 22 23 #ifndef AVC1394_PANEL_OPERATION_0 24 #define AVC1394_PANEL_OPERATION_0 0x000000020 25 #endif 26 27 #define DCT6200_CMD0 (AVC1394_CTYPE_CONTROL | \ 28 AVC1394_SUBUNIT_TYPE_PANEL | \ 29 AVC1394_SUBUNIT_ID_0 | \ 30 AVC1394_PANEL_COMMAND_PASS_THROUGH | \ 31 AVC1394_PANEL_OPERATION_0) 32 33 // SA3250HD defines 34 #define AVC1394_SA3250_OPERAND_KEY_PRESS 0xE7 35 #define AVC1394_SA3250_OPERAND_KEY_RELEASE 0x67 36 37 #define SA3250_CMD0 (AVC1394_CTYPE_CONTROL | \ 38 AVC1394_SUBUNIT_TYPE_PANEL | \ 39 AVC1394_SUBUNIT_ID_0 | \ 40 AVC1394_PANEL_COMMAND_PASS_THROUGH) 41 #define SA3250_CMD1 (0x04 << 24) 42 #define SA3250_CMD2 0xff000000 43 44 // power defines 45 #define AVC1394_CMD_OPERAND_POWER_STATE 0x7F 46 #define STB_POWER_STATE (AVC1394_CTYPE_STATUS | \ 47 AVC1394_SUBUNIT_TYPE_UNIT | \ 48 AVC1394_SUBUNIT_ID_IGNORE | \ 49 AVC1394_COMMAND_POWER | \ 50 AVC1394_CMD_OPERAND_POWER_STATE) 51 52 #define STB_POWER_ON (AVC1394_CTYPE_CONTROL | \ 53 AVC1394_SUBUNIT_TYPE_UNIT | \ 54 AVC1394_SUBUNIT_ID_IGNORE | \ 55 AVC1394_COMMAND_POWER | \ 56 AVC1394_CMD_OPERAND_POWER_ON) 57 58 static bool is_supported(const QString &model) 18 LinuxFirewireChannel::LinuxFirewireChannel( 19 FireWireDBOptions firewire_opts, TVRec *parent) : 20 FirewireChannelBase(parent), 21 fw_opts(firewire_opts), 22 device(new LinuxFirewireDevice( 23 fw_opts.port, fw_opts.node, fw_opts.speed, 24 LinuxFirewireDevice::kConnectionP2P == 25 (uint) fw_opts.connection)), 26 current_channel(0), 27 is_port_open(false) 59 28 { 60 return ((model == "DCT-6200") ||61 (model == "SA3250HD") ||62 (model == "SA4200HD"));63 29 } 64 30 65 FirewireChannel::FirewireChannel(FireWireDBOptions firewire_opts, 66 TVRec *parent) 67 : FirewireChannelBase(parent), fw_opts(firewire_opts), fwhandle(NULL) 31 LinuxFirewireChannel::~LinuxFirewireChannel(void) 68 32 { 69 }70 71 FirewireChannel::~FirewireChannel(void)72 {73 33 Close(); 74 34 } 75 35 76 bool FirewireChannel::SetChannelByNumber(int channel)36 bool LinuxFirewireChannel::Retune(void) 77 37 { 78 // Change channel using internal changer38 VERBOSE(VB_CHANNEL, LOC + "Retune()"); 79 39 80 if ( !is_supported(fw_opts.model))40 if (FirewireDevice::kAVCPowerOff == GetPowerState()) 81 41 { 82 42 VERBOSE(VB_IMPORTANT, LOC_ERR + 83 QString("Model: '%1' ").arg(fw_opts.model) +84 "is not supported by internal channel changer."); 43 "STB is turned off, must be on to retune."); 44 85 45 return false; 86 46 } 87 47 88 int dig[3]; 89 dig[0] = (channel % 1000) / 100; 90 dig[1] = (channel % 100) / 10; 91 dig[2] = (channel % 10); 48 if (current_channel) 49 return SetChannelByNumber(current_channel); 92 50 93 if (fw_opts.model == "DCT-6200") 94 { 95 VERBOSE(VB_CHANNEL, LOC + 96 QString("Channel1: %1%2%3 cmds: 0x%4, 0x%5, 0x%6") 97 .arg(dig[0]).arg(dig[1]) 98 .arg(dig[2]).arg(DCT6200_CMD0 | dig[0], 0, 16) 99 .arg(DCT6200_CMD0 | dig[1], 0, 16) 100 .arg(DCT6200_CMD0 | dig[2], 0, 16)); 51 return false; 52 } 101 53 102 for (uint i = 0; i < 3 ;i++) 103 { 104 quadlet_t cmd[2] = { DCT6200_CMD0 | dig[i], 0x0, }; 105 if (!avc1394_transaction_block(fwhandle, fw_opts.node, cmd, 2, 1)) 106 { 107 VERBOSE(VB_IMPORTANT, "AVC transaction failed."); 108 return false; 109 } 110 usleep(500000); 111 } 112 } 113 else if (fw_opts.model == "SA3250HD") 54 bool LinuxFirewireChannel::SetChannelByNumber(int channel) 55 { 56 current_channel = channel; 57 58 if (FirewireDevice::kAVCPowerOff == GetPowerState()) 114 59 { 115 dig[0] |= 0x30; 116 dig[1] |= 0x30; 117 dig[2] |= 0x30; 60 VERBOSE(VB_IMPORTANT, LOC_WARN + 61 "STB is turned off, must be on to set channel."); 118 62 119 quadlet_t cmd[3] = 120 { 121 SA3250_CMD0 | AVC1394_SA3250_OPERAND_KEY_PRESS, 122 SA3250_CMD1 | (dig[2] << 16) | (dig[1] << 8) | dig[0], 123 SA3250_CMD2, 124 }; 63 SetSIStandard("mpeg"); 64 SetCachedATSCInfo(QString("%1-1").arg(channel)); 125 65 126 VERBOSE(VB_CHANNEL, LOC + 127 QString("Channel2: %1%2%3 cmds: 0x%4, 0x%5, 0x%6") 128 .arg(dig[0] & 0xf).arg(dig[1] & 0xf) 129 .arg(dig[2] & 0xf) 130 .arg(cmd[0], 0, 16).arg(cmd[1], 0, 16) 131 .arg(cmd[2], 0, 16)); 132 133 if(!avc1394_transaction_block(fwhandle, fw_opts.node, cmd, 3, 1)) 134 { 135 VERBOSE(VB_IMPORTANT, "AVC transaction failed."); 136 return false; 137 } 138 139 cmd[0] = SA3250_CMD0 | AVC1394_SA3250_OPERAND_KEY_RELEASE; 140 cmd[1] = SA3250_CMD1 | (dig[0] << 16) | (dig[1] << 8) | dig[2]; 141 cmd[2] = SA3250_CMD2; 142 143 VERBOSE(VB_CHANNEL, LOC + 144 QString("Channel3: %1%2%3 cmds: 0x%4, 0x%5, 0x%6") 145 .arg(dig[0] & 0xf).arg(dig[1] & 0xf) 146 .arg(dig[2] & 0xf) 147 .arg(cmd[0], 0, 16).arg(cmd[1], 0, 16) 148 .arg(cmd[2], 0, 16)); 149 150 if (!avc1394_transaction_block(fwhandle, fw_opts.node, cmd, 3, 1)) 151 { 152 VERBOSE(VB_IMPORTANT, "AVC transaction failed."); 153 return false; 154 } 66 return true; // signal monitor will call retune later... 155 67 } 156 else if (fw_opts.model == "SA4200HD")157 {158 quadlet_t cmd[3] =159 {160 SA3250_CMD0 | AVC1394_SA3250_OPERAND_KEY_PRESS,161 SA3250_CMD1 | (channel << 8),162 SA3250_CMD2,163 };164 68 165 VERBOSE(VB_CHANNEL, LOC + 166 QString("SA4200Channel: %1 cmds: 0x%2 0x%3 0x%4") 167 .arg(channel).arg(cmd[0], 0, 16) 168 .arg(cmd[1], 0, 16) 169 .arg(cmd[2], 0, 16)); 69 if (!device->SetChannel(fw_opts.model, channel)) 70 return false; 170 71 171 if (!avc1394_transaction_block(fwhandle, fw_opts.node, cmd, 3, 1)) 172 { 173 VERBOSE(VB_IMPORTANT, "AVC transaction failed."); 174 return false; 175 } 176 } 72 SetSIStandard("mpeg"); 73 SetCachedATSCInfo(QString("%1-1").arg(channel)); 177 74 178 75 return true; 179 76 } 180 77 181 bool FirewireChannel::OpenFirewire(void)78 bool LinuxFirewireChannel::OpenFirewire(void) 182 79 { 183 if (!is_supported(fw_opts.model)) 80 VERBOSE(VB_IMPORTANT, LOC + "OpenFirewire()"); 81 82 if (is_port_open) 83 return true; 84 85 if (!LinuxFirewireDevice::IsSTBSupported(fw_opts.model)) 184 86 { 185 87 VERBOSE(VB_IMPORTANT, LOC_ERR + 186 88 QString("Model: '%1' ").arg(fw_opts.model) + 187 89 "is not supported by internal channel changer."); 188 return false;189 }190 90 191 // Open channel192 fwhandle = raw1394_new_handle_on_port(fw_opts.port);193 if (!fwhandle)194 {195 VERBOSE(VB_IMPORTANT, LOC_ERR + "Unable to get handle " +196 QString("for port: %1").arg(fw_opts.port));197 91 return false; 198 92 } 199 93 200 VERBOSE(VB_CHANNEL, LOC + "Allocated raw1394 handle " + 201 QString("for port %1").arg(fw_opts.port)); 202 203 // verify node looks like a stb 204 if (!avc1394_check_subunit_type(fwhandle, fw_opts.node, 205 AVC1394_SUBUNIT_TYPE_TUNER)) 206 { 207 VERBOSE(VB_IMPORTANT, LOC_ERR + QString("node %1 is not subunit " 208 "type tuner.").arg(fw_opts.node)); 209 CloseFirewire(); 94 if (!device->OpenPort()) 210 95 return false; 211 }212 96 213 if (!avc1394_check_subunit_type(fwhandle, fw_opts.node, 214 AVC1394_SUBUNIT_TYPE_PANEL)) 97 if (!device->IsSTB()) 215 98 { 216 VERBOSE(VB_IMPORTANT, LOC_ERR + QString("node %1 is not subunit " 217 "type panel.").arg(fw_opts.node)); 218 CloseFirewire(); 99 device->ClosePort(); 219 100 return false; 220 101 } 221 102 222 // check power, power on if off 223 if (GetPowerState() == Off) 224 { 225 quadlet_t *rval, response, cmd = STB_POWER_ON; 226 VERBOSE(VB_IMPORTANT, LOC + QString("Powering on (cmd: 0x%1)") 227 .arg(cmd, 0, 16)); 228 rval = avc1394_transaction_block(fwhandle, fw_opts.node, &cmd, 1, 1); 229 if (rval) 230 { 231 response = rval[0]; 103 is_port_open = true; 232 104 233 if (AVC1394_MASK_RESPONSE(response) == AVC1394_RESPONSE_ACCEPTED)234 {235 VERBOSE(VB_IMPORTANT, LOC + QString("Power on cmd successful "236 "(0x%1)")237 .arg(response, 0, 16));238 // allow some time for the stb to power on239 sleep(3);240 if (GetPowerState() == Off)241 {242 VERBOSE(VB_IMPORTANT, LOC + "STB is still off!?");243 return false;244 }245 return true;246 }247 else248 {249 VERBOSE(VB_IMPORTANT, LOC + QString("Power on cmd failed "250 "(0x%1)")251 .arg(response, 0, 16));252 return false;253 }254 }255 else256 {257 VERBOSE(VB_IMPORTANT, LOC + "Power on cmd failed (no response)");258 return false;259 }260 }261 105 return true; 262 106 } 263 107 264 void FirewireChannel::CloseFirewire(void)108 void LinuxFirewireChannel::CloseFirewire(void) 265 109 { 266 VERBOSE(VB_CHANNEL, LOC + "Releasing raw1394 handle"); 267 raw1394_destroy_handle(fwhandle); 110 VERBOSE(VB_IMPORTANT, LOC + "CloseFirewire()"); 111 112 if (!is_port_open) 113 return; 114 115 device->ClosePort(); 116 is_port_open = false; 268 117 } 269 118 270 FirewireChannel::PowerState FirewireChannel::GetPowerState(void)119 bool LinuxFirewireChannel::SetPowerState(bool on) 271 120 { 272 quadlet_t *rval, response, cmd = STB_POWER_STATE; 121 return device->SetPowerState(on); 122 } 273 123 274 VERBOSE(VB_CHANNEL, LOC + QString("Requesting STB Power State (cmd: 0x%1)") 275 .arg(STB_POWER_STATE, 0, 16)); 276 rval = avc1394_transaction_block(fwhandle, fw_opts.node, &cmd, 1, 1); 277 278 if (rval) 279 { 280 response = rval[0]; 281 282 if (AVC1394_MASK_RESPONSE(response) == AVC1394_RESPONSE_IMPLEMENTED) 283 { 284 if ((response & 0xFF) == AVC1394_CMD_OPERAND_POWER_ON) 285 { 286 VERBOSE(VB_CHANNEL, LOC + QString("STB Power State: ON (0x%1)") 287 .arg(response, 0, 16)); 288 return On; 289 } 290 else if ((response & 0xFF) == AVC1394_CMD_OPERAND_POWER_OFF) 291 { 292 VERBOSE(VB_IMPORTANT, LOC + QString("STB Power State: OFF " 293 "(0x%1)") 294 .arg(response, 0, 16)); 295 return Off; 296 } 297 else 298 { 299 VERBOSE(VB_CHANNEL, LOC + QString("STB Power State: " 300 "Unknown Response (0x%1)") 301 .arg(response, 0, 16)); 302 return Failed; 303 } 304 } 305 else 306 { 307 VERBOSE(VB_CHANNEL, LOC + QString("STB Power State: Failed (0x%1)") 308 .arg(response, 0, 16)); 309 return Failed; 310 } 311 } 312 VERBOSE(VB_CHANNEL, LOC + "Failed to get STB Power State"); 313 return Failed; 124 FirewireDevice::PowerState LinuxFirewireChannel::GetPowerState(void) const 125 { 126 return device->GetPowerState(); 314 127 } -
libs/libmythtv/firewirerecorderbase.h
12 12 #include "tspacket.h" 13 13 #include "streamlisteners.h" 14 14 15 class TVRec; 16 class FirewireChannelBase; 17 15 18 /** \class FirewireRecorderBase 16 19 * \brief This is a specialization of DTVRecorder used to 17 20 * handle DVB and ATSC streams from a firewire input. … … 25 28 friend class TSPacketProcessor; 26 29 27 30 public: 28 FirewireRecorderBase(TVRec *rec); 29 ~FirewireRecorderBase(); 31 virtual ~FirewireRecorderBase(); 30 32 31 33 // Commands 32 34 void StartRecording(void); … … 41 43 void SetStreamData(MPEGStreamData*); 42 44 43 45 // Gets 44 MPEGStreamData *StreamData(void) { return _mpeg_stream_data; }46 MPEGStreamData *GetStreamData(void) { return _mpeg_stream_data; } 45 47 46 48 // MPEG Single Program 47 49 void HandleSingleProgramPAT(ProgramAssociationTable*); 48 50 void HandleSingleProgramPMT(ProgramMapTable*); 49 51 52 // Factory 53 static FirewireRecorderBase *Init( 54 TVRec *rec, FirewireChannelBase *channel); 55 56 protected: 57 FirewireRecorderBase(TVRec *rec); 58 50 59 private: 51 60 virtual void Close() = 0; 52 virtual void start() = 0; 53 virtual void stop() = 0; 54 virtual bool grab_frames() = 0; 61 virtual void StartStreaming(void) = 0; 62 virtual void StopStreaming(void) = 0; 55 63 56 64 MPEGStreamData *_mpeg_stream_data; 57 65 TSStats _ts_stats; -
libs/libmythtv/firewirechannelbase.h
8 8 #ifndef LIBMYTHTV_FIREWIRECHANNELBASE_H 9 9 #define LIBMYTHTV_FIREWIRECHANNELBASE_H 10 10 11 #include <qstring.h> 12 #include "tv_rec.h" 13 #include "channelbase.h" 11 #include "dtvchannel.h" 12 #include "firewiredevice.h" 14 13 15 #include "mythconfig.h" 14 class TVRec; 15 class FireWireDBOptions; 16 16 17 namespace AVS 17 class FirewireChannelBase : public DTVChannel 18 18 { 19 class AVCDeviceController;20 class AVCDevice;21 }22 23 class FirewireChannelBase : public ChannelBase24 {25 19 public: 26 FirewireChannelBase(TVRec *parent) 27 : ChannelBase(parent), isopen(false) { } 28 ~FirewireChannelBase() { Close(); } 20 // Commands 21 virtual bool Open(void); 22 virtual void Close(void); 23 virtual bool SwitchToInput(const QString &inputname, const QString &chan); 24 virtual bool SwitchToInput(int newcapchannel, bool setstarting) 25 { (void)newcapchannel; (void)setstarting; return false; } 29 26 30 bool Open(void); 31 void Close(void); 27 virtual bool TuneMultiplex(uint /*mplexid*/, QString /*inputname*/) 28 { return false; } 29 virtual bool Tune(const DTVMultiplex &/*tuning*/, QString /*inputname*/) 30 { return false; } 31 virtual bool Retune(void) 32 { return false; } 32 33 33 34 // Sets 34 bool SetChannelByString(const QString &chan);35 virtual bool SetChannelByString(const QString &chan); 35 36 virtual bool SetChannelByNumber(int channel) = 0; 37 virtual bool SetPowerState(bool /*on*/) = 0; 36 38 37 39 // Gets 38 bool IsOpen(void) const { return isopen; } 40 virtual bool IsOpen(void) const { return isopen; } 41 virtual FirewireDevice::PowerState GetPowerState(void) const = 0; 39 42 40 // Commands 41 bool SwitchToInput(const QString &inputname, const QString &chan); 42 bool SwitchToInput(int newcapchannel, bool setstarting) 43 { (void)newcapchannel; (void)setstarting; return false; } 43 // Factory method 44 static FirewireChannelBase *Init( 45 const FireWireDBOptions &firewire_opts, TVRec *parent); 44 46 47 protected: 48 FirewireChannelBase(TVRec *parent) : 49 DTVChannel(parent), isopen(false) { } 50 ~FirewireChannelBase() { Close(); } 51 45 52 private: 46 virtual bool OpenFirewire( ) = 0;47 virtual void CloseFirewire( ) = 0;53 virtual bool OpenFirewire(void) = 0; 54 virtual void CloseFirewire(void) = 0; 48 55 49 56 protected: 50 57 bool isopen; -
libs/libmythtv/libmythtv.pro
380 380 using_firewire { 381 381 HEADERS += firewirechannelbase.h firewirerecorderbase.h 382 382 SOURCES += firewirechannelbase.cpp firewirerecorderbase.cpp 383 HEADERS += firewiresignalmonitor.h firewiredevice.h 384 SOURCES += firewiresignalmonitor.cpp 383 385 384 386 macx { 385 387 HEADERS += darwinfirewirechannel.h darwinfirewirerecorder.h … … 391 393 !macx { 392 394 HEADERS += firewirechannel.h firewirerecorder.h 393 395 SOURCES += firewirechannel.cpp firewirerecorder.cpp 396 HEADERS += linuxfirewiredevice.h 397 SOURCES += linuxfirewiredevice.cpp 394 398 } 395 399 396 400 DEFINES += USING_FIREWIRE -
libs/libmythtv/darwinfirewirerecorder.cpp
11 11 #undef always_inline 12 12 #include <AVCVideoServices/AVCVideoServices.h> 13 13 14 DarwinFirewireRecorder::DarwinFirewireRecorder(TVRec *rec, ChannelBase* tuner) 15 : FirewireRecorderBase(rec), 16 capture_device( 17 dynamic_cast<DarwinFirewireChannel*>(tuner)->GetAVCDevice() 18 ), 19 message_log(NULL), 20 video_stream(NULL), 21 isopen(false) 22 {;} 14 DarwinFirewireRecorder::DarwinFirewireRecorder( 15 TVRec *rec, DarwinFirewireChannel *channel) : 16 FirewireRecorderBase(rec), 17 capture_device(channel->GetAVCDevice()), 18 message_log(NULL), 19 video_stream(NULL), 20 isopen(false) 21 { 22 SetStreamData(new MPEGStreamData(1, true)); 23 } 23 24 24 25 DarwinFirewireRecorder::~DarwinFirewireRecorder() 25 26 { … … 196 197 this->message_log = 0; 197 198 } 198 199 199 void DarwinFirewireRecorder:: start()200 void DarwinFirewireRecorder::StartStreaming(void) 200 201 { 201 202 VERBOSE(VB_RECORD, "Firewire: Starting video stream"); 202 203 this->capture_device->StartAVCDeviceStream(this->video_stream); 203 204 } 204 205 205 void DarwinFirewireRecorder:: stop()206 void DarwinFirewireRecorder::StopStreaming(void) 206 207 { 207 208 VERBOSE(VB_RECORD, "Firewire: Stopping video stream"); 208 209 this->capture_device->StopAVCDeviceStream(this->video_stream); 209 210 } 210 211 bool DarwinFirewireRecorder::grab_frames()212 {213 usleep(1000000 / 2); // 2 times a second214 return true;215 }216 217 void DarwinFirewireRecorder::SetOption(const QString &name, const QString &value)218 {219 (void)name;220 (void)value;221 }222 223 void DarwinFirewireRecorder::SetOption(const QString &name, int value)224 {225 (void)name;226 (void)value;227 } -
libs/libmythtv/signalmonitor.h
285 285 return (CardUtil::IsDVBCardType(cardtype) || 286 286 (cardtype.upper() == "HDTV") || 287 287 (cardtype.upper() == "HDHOMERUN") || 288 (cardtype.upper() == "FIREWIRE") || 288 289 (cardtype.upper() == "FREEBOX")); 289 290 } 290 291 -
libs/libmythtv/firewirerecorderbase.cpp
5 5 */ 6 6 7 7 // MythTV includes 8 #include "mythconfig.h" // for CONFIG_DARWIN 8 9 #include "firewirerecorderbase.h" 9 10 #include "mythcontext.h" 10 11 #include "mpegtables.h" 11 12 #include "mpegstreamdata.h" 12 13 #include "tv_rec.h" 13 14 15 #ifdef CONFIG_DARWIN 16 # include "darwinfirewirechannel.h" 17 # include "darwinfirewirerecorder.h" 18 #else 19 # include "firewirechannel.h" 20 # include "firewirerecorder.h" 21 # include "linuxfirewiredevice.h" 22 #endif 23 14 24 #define LOC QString("FireRecBase: ") 15 25 #define LOC_ERR QString("FireRecBase, Error: ") 16 26 17 27 const int FirewireRecorderBase::kTimeoutInSeconds = 15; 18 28 29 FirewireRecorderBase *FirewireRecorderBase::Init( 30 TVRec *rec, FirewireChannelBase *channel) 31 { 32 #ifdef CONFIG_DARWIN 33 DarwinFirewireChannel *dfch = 34 dynamic_cast<DarwinFirewireChannel*>(channel); 35 if (dfch) 36 return new DarwinFirewireRecorder(rec, channel); 37 #else 38 LinuxFirewireChannel *lfch = 39 dynamic_cast<LinuxFirewireChannel*>(channel); 40 if (lfch) 41 return new LinuxFirewireRecorder(rec, lfch); 42 #endif 43 44 return NULL; 45 } 46 19 47 FirewireRecorderBase::FirewireRecorderBase(TVRec *rec) 20 48 : DTVRecorder(rec), _mpeg_stream_data(NULL) 21 49 { 22 SetStreamData(new MPEGStreamData(1, true));23 50 } 24 51 25 52 FirewireRecorderBase::~FirewireRecorderBase() … … 39 66 _request_recording = true; 40 67 _recording = true; 41 68 42 start();69 StartStreaming(); 43 70 44 while(_request_recording) { 45 if (PauseAndWait()) 46 continue; 47 48 if (!grab_frames()) 49 { 50 _error = true; 51 return; 52 } 71 while (_request_recording) 72 { 73 if (!PauseAndWait()) 74 usleep(250 * 1000); 53 75 } 54 76 55 stop();77 StopStreaming(); 56 78 FinishRecording(); 57 79 58 80 _recording = false; … … 67 89 return; 68 90 69 91 if (tspacket.HasAdaptationField()) 70 StreamData()->HandleAdaptationFieldControl(&tspacket);92 GetStreamData()->HandleAdaptationFieldControl(&tspacket); 71 93 72 94 if (tspacket.HasPayload()) 73 95 { 74 96 const unsigned int lpid = tspacket.PID(); 75 97 76 98 // Pass or reject packets based on PID, and parse info from them 77 if (lpid == StreamData()->VideoPIDSingleProgram())99 if (lpid == GetStreamData()->VideoPIDSingleProgram()) 78 100 { 79 101 _buffer_packets = !FindMPEG2Keyframes(&tspacket); 80 102 BufferedWrite(tspacket); 81 103 } 82 else if ( StreamData()->IsAudioPID(lpid))104 else if (GetStreamData()->IsAudioPID(lpid)) 83 105 BufferedWrite(tspacket); 84 else if ( StreamData()->IsListeningPID(lpid))85 StreamData()->HandleTSTables(&tspacket);86 else if ( StreamData()->IsWritingPID(lpid))106 else if (GetStreamData()->IsListeningPID(lpid)) 107 GetStreamData()->HandleTSTables(&tspacket); 108 else if (GetStreamData()->IsWritingPID(lpid)) 87 109 BufferedWrite(tspacket); 88 110 } 89 111 … … 108 130 { 109 131 if (request_pause) 110 132 { 133 VERBOSE(VB_RECORD, LOC + "PauseAndWait("<<timeout<<") -- pause"); 111 134 if (!paused) 112 135 { 113 stop();136 StopStreaming(); 114 137 paused = true; 115 138 pauseWait.wakeAll(); 116 139 if (tvrec) … … 120 143 } 121 144 if (!request_pause && paused) 122 145 { 123 start(); 146 VERBOSE(VB_RECORD, LOC + "PauseAndWait("<<timeout<<") -- unpause"); 147 StartStreaming(); 124 148 paused = false; 125 149 } 126 150 return paused; -
libs/libmythtv/firewirerecorder.cpp
8 8 #include <pthread.h> 9 9 #include <sys/select.h> 10 10 11 // C++ includes 12 #include <iostream> 13 using namespace std; 11 // Linux C includes 12 #include <libraw1394/raw1394.h> 14 13 15 14 // MythTV includes 16 15 #include "firewirerecorder.h" 16 #include "firewirechannel.h" 17 #include "linuxfirewiredevice.h" 17 18 #include "mythcontext.h" 18 19 #include "mpegtables.h" 19 20 #include "mpegstreamdata.h" 20 21 #include "tv_rec.h" 21 22 22 #define LOC QString("FireRec : ")23 #define LOC_ERR QString("FireRec , Error: ")23 #define LOC QString("FireRec(%1): ").arg(channel->GetDevice()) 24 #define LOC_ERR QString("FireRec(%1), Error: ").arg(tvrec->GetDevice()) 24 25 25 const int FirewireRecorder::kBroadcastChannel = 63; 26 const int FirewireRecorder::kConnectionP2P = 0; 27 const int FirewireRecorder::kConnectionBroadcast = 1; 28 const uint FirewireRecorder::kMaxBufferedPackets = 2000; 29 30 // callback function for libiec61883 31 int fw_tspacket_handler(unsigned char *tspacket, int /*len*/, 32 uint dropped, void *callback_data) 26 LinuxFirewireRecorder::LinuxFirewireRecorder( 27 TVRec *rec, 28 LinuxFirewireChannel *chan) : 29 FirewireRecorderBase(rec), channel(chan), isopen(false) 33 30 { 34 if (dropped)35 {36 VERBOSE(VB_RECORD, LOC_ERR +37 QString("Dropped %1 packet(s).").arg(dropped));38 }39 40 if (SYNC_BYTE != tspacket[0])41 {42 VERBOSE(VB_IMPORTANT, LOC_ERR + "TS packet out of sync.");43 return 1;44 }45 46 FirewireRecorder *fw = (FirewireRecorder*) callback_data;47 if (fw)48 fw->ProcessTSPacket(*(reinterpret_cast<TSPacket*>(tspacket)));49 50 return (fw) ? 1 : 0;51 31 } 52 32 53 static QString speed_to_string(uint speed)33 LinuxFirewireRecorder::~LinuxFirewireRecorder() 54 34 { 55 if (speed > RAW1394_ISO_SPEED_400) 56 return QString("Invalid Speed (%1)").arg(speed); 57 58 static const uint speeds[] = { 100, 200, 400, }; 59 return QString("%1Mbps").arg(speeds[speed]); 35 Close(); 60 36 } 61 37 62 bool FirewireRecorder::Open(void)38 bool LinuxFirewireRecorder::Open(void) 63 39 { 64 if ( isopen)65 return true;40 if (!isopen) 41 isopen = channel->GetFirewireDevice()->OpenPort(); 66 42 67 VERBOSE(VB_RECORD, LOC + 68 QString("Initializing Port: %1, Node: %2, Speed: %3") 69 .arg(fwport).arg(fwnode).arg(speed_to_string(fwspeed))); 70 71 fwhandle = raw1394_new_handle_on_port(fwport); 72 if (!fwhandle) 73 { 74 VERBOSE(VB_IMPORTANT, LOC_ERR + "Unable to get handle for " + 75 QString("port: %1, bailing").arg(fwport) + ENO); 76 return false; 77 } 78 79 if (kConnectionP2P == fwconnection) 80 { 81 VERBOSE(VB_RECORD, LOC + "Creating P2P Connection " + 82 QString("with Node: %1").arg(fwnode)); 83 fwchannel = iec61883_cmp_connect(fwhandle, 84 fwnode | 0xffc0, &fwoplug, 85 raw1394_get_local_id(fwhandle), 86 &fwiplug, &fwbandwidth); 87 if (fwchannel > -1) 88 { 89 VERBOSE(VB_RECORD, LOC + 90 QString("Created Channel: %1, " 91 "Bandwidth Allocation: %2") 92 .arg(fwchannel).arg(fwbandwidth)); 93 } 94 } 95 else 96 { 97 fwchannel = kBroadcastChannel - fwnode; 98 99 VERBOSE(VB_RECORD, LOC + "Creating Broadcast Connection " + 100 QString("with Node: %1, Channel: %2").arg(fwnode) 101 .arg(fwchannel)); 102 if (iec61883_cmp_create_bcast_output(fwhandle, 103 fwnode | 0xffc0, 0, 104 fwchannel, 105 fwspeed) != 0) 106 { 107 VERBOSE(VB_IMPORTANT, LOC + "Failed to create connection"); 108 // release raw1394 object; 109 raw1394_destroy_handle(fwhandle); 110 return false; 111 } 112 fwbandwidth = 0; 113 } 114 115 fwmpeg = iec61883_mpeg2_recv_init(fwhandle, fw_tspacket_handler, this); 116 if (!fwmpeg) 117 { 118 VERBOSE(VB_IMPORTANT, LOC + 119 "Unable to init iec61883_mpeg2 object, bailing" + ENO); 120 121 // release raw1394 object; 122 raw1394_destroy_handle(fwhandle); 123 return false; 124 } 125 126 // Set buffered packets size 127 size_t buffer_size = gContext->GetNumSetting("HDRingbufferSize", 128 50 * TSPacket::SIZE); 129 size_t buffered_packets = min(buffer_size / 4, 130 (size_t) kMaxBufferedPackets); 131 iec61883_mpeg2_set_buffers(fwmpeg, buffered_packets); 132 VERBOSE(VB_IMPORTANT, LOC + 133 QString("Buffered packets %1 (%2 KB)") 134 .arg(buffered_packets).arg(buffered_packets * 4)); 135 136 // Set speed if needed. 137 // Probably shouldn't even allow user to set, 138 // 100Mbps should be more the enough. 139 int curspeed = iec61883_mpeg2_get_speed(fwmpeg); 140 if (curspeed != fwspeed) 141 { 142 VERBOSE(VB_RECORD, LOC + 143 QString("Changing Speed %1 -> %2") 144 .arg(speed_to_string(curspeed)) 145 .arg(speed_to_string(fwspeed))); 146 147 iec61883_mpeg2_set_speed(fwmpeg, fwspeed); 148 if (fwspeed != iec61883_mpeg2_get_speed(fwmpeg)) 149 { 150 VERBOSE(VB_IMPORTANT, LOC + 151 "Unable to set firewire speed, continuing"); 152 } 153 } 154 155 fwfd = raw1394_get_fd(fwhandle); 156 157 return isopen = true; 43 return isopen; 158 44 } 159 45 160 void FirewireRecorder::Close(void)46 void LinuxFirewireRecorder::Close(void) 161 47 { 162 if (!isopen) 163 return; 164 165 isopen = false; 166 167 VERBOSE(VB_RECORD, LOC + "Releasing iec61883_mpeg2 object"); 168 iec61883_mpeg2_close(fwmpeg); 169 170 if (fwconnection == kConnectionP2P && fwchannel > -1) 48 if (isopen) 171 49 { 172 VERBOSE(VB_RECORD, LOC + 173 QString("Disconnecting channel %1").arg(fwchannel)); 174 175 iec61883_cmp_disconnect(fwhandle, fwnode | 0xffc0, fwoplug, 176 raw1394_get_local_id (fwhandle), 177 fwiplug, fwchannel, fwbandwidth); 50 channel->GetFirewireDevice()->ClosePort(); 51 isopen = false; 178 52 } 53 } 179 54 180 VERBOSE(VB_RECORD, LOC + "Releasing raw1394 handle"); 181 raw1394_destroy_handle(fwhandle); 55 void LinuxFirewireRecorder::StartStreaming(void) 56 { 57 channel->GetFirewireDevice()->AddListener(this); 182 58 } 183 59 184 bool FirewireRecorder::grab_frames()60 void LinuxFirewireRecorder::StopStreaming(void) 185 61 { 186 struct timeval tv;187 fd_set rfds; 62 channel->GetFirewireDevice()->RemoveListener(this); 63 } 188 64 189 FD_ZERO(&rfds); 190 FD_SET(fwfd, &rfds); 191 tv.tv_sec = kTimeoutInSeconds; 192 tv.tv_usec = 0; 65 void LinuxFirewireRecorder::AddData(const unsigned char *data, uint len) 66 { 67 //cout<<":"; 193 68 194 if (select(fwfd + 1, &rfds, NULL, NULL, &tv) <= 0) 195 { 196 VERBOSE(VB_IMPORTANT, LOC + 197 QString("No Input in %1 seconds [P:%2 N:%3] (select)") 198 .arg(kTimeoutInSeconds).arg(fwport).arg(fwnode)); 199 return false; 69 uint bufsz = buffer.size(); 70 if ((SYNC_BYTE == data[0]) && (TSPacket::SIZE == len) && 71 (TSPacket::SIZE > bufsz)) 72 { 73 if (bufsz) 74 buffer.clear(); 75 76 ProcessTSPacket(*(reinterpret_cast<const TSPacket*>(data))); 77 return; 200 78 } 201 79 202 int ret = raw1394_loop_iterate(fwhandle); 203 if (ret) 80 buffer.insert(buffer.end(), data, data + len); 81 bufsz += len; 82 83 int sync_at = -1; 84 for (uint i = 0; (i < bufsz) && (sync_at < 0); i++) 204 85 { 205 VERBOSE(VB_IMPORTANT, LOC_ERR + "libraw1394_loop_iterate() " + 206 QString("returned %1").arg(ret)); 207 return false; 86 if (buffer[i] == SYNC_BYTE) 87 sync_at = i; 208 88 } 209 89 210 return true;211 } 90 if (sync_at < 0) 91 return; 212 92 213 void FirewireRecorder::SetOption(const QString &name, const QString &value) 214 { 215 if (name == "model") 216 fwmodel = value; 217 } 93 if (bufsz < 30 * TSPacket::SIZE) 94 return; // build up a little buffer 218 95 219 void FirewireRecorder::SetOption(const QString &name, int value) 220 { 221 if (name == "port") 222 fwport = value; 223 else if (name == "node") 224 fwnode = value; 225 else if (name == "speed") 96 while (sync_at + TSPacket::SIZE < bufsz) 226 97 { 227 if (RAW1394_ISO_SPEED_100 != value && 228 RAW1394_ISO_SPEED_200 != value && 229 RAW1394_ISO_SPEED_400 != value) 230 { 231 VERBOSE(VB_IMPORTANT, LOC_ERR + 232 QString("Unknown speed '%1', will use 100Mbps") 233 .arg(value)); 98 ProcessTSPacket(*(reinterpret_cast<const TSPacket*>( 99 &buffer[0] + sync_at))); 234 100 235 value = RAW1394_ISO_SPEED_100; 236 } 237 fwspeed = value; 101 sync_at += TSPacket::SIZE; 238 102 } 239 else if (name == "connection")240 {241 if (kConnectionP2P != value &&242 kConnectionBroadcast != value)243 {244 VERBOSE(VB_IMPORTANT, LOC_ERR +245 QString("Unknown connection type '%1', will use P2P")246 .arg(fwconnection));247 103 248 fwconnection = kConnectionP2P; 249 } 250 fwconnection = value; 251 } 104 buffer.erase(buffer.begin(), buffer.begin() + sync_at); 105 106 return; 252 107 } -
libs/libmythtv/firewirerecorder.h
4 4 * Distributed as part of MythTV under GPL v2 and later. 5 5 */ 6 6 7 #ifndef FIREWIRERECORDER_H_8 #define FIREWIRERECORDER_H_7 #ifndef _LINUX_FIREWIRE_RECORDER_H_ 8 #define _LINUX_FIREWIRE_RECORDER_H_ 9 9 10 10 #include "firewirerecorderbase.h" 11 #include "tsstats.h" 12 #include <libraw1394/raw1394.h> 13 #include <libiec61883/iec61883.h> 11 #include "linuxfirewiredevice.h" 14 12 15 /** \class FirewireRecorder 16 * \brief Linux FirewireRFecorder 13 class LinuxFirewireChannel; 14 15 /** \class LinuxFirewireRecorder 16 * \brief Linux Firewire Recorder 17 17 * 18 18 * \sa FirewireRecorderBase 19 19 */ 20 class FirewireRecorder : public FirewireRecorderBase 20 class LinuxFirewireRecorder : 21 public FirewireRecorderBase, public TSDataListener 21 22 { 22 friend int fw_tspacket_handler(unsigned char*,int,uint,void*);23 24 23 public: 25 FirewireRecorder(TVRec *rec) 26 : FirewireRecorderBase(rec), 27 fwport(-1), fwchannel(-1), fwspeed(-1), fwbandwidth(-1), 28 fwfd(-1), fwconnection(kConnectionP2P), 29 fwoplug(-1), fwiplug(-1), fwmodel(""), fwnode(0), 30 fwhandle(NULL), fwmpeg(NULL), isopen(false) { } 31 ~FirewireRecorder() { Close(); } 24 LinuxFirewireRecorder(TVRec *rec, LinuxFirewireChannel *chan); 25 ~LinuxFirewireRecorder(); 32 26 33 27 // Commands 34 bool Open(void); 35 36 // Sets 37 void SetOption(const QString &name, const QString &value); 38 void SetOption(const QString &name, int value); 39 40 private: 28 bool Open(void); 29 void StartStreaming(void); 30 void StopStreaming(void); 41 31 void Close(void); 42 void start() { iec61883_mpeg2_recv_start(fwmpeg, fwchannel); }43 void stop() { iec61883_mpeg2_recv_stop(fwmpeg); }44 bool grab_frames();45 32 46 33 private: 47 int fwport; 48 int fwchannel; 49 int fwspeed; 50 int fwbandwidth; 51 int fwfd; 52 int fwconnection; 53 int fwoplug; 54 int fwiplug; 55 QString fwmodel; 56 nodeid_t fwnode; 57 raw1394handle_t fwhandle; 58 iec61883_mpeg2_t fwmpeg; 59 bool isopen; 34 void AddData(const unsigned char *data, uint dataSize); 60 35 61 static const int kBroadcastChannel;62 static const int kConnectionP2P;63 static const int kConnectionBroadcast;64 static const uint kMaxBufferedPackets;36 private: 37 LinuxFirewireChannel *channel; 38 bool isopen; 39 vector<unsigned char> buffer; 65 40 }; 66 41 67 #endif 42 #endif // _LINUX_FIREWIRE_RECORDER_H_ -
libs/libmythtv/darwinfirewirechannel.cpp
15 15 #undef always_inline 16 16 #include <AVCVideoServices/AVCVideoServices.h> 17 17 18 #define LOC QString("DarwinFirewireChannel: ") 19 #define LOC_ERR QString("DarwinFirewireChannel, Error: ") 18 20 19 21 namespace 20 22 { … … 84 86 return this->device; 85 87 } 86 88 89 FirewireDevice::PowerState DarwinFirewireChannel::GetPowerState(void) const 90 { 91 UInt8 power_state; 92 IOReturn err = device->GetPowerState(&power_state); 93 94 if (err != kIOReturnSuccess) 95 return FirewireDevice::kAVCPowerQueryFailed; 96 else if (kAVCPowerStateOff == power_state) 97 return FirewireDevice::kAVCPowerOff; 98 else if (kAVCPowerStateOn == power_state) 99 return FirewireDevice::kAVCPowerOn; 100 else 101 return FirewireDevice::kAVCPowerUnknown; 102 } 103 104 bool DarwinFirewireChannel::SetPowerState(bool on) 105 { 106 if (on) 107 SetPowerState(kAVCPowerStateOn); 108 else 109 SetPowerState(kAVCPowerStateOff); 110 111 return true; 112 } 113 87 114 bool DarwinFirewireChannel::SetChannelByNumber(int channel) 88 115 { 89 116 // If the tuner is off, try to turn it on. 90 UInt8 power_state; 91 IOReturn err = this->device->GetPowerState(&power_state); 92 if (err == kIOReturnSuccess && power_state == kAVCPowerStateOff) 117 if (FirewireDevice::kAVCPowerOff == GetPowerState()) 93 118 { 94 this->device->SetPowerState(kAVCPowerStateOn);119 SetPowerState(true); 95 120 96 121 // Give it time to power up. 97 122 usleep(2000000); // Sleep for two seconds … … 101 126 err = panel.Tune(channel); 102 127 if (err != kIOReturnSuccess) 103 128 { 104 VERBOSE(VB_GENERAL, QString("DarwinFirewireChannel: Tuning failed: %1").arg(err,0,16)); 105 VERBOSE(VB_GENERAL, QString("Ignoring error per apple example")); 129 VERBOSE(VB_GENERAL, LOC_ERR + 130 QString("Tuning failed: %1").arg(err,0,16) + 131 QString("Ignoring error per apple example")); 106 132 } 133 107 134 // Give it time to transition. 108 135 usleep(1000000); // Sleep for one second 136 109 137 return true; 110 138 } -
libs/libmythtv/darwinfirewirechannel.h
24 24 public: 25 25 DarwinFirewireChannel(FireWireDBOptions const&, TVRec *parent); 26 26 27 // Sets 28 virtual bool SetChannelByNumber(int channel); 29 virtual bool SetPowerState(bool on); 30 27 31 // Gets 28 AVS::AVCDevice* GetAVCDevice() const; 32 AVS::AVCDevice* GetAVCDevice(void) const; 33 virtual FirewireDevice::PowerState GetPowerState(void) const; 29 34 30 // Sets31 bool SetChannelByNumber(int channel);32 33 35 private: 34 bool OpenFirewire();35 v oid CloseFirewire();36 virtual bool OpenFirewire(void); 37 virtual void CloseFirewire(void); 36 38 37 39 private: 38 40 AVS::AVCDeviceController* device_controller; -
libs/libmythtv/signalmonitor.cpp
34 34 # include "iptvchannel.h" 35 35 #endif 36 36 37 #ifdef USING_FIREWIRE 38 # include "firewiresignalmonitor.h" 39 # include "firewirechannelbase.h" 40 #endif 41 37 42 #undef DBG_SM 38 43 #define DBG_SM(FUNC, MSG) VERBOSE(VB_CHANNEL, \ 39 44 "SM("<<channel->GetDevice()<<")::"<<FUNC<<": "<<MSG); … … 117 122 } 118 123 #endif 119 124 125 #ifdef USING_FIREWIRE 126 if (cardtype.upper() == "FIREWIRE") 127 { 128 FirewireChannelBase *fc = dynamic_cast<FirewireChannelBase*>(channel); 129 if (fc) 130 signalMonitor = new FirewireSignalMonitor(db_cardnum, fc); 131 } 132 #endif 133 120 134 if (!signalMonitor) 121 135 { 122 136 VERBOSE(VB_IMPORTANT, -
libs/libmythtv/darwinfirewirerecorder.h
33 33 class DarwinFirewireRecorder : public FirewireRecorderBase 34 34 { 35 35 public: 36 DarwinFirewireRecorder(TVRec *rec, ChannelBase* tuner);36 DarwinFirewireRecorder(TVRec *rec, DarwinFirewireChannel *channel); 37 37 ~DarwinFirewireRecorder(); 38 38 39 39 bool Open(void); 40 40 41 void SetOption(const QString &name, const QString &value);42 void SetOption(const QString &name, int value);43 44 41 private: 45 42 void Close(); 46 43 47 44 void start(); 48 45 void stop(); 49 46 void no_data(); 50 bool grab_frames();51 47 52 48 static IOReturn MPEGNoData(void* pRefCon); 53 49 static IOReturn tspacket_callback(UInt32 tsPacketCount, UInt32 **ppBuf, void *pRefCon); -
libs/libmythtv/firewirechannel.h
5 5 * Distributed as part of MythTV under GPL v2 and later. 6 6 */ 7 7 8 #ifndef _LINUX_FIREWIRE_CHANNEL_H_ 9 #define _LINUX_FIREWIRE_CHANNEL_H_ 8 10 9 #ifndef FIREWIRECHANNEL_H10 #define FIREWIRECHANNEL_H11 12 11 #include <qstring.h> 13 12 #include "tv_rec.h" 14 13 #include "firewirechannelbase.h" 15 #include <libavc1394/avc1394.h>16 14 17 15 using namespace std; 18 16 19 class FirewireChannel : public FirewireChannelBase 17 class LinuxFirewireDevice; 18 19 class LinuxFirewireChannel : public FirewireChannelBase 20 20 { 21 21 public: 22 enum PowerState { 23 On, 24 Off, 25 Failed 26 }; 22 LinuxFirewireChannel(FireWireDBOptions firewire_opts, TVRec *parent); 23 ~LinuxFirewireChannel(void); 27 24 28 FirewireChannel(FireWireDBOptions firewire_opts, TVRec *parent);29 ~FirewireChannel(void);25 // Commands 26 virtual bool Retune(void); 30 27 31 bool OpenFirewire(void);32 void CloseFirewire(void);33 34 28 // Sets 35 v oid SetExternalChanger(void);36 bool SetChannelByNumber(int channel);29 virtual bool SetChannelByNumber(int channel); 30 virtual bool SetPowerState(bool on); 37 31 38 32 // Gets 39 bool IsOpen(void) const { return isopen; } 40 QString GetDevice(void) const 33 virtual QString GetDevice(void) const 41 34 { return QString("%1:%2").arg(fw_opts.port).arg(fw_opts.node); } 42 PowerState GetPowerState(void); 35 virtual LinuxFirewireDevice *GetFirewireDevice(void) 36 { return device; } 37 virtual FirewireDevice::PowerState GetPowerState(void) const; 43 38 44 39 private: 45 FireWireDBOptions fw_opts; 46 nodeid_t fwnode; 47 raw1394handle_t fwhandle; 40 virtual bool OpenFirewire(void); 41 virtual void CloseFirewire(void); 42 43 private: 44 FireWireDBOptions fw_opts; 45 LinuxFirewireDevice *device; 46 uint current_channel; 47 bool is_port_open; 48 48 }; 49 49 50 #endif 50 #endif // _LINUX_FIREWIRE_CHANNEL_H_ -
libs/libmythtv/firewirechannelbase.cpp
5 5 */ 6 6 7 7 8 #include <iostream>8 #include "mythconfig.h" // for CONFIG_DARWIN 9 9 #include "mythcontext.h" 10 10 #include "firewirechannelbase.h" 11 #include "tv_rec.h" 11 12 13 #ifdef CONFIG_DARWIN 14 # include "darwinfirewirechannel.h" 15 #else 16 # include "firewirechannel.h" 17 #endif 18 19 FirewireChannelBase *FirewireChannelBase::Init( 20 const FireWireDBOptions &firewire_opts, TVRec *parent) 21 { 22 #ifdef CONFIG_DARWIN 23 return new DarwinFirewireChannel(firewire_opts, parent); 24 #else 25 return new LinuxFirewireChannel(firewire_opts, parent); 26 #endif 27 } 28 12 29 bool FirewireChannelBase::SetChannelByString(const QString &chan) 13 30 { 14 31 inputs[currentInputID]->startChanNum = chan; … … 22 39 return isopen && SetChannelByNumber(chan.toInt()); 23 40 } 24 41 25 bool FirewireChannelBase::Open( )42 bool FirewireChannelBase::Open(void) 26 43 { 27 44 if (!InitializeInputs()) 28 45 return false; … … 39 56 return true; 40 57 } 41 58 42 void FirewireChannelBase::Close( )59 void FirewireChannelBase::Close(void) 43 60 { 44 61 if (isopen) 45 62 CloseFirewire(); -
libs/libmythtv/tv_rec.cpp
48 48 #include "dbox2channel.h" 49 49 #include "hdhrchannel.h" 50 50 #include "iptvchannel.h" 51 #include "firewirechannelbase.h" 51 52 52 53 #include "recorderbase.h" 53 54 #include "NuppelVideoRecorder.h" … … 57 58 #include "dbox2recorder.h" 58 59 #include "hdhrrecorder.h" 59 60 #include "iptvrecorder.h" 61 #include "firewirerecorderbase.h" 60 62 61 63 #ifdef USING_V4L 62 64 #include "channel.h" 63 65 #endif 64 66 65 #ifdef USING_FIREWIRE66 #ifdef CONFIG_DARWIN67 #include "darwinfirewirerecorder.h"68 #include "darwinfirewirechannel.h"69 #else70 #include "firewirerecorder.h"71 #include "firewirechannel.h"72 #endif73 #endif74 75 67 #define DEBUG_CHANNEL_PREFIX 0 /**< set to 1 to channel prefixing */ 76 68 77 69 #define LOC QString("TVRec(%1): ").arg(cardid) … … 158 150 else if (genOpt.cardtype == "FIREWIRE") 159 151 { 160 152 #ifdef USING_FIREWIRE 161 # ifdef CONFIG_DARWIN 162 channel = new DarwinFirewireChannel(fwOpt, this); 163 # else 164 channel = new FirewireChannel(fwOpt, this); 165 # endif 166 if (!channel->Open()) 153 channel = FirewireChannelBase::Init(fwOpt, this); 154 if (!channel || !channel->Open()) 167 155 return false; 168 156 InitChannel(genOpt.defaultinput, startchannel); 169 157 init_run = true; … … 831 819 else if (genOpt.cardtype == "FIREWIRE") 832 820 { 833 821 #ifdef USING_FIREWIRE 834 # ifdef CONFIG_DARWIN 835 recorder = new DarwinFirewireRecorder(this, this->channel); 836 # else 837 recorder = new FirewireRecorder(this); 838 recorder->SetOption("port", fwOpt.port); 839 recorder->SetOption("node", fwOpt.node); 840 recorder->SetOption("speed", fwOpt.speed); 841 recorder->SetOption("model", fwOpt.model); 842 recorder->SetOption("connection", fwOpt.connection); 843 # endif // !CONFIG_DARWIN 822 recorder = FirewireRecorderBase::Init(this, GetFirewireChannel()); 823 if (recorder) 824 { 825 recorder->SetOption("port", fwOpt.port); 826 recorder->SetOption("node", fwOpt.node); 827 recorder->SetOption("speed", fwOpt.speed); 828 recorder->SetOption("model", fwOpt.model); 829 recorder->SetOption("connection", fwOpt.connection); 830 } 844 831 #endif // USING_FIREWIRE 845 832 } 846 833 else if (genOpt.cardtype == "DBOX2") … … 1114 1101 #endif // USING_DVB 1115 1102 } 1116 1103 1104 FirewireChannelBase *TVRec::GetFirewireChannel(void) 1105 { 1106 #ifdef USING_FIREWIRE 1107 return dynamic_cast<FirewireChannelBase*>(channel); 1108 #else 1109 return NULL; 1110 #endif // USING_FIREWIRE 1111 } 1112 1117 1113 Channel *TVRec::GetV4LChannel(void) 1118 1114 { 1119 1115 #ifdef USING_V4L -
libs/libmythtv/tv_rec.h
35 35 class DBox2Channel; 36 36 class DTVChannel; 37 37 class DVBChannel; 38 class FirewireChannelBase; 38 39 class Channel; 39 40 class HDHRChannel; 40 41 … … 261 262 DTVChannel *GetDTVChannel(void); 262 263 HDHRChannel *GetHDHRChannel(void); 263 264 DVBChannel *GetDVBChannel(void); 265 FirewireChannelBase *GetFirewireChannel(void); 264 266 Channel *GetV4LChannel(void); 265 267 266 268 bool SetupSignalMonitor(bool enable_table_monitoring, bool notify);