Hello community, here is the log from the commit of package libhdhomerun for openSUSE:Factory checked in at 2015-02-10 20:23:42 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libhdhomerun (Old) and /work/SRC/openSUSE:Factory/.libhdhomerun.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libhdhomerun" Changes: -------- --- /work/SRC/openSUSE:Factory/libhdhomerun/libhdhomerun.changes 2014-07-12 17:14:52.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.libhdhomerun.new/libhdhomerun.changes 2015-02-10 20:23:43.000000000 +0100 @@ -1,0 +2,6 @@ +Mon Feb 9 16:56:50 UTC 2015 - [email protected] + +- Update to version 20141210 + * Fix problem where libhdhomerun could interrupt http stream. + +------------------------------------------------------------------- Old: ---- hdhomerun_config_gui_20140604.tgz libhdhomerun_20140604.tgz New: ---- hdhomerun_config_gui_20141210.tgz libhdhomerun_20141210.tgz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libhdhomerun.spec ++++++ --- /var/tmp/diff_new_pack.paGOOu/_old 2015-02-10 20:23:44.000000000 +0100 +++ /var/tmp/diff_new_pack.paGOOu/_new 2015-02-10 20:23:44.000000000 +0100 @@ -1,7 +1,7 @@ # # spec file for package libhdhomerun # -# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -23,7 +23,7 @@ BuildRequires: gtk2-devel BuildRequires: pkg-config BuildRequires: update-desktop-files -Version: 20140604 +Version: 20141210 Release: 0 Source0: http://download.silicondust.com/hdhomerun/libhdhomerun_%version.tgz Source1: http://download.silicondust.com/hdhomerun/hdhomerun_config_gui_%version.tgz ++++++ hdhomerun_config_gui_20140604.tgz -> hdhomerun_config_gui_20141210.tgz ++++++ ++++ 3113 lines of diff (skipped) ++++ retrying with extended exclude list diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/hdhomerun_config_gui/configure.in new/hdhomerun_config_gui/configure.in --- old/hdhomerun_config_gui/configure.in 2014-05-20 00:41:10.000000000 +0200 +++ new/hdhomerun_config_gui/configure.in 2014-10-18 00:18:42.000000000 +0200 @@ -7,7 +7,7 @@ case ${OSTYPE} in darwin*) - LIBS="${LIBS} -framework CoreFoundation -framework CoreServices" + LIBS="${LIBS} -framework CoreFoundation -framework CoreServices -lgtkmacintegration" ;; esac @@ -17,7 +17,7 @@ AC_HEADER_STDC AC_PROG_CXX -pkg_modules="gtk+-2.0 >= 2.0.0 gthread-2.0" +pkg_modules="gtk+-2.0 >= 2.0.0" PKG_CHECK_MODULES(PACKAGE, [$pkg_modules]) AC_SUBST(PACKAGE_CFLAGS) AC_SUBST(PACKAGE_LIBS) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/hdhomerun_config_gui/src/AppInclude.h new/hdhomerun_config_gui/src/AppInclude.h --- old/hdhomerun_config_gui/src/AppInclude.h 2013-05-03 23:14:06.000000000 +0200 +++ new/hdhomerun_config_gui/src/AppInclude.h 2014-06-14 22:10:10.000000000 +0200 @@ -13,6 +13,7 @@ # include <ApplicationServices/ApplicationServices.h> # include <CoreServices/CoreServices.h> # include <CoreFoundation/CoreFoundation.h> +# include <gtkmacintegration/gtkosxapplication.h> #endif #include "hdhomerun.h" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/hdhomerun_config_gui/src/Devices.cpp new/hdhomerun_config_gui/src/Devices.cpp --- old/hdhomerun_config_gui/src/Devices.cpp 2013-05-03 23:14:06.000000000 +0200 +++ new/hdhomerun_config_gui/src/Devices.cpp 2014-10-18 00:18:42.000000000 +0200 @@ -44,7 +44,7 @@ THDHomeRunDeviceList::THDHomeRunDeviceList() { - g_static_rw_lock_init(&Lock); + g_rw_lock_init(&Lock); DeviceList = NULL; FFoundErrorCode = 0; } @@ -55,9 +55,9 @@ uint16_t THDHomeRunDeviceList::FoundErrorCode() { - g_static_rw_lock_reader_lock(&Lock); + g_rw_lock_reader_lock(&Lock); uint16_t Result = FFoundErrorCode; - g_static_rw_lock_reader_unlock(&Lock); + g_rw_lock_reader_unlock(&Lock); return Result; } @@ -170,7 +170,7 @@ THDHomeRunDevice *THDHomeRunDeviceList::IterateFirst() { - g_static_rw_lock_writer_lock(&Lock); + g_rw_lock_writer_lock(&Lock); return DeviceList; } @@ -181,12 +181,12 @@ void THDHomeRunDeviceList::IterateComplete() { - g_static_rw_lock_writer_unlock(&Lock); + g_rw_lock_writer_unlock(&Lock); } void THDHomeRunDeviceList::IterateExceptionCleanup() { - g_static_rw_lock_writer_unlock(&Lock); + g_rw_lock_writer_unlock(&Lock); } THDHomeRunDevice *THDHomeRunDeviceList::AddDeviceInternal(string Name, uint32_t DeviceID, guint8 TunerIndex) @@ -242,7 +242,7 @@ return NULL; } - g_static_rw_lock_writer_lock(&Lock); + g_rw_lock_writer_lock(&Lock); THDHomeRunDevice *Dev = NULL; try { @@ -252,7 +252,7 @@ hdhomerun_debug_printf(dbg, "devices: AddDevice exception!\n"); } - g_static_rw_lock_writer_unlock(&Lock); + g_rw_lock_writer_unlock(&Lock); return Dev; } @@ -327,7 +327,7 @@ void THDHomeRunDeviceList::DetectEntry() { - g_static_rw_lock_writer_lock(&Lock); + g_rw_lock_writer_lock(&Lock); THDHomeRunDevice *Dev = DeviceList; while (Dev) { @@ -337,12 +337,12 @@ FFoundErrorCode = 0; - g_static_rw_lock_writer_unlock(&Lock); + g_rw_lock_writer_unlock(&Lock); } void THDHomeRunDeviceList::DetectCleanup() { - g_static_rw_lock_writer_lock(&Lock); + g_rw_lock_writer_lock(&Lock); THDHomeRunDevice *Prev = NULL; THDHomeRunDevice *Dev = DeviceList; @@ -362,7 +362,7 @@ } } - g_static_rw_lock_writer_unlock(&Lock); + g_rw_lock_writer_unlock(&Lock); } void THDHomeRunDeviceList::Detect() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/hdhomerun_config_gui/src/Devices.h new/hdhomerun_config_gui/src/Devices.h --- old/hdhomerun_config_gui/src/Devices.h 2013-05-03 23:14:06.000000000 +0200 +++ new/hdhomerun_config_gui/src/Devices.h 2014-10-18 00:18:42.000000000 +0200 @@ -23,7 +23,7 @@ class THDHomeRunDeviceList { protected: - GStaticRWLock Lock; + GRWLock Lock; THDHomeRunDevice *DeviceList; uint16_t FFoundErrorCode; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/hdhomerun_config_gui/src/HDHRConfig.cpp new/hdhomerun_config_gui/src/HDHRConfig.cpp --- old/hdhomerun_config_gui/src/HDHRConfig.cpp 2014-06-02 23:50:42.000000000 +0200 +++ new/hdhomerun_config_gui/src/HDHRConfig.cpp 2014-10-18 00:18:42.000000000 +0200 @@ -258,7 +258,7 @@ /* Channelmaps. */ char *cChannelmaps; - if (hdhomerun_device_get_supported(SelectedDev->hd, "channelmap: ", &cChannelmaps) <= 0) { + if (hdhomerun_device_get_supported(SelectedDev->hd, (char *)"channelmap: ", &cChannelmaps) <= 0) { Tab_Changed(); return; } @@ -479,7 +479,7 @@ return; } if (ret == 0) { - cStatusStr = ""; + cStatusStr = (char *)""; } GString *text = g_string_new(NULL); @@ -544,7 +544,7 @@ return; } if (ret == 0) { - cChannelMap = ""; + cChannelMap = (char *)""; } string ChannelMap = cChannelMap; @@ -587,7 +587,7 @@ return; } if (ret == 0) { - cProgramStr = "0"; + cProgramStr = (char *)"0"; } uint32_t ProgramNumber = atol(cProgramStr); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/hdhomerun_config_gui/src/Viewer.cpp new/hdhomerun_config_gui/src/Viewer.cpp --- old/hdhomerun_config_gui/src/Viewer.cpp 2013-05-03 23:14:06.000000000 +0200 +++ new/hdhomerun_config_gui/src/Viewer.cpp 2014-10-18 00:18:42.000000000 +0200 @@ -16,7 +16,7 @@ { ExeName = "vlc"; FindViewer(); - g_static_mutex_init(&mutex); + g_mutex_init(&mutex); hdhomerun_debug_printf(dbg, "Viewer: viewer location: %s\n", ExeName.c_str()); @@ -137,9 +137,7 @@ /* Start thread. */ ThreadExecute = true; - GError *err = NULL; - - StreamThread = g_thread_create((GThreadFunc) & cStreamThreadExecute, (gpointer) this, true, &err); + StreamThread = g_thread_new("Viewer", (GThreadFunc) cStreamThreadExecute, (gpointer) this); /* Start viewer. */ #ifdef __WINDOWS__ @@ -185,7 +183,7 @@ } #endif - if (g_static_mutex_trylock(&mutex) == false) { + if (g_mutex_trylock(&mutex) == false) { return; } @@ -203,7 +201,7 @@ hdhomerun_debug_set_prefix(dbg, NULL); - g_static_mutex_unlock(&mutex); + g_mutex_unlock(&mutex); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/hdhomerun_config_gui/src/Viewer.h new/hdhomerun_config_gui/src/Viewer.h --- old/hdhomerun_config_gui/src/Viewer.h 2013-05-03 23:14:06.000000000 +0200 +++ new/hdhomerun_config_gui/src/Viewer.h 2014-10-18 00:18:42.000000000 +0200 @@ -31,7 +31,7 @@ struct hdhomerun_device_t *hd; bool ThreadExecute; - GStaticMutex mutex; + GMutex mutex; }; #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/hdhomerun_config_gui/src/main.cpp new/hdhomerun_config_gui/src/main.cpp --- old/hdhomerun_config_gui/src/main.cpp 2013-05-03 23:14:06.000000000 +0200 +++ new/hdhomerun_config_gui/src/main.cpp 2014-09-17 22:12:18.000000000 +0200 @@ -6,6 +6,7 @@ int main(int argc, char *argv[]) { + #ifdef __WINDOWS__ WORD wVersionRequested = MAKEWORD(2, 0); WSADATA wsaData; @@ -21,12 +22,15 @@ gtk_set_locale(); gtk_init(&argc, &argv); - g_thread_init(NULL); - gdk_threads_init(); +#ifdef __APPLE__ + GtkosxApplication *osx = (GtkosxApplication *)g_object_new (GTKOSX_TYPE_APPLICATION, NULL); + GtkWidget *menubar = gtk_menu_bar_new (); + gtkosx_application_set_menu_bar (osx, GTK_MENU_SHELL (menubar)); + gtkosx_application_set_use_quartz_accelerators (osx, TRUE); + gtkosx_application_ready(osx); +#endif - gdk_threads_enter(); HDHRConfig HDHomeRunConfig; - gdk_threads_leave(); gtk_main(); ++++++ libhdhomerun_20140604.tgz -> libhdhomerun_20141210.tgz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libhdhomerun/hdhomerun_device.c new/libhdhomerun/hdhomerun_device.c --- old/libhdhomerun/hdhomerun_device.c 2014-01-16 20:01:59.000000000 +0100 +++ new/libhdhomerun/hdhomerun_device.c 2014-07-02 00:40:07.000000000 +0200 @@ -34,8 +34,18 @@ char model[32]; }; -static int hdhomerun_device_set_device_normal(struct hdhomerun_device_t *hd, uint32_t device_id, uint32_t device_ip) +int hdhomerun_device_set_device(struct hdhomerun_device_t *hd, uint32_t device_id, uint32_t device_ip) { + if ((device_id == 0) && (device_ip == 0)) { + hdhomerun_debug_printf(hd->dbg, "hdhomerun_device_set_device: device not specified\n"); + return -1; + } + + if (hdhomerun_discover_is_ip_multicast(device_ip)) { + hdhomerun_debug_printf(hd->dbg, "hdhomerun_device_set_device: invalid address %08X\n", (unsigned int)device_ip); + return -1; + } + if (!hd->cs) { hd->cs = hdhomerun_control_create(0, 0, hd->dbg); if (!hd->cs) { @@ -62,40 +72,36 @@ return 1; } -static int hdhomerun_device_set_device_multicast(struct hdhomerun_device_t *hd, uint32_t multicast_ip) +int hdhomerun_device_set_multicast(struct hdhomerun_device_t *hd, uint32_t multicast_ip, uint16_t multicast_port) { + if (!hdhomerun_discover_is_ip_multicast(multicast_ip)) { + hdhomerun_debug_printf(hd->dbg, "hdhomerun_device_set_device_multicast: invalid address %08X\n", (unsigned int)multicast_ip); + return -1; + } + + if (multicast_port == 0) { + hdhomerun_debug_printf(hd->dbg, "hdhomerun_device_set_device_multicast: invalid port %u\n", (unsigned int)multicast_port); + return -1; + } + if (hd->cs) { hdhomerun_control_destroy(hd->cs); hd->cs = NULL; } hd->multicast_ip = multicast_ip; - hd->multicast_port = 0; + hd->multicast_port = multicast_port; hd->device_id = 0; hd->tuner = 0; hd->lockkey = 0; unsigned int ip = multicast_ip; - hdhomerun_sprintf(hd->name, hd->name + sizeof(hd->name), "%u.%u.%u.%u", (ip >> 24) & 0xFF, (ip >> 16) & 0xFF, (ip >> 8) & 0xFF, (ip >> 0) & 0xFF); + hdhomerun_sprintf(hd->name, hd->name + sizeof(hd->name), "%u.%u.%u.%u:%u", (ip >> 24) & 0xFF, (ip >> 16) & 0xFF, (ip >> 8) & 0xFF, (ip >> 0) & 0xFF, (unsigned int)multicast_port); hdhomerun_sprintf(hd->model, hd->model + sizeof(hd->model), "multicast"); return 1; } -int hdhomerun_device_set_device(struct hdhomerun_device_t *hd, uint32_t device_id, uint32_t device_ip) -{ - if ((device_id == 0) && (device_ip == 0)) { - hdhomerun_debug_printf(hd->dbg, "hdhomerun_device_set_device: device not specified\n"); - return -1; - } - - if (hdhomerun_discover_is_ip_multicast(device_ip)) { - return hdhomerun_device_set_device_multicast(hd, device_ip); - } - - return hdhomerun_device_set_device_normal(hd, device_id, device_ip); -} - int hdhomerun_device_set_tuner(struct hdhomerun_device_t *hd, unsigned int tuner) { if (hd->multicast_ip != 0) { @@ -113,7 +119,22 @@ return 1; } -struct hdhomerun_device_t *hdhomerun_device_create(uint32_t device_id, uint32_t device_ip, unsigned int tuner, struct hdhomerun_debug_t *dbg) +int hdhomerun_device_set_tuner_from_str(struct hdhomerun_device_t *hd, const char *tuner_str) +{ + unsigned int tuner; + if (sscanf(tuner_str, "%u", &tuner) == 1) { + hdhomerun_device_set_tuner(hd, tuner); + return 1; + } + if (sscanf(tuner_str, "/tuner%u", &tuner) == 1) { + hdhomerun_device_set_tuner(hd, tuner); + return 1; + } + + return -1; +} + +static struct hdhomerun_device_t *hdhomerun_device_create_internal(struct hdhomerun_debug_t *dbg) { struct hdhomerun_device_t *hd = (struct hdhomerun_device_t *)calloc(1, sizeof(struct hdhomerun_device_t)); if (!hd) { @@ -122,6 +143,15 @@ } hd->dbg = dbg; + return hd; +} + +struct hdhomerun_device_t *hdhomerun_device_create(uint32_t device_id, uint32_t device_ip, unsigned int tuner, struct hdhomerun_debug_t *dbg) +{ + struct hdhomerun_device_t *hd = hdhomerun_device_create_internal(dbg); + if (!hd) { + return NULL; + } if ((device_id == 0) && (device_ip == 0) && (tuner == 0)) { return hd; @@ -139,6 +169,21 @@ return hd; } +struct hdhomerun_device_t *hdhomerun_device_create_multicast(uint32_t multicast_ip, uint16_t multicast_port, struct hdhomerun_debug_t *dbg) +{ + struct hdhomerun_device_t *hd = hdhomerun_device_create_internal(dbg); + if (!hd) { + return NULL; + } + + if (hdhomerun_device_set_multicast(hd, multicast_ip, multicast_port) <= 0) { + free(hd); + return NULL; + } + + return hd; +} + void hdhomerun_device_destroy(struct hdhomerun_device_t *hd) { if (hd->scan) { @@ -156,89 +201,60 @@ free(hd); } -static bool_t is_hex_char(char c) -{ - if ((c >= '0') && (c <= '9')) { - return TRUE; - } - if ((c >= 'A') && (c <= 'F')) { - return TRUE; - } - if ((c >= 'a') && (c <= 'f')) { - return TRUE; - } - return FALSE; -} - -static struct hdhomerun_device_t *hdhomerun_device_create_from_str_device_id(const char *device_str, struct hdhomerun_debug_t *dbg) +struct hdhomerun_device_t *hdhomerun_device_create_from_str(const char *device_str, struct hdhomerun_debug_t *dbg) { - int i; - const char *ptr = device_str; - for (i = 0; i < 8; i++) { - if (!is_hex_char(*ptr++)) { - return NULL; - } - } + /* + * IP address based device_str. + */ + unsigned int a[4]; + if (sscanf(device_str, "%u.%u.%u.%u", &a[0], &a[1], &a[2], &a[3]) == 4) { + uint32_t ip_addr = (uint32_t)((a[0] << 24) | (a[1] << 16) | (a[2] << 8) | (a[3] << 0)); - if (*ptr == 0) { - unsigned int device_id; - if (sscanf(device_str, "%x", &device_id) != 1) { - return NULL; + /* + * Multicast IP address. + */ + unsigned int port; + if (sscanf(device_str, "%u.%u.%u.%u:%u", &a[0], &a[1], &a[2], &a[3], &port) == 5) { + return hdhomerun_device_create_multicast(ip_addr, port, dbg); } - return hdhomerun_device_create((uint32_t)device_id, 0, 0, dbg); - } - if (*ptr == '-') { - unsigned int device_id; + /* + * IP address + tuner number. + */ unsigned int tuner; - if (sscanf(device_str, "%x-%u", &device_id, &tuner) != 2) { - return NULL; + if (sscanf(device_str, "%u.%u.%u.%u-%u", &a[0], &a[1], &a[2], &a[3], &tuner) == 5) { + return hdhomerun_device_create(HDHOMERUN_DEVICE_ID_WILDCARD, ip_addr, tuner, dbg); } - return hdhomerun_device_create((uint32_t)device_id, 0, tuner, dbg); - } - return NULL; -} - -static struct hdhomerun_device_t *hdhomerun_device_create_from_str_ip_result(unsigned int a[4], unsigned int port, unsigned int tuner, struct hdhomerun_debug_t *dbg) -{ - uint32_t device_ip = (uint32_t)((a[0] << 24) | (a[1] << 16) | (a[2] << 8) | (a[3] << 0)); - struct hdhomerun_device_t *hd = hdhomerun_device_create(HDHOMERUN_DEVICE_ID_WILDCARD, device_ip, tuner, dbg); - if (!hd) { - return NULL; - } - - if (hd->multicast_ip != 0) { - hd->multicast_port = (uint16_t)port; - } - - return hd; -} - -static struct hdhomerun_device_t *hdhomerun_device_create_from_str_ip(const char *device_str, struct hdhomerun_debug_t *dbg) -{ - unsigned int a[4]; - unsigned int port = 0; - unsigned int tuner = 0; + /* + * IP address only. + */ + return hdhomerun_device_create(HDHOMERUN_DEVICE_ID_WILDCARD, ip_addr, 0, dbg); + } + + /* + * Device ID based device_str. + */ + char *end; + uint32_t device_id = (uint32_t)strtoul(device_str, &end, 16); + if ((end == device_str + 8) && hdhomerun_discover_validate_device_id(device_id)) { + /* + * IP address + tuner number. + */ + if (*end == '-') { + unsigned int tuner = (unsigned int)strtoul(end + 1, NULL, 10); + return hdhomerun_device_create(device_id, 0, tuner, dbg); + } - if (sscanf(device_str, "%u.%u.%u.%u:%u", &a[0], &a[1], &a[2], &a[3], &port) == 5) { - return hdhomerun_device_create_from_str_ip_result(a, port, tuner, dbg); + /* + * Device ID only. + */ + return hdhomerun_device_create(device_id, 0, 0, dbg); } - if (sscanf(device_str, "%u.%u.%u.%u-%u", &a[0], &a[1], &a[2], &a[3], &tuner) == 5) { - return hdhomerun_device_create_from_str_ip_result(a, port, tuner, dbg); - } - if (sscanf(device_str, "%u.%u.%u.%u", &a[0], &a[1], &a[2], &a[3]) == 4) { - return hdhomerun_device_create_from_str_ip_result(a, port, tuner, dbg); - } - - return NULL; -} -static struct hdhomerun_device_t *hdhomerun_device_create_from_str_dns(const char *device_str, struct hdhomerun_debug_t *dbg) -{ -#if defined(__CYGWIN__) - return NULL; -#else + /* + * DNS based device_str. + */ struct addrinfo hints; memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET; @@ -251,50 +267,14 @@ } struct sockaddr_in *sock_addr = (struct sockaddr_in *)sock_info->ai_addr; - uint32_t device_ip = ntohl(sock_addr->sin_addr.s_addr); + uint32_t ip_addr = (uint32_t)ntohl(sock_addr->sin_addr.s_addr); freeaddrinfo(sock_info); - if (device_ip == 0) { + if (ip_addr == 0) { return NULL; } - return hdhomerun_device_create(HDHOMERUN_DEVICE_ID_WILDCARD, (uint32_t)device_ip, 0, dbg); -#endif -} - -struct hdhomerun_device_t *hdhomerun_device_create_from_str(const char *device_str, struct hdhomerun_debug_t *dbg) -{ - struct hdhomerun_device_t *device = hdhomerun_device_create_from_str_device_id(device_str, dbg); - if (device) { - return device; - } - - device = hdhomerun_device_create_from_str_ip(device_str, dbg); - if (device) { - return device; - } - - device = hdhomerun_device_create_from_str_dns(device_str, dbg); - if (device) { - return device; - } - - return NULL; -} - -int hdhomerun_device_set_tuner_from_str(struct hdhomerun_device_t *hd, const char *tuner_str) -{ - unsigned int tuner; - if (sscanf(tuner_str, "%u", &tuner) == 1) { - hdhomerun_device_set_tuner(hd, tuner); - return 1; - } - if (sscanf(tuner_str, "/tuner%u", &tuner) == 1) { - hdhomerun_device_set_tuner(hd, tuner); - return 1; - } - - return -1; + return hdhomerun_device_create(HDHOMERUN_DEVICE_ID_WILDCARD, ip_addr, 0, dbg); } const char *hdhomerun_device_get_name(struct hdhomerun_device_t *hd) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libhdhomerun/hdhomerun_device.h new/libhdhomerun/hdhomerun_device.h --- old/libhdhomerun/hdhomerun_device.h 2014-01-16 20:01:59.000000000 +0100 +++ new/libhdhomerun/hdhomerun_device.h 2014-07-02 00:40:07.000000000 +0200 @@ -64,6 +64,7 @@ * /tuner<tuner index> */ extern LIBTYPE struct hdhomerun_device_t *hdhomerun_device_create(uint32_t device_id, uint32_t device_ip, unsigned int tuner, struct hdhomerun_debug_t *dbg); +extern LIBTYPE struct hdhomerun_device_t *hdhomerun_device_create_multicast(uint32_t multicast_ip, uint16_t multicast_port, struct hdhomerun_debug_t *dbg); extern LIBTYPE struct hdhomerun_device_t *hdhomerun_device_create_from_str(const char *device_str, struct hdhomerun_debug_t *dbg); extern LIBTYPE void hdhomerun_device_destroy(struct hdhomerun_device_t *hd); @@ -78,6 +79,7 @@ extern LIBTYPE unsigned int hdhomerun_device_get_tuner(struct hdhomerun_device_t *hd); extern LIBTYPE int hdhomerun_device_set_device(struct hdhomerun_device_t *hd, uint32_t device_id, uint32_t device_ip); +extern LIBTYPE int hdhomerun_device_set_multicast(struct hdhomerun_device_t *hd, uint32_t multicast_ip, uint16_t multicast_port); extern LIBTYPE int hdhomerun_device_set_tuner(struct hdhomerun_device_t *hd, unsigned int tuner); extern LIBTYPE int hdhomerun_device_set_tuner_from_str(struct hdhomerun_device_t *hd, const char *tuner_str); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libhdhomerun/hdhomerun_device_selector.c new/libhdhomerun/hdhomerun_device_selector.c --- old/libhdhomerun/hdhomerun_device_selector.c 2014-01-16 20:01:59.000000000 +0100 +++ new/libhdhomerun/hdhomerun_device_selector.c 2014-12-09 02:09:38.000000000 +0100 @@ -122,6 +122,126 @@ return NULL; } +static int hdhomerun_device_selector_load_from_str_discover(struct hdhomerun_device_selector_t *hds, uint32_t target_ip, uint32_t device_id) +{ + struct hdhomerun_discover_device_t result_list[64]; + int discover_count = hdhomerun_discover_find_devices_custom(target_ip, HDHOMERUN_DEVICE_TYPE_TUNER, device_id, result_list, 64); + + int count = 0; + int result_index; + struct hdhomerun_discover_device_t *result = result_list; + for (result_index = 0; result_index < discover_count; result_index++) { + unsigned int tuner_index; + for (tuner_index = 0; tuner_index < result->tuner_count; tuner_index++) { + struct hdhomerun_device_t *hd = hdhomerun_device_create(result->device_id, result->ip_addr, tuner_index, hds->dbg); + if (!hd) { + continue; + } + + hdhomerun_device_selector_add_device(hds, hd); + count++; + } + + result++; + } + + return count; +} + +int hdhomerun_device_selector_load_from_str(struct hdhomerun_device_selector_t *hds, char *device_str) +{ + /* + * IP address based device_str. + */ + unsigned int a[4]; + if (sscanf(device_str, "%u.%u.%u.%u", &a[0], &a[1], &a[2], &a[3]) == 4) { + uint32_t ip_addr = (uint32_t)((a[0] << 24) | (a[1] << 16) | (a[2] << 8) | (a[3] << 0)); + + /* + * Multicast IP address. + */ + unsigned int port; + if (sscanf(device_str, "%u.%u.%u.%u:%u", &a[0], &a[1], &a[2], &a[3], &port) == 5) { + struct hdhomerun_device_t *hd = hdhomerun_device_create_multicast(ip_addr, port, hds->dbg); + if (!hd) { + return 0; + } + + hdhomerun_device_selector_add_device(hds, hd); + return 1; + } + + /* + * IP address + tuner number. + */ + unsigned int tuner; + if (sscanf(device_str, "%u.%u.%u.%u-%u", &a[0], &a[1], &a[2], &a[3], &tuner) == 5) { + struct hdhomerun_device_t *hd = hdhomerun_device_create(HDHOMERUN_DEVICE_ID_WILDCARD, ip_addr, tuner, hds->dbg); + if (!hd) { + return 0; + } + + hdhomerun_device_selector_add_device(hds, hd); + return 1; + } + + /* + * IP address only - discover and add tuners. + */ + return hdhomerun_device_selector_load_from_str_discover(hds, ip_addr, HDHOMERUN_DEVICE_ID_WILDCARD); + } + + /* + * Device ID based device_str. + */ + char *end; + uint32_t device_id = (uint32_t)strtoul(device_str, &end, 16); + if ((end == device_str + 8) && hdhomerun_discover_validate_device_id(device_id)) { + /* + * IP address + tuner number. + */ + if (*end == '-') { + unsigned int tuner = (unsigned int)strtoul(end + 1, NULL, 10); + struct hdhomerun_device_t *hd = hdhomerun_device_create(device_id, 0, tuner, hds->dbg); + if (!hd) { + return 0; + } + + hdhomerun_device_selector_add_device(hds, hd); + return 1; + } + + /* + * Device ID only - discover and add tuners. + */ + return hdhomerun_device_selector_load_from_str_discover(hds, 0, device_id); + } + + /* + * DNS based device_str. + */ + struct addrinfo hints; + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_INET; + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = IPPROTO_TCP; + + struct addrinfo *sock_info; + if (getaddrinfo(device_str, "65001", &hints, &sock_info) != 0) { + return 0; + } + + struct sockaddr_in *sock_addr = (struct sockaddr_in *)sock_info->ai_addr; + uint32_t ip_addr = (uint32_t)ntohl(sock_addr->sin_addr.s_addr); + freeaddrinfo(sock_info); + + if (ip_addr == 0) { + return 0; + } + + return hdhomerun_device_selector_load_from_str_discover(hds, ip_addr, HDHOMERUN_DEVICE_ID_WILDCARD); +} + int hdhomerun_device_selector_load_from_file(struct hdhomerun_device_selector_t *hds, char *filename) { FILE *fp = fopen(filename, "r"); @@ -129,22 +249,18 @@ return 0; } + int count = 0; while(1) { - char device_name[32]; - if (!fgets(device_name, sizeof(device_name), fp)) { + char device_str[32]; + if (!fgets(device_str, sizeof(device_str), fp)) { break; } - struct hdhomerun_device_t *hd = hdhomerun_device_create_from_str(device_name, hds->dbg); - if (!hd) { - continue; - } - - hdhomerun_device_selector_add_device(hds, hd); + count += hdhomerun_device_selector_load_from_str(hds, device_str); } fclose(fp); - return (int)hds->hd_count; + return count; } #if defined(__WINDOWS__) @@ -157,21 +273,22 @@ return 0; } + int count = 0; DWORD index = 0; while (1) { /* Next tuner device. */ - wchar_t wdevice_name[32]; - DWORD size = sizeof(wdevice_name); - ret = RegEnumKeyEx(tuners_key, index++, wdevice_name, &size, NULL, NULL, NULL, NULL); + wchar_t wdevice_str[32]; + DWORD size = sizeof(wdevice_str); + ret = RegEnumKeyEx(tuners_key, index++, wdevice_str, &size, NULL, NULL, NULL, NULL); if (ret != ERROR_SUCCESS) { break; } /* Check device configuation. */ HKEY device_key; - ret = RegOpenKeyEx(tuners_key, wdevice_name, 0, KEY_QUERY_VALUE, &device_key); + ret = RegOpenKeyEx(tuners_key, wdevice_str, 0, KEY_QUERY_VALUE, &device_key); if (ret != ERROR_SUCCESS) { - hdhomerun_debug_printf(hds->dbg, "hdhomerun_device_selector_load_from_windows_registry: failed to open registry key for %S (%ld)\n", wdevice_name, (long)ret); + hdhomerun_debug_printf(hds->dbg, "hdhomerun_device_selector_load_from_windows_registry: failed to open registry key for %S (%ld)\n", wdevice_str, (long)ret); continue; } @@ -188,20 +305,13 @@ } /* Create and add device. */ - char device_name[32]; - hdhomerun_sprintf(device_name, device_name + sizeof(device_name), "%S", wdevice_name); - - struct hdhomerun_device_t *hd = hdhomerun_device_create_from_str(device_name, hds->dbg); - if (!hd) { - hdhomerun_debug_printf(hds->dbg, "hdhomerun_device_selector_load_from_windows_registry: invalid device name '%s' / failed to create device object\n", device_name); - continue; - } - - hdhomerun_device_selector_add_device(hds, hd); + char device_str[32]; + hdhomerun_sprintf(device_str, device_str + sizeof(device_str), "%S", wdevice_str); + count += hdhomerun_device_selector_load_from_str(hds, device_str); } RegCloseKey(tuners_key); - return (int)hds->hd_count; + return count; } #endif @@ -237,19 +347,20 @@ return FALSE; } - char *ptr = strstr(target, "//"); - if (ptr) { - target = ptr + 2; - } - ptr = strchr(target, ' '); - if (ptr) { - *ptr = 0; + if (strcmp(target, "none") == 0) { + hdhomerun_debug_printf(hds->dbg, "hdhomerun_device_selector_choose_test: device %s in use, no target set\n", name); + return FALSE; + } + + if ((strncmp(target, "udp://", 6) != 0) && (strncmp(target, "rtp://", 6) != 0)) { + hdhomerun_debug_printf(hds->dbg, "hdhomerun_device_selector_choose_test: device %s in use by %s\n", name, target); + return FALSE; } unsigned int a[4]; unsigned int target_port; - if (sscanf(target, "%u.%u.%u.%u:%u", &a[0], &a[1], &a[2], &a[3], &target_port) != 5) { - hdhomerun_debug_printf(hds->dbg, "hdhomerun_device_selector_choose_test: device %s in use, no target set (%s)\n", name, target); + if (sscanf(target + 6, "%u.%u.%u.%u:%u", &a[0], &a[1], &a[2], &a[3], &target_port) != 5) { + hdhomerun_debug_printf(hds->dbg, "hdhomerun_device_selector_choose_test: device %s in use, unexpected target set (%s)\n", name, target); return FALSE; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libhdhomerun/hdhomerun_device_selector.h new/libhdhomerun/hdhomerun_device_selector.h --- old/libhdhomerun/hdhomerun_device_selector.h 2014-01-16 20:01:59.000000000 +0100 +++ new/libhdhomerun/hdhomerun_device_selector.h 2014-07-02 00:40:07.000000000 +0200 @@ -39,6 +39,7 @@ * Populate device selector with devices from given source. * Returns the number of devices populated. */ +extern LIBTYPE int hdhomerun_device_selector_load_from_str(struct hdhomerun_device_selector_t *hds, char *device_str); extern LIBTYPE int hdhomerun_device_selector_load_from_file(struct hdhomerun_device_selector_t *hds, char *filename); #if defined(__WINDOWS__) extern LIBTYPE int hdhomerun_device_selector_load_from_windows_registry(struct hdhomerun_device_selector_t *hds, wchar_t *wsource); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libhdhomerun/hdhomerun_os_posix.c new/libhdhomerun/hdhomerun_os_posix.c --- old/libhdhomerun/hdhomerun_os_posix.c 2014-01-16 20:01:59.000000000 +0100 +++ new/libhdhomerun/hdhomerun_os_posix.c 2014-07-24 01:28:12.000000000 +0200 @@ -20,48 +20,52 @@ #include "hdhomerun_os.h" +#if defined(__APPLE__) +#include "mach/clock.h" +#endif + +static pthread_once_t random_get32_once = PTHREAD_ONCE_INIT; +static FILE *random_get32_fp = NULL; + +static void random_get32_init(void) +{ + random_get32_fp = fopen("/dev/urandom", "rb"); +} + uint32_t random_get32(void) { - FILE *fp = fopen("/dev/urandom", "rb"); - if (!fp) { + pthread_once(&random_get32_once, random_get32_init); + + if (!random_get32_fp) { return (uint32_t)getcurrenttime(); } uint32_t Result; - if (fread(&Result, 4, 1, fp) != 1) { - Result = (uint32_t)getcurrenttime(); + if (fread(&Result, 4, 1, random_get32_fp) != 1) { + return (uint32_t)getcurrenttime(); } - fclose(fp); return Result; } uint64_t getcurrenttime(void) { - static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; - static uint64_t result = 0; - static uint64_t previous_time = 0; +#if defined(CLOCK_MONOTONIC) + struct timespec t; + clock_gettime(CLOCK_MONOTONIC, &t); + return ((uint64_t)t.tv_sec * 1000) + (t.tv_nsec / 1000000); +#elif defined(__APPLE__) + clock_serv_t clock_serv; + host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &clock_serv); - pthread_mutex_lock(&lock); + struct mach_timespec t; + clock_get_time(clock_serv, &t); -#if defined(CLOCK_MONOTONIC) - struct timespec tp; - clock_gettime(CLOCK_MONOTONIC, &tp); - uint64_t current_time = ((uint64_t)tp.tv_sec * 1000) + (tp.tv_nsec / 1000000); + mach_port_deallocate(mach_task_self(), clock_serv); + return ((uint64_t)t.tv_sec * 1000) + (t.tv_nsec / 1000000); #else - struct timeval t; - gettimeofday(&t, NULL); - uint64_t current_time = ((uint64_t)t.tv_sec * 1000) + (t.tv_usec / 1000); +#error no clock source for getcurrenttime() #endif - - if (current_time > previous_time) { - result += current_time - previous_time; - } - - previous_time = current_time; - - pthread_mutex_unlock(&lock); - return result; } void msleep_approx(uint64_t ms) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libhdhomerun/hdhomerun_os_windows.c new/libhdhomerun/hdhomerun_os_windows.c --- old/libhdhomerun/hdhomerun_os_windows.c 2014-01-16 20:01:59.000000000 +0100 +++ new/libhdhomerun/hdhomerun_os_windows.c 2014-07-09 02:24:44.000000000 +0200 @@ -20,43 +20,28 @@ #include "hdhomerun_os.h" +static DWORD random_get32_context_tls = TlsAlloc(); + uint32_t random_get32(void) { - HCRYPTPROV hProv; - if (!CryptAcquireContext(&hProv, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) { - return (uint32_t)getcurrenttime(); + HCRYPTPROV *phProv = (HCRYPTPROV *)TlsGetValue(random_get32_context_tls); + if (!phProv) { + phProv = (HCRYPTPROV *)calloc(1, sizeof(HCRYPTPROV)); + CryptAcquireContext(phProv, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); + TlsSetValue(random_get32_context_tls, phProv); } uint32_t Result; - CryptGenRandom(hProv, sizeof(Result), (BYTE*)&Result); + if (!CryptGenRandom(*phProv, sizeof(Result), (BYTE *)&Result)) { + return (uint32_t)getcurrenttime(); + } - CryptReleaseContext(hProv, 0); return Result; } uint64_t getcurrenttime(void) { - static pthread_mutex_t lock = INVALID_HANDLE_VALUE; - static uint64_t result = 0; - static uint32_t previous_time = 0; - - /* Initialization is not thread safe. */ - if (lock == INVALID_HANDLE_VALUE) { - pthread_mutex_init(&lock, NULL); - } - - pthread_mutex_lock(&lock); - - uint32_t current_time = GetTickCount(); - - if (current_time > previous_time) { - result += current_time - previous_time; - } - - previous_time = current_time; - - pthread_mutex_unlock(&lock); - return result; + return GetTickCount64(); } void msleep_approx(uint64_t ms) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libhdhomerun/hdhomerun_pkt.c new/libhdhomerun/hdhomerun_pkt.c --- old/libhdhomerun/hdhomerun_pkt.c 2014-01-16 20:01:59.000000000 +0100 +++ new/libhdhomerun/hdhomerun_pkt.c 2014-07-08 02:01:44.000000000 +0200 @@ -125,6 +125,12 @@ return pkt->pos + *plength; } +void hdhomerun_pkt_read_mem(struct hdhomerun_pkt_t *pkt, void *mem, size_t length) +{ + memcpy(mem, pkt->pos, length); + pkt->pos += length; +} + void hdhomerun_pkt_write_u8(struct hdhomerun_pkt_t *pkt, uint8_t v) { *pkt->pos++ = v; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libhdhomerun/hdhomerun_pkt.h new/libhdhomerun/hdhomerun_pkt.h --- old/libhdhomerun/hdhomerun_pkt.h 2014-01-16 20:01:59.000000000 +0100 +++ new/libhdhomerun/hdhomerun_pkt.h 2014-07-08 02:01:44.000000000 +0200 @@ -151,6 +151,7 @@ extern LIBTYPE uint32_t hdhomerun_pkt_read_u32(struct hdhomerun_pkt_t *pkt); extern LIBTYPE size_t hdhomerun_pkt_read_var_length(struct hdhomerun_pkt_t *pkt); extern LIBTYPE uint8_t *hdhomerun_pkt_read_tlv(struct hdhomerun_pkt_t *pkt, uint8_t *ptag, size_t *plength); +extern LIBTYPE void hdhomerun_pkt_read_mem(struct hdhomerun_pkt_t *pkt, void *mem, size_t length); extern LIBTYPE void hdhomerun_pkt_write_u8(struct hdhomerun_pkt_t *pkt, uint8_t v); extern LIBTYPE void hdhomerun_pkt_write_u16(struct hdhomerun_pkt_t *pkt, uint16_t v); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libhdhomerun/hdhomerun_sock_posix.c new/libhdhomerun/hdhomerun_sock_posix.c --- old/libhdhomerun/hdhomerun_sock_posix.c 2014-01-16 20:01:59.000000000 +0100 +++ new/libhdhomerun/hdhomerun_sock_posix.c 2014-08-02 02:04:42.000000000 +0200 @@ -234,7 +234,7 @@ hints.ai_protocol = IPPROTO_TCP; struct addrinfo *sock_info; - if (getaddrinfo(name, "", &hints, &sock_info) != 0) { + if (getaddrinfo(name, NULL, &hints, &sock_info) != 0) { return 0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libhdhomerun/hdhomerun_sock_windows.c new/libhdhomerun/hdhomerun_sock_windows.c --- old/libhdhomerun/hdhomerun_sock_windows.c 2014-01-16 20:01:59.000000000 +0100 +++ new/libhdhomerun/hdhomerun_sock_windows.c 2014-08-02 02:04:42.000000000 +0200 @@ -197,7 +197,7 @@ hints.ai_protocol = IPPROTO_TCP; struct addrinfo *sock_info; - if (getaddrinfo(name, "", &hints, &sock_info) != 0) { + if (getaddrinfo(name, NULL, &hints, &sock_info) != 0) { return 0; } -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
