This is a mirror of the documentation from: https://www.silicondust.com/hdhomerun/hdhomerun_discover_api.pdf
20240203-1
https://download.silicondust.com/hdhomerun/libhdhomerun.tgz
https://github.com/Silicondust/libhdhomerun
The libhdhomerun library is available under a commercial license suitable for compiling directly into an app – contact Silicondust to request.
Requires C99 compliant compiler.
Example code:
See hdhomerun_discover_example.c for an example of using the discover API. Header files:
Include hdhomerun.h to access libhdhomerun APIs.
The discover API is declared in hdhomerun_discover.h.
File | Purpose |
---|---|
All platforms | |
hdhomerun_discover.c | Discover API |
hdhomerun_debug.c | Internal debug logging |
hdhomerun_pkt.c | Internal packet handling |
hdhomerun_sock.c | Internal socket handling (common code) |
Linux / Android | |
hdhomerun_os_posix.c | Internal OS wrapper functions |
hdhomerun_sock_posix.c | Internal socket handling |
hdhomerun_sock_netlink.c | Internal IP address detection |
Mac / BSD | |
hdhomerun_os_posix.c | Internal OS wrapper functions |
hdhomerun_sock_posix.c | Internal socket handling |
hdhomerun_sock_getifaddrs.c | Internal IP address detection |
Windows | |
hdhomerun_os_windows.c | Internal OS wrapper functions |
hdhomerun_sock_windows.c | Internal IP address detection & socket handling |
struct hdhomerun_discover_t *hdhomerun_discover_create(struct hdhomerun_debug_t *dbg);
Creates a discover object for managing / executing the discover process. The object may be maintained across the lifespan of the app or may be created and destroyed for each discover.
If the app polls discover often the discover object should be maintained and reused to avoid excessive cycling through local port numbers.
Parameters:
Returns:
void hdhomerun_discover_destroy(struct hdhomerun_discover_t *ds);
Frees all resources associated with the given discover object.
Parameters:
Returns:
int hdhomerun_discover2_find_devices_broadcast(struct hdhomerun_discover_t *ds, uint32_t flags, uint32_t const device_types[], size_t device_types_count);
Execute discover process to find devices of the specified type(s) on the local network(s). Results from any prior discover are wiped.
This is the primary API to discover devices.
Execution time is 400ms.
Parameters:
HDHOMERUN_DISCOVER_FLAGS_IPV4_GENERAL | Discover using all local IPv4 addresses (excluding localhost). |
HDHOMERUN_DISCOVER_FLAGS_IPV4_LOCALHOST | Discover via IPv4 localhost. Specify if the local system can support running the HDHomeRun record engine for storing recordings on the local system. |
HDHOMERUN_DISCOVER_FLAGS_IPV6_GENERAL | Discover using all global and site-local IPv6 addresses. |
HDHOMERUN_DISCOVER_FLAGS_IPV6_LINKLOC | Discover using all link-local IPv6 addresses. Only specify if the application supports tracking IPv6 scope IDs. |
HDHOMERUN_DISCOVER_FLAGS_IPV6_LOCALHOST | Discover via IPv6 localhost. Specify if the local system can support running the HDHomeRun record engine for storing recordings on the local system. |
HDHOMERUN_DEVICE_TYPE_TUNE | Detect HDHomeRun tuner devices. |
HDHOMERUN_DEVICE_TYPE_STORAGE | Detect HDHomeRun record engines. |
Returns:
Notes:
Applications that support the complete HDHomeRun DVR system should pass in a 2 element device_type array indicating both TUNER and STORAGE.
Applications that support live TV or don’t use the HDHomeRun DVR system should pass in a 1 element device_type array indicating TUNER.
HDHomeRun tuner models with a hard drive present respond as both TUNER and STORAGE and report both TUNER and STORAGE types in the results.
int hdhomerun_discover2_find_devices_targeted(struct hdhomerun_discover_t *ds, const struct sockaddr *target_addr, const uint32_t device_types[], size_t device_types_count);
Execute discover process to get information about the device where the IP address is known. Results from any prior discover are wiped.
Execution time can be up to 400ms if there is no response.
Parameters:
Returns:
int hdhomerun_discover2_find_device_id_broadcast(struct hdhomerun_discover_t *ds, uint32_t flags, uint32_t device_id);
Execute discover process to locate the specified device by Device ID (serial number) on the local network(s). Results from any prior discover are wiped.
Execution time can be up to 400ms if the device is not detected.
Parameters:
Returns:
int hdhomerun_discover2_find_device_id_targeted(struct hdhomerun_discover_t *ds, const struct sockaddr *target_addr, uint32_t device_id);
Execute discover process to get information about the device where both the Device ID (serial number) and IP address are known.
Execution time can be up to 400ms if there is no response.
Parameters:
Returns:
struct hdhomerun_discover2_device_t *hdhomerun_discover2_iter_device_first(struct hdhomerun_discover_t *ds);
Return the first device from the list of devices discovered by the most recent invocation of one of the hdhomerun_discover2_find_devices_xxx() APIs.
Parameters:
Returns:
struct hdhomerun_discover2_device_t *hdhomerun_discover2_iter_device_next(struct hdhomerun_discover2_device_t *device);
Return the next device from the list of devices discovered by the most recent invocation of one of the hdhomerun_discover2_find_devices_xxx() APIs.
Parameters:
Returns:
bool hdhomerun_discover2_device_is_legacy(struct hdhomerun_discover2_device_t *device);
Check if the detected device is a legacy tuner lacking channel management and http streaming support.
Parameters:
Returns:
bool hdhomerun_discover2_device_is_type(struct hdhomerun_discover2_device_t *device, uint32_t device_type);
Check if the detected device is of a given type.
Parameters:
HDHOMERUN_DEVICE_TYPE_TUNER | HDHomeRun tuner device. |
HDHOMERUN_DEVICE_TYPE_STORAGE | HDHomeRun record engine. |
Returns:
uint32_t hdhomerun_discover2_device_get_device_id(struct hdhomerun_discover2_device_t *device);
Return the 32-bit Device ID (serial number) of the device if the device is HDHomeRun hardware.
Devices of type TUNER are hardware products and always have a Device ID.
Devices of type STORAGE may be a hardware product with a Device ID or may be a software product with no Device ID (such as the HDHomeRun DVR record engine installed on a PC or NAS). To uniquely identify devices of type STORAGE use the alternative hdhomerun_discover2_device_get_storage_id() API.
Parameters:
Returns:
const char *hdhomerun_discover2_device_get_device_auth(struct hdhomerun_discover2_device_t *device);
Return the UUID string Storage ID of the device.
Parameters:
Returns:
uint8_t hdhomerun_discover2_device_get_tuner_count(struct hdhomerun_discover2_device_t *device);
Return the number of tuners the device has.
Parameters:
Returns:
const char *hdhomerun_discover2_device_get_device_auth(struct hdhomerun_discover2_device_t *device);
The DeviceAuth string reported by the device. Used to access HDHomeRun cloud APIs.
Parameters:
Returns:
struct hdhomerun_discover2_device_if_t *hdhomerun_discover2_iter_device_if_first(struct hdhomerun_discover2_device_t *device);
A device can have multiple IP addresses, for example IPv4, IPv6 global, and IPv6 link-local. Use hdhomerun_discover2_iter_device_if_first() to obtain the first device-if object (IP address object) in the list associated with a device. This object is used to query the IP address and associated URLs.
A typical application only needs to get the first device-if object and does not need to iterate through the list of device-if objects.
Parameters:
Returns:
struct hdhomerun_discover2_device_if_t *hdhomerun_discover2_iter_device_if_next(struct hdhomerun_discover2_device_if_t *device_if)
Return the next device-if object (IP address object) in the list associated with a device. This object is used to query the IP address and associated URLs.
A typical application only needs to get the first device-if object and does not need to iterate through the list of device-if objects.
Parameters:
Returns:
void hdhomerun_discover2_device_if_get_ip_addr(struct hdhomerun_discover2_device_if_t *device_if, struct sockaddr_storage *ip_addr);
Return the IP address of the device.
Parameters:
Returns:
const char *hdhomerun_discover2_device_if_get_base_url(struct hdhomerun_discover2_device_if_t *device_if);
Return the base URL of the device as a string.
Parameters:
Returns:
const char *hdhomerun_discover2_device_if_get_lineup_url(struct hdhomerun_discover2_device_if_t *device_if);
Return the lineup URL (lineup.json) of the device as a string. Only present for devices of type TUNER.
Parameters:
Returns:
const char *hdhomerun_discover2_device_if_get_storage_url(struct hdhomerun_discover2_device_if_t *device_if);
Return the storage URL (recorded_files.json) of the device as a string. Only present for devices of type STORAGE.
Parameters:
Returns: