Ticket #1530: fwupdate.diff
File fwupdate.diff, 28.5 KB (added by , 20 years ago) |
---|
-
libs/libmythtv/firewirechannel.cpp
44 44 45 45 FirewireChannel::FirewireChannel(FireWireDBOptions firewire_opts, 46 46 TVRec *parent) 47 : ChannelBase(parent), fw_opts(firewire_opts),48 fwhandle(NULL) , isopen(false)47 : FirewireChannelBase(parent), fw_opts(firewire_opts), 48 fwhandle(NULL) 49 49 { 50 50 } 51 51 … … 54 54 Close(); 55 55 } 56 56 57 bool FirewireChannel::SetChannelBy String(const QString &chan)57 bool FirewireChannel::SetChannelByNumber(int channel) 58 58 { 59 inputs[currentInputID]->startChanNum = chan;60 curchannelname = chan;61 62 InputMap::const_iterator it = inputs.find(currentInputID);63 64 if (!(*it)->externalChanger.isEmpty())65 return ChangeExternalChannel(chan);66 67 59 // Change channel using internal changer 68 60 69 61 if (!is_supported(fw_opts.model)) … … 74 66 return false; 75 67 } 76 68 77 if (!isopen)78 return false;79 80 int channel = chan.toInt();81 69 int dig[3]; 82 70 dig[0] = (channel % 1000) / 100; 83 71 dig[1] = (channel % 100) / 10; … … 138 126 return true; 139 127 } 140 128 141 bool FirewireChannel::Open (void)129 bool FirewireChannel::OpenFirewire(void) 142 130 { 143 if (!InitializeInputs())144 return false;145 146 InputMap::const_iterator it = inputs.find(currentInputID);147 if (!(*it)->externalChanger.isEmpty())148 return true;149 150 131 if (!is_supported(fw_opts.model)) 151 132 { 152 133 VERBOSE(VB_IMPORTANT, LOC_ERR + … … 167 148 VERBOSE(VB_CHANNEL, LOC + "Allocated raw1394 handle " + 168 149 QString("for port %1").arg(fw_opts.port)); 169 150 170 isopen = true;171 151 return true; 172 152 } 173 153 174 void FirewireChannel::Close (void)154 void FirewireChannel::CloseFirewire(void) 175 155 { 176 // Close channel 177 if (isopen) 178 { 179 VERBOSE(VB_CHANNEL, LOC + "Releasing raw1394 handle"); 180 raw1394_destroy_handle(fwhandle); 181 isopen = false; 182 } 156 VERBOSE(VB_CHANNEL, LOC + "Releasing raw1394 handle"); 157 raw1394_destroy_handle(fwhandle); 183 158 } 184 185 bool FirewireChannel::SwitchToInput(const QString &input, const QString &chan)186 {187 int inputNum = GetInputByName(input);188 if (inputNum < 0)189 return false;190 191 // input switching code would go here192 193 return SetChannelByString(chan);194 } -
libs/libmythtv/firewirerecorderbase.h
8 8 #define FIREWIRERECORDERBASE_H_ 9 9 10 10 #include "dtvrecorder.h" 11 #include "tsstats.h" 11 12 #include "mpeg/tspacket.h" 12 #include <time.h>13 13 14 #define FIREWIRE_TIMEOUT 15 14 class MPEGStreamData; 15 class ProgramAssociationTable; 16 class ProgramMapTable; 15 17 16 18 /** \class FirewireRecorderBase 17 19 * \brief This is a specialization of DTVRecorder used to … … 21 23 */ 22 24 class FirewireRecorderBase : public DTVRecorder 23 25 { 26 Q_OBJECT 27 friend class MPEGStreamData; 28 friend class TSPacketProcessor; 29 24 30 public: 25 FirewireRecorderBase(TVRec *rec, char const* name) : 26 DTVRecorder(rec, name), 27 lastpacket(0) 28 {;} 29 31 FirewireRecorderBase(TVRec *rec, char const* name); 32 ~FirewireRecorderBase(); 33 34 // Commands 30 35 void StartRecording(void); 31 36 void ProcessTSPacket(const TSPacket &tspacket); 37 bool PauseAndWait(int timeout = 100); 38 39 // Sets 32 40 void SetOptionsFromProfile(RecordingProfile *profile, 33 41 const QString &videodev, 34 42 const QString &audiodev, 35 43 const QString &vbidev); 44 void SetStreamData(MPEGStreamData*); 36 45 37 bool PauseAndWait(int timeout = 100); 46 // Gets 47 MPEGStreamData* StreamData(void) { return _mpeg_stream_data; } 38 48 39 49 public slots: 40 50 void deleteLater(void); 51 void WritePAT(ProgramAssociationTable*); 52 void WritePMT(ProgramMapTable*); 41 53 42 protected: 43 static int read_tspacket ( 44 unsigned char *tspacket, int len, uint dropped, void *callback_data); 54 private: 45 55 46 private:47 56 virtual void Close() = 0; 48 49 57 virtual void start() = 0; 50 58 virtual void stop() = 0; 51 59 virtual bool grab_frames() = 0; 52 virtual void no_data() = 0;53 60 54 private: 55 time_t lastpacket; 61 MPEGStreamData *_mpeg_stream_data; 62 TSStats _ts_stats; 63 64 protected: 65 static const int kTimeoutInSeconds; 66 56 67 }; 57 68 58 69 #endif -
libs/libmythtv/firewirechannelbase.h
23 23 class FirewireChannelBase : public ChannelBase 24 24 { 25 25 public: 26 FirewireChannelBase(TVRec *parent); 27 ~FirewireChannelBase(); 26 FirewireChannelBase(TVRec *parent) 27 : ChannelBase(parent), isopen(false) { } 28 ~FirewireChannelBase() { Close(); } 28 29 29 30 bool Open(void); 30 31 void Close(void); 31 32 32 33 // Sets 33 34 bool SetChannelByString(const QString &chan); 34 void SetExternalChanger(void);35 35 virtual bool SetChannelByNumber(int channel) = 0; 36 36 37 37 // Gets 38 38 bool IsOpen(void) const { return isopen; } 39 // QString GetDevice(void) const;40 39 41 40 // Commands 42 41 bool SwitchToInput(const QString &inputname, const QString &chan); … … 48 47 virtual void CloseFirewire() = 0; 49 48 50 49 protected: 51 bool UseExternalChanger();52 50 bool isopen; 53 51 }; 54 52 -
libs/libmythtv/libmythtv.pro
288 288 DEFINES += USING_V4L 289 289 } 290 290 291 # Support for cable boxes that provide Firewire out on Linux292 using_firewire :HEADERS += firewirerecorder.h firewirechannel.h293 using_firewire:SOURCES += firewirerecorder.cpp firewirechannel.cpp294 using_firewire:DEFINES += USING_FIREWIRE291 # Support for cable boxes that provide Firewire out 292 using_firewire { 293 HEADERS += firewirerecorderbase.h firewirechannelbase.h 294 SOURCES += firewirerecorderbase.cpp firewirechannelbase.cpp 295 295 296 # macx { 297 # HEADERS += darwinfirewirechannel.h darwinfirewirerecorder.h 298 # SOURCES += darwinfirewirechannel.cpp darwinfirewirerecorder.cpp 299 # HEADERS += selectavcdevice.h 300 # SOURCES += selectavcdevice.cpp 301 # } 302 303 linux { 304 HEADERS += firewirechannel.h firewirerecorder.h 305 SOURCES += firewirechannel.cpp firewirerecorder.cpp 306 } 307 308 DEFINES += USING_FIREWIRE 309 } 310 296 311 # Support for set top boxes (Nokia DBox2 etc.) 297 312 using_dbox2:SOURCES += dbox2recorder.cpp dbox2channel.cpp dbox2epg.cpp 298 313 using_dbox2:HEADERS += dbox2recorder.h dbox2channel.h dbox2epg.h -
libs/libmythtv/darwinfirewirerecorder.cpp
113 113 { 114 114 for (UInt32 i = 0; i < tsPacketCount; ++i) 115 115 { 116 void* packet = ppBuf[i]; 117 int ok = FirewireRecorderBase::read_tspacket( 118 static_cast<unsigned char *>(packet), 119 AVS::kMPEG2TSPacketSize, 120 0, // dropped 121 pRefCon); 122 123 // This is based on knowledge of what read_tspacket does -- 124 // the only way it fails is with a NULL callback_data 125 // argument. 126 if (!ok) 127 return kIOReturnBadArgument; 116 ProcessTSPacket(*(reinterpret_cast<TSPacket*>(ppBuf[i]))); 128 117 } 129 118 130 119 return 0; -
libs/libmythtv/firewirerecorderbase.cpp
7 7 // MythTV includes 8 8 #include "firewirerecorderbase.h" 9 9 #include "mythcontext.h" 10 #include "tspacket.h" 10 #include "mpegtables.h" 11 #include "mpegstreamdata.h" 11 12 #include "tv_rec.h" 12 13 13 // callback function for libiec61883 14 int FirewireRecorderBase::read_tspacket (unsigned char *tspacket, int /*len*/, 15 uint dropped, void *callback_data) 16 { 17 FirewireRecorderBase *fw = (FirewireRecorderBase*) callback_data; 14 #define LOC QString("FireRecBase: ") 15 #define LOC_ERR QString("FireRecBase, Error: ") 18 16 19 if (!fw) 20 return 0; 17 const int FirewireRecorderBase::kTimeoutInSeconds = 15; 21 18 22 if (dropped) 23 { 24 VERBOSE(VB_RECORD, 25 QString("Firewire: %1 packet(s) dropped.").arg(dropped)); 26 } 19 FirewireRecorderBase::FirewireRecorderBase(TVRec *rec, char const* name) 20 : DTVRecorder(rec, name), 21 _mpeg_stream_data(NULL) 22 { 23 _mpeg_stream_data = new MPEGStreamData(1, true); 24 connect(_mpeg_stream_data, 25 SIGNAL(UpdatePATSingleProgram(ProgramAssociationTable*)), 26 this, SLOT(WritePAT(ProgramAssociationTable*))); 27 connect(_mpeg_stream_data, 28 SIGNAL(UpdatePMTSingleProgram(ProgramMapTable*)), 29 this, SLOT(WritePMT(ProgramMapTable*))); 30 } 27 31 28 if (SYNC_BYTE != tspacket[0]) 29 { 30 VERBOSE(VB_IMPORTANT, "Firewire: Got out of sync TS Packet"); 31 return 1; 32 } 32 FirewireRecorderBase::~FirewireRecorderBase() 33 { 34 if (_mpeg_stream_data) 35 { 36 delete _mpeg_stream_data; 37 _mpeg_stream_data = NULL; 38 } 39 } 33 40 34 fw->ProcessTSPacket(*(reinterpret_cast<TSPacket*>(tspacket)));35 36 return 1;37 }38 39 41 void FirewireRecorderBase::deleteLater(void) 40 42 { 41 43 Close(); … … 44 46 45 47 void FirewireRecorderBase::StartRecording(void) { 46 48 47 VERBOSE(VB_RECORD, QString("StartRecording"));49 VERBOSE(VB_RECORD, LOC + "StartRecording"); 48 50 49 51 if (!Open()) { 50 52 _error = true; … … 54 56 _request_recording = true; 55 57 _recording = true; 56 58 57 this->start();59 start(); 58 60 59 lastpacket = time(NULL);60 61 while(_request_recording) { 61 62 if (PauseAndWait()) 62 63 continue; 63 64 64 if (time(NULL) - lastpacket > FIREWIRE_TIMEOUT) { 65 this->no_data(); 66 this->stop(); 67 _error = true; 68 return; 69 } 70 71 if (!this->grab_frames()) 65 if (!grab_frames()) 72 66 { 73 67 _error = true; 74 68 return; 75 69 } 76 70 } 77 71 78 this->stop();72 stop(); 79 73 FinishRecording(); 80 74 81 75 _recording = false; … … 83 77 84 78 void FirewireRecorderBase::ProcessTSPacket(const TSPacket &tspacket) 85 79 { 86 lastpacket = time(NULL); 87 _buffer_packets = !FindKeyframes(&tspacket); 88 BufferedWrite(tspacket); 80 if (tspacket.TransportError()) 81 return; 82 83 if (tspacket.ScramplingControl()) 84 return; 85 86 if (tspacket.HasAdaptationField()) 87 StreamData()->HandleAdaptationFieldControl(&tspacket); 88 89 if (tspacket.HasPayload()) 90 { 91 const unsigned int lpid = tspacket.PID(); 92 93 // Pass or reject packets based on PID, and parse info from them 94 if (lpid == StreamData()->VideoPIDSingleProgram()) 95 { 96 _buffer_packets = !FindKeyframes(&tspacket); 97 BufferedWrite(tspacket); 98 } 99 else if (StreamData()->IsAudioPID(lpid)) 100 BufferedWrite(tspacket); 101 else if (StreamData()->IsListeningPID(lpid)) 102 StreamData()->HandleTSTables(&tspacket); 103 else if (StreamData()->IsWritingPID(lpid)) 104 BufferedWrite(tspacket); 105 } 106 107 _ts_stats.IncrTSPacketCount(); 108 if (0 == _ts_stats.TSPacketCount()%1000000) 109 VERBOSE(VB_RECORD, _ts_stats.toString()); 89 110 } 90 111 91 112 void FirewireRecorderBase::SetOptionsFromProfile(RecordingProfile *profile, … … 106 127 { 107 128 if (!paused) 108 129 { 109 this->stop();130 stop(); 110 131 paused = true; 111 132 pauseWait.wakeAll(); 112 133 if (tvrec) … … 116 137 } 117 138 if (!request_pause && paused) 118 139 { 119 this->start();140 start(); 120 141 paused = false; 121 142 } 122 143 return paused; 123 144 } 145 146 void FirewireRecorderBase::SetStreamData(MPEGStreamData *stream_data) 147 { 148 if (stream_data == _mpeg_stream_data) 149 return; 150 151 MPEGStreamData *old_data = _mpeg_stream_data; 152 _mpeg_stream_data = stream_data; 153 if (old_data) 154 delete old_data; 155 } 156 157 void FirewireRecorderBase::WritePAT(ProgramAssociationTable *pat) 158 { 159 if (!pat) 160 return; 161 162 int next = (pat->tsheader()->ContinuityCounter()+1)&0xf; 163 pat->tsheader()->SetContinuityCounter(next); 164 BufferedWrite(*(reinterpret_cast<const TSPacket*>(pat->tsheader()))); 165 } 166 167 void FirewireRecorderBase::WritePMT(ProgramMapTable *pmt) 168 { 169 if (!pmt) 170 return; 171 172 int next = (pmt->tsheader()->ContinuityCounter()+1)&0xf; 173 pmt->tsheader()->SetContinuityCounter(next); 174 BufferedWrite(*(reinterpret_cast<const TSPacket*>(pmt->tsheader()))); 175 } -
libs/libmythtv/firewirerecorder.cpp
22 22 #define LOC QString("FireRec: ") 23 23 #define LOC_ERR QString("FireRec, Error: ") 24 24 25 const int FirewireRecorder::kBroadcastChannel = 63;26 const int FirewireRecorder::kTimeoutInSeconds = 15;27 const int FirewireRecorder::kConnectionP2P = 0;28 const int FirewireRecorder::kConnectionBroadcast = 1;25 const int FirewireRecorder::kBroadcastChannel = 63; 26 const int FirewireRecorder::kConnectionP2P = 0; 27 const int FirewireRecorder::kConnectionBroadcast = 1; 28 const uint FirewireRecorder::kMaxBufferedPackets = 8000; 29 29 30 30 // callback function for libiec61883 31 31 int fw_tspacket_handler(unsigned char *tspacket, int /*len*/, … … 59 59 return QString("%1Mbps").arg(speeds[speed]); 60 60 } 61 61 62 FirewireRecorder::FirewireRecorder(TVRec *rec)63 : DTVRecorder(rec, "FirewireRecorder"),64 fwport(-1), fwchannel(-1), fwspeed(-1), fwbandwidth(-1),65 fwfd(-1), fwconnection(kConnectionP2P),66 fwoplug(-1), fwiplug(-1), fwmodel(""), fwnode(0),67 fwhandle(NULL), fwmpeg(NULL), isopen(false), lastpacket(0),68 _mpeg_stream_data(NULL)69 {70 _mpeg_stream_data = new MPEGStreamData(1, true);71 connect(_mpeg_stream_data,72 SIGNAL(UpdatePATSingleProgram(ProgramAssociationTable*)),73 this, SLOT(WritePAT(ProgramAssociationTable*)));74 connect(_mpeg_stream_data,75 SIGNAL(UpdatePMTSingleProgram(ProgramMapTable*)),76 this, SLOT(WritePMT(ProgramMapTable*)));77 }78 79 FirewireRecorder::~FirewireRecorder()80 {81 Close();82 if (_mpeg_stream_data)83 {84 delete _mpeg_stream_data;85 _mpeg_stream_data = NULL;86 }87 }88 89 void FirewireRecorder::deleteLater(void)90 {91 Close();92 DTVRecorder::deleteLater();93 }94 95 62 bool FirewireRecorder::Open(void) 96 63 { 97 64 if (isopen) 98 65 return true; 99 66 100 if (!_mpeg_stream_data)101 return false;102 103 67 VERBOSE(VB_RECORD, LOC + 104 68 QString("Initializing Port: %1, Node: %2, Speed: %3") 105 69 .arg(fwport).arg(fwnode).arg(speed_to_string(fwspeed))); … … 157 121 return false; 158 122 } 159 123 160 // Set buffer size124 // Set buffered packets size 161 125 size_t buffer_size = gContext->GetNumSetting("HDRingbufferSize", 162 126 50 * TSPacket::SIZE); 163 iec61883_mpeg2_set_buffers(fwmpeg, buffer_size / 2); 127 size_t buffered_packets = min(buffer_size / 4, kMaxBufferedPackets); 128 iec61883_mpeg2_set_buffers(fwmpeg, buffered_packets); 164 129 VERBOSE(VB_IMPORTANT, LOC + 165 QString("Buffer size %1 KB").arg(buffer_size)); 130 QString("Buffered packets %1 (%2 KB)"). 131 arg(buffered_packets).arg(buffered_packets * 4)); 166 132 167 133 // Set speed if needed. 168 134 // Probably shouldn't even allow user to set, … … 188 154 return isopen = true; 189 155 } 190 156 191 void FirewireRecorder::SetStreamData(MPEGStreamData *stream_data)192 {193 if (stream_data == _mpeg_stream_data)194 return;195 196 MPEGStreamData *old_data = _mpeg_stream_data;197 _mpeg_stream_data = stream_data;198 if (old_data)199 delete old_data;200 }201 202 157 void FirewireRecorder::Close(void) 203 158 { 204 159 if (!isopen) … … 223 178 raw1394_destroy_handle(fwhandle); 224 179 } 225 180 226 void FirewireRecorder::StartRecording(void)181 bool FirewireRecorder::grab_frames() 227 182 { 228 183 struct timeval tv; 229 184 fd_set rfds; 230 185 231 VERBOSE(VB_RECORD, LOC + "StartRecording"); 186 FD_ZERO(&rfds); 187 FD_SET(fwfd, &rfds); 188 tv.tv_sec = kTimeoutInSeconds; 189 tv.tv_usec = 0; 232 190 233 if ( !Open())191 if (select(fwfd + 1, &rfds, NULL, NULL, &tv) <= 0) 234 192 { 235 _error = true; 236 return; 193 VERBOSE(VB_IMPORTANT, LOC + 194 QString("No Input in %1 seconds [P:%2 N:%3] (select)") 195 .arg(kTimeoutInSeconds).arg(fwport).arg(fwnode)); 196 return false; 237 197 } 238 198 239 _request_recording = true; 240 _recording = true; 241 242 iec61883_mpeg2_recv_start(fwmpeg,fwchannel); 243 lastpacket = time(NULL); 244 while (_request_recording) 199 int ret = raw1394_loop_iterate(fwhandle); 200 if (ret) 245 201 { 246 if (PauseAndWait()) 247 continue; 248 249 if (time(NULL) - lastpacket > kTimeoutInSeconds) 250 { 251 VERBOSE(VB_IMPORTANT, LOC + 252 QString("No Input in %1 seconds [P:%2 N:%3] (time)") 253 .arg(kTimeoutInSeconds).arg(fwport).arg(fwnode)); 254 255 iec61883_mpeg2_recv_stop(fwmpeg); 256 _error = true; 257 return; 258 } 259 260 FD_ZERO(&rfds); 261 FD_SET(fwfd, &rfds); 262 tv.tv_sec = kTimeoutInSeconds; 263 tv.tv_usec = 0; 264 265 if (select(fwfd + 1, &rfds, NULL, NULL, &tv) > 0) 266 { 267 int ret = raw1394_loop_iterate(fwhandle); 268 if (ret) 269 { 270 VERBOSE(VB_IMPORTANT, LOC_ERR + "libraw1394_loop_iterate() " + 271 QString("returned %1").arg(ret)); 272 273 iec61883_mpeg2_recv_stop(fwmpeg); 274 _error = true; 275 return; 276 } 277 } 278 else 279 { 280 VERBOSE(VB_IMPORTANT, LOC + 281 QString("No Input in %1 seconds [P:%2 N:%3] (select)") 282 .arg(kTimeoutInSeconds).arg(fwport).arg(fwnode)); 283 284 iec61883_mpeg2_recv_stop(fwmpeg); 285 // to bad setting _error does nothing once recording has started.. 286 _error = true; 287 return; 288 } 202 VERBOSE(VB_IMPORTANT, LOC_ERR + "libraw1394_loop_iterate() " + 203 QString("returned %1").arg(ret)); 204 return false; 289 205 } 290 291 iec61883_mpeg2_recv_stop(fwmpeg); 292 293 VERBOSE(VB_IMPORTANT, QString("Firewire: Total dropped packets %1") 294 .arg(iec61883_mpeg2_get_dropped(fwmpeg))); 295 296 FinishRecording(); 297 _recording = false; 206 207 return true; 298 208 } 299 209 300 void FirewireRecorder::WritePAT(ProgramAssociationTable *pat)301 {302 if (!pat)303 return;304 305 int next = (pat->tsheader()->ContinuityCounter()+1)&0xf;306 pat->tsheader()->SetContinuityCounter(next);307 BufferedWrite(*(reinterpret_cast<const TSPacket*>(pat->tsheader())));308 }309 310 void FirewireRecorder::WritePMT(ProgramMapTable *pmt)311 {312 if (!pmt)313 return;314 315 int next = (pmt->tsheader()->ContinuityCounter()+1)&0xf;316 pmt->tsheader()->SetContinuityCounter(next);317 BufferedWrite(*(reinterpret_cast<const TSPacket*>(pmt->tsheader())));318 }319 320 void FirewireRecorder::ProcessTSPacket(const TSPacket &tspacket)321 {322 if (tspacket.TransportError())323 return;324 325 if (tspacket.ScramplingControl())326 return;327 328 if (tspacket.HasAdaptationField())329 StreamData()->HandleAdaptationFieldControl(&tspacket);330 331 if (tspacket.HasPayload())332 {333 const unsigned int lpid = tspacket.PID();334 335 // Pass or reject packets based on PID, and parse info from them336 if (lpid == StreamData()->VideoPIDSingleProgram())337 {338 _buffer_packets = !FindKeyframes(&tspacket);339 BufferedWrite(tspacket);340 }341 else if (StreamData()->IsAudioPID(lpid))342 BufferedWrite(tspacket);343 else if (StreamData()->IsListeningPID(lpid))344 StreamData()->HandleTSTables(&tspacket);345 else if (StreamData()->IsWritingPID(lpid))346 BufferedWrite(tspacket);347 }348 349 lastpacket = time(NULL);350 _ts_stats.IncrTSPacketCount();351 if (0 == _ts_stats.TSPacketCount()%1000000)352 VERBOSE(VB_RECORD, _ts_stats.toString());353 }354 355 void FirewireRecorder::SetOptionsFromProfile(RecordingProfile *profile,356 const QString &videodev,357 const QString &audiodev,358 const QString &vbidev)359 {360 (void)videodev;361 (void)audiodev;362 (void)vbidev;363 (void)profile;364 }365 366 210 void FirewireRecorder::SetOption(const QString &name, const QString &value) 367 211 { 368 212 if (name == "model") … … 403 247 fwconnection = value; 404 248 } 405 249 } 406 407 // documented in recorderbase.cpp408 bool FirewireRecorder::PauseAndWait(int timeout)409 {410 if (request_pause)411 {412 if (!paused)413 {414 iec61883_mpeg2_recv_stop(fwmpeg);415 paused = true;416 pauseWait.wakeAll();417 if (tvrec)418 tvrec->RecorderPaused();419 }420 unpauseWait.wait(timeout);421 }422 423 if (!request_pause && paused)424 {425 iec61883_mpeg2_recv_start(fwmpeg, fwchannel);426 paused = false;427 }428 429 return paused;430 } -
libs/libmythtv/firewirerecorder.h
7 7 #ifndef FIREWIRERECORDER_H_ 8 8 #define FIREWIRERECORDER_H_ 9 9 10 #include " dtvrecorder.h"10 #include "firewirerecorderbase.h" 11 11 #include "tsstats.h" 12 12 #include <libraw1394/raw1394.h> 13 13 #include <libiec61883/iec61883.h> 14 #include <time.h>15 14 16 class MPEGStreamData;17 class ProgramAssociationTable;18 class ProgramMapTable;19 20 15 /** \class FirewireRecorder 21 * \brief This is a specialization of DTVRecorder used to 22 * handle DVB and ATSC streams from a firewire input. 16 * \brief Linux FirewireRecorder 23 17 * 24 * \sa DTVRecorder18 * \sa FirewireRecorderBase 25 19 */ 26 class FirewireRecorder : public DTVRecorder20 class FirewireRecorder : public FirewireRecorderBase 27 21 { 28 Q_OBJECT29 friend class MPEGStreamData;30 friend class TSPacketProcessor;31 22 friend int fw_tspacket_handler(unsigned char*,int,uint,void*); 32 23 33 24 public: 34 FirewireRecorder(TVRec *rec); 35 ~FirewireRecorder(); 25 FirewireRecorder(TVRec *rec) 26 : FirewireRecorderBase(rec, "FirewireRecorder"), 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(); } 36 32 37 33 // Commands 38 void StartRecording(void);39 34 bool Open(void); 40 bool PauseAndWait(int timeout = 100);41 35 42 36 // Sets 43 void SetOptionsFromProfile(RecordingProfile *profile,44 const QString &videodev,45 const QString &audiodev,46 const QString &vbidev);47 37 void SetOption(const QString &name, const QString &value); 48 38 void SetOption(const QString &name, int value); 49 void SetStreamData(MPEGStreamData*);50 39 51 // Gets52 MPEGStreamData* StreamData(void) { return _mpeg_stream_data; }53 54 public slots:55 void deleteLater(void);56 void WritePAT(ProgramAssociationTable*);57 void WritePMT(ProgramMapTable*);58 59 40 private: 60 41 void Close(void); 61 void ProcessTSPacket(const TSPacket &tspacket); 42 void start() { iec61883_mpeg2_recv_start(fwmpeg, fwchannel); } 43 void stop() { iec61883_mpeg2_recv_stop(fwmpeg); } 44 bool grab_frames(); 62 45 63 46 private: 64 47 int fwport; … … 74 57 raw1394handle_t fwhandle; 75 58 iec61883_mpeg2_t fwmpeg; 76 59 bool isopen; 77 time_t lastpacket;78 MPEGStreamData *_mpeg_stream_data;79 TSStats _ts_stats;80 60 81 static const int kBroadcastChannel;82 static const int kTimeoutInSeconds;83 static const int kConnectionP2P;84 static const int kConnectionBroadcast;61 static const int kBroadcastChannel; 62 static const int kConnectionP2P; 63 static const int kConnectionBroadcast; 64 static const uint kMaxBufferedPackets; 85 65 }; 86 66 87 67 #endif -
libs/libmythtv/firewirechannel.h
11 11 12 12 #include <qstring.h> 13 13 #include "tv_rec.h" 14 #include " channelbase.h"14 #include "firewirechannelbase.h" 15 15 #include <libavc1394/avc1394.h> 16 16 17 17 using namespace std; 18 18 19 class FirewireChannel : public ChannelBase19 class FirewireChannel : public FirewireChannelBase 20 20 { 21 21 public: 22 22 FirewireChannel(FireWireDBOptions firewire_opts, TVRec *parent); 23 23 ~FirewireChannel(void); 24 24 25 bool Open (void);26 void Close (void);25 bool OpenFirewire(void); 26 void CloseFirewire(void); 27 27 28 28 // Sets 29 bool SetChannelByString(const QString &chan);30 void SetExternalChanger(void);29 void SetExternalChanger(void); 30 bool SetChannelByNumber(int channel); 31 31 32 32 // Gets 33 33 bool IsOpen(void) const { return isopen; } 34 34 QString GetDevice(void) const 35 35 { return QString("%1:%2").arg(fw_opts.port).arg(fw_opts.node); } 36 36 37 // Commands38 bool SwitchToInput(const QString &inputname, const QString &chan);39 bool SwitchToInput(int newcapchannel, bool setstarting)40 { (void)newcapchannel; (void)setstarting; return false; }41 37 42 38 private: 43 39 FireWireDBOptions fw_opts; 44 40 nodeid_t fwnode; 45 41 raw1394handle_t fwhandle; 46 bool isopen;47 42 }; 48 43 49 44 #endif -
libs/libmythtv/firewirechannelbase.cpp
9 9 #include "mythcontext.h" 10 10 #include "firewirechannelbase.h" 11 11 12 bool FirewireChannelBase::UseExternalChanger() 13 { 14 return !externalChanger[currentcapchannel].isEmpty(); 15 } 16 17 FirewireChannelBase::FirewireChannelBase(TVRec *parent) 18 : ChannelBase(parent), isopen(false) 12 bool FirewireChannelBase::SetChannelByString(const QString &chan) 19 13 { 20 21 isopen = false; 22 channelnames[0] = "MPEG2TS"; 23 } 14 inputs[currentInputID]->startChanNum = chan; 15 curchannelname = chan; 24 16 25 FirewireChannelBase::~FirewireChannelBase(void) 26 { 27 this->Close(); 28 } 17 InputMap::const_iterator it = inputs.find(currentInputID); 29 18 30 bool FirewireChannelBase::SetChannelByString(const QString &chan) 31 { 32 inputChannel[currentcapchannel] = chan; 33 curchannelname = chan; 19 if (!(*it)->externalChanger.isEmpty()) 20 return ChangeExternalChannel(chan); 34 21 35 if (this->UseExternalChanger()) 36 return ChangeExternalChannel(chan); 37 else 38 return isopen && SetChannelByNumber(chan.toInt()); 22 return isopen && SetChannelByNumber(chan.toInt()); 39 23 } 40 24 41 25 bool FirewireChannelBase::Open() 42 26 { 43 if (this->UseExternalChanger()) 44 { 45 this->SetExternalChanger(); 27 if (!InitializeInputs()) 28 return false; 29 30 InputMap::const_iterator it = inputs.find(currentInputID); 31 if (!(*it)->externalChanger.isEmpty()) 46 32 return true; 47 } 48 else33 34 if (!isopen) 49 35 { 50 if (!this->isopen) 51 this->isopen = this->OpenFirewire(); 52 return this->isopen; 36 isopen = OpenFirewire(); 37 return isopen; 53 38 } 39 return true; 54 40 } 55 41 56 42 void FirewireChannelBase::Close() 57 43 { 58 if ( this->isopen)44 if (isopen) 59 45 CloseFirewire(); 60 this->isopen = false;46 isopen = false; 61 47 } 62 48 63 49 bool FirewireChannelBase::SwitchToInput(const QString &input, const QString &chan) 64 50 { 65 currentcapchannel = 0;66 if ( channelnames.empty())67 channelnames[currentcapchannel] = input;51 int inputNum = GetInputByName(input); 52 if (inputNum < 0) 53 return false; 68 54 69 55 return SetChannelByString(chan); 70 56 } 71 72 void FirewireChannelBase::SetExternalChanger(void)73 {74 RetrieveInputChannels(inputChannel, inputTuneTo,75 externalChanger, sourceid);76 }