diff -p -r -u -N -X /tmp/diff.exclude.16545 -x myth.20746.0626c -x myth.20746.0626d myth.20746.0626c/mythtv/libs/libmythhdhomerun/hdhomerun_device.c myth.20746.0626d/mythtv/libs/libmythhdhomerun/hdhomerun_device.c
|
|
static struct hdhomerun_device_t *hdhome |
145 | 145 | static struct hdhomerun_device_t *hdhomerun_device_create_from_str_ip(const char *device_str) |
146 | 146 | { |
147 | 147 | unsigned long a[4]; |
148 | | if (sscanf(device_str, "%lu.%lu.%lu.%lu", &a[0], &a[1], &a[2], &a[3]) != 4) { |
149 | | return NULL; |
| 148 | unsigned int tuner; |
| 149 | |
| 150 | if (sscanf(device_str, "%lu.%lu.%lu.%lu-%u", &a[0], &a[1], &a[2], &a[3], &tuner) != 5) { |
| 151 | tuner = 0; |
| 152 | if (sscanf(device_str, "%lu.%lu.%lu.%lu", &a[0], &a[1], &a[2], &a[3]) != 4) { |
| 153 | return NULL; |
| 154 | } |
150 | 155 | } |
151 | 156 | |
152 | 157 | unsigned long device_ip = (a[0] << 24) | (a[1] << 16) | (a[2] << 8) | (a[3] << 0); |
153 | | return hdhomerun_device_create(HDHOMERUN_DEVICE_ID_WILDCARD, (uint32_t)device_ip, 0); |
| 158 | return hdhomerun_device_create(HDHOMERUN_DEVICE_ID_WILDCARD, (uint32_t)device_ip, tuner); |
154 | 159 | } |
155 | 160 | |
156 | 161 | static struct hdhomerun_device_t *hdhomerun_device_create_from_str_dns(const char *device_str) |
diff -p -r -u -N -X /tmp/diff.exclude.16545 -x myth.20746.0626c -x myth.20746.0626d myth.20746.0626c/mythtv/libs/libmythtv/hdhrstreamhandler.cpp myth.20746.0626d/mythtv/libs/libmythtv/hdhrstreamhandler.cpp
|
|
HDHRStreamHandler *HDHRStreamHandler::Ge |
35 | 35 | { |
36 | 36 | QMutexLocker locker(&_handlers_lock); |
37 | 37 | |
| 38 | QString devkey = devname.toUpper(); |
| 39 | |
38 | 40 | QMap<QString,HDHRStreamHandler*>::iterator it = |
39 | | _handlers.find(devname); |
| 41 | _handlers.find(devkey); |
| 42 | |
| 43 | hdhr_id_data device_data; |
40 | 44 | |
41 | 45 | if (it == _handlers.end()) |
42 | 46 | { |
43 | | HDHRStreamHandler *newhandler = new HDHRStreamHandler(devname); |
| 47 | // Not found in the current _handlers |
| 48 | // Try to find the physical device and determine a unique device key |
| 49 | // Then check to see if the unique key exists |
| 50 | FindDevice(devname, device_data); |
| 51 | |
| 52 | devkey = QString("%1-%2").arg(device_data.device_id, 8, 16) |
| 53 | .arg(device_data.tuner); |
| 54 | |
| 55 | // If the physical device is not found use the key "NOTFOUND-0" |
| 56 | if (device_data.device_id == 0) |
| 57 | devkey = "NOTFOUND-0"; |
| 58 | |
| 59 | devkey = devkey.toUpper(); |
| 60 | it = _handlers.find(devkey); |
| 61 | } |
| 62 | |
| 63 | |
| 64 | if (it == _handlers.end()) |
| 65 | { |
| 66 | HDHRStreamHandler *newhandler = new HDHRStreamHandler(devkey, device_data); |
44 | 67 | newhandler->Open(); |
45 | | _handlers[devname] = newhandler; |
46 | | _handlers_refcnt[devname] = 1; |
| 68 | _handlers[devkey] = newhandler; |
| 69 | _handlers_refcnt[devkey] = 1; |
| 70 | |
| 71 | // If we are adding a "NOTFOUND" device, up its refcount so we never delete it. |
| 72 | if (device_data.device_id == 0) |
| 73 | _handlers_refcnt[devkey]++; |
| 74 | |
47 | 75 | VERBOSE(VB_RECORD, |
48 | | QString("HDHRSH: Creating new stream handler for %1") |
49 | | .arg(devname)); |
| 76 | QString("HDHRSH: Creating new stream handler %1 for %2") |
| 77 | .arg(devkey).arg(devname)); |
50 | 78 | } |
51 | 79 | else |
52 | 80 | { |
53 | | _handlers_refcnt[devname]++; |
54 | | uint rcount = _handlers_refcnt[devname]; |
| 81 | _handlers_refcnt[devkey]++; |
| 82 | uint rcount = _handlers_refcnt[devkey]; |
55 | 83 | VERBOSE(VB_RECORD, |
56 | | QString("HDHRSH: Using existing stream handler for %1") |
57 | | .arg(devname) + QString(" (%2 in use)").arg(rcount)); |
| 84 | QString("HDHRSH: Using existing stream handler %1 for %2") |
| 85 | .arg(devkey).arg(devname) + QString(" (%1 in use)").arg(rcount)); |
58 | 86 | } |
59 | 87 | |
60 | | return _handlers[devname]; |
| 88 | return _handlers[devkey]; |
61 | 89 | } |
62 | 90 | |
63 | 91 | void HDHRStreamHandler::Return(HDHRStreamHandler * & ref) |
… |
… |
void HDHRStreamHandler::Return(HDHRStrea |
98 | 126 | ref = NULL; |
99 | 127 | } |
100 | 128 | |
101 | | HDHRStreamHandler::HDHRStreamHandler(const QString &devicename) : |
| 129 | HDHRStreamHandler::HDHRStreamHandler(const QString &devicename, hdhr_id_data & device_data) : |
102 | 130 | _control_socket(NULL), |
103 | 131 | _video_socket(NULL), |
| 132 | _device_id(device_data.device_id), |
| 133 | _device_ip(device_data.device_ip), |
| 134 | _tuner(device_data.tuner), |
104 | 135 | _devicename(devicename), |
105 | 136 | |
106 | 137 | _start_stop_lock(QMutex::Recursive), |
… |
… |
PIDPriority HDHRStreamHandler::GetPIDPri |
577 | 608 | |
578 | 609 | bool HDHRStreamHandler::Open(void) |
579 | 610 | { |
580 | | if (!FindDevice()) |
| 611 | // By the time we get here we have a unique device_id & device_ip pair |
| 612 | // for the hdhomerun. _device_id == 0 and _devicename == "NOTFOUND-0" |
| 613 | // denote a device which is configured but we coudn't find. |
| 614 | if (_device_id == 0) |
581 | 615 | return false; |
582 | | |
583 | 616 | return Connect(); |
584 | 617 | } |
585 | 618 | |
… |
… |
bool HDHRStreamHandler::Connect(void) |
613 | 646 | return true; |
614 | 647 | } |
615 | 648 | |
616 | | bool HDHRStreamHandler::FindDevice(void) |
| 649 | void HDHRStreamHandler::FindDevice(const QString & _devicename, hdhr_id_data &device_data) |
617 | 650 | { |
618 | 651 | hdhomerun_device_t* thisdevice = hdhomerun_device_create_from_str( |
619 | 652 | _devicename.toLocal8Bit().constData()); |
620 | 653 | |
621 | 654 | if (thisdevice) |
622 | 655 | { |
623 | | _device_id = hdhomerun_device_get_device_id(thisdevice); |
624 | | _device_ip = hdhomerun_device_get_device_ip(thisdevice); |
625 | | _tuner = hdhomerun_device_get_tuner(thisdevice); |
| 656 | device_data.device_id = hdhomerun_device_get_device_id(thisdevice); |
| 657 | device_data.device_ip = hdhomerun_device_get_device_ip(thisdevice); |
| 658 | device_data.tuner = hdhomerun_device_get_tuner(thisdevice); |
626 | 659 | hdhomerun_device_destroy(thisdevice); |
627 | 660 | |
628 | | VERBOSE(VB_IMPORTANT, LOC + |
629 | | QString("device %5 found at address %1.%2.%3.%4 tuner %6") |
630 | | .arg((_device_ip>>24) & 0xFF).arg((_device_ip>>16) & 0xFF) |
631 | | .arg((_device_ip>> 8) & 0xFF).arg((_device_ip>> 0) & 0xFF) |
632 | | .arg(_devicename).arg(_tuner)); |
633 | | |
634 | | return true; |
| 661 | if (device_data.device_ip != 0) |
| 662 | { |
| 663 | VERBOSE(VB_IMPORTANT, |
| 664 | QString("HDHRSH: device %1 found at address %2.%3.%4.%5 tuner %6") |
| 665 | .arg(_devicename) |
| 666 | .arg((device_data.device_ip>>24) & 0xFF) |
| 667 | .arg((device_data.device_ip>>16) & 0xFF) |
| 668 | .arg((device_data.device_ip>> 8) & 0xFF) |
| 669 | .arg((device_data.device_ip>> 0) & 0xFF) |
| 670 | .arg(device_data.tuner)); |
| 671 | } |
| 672 | else |
| 673 | { |
| 674 | VERBOSE(VB_IMPORTANT, |
| 675 | QString("HDHRSH: hdhomerun device %1 not found").arg(_devicename)); |
| 676 | device_data.device_id = 0; |
| 677 | device_data.device_ip = hdhomerun_device_get_device_ip_requested(thisdevice); |
| 678 | device_data.tuner = 0; |
| 679 | } |
| 680 | } |
| 681 | else |
| 682 | { |
| 683 | VERBOSE(VB_IMPORTANT, |
| 684 | QString("HDHRSH: hdhomerun device %1 not found").arg(_devicename)); |
| 685 | device_data.device_id = 0; |
| 686 | device_data.device_ip = 0; |
| 687 | device_data.tuner = 0; |
635 | 688 | } |
636 | | return false; |
637 | 689 | } |
638 | 690 | |
639 | 691 | |
diff -p -r -u -N -X /tmp/diff.exclude.16545 -x myth.20746.0626c -x myth.20746.0626d myth.20746.0626c/mythtv/libs/libmythtv/hdhrstreamhandler.h myth.20746.0626d/mythtv/libs/libmythtv/hdhrstreamhandler.h
|
|
typedef QMap<uint,int> FilterMap; |
30 | 30 | |
31 | 31 | //#define RETUNE_TIMEOUT 5000 |
32 | 32 | |
| 33 | struct hdhr_id_data { |
| 34 | uint device_id; |
| 35 | uint device_ip; |
| 36 | uint tuner; |
| 37 | }; |
| 38 | |
33 | 39 | class HDHRStreamHandler : public ReaderPausedCB |
34 | 40 | { |
35 | 41 | friend void *run_hdhr_stream_handler_thunk(void *param); |
… |
… |
class HDHRStreamHandler : public ReaderP |
55 | 61 | virtual void ReaderPaused(int fd) { (void) fd; } |
56 | 62 | |
57 | 63 | private: |
58 | | HDHRStreamHandler(const QString &); |
| 64 | HDHRStreamHandler(const QString &, hdhr_id_data &); |
59 | 65 | ~HDHRStreamHandler(); |
60 | 66 | |
61 | | bool FindDevice(void); |
| 67 | static void FindDevice(const QString &, hdhr_id_data &); |
62 | 68 | bool Connect(void); |
63 | 69 | |
64 | 70 | QString DeviceGet(const QString &name, |