Ticket #6881: hdhr-device-api.patch
File hdhr-device-api.patch, 8.6 KB (added by , 15 years ago) |
---|
-
mythtv/libs/libmythtv/hdhrstreamhandler.cpp
129 129 130 130 HDHRStreamHandler::HDHRStreamHandler(const QString &devicename, 131 131 hdhr_id_data &device_data) : 132 _control_socket(NULL), 133 _video_socket(NULL), 132 _hdhomerun_device(NULL), 134 133 _device_id(device_data.device_id), 135 134 _device_ip(device_data.device_ip), 136 135 _tuner(device_data.tuner), … … 284 283 buffersize = max(49 * TSPacket::SIZE * 128, buffersize); 285 284 286 285 /* Create TS socket. */ 287 _video_socket = hdhomerun_video_create(0, buffersize, NULL); 288 if (!_video_socket) 286 if (!hdhomerun_device_stream_start(_hdhomerun_device)) 289 287 { 290 VERBOSE(VB_IMPORTANT, LOC + "Open() failed to open socket");291 return;292 }293 294 uint localPort = hdhomerun_video_get_local_port(_video_socket);295 if (!DeviceSetTarget(localPort))296 {297 288 VERBOSE(VB_IMPORTANT, LOC_ERR + 298 289 "Starting recording (set target failed). Aborting."); 299 290 return; 300 291 } 301 hdhomerun_ video_flush(_video_socket);292 hdhomerun_device_stream_flush(_hdhomerun_device); 302 293 303 294 bool _error = false; 304 295 … … 313 304 read_size *= VIDEO_DATA_PACKET_SIZE; 314 305 315 306 size_t data_length; 316 unsigned char *data_buffer = 317 hdhomerun_video_recv(_video_socket, read_size, &data_length);307 unsigned char *data_buffer = hdhomerun_device_stream_recv( 308 _hdhomerun_device, read_size, &data_length); 318 309 319 310 if (!data_buffer) 320 311 { … … 350 341 351 342 RemoveAllPIDFilters(); 352 343 353 DeviceClearTarget();344 hdhomerun_device_stream_stop(_hdhomerun_device); 354 345 VERBOSE(VB_RECORD, LOC + "RunTS(): " + "end"); 355 346 356 hdhomerun_video_sock_t* tmp_video_socket;357 {358 QMutexLocker locker(&_hdhr_lock);359 tmp_video_socket = _video_socket;360 _video_socket=NULL;361 }362 363 hdhomerun_video_destroy(tmp_video_socket);364 365 VERBOSE(VB_RECORD, LOC + "RunTS(): " + "end");366 367 347 SetRunning(false); 368 348 } 369 349 … … 620 600 621 601 void HDHRStreamHandler::Close(void) 622 602 { 623 if (_ control_socket)603 if (_hdhomerun_device) 624 604 { 625 605 TuneChannel("none"); 626 hdhomerun_ control_destroy(_control_socket);627 _ control_socket=NULL;606 hdhomerun_device_destroy(_hdhomerun_device); 607 _hdhomerun_device=NULL; 628 608 } 629 609 } 630 610 631 611 bool HDHRStreamHandler::Connect(void) 632 612 { 633 _ control_socket = hdhomerun_control_create(_device_id, _device_ip, NULL);613 _hdhomerun_device = hdhomerun_device_create(_device_id, _device_ip, _tuner, NULL); 634 614 635 if (!_ control_socket)615 if (!_hdhomerun_device) 636 616 { 637 VERBOSE(VB_IMPORTANT, LOC_ERR + "Unable to create control socket");617 VERBOSE(VB_IMPORTANT, LOC_ERR + "Unable to create hdhomerun object"); 638 618 return false; 639 619 } 640 620 641 if (hdhomerun_ control_get_local_addr(_control_socket) == 0)621 if (hdhomerun_device_get_local_machine_addr(_hdhomerun_device) == 0) 642 622 { 643 623 VERBOSE(VB_IMPORTANT, LOC_ERR + "Unable to connect to device"); 644 624 return false; … … 694 674 695 675 bool HDHRStreamHandler::EnterPowerSavingMode(void) 696 676 { 697 if ( _video_socket)677 if (!hdhomerun_device_get_video_sock(_hdhomerun_device)) 698 678 { 699 679 VERBOSE(VB_RECORD, LOC + "Ignoring request - video streaming active"); 700 680 return false; … … 710 690 { 711 691 QMutexLocker locker(&_hdhr_lock); 712 692 713 if (!_ control_socket)693 if (!_hdhomerun_device) 714 694 { 715 695 VERBOSE(VB_IMPORTANT, LOC_ERR + "Get request failed (not connected)"); 716 696 return QString::null; … … 718 698 719 699 char *value = NULL; 720 700 char *error = NULL; 721 if (hdhomerun_ control_get(722 _ control_socket, name.toLocal8Bit().constData(),701 if (hdhomerun_device_get_var( 702 _hdhomerun_device, name.toLocal8Bit().constData(), 723 703 &value, &error) < 0) 724 704 { 725 705 VERBOSE(VB_IMPORTANT, LOC_ERR + "Get request failed" + ENO); … … 746 726 { 747 727 QMutexLocker locker(&_hdhr_lock); 748 728 749 if (!_ control_socket)729 if (!_hdhomerun_device) 750 730 { 751 731 VERBOSE(VB_IMPORTANT, LOC_ERR + "Set request failed (not connected)"); 752 732 return QString::null; … … 754 734 755 735 char *value = NULL; 756 736 char *error = NULL; 757 if (hdhomerun_ control_set(758 _ control_socket, name.toLocal8Bit().constData(),737 if (hdhomerun_device_set_var( 738 _hdhomerun_device, name.toLocal8Bit().constData(), 759 739 val.toLocal8Bit().constData(), &value, &error) < 0) 760 740 { 761 741 VERBOSE(VB_IMPORTANT, LOC_ERR + "Set request failed" + ENO); … … 800 780 return false; 801 781 } 802 782 803 unsigned long localIP = hdhomerun_control_get_local_addr(_control_socket); 783 unsigned long localIP = hdhomerun_device_get_local_machine_addr( 784 _hdhomerun_device); 804 785 if (localIP == 0) 805 786 { 806 787 return false; … … 830 811 return !TunerSet("target", "0.0.0.0:0").isEmpty(); 831 812 } 832 813 833 QString HDHRStreamHandler::GetTunerStatus(void) const 814 void HDHRStreamHandler::GetTunerStatus(struct hdhomerun_tuner_status_t *status) 834 815 { 835 return TunerGet("status");816 hdhomerun_device_get_tuner_status(_hdhomerun_device, NULL, status); 836 817 } 837 818 838 819 bool HDHRStreamHandler::IsConnected(void) const 839 820 { 840 return (_ control_socket!= NULL);821 return (_hdhomerun_device != NULL); 841 822 } 842 823 843 824 bool HDHRStreamHandler::TuneChannel(const QString &chn) -
mythtv/libs/libmythtv/hdhrsignalmonitor.cpp
103 103 return; 104 104 } 105 105 106 QString msg = streamHandler->GetTunerStatus(); 107 //ss = signal strength, [0,100] 108 //snq = signal to noise quality [0,100] 109 //seq = signal error quality [0,100] 110 int loc_sig = msg.indexOf("ss="), loc_snq = msg.indexOf("snq="); 111 int loc_seq = msg.indexOf("seq="), loc_end = msg.length(); 112 bool ok0, ok1, ok2; 113 uint sig = msg.mid(loc_sig + 3, loc_snq - loc_sig - 4).toUInt(&ok0); 114 uint snq = msg.mid(loc_snq + 4, loc_seq - loc_snq - 5).toUInt(&ok1); 115 uint seq = msg.mid(loc_seq + 4, loc_end - loc_seq - 4).toUInt(&ok2); 106 struct hdhomerun_tuner_status_t status; 107 streamHandler->GetTunerStatus(&status); 108 109 uint sig = status.signal_strength; 110 uint snq = status.signal_to_noise_quality; 111 uint seq = status.symbol_error_quality; 112 116 113 (void) snq; // TODO should convert to S/N 117 114 (void) seq; // TODO should report this... 118 115 … … 124 121 bool isLocked = false; 125 122 { 126 123 QMutexLocker locker(&statusLock); 127 if (loc_sig > 0 && loc_snq > 0 && ok0) 128 signalStrength.SetValue(sig); 129 signalLock.SetValue(signalStrength.IsGood() ? 1 : 0); 124 signalStrength.SetValue(sig); 125 signalLock.SetValue(status.lock_supported); 130 126 isLocked = signalLock.IsGood(); 131 127 } 132 128 -
mythtv/libs/libmythtv/hdhrchannel.cpp
27 27 #include "channelutil.h" 28 28 #include "hdhrstreamhandler.h" 29 29 30 // HDHomeRun header31 #include "hdhomerun.h"32 33 30 #define DEBUG_PID_FILTERS 34 31 35 32 #define LOC QString("HDHRChan(%1): ").arg(GetDevice()) -
mythtv/libs/libmythtv/hdhrstreamhandler.h
22 22 // HDHomeRun headers 23 23 #ifdef USING_HDHOMERUN 24 24 #include "hdhomerun.h" 25 #undef max26 #undef min27 25 #else 28 struct hdhomerun_ control_sock_t { int dummy; };26 struct hdhomerun_device_t { int dummy; }; 29 27 #endif 30 28 31 29 typedef QMap<uint,int> FilterMap; … … 50 48 void RemoveListener(MPEGStreamData *data); 51 49 52 50 bool IsRunning(void) const { return _running; } 53 QString GetTunerStatus(void) const;51 void GetTunerStatus(struct hdhomerun_tuner_status_t *status); 54 52 bool IsConnected(void) const; 55 53 56 54 // Commands … … 107 105 PIDPriority GetPIDPriority(uint pid) const; 108 106 109 107 private: 110 hdhomerun_control_sock_t *_control_socket; 111 hdhomerun_video_sock_t *_video_socket; 108 hdhomerun_device_t *_hdhomerun_device; 112 109 uint _device_id; 113 110 uint _device_ip; 114 111 uint _tuner;