Relation between device and storage engine

Want to write your own code to work with a HDHomeRun or work with the HDHomeRun DVR? We are happy to help with concepts, APIs, best practices.
Post Reply
ystad
Posts: 5
Joined: Thu Nov 19, 2020 4:31 am

Relation between device and storage engine

Post by ystad »

I'm working on an app with Hdhomerun support and I am using "http api" with success. Using discovery (https://api.hdhomerun.com/discover) I can easily find one or more devices on the network to register and use in the app.

Even though this works great one feature that is missing is the ability to share tuners. Of course I would like the http api to have this feature but since it doesn't I guess you have a technical reason for this. Just recently I found out that you have a feature called "storage engine" (at least that's what I think you call it) that can be enabled by installing your software and checking "Use this PC for making recordings". Now I'm able to use the "dvr api" with shared tuners as well as server side timeshift. I understand that the actual dvr operations such as scheduling and recording are not available unless I have a dvr subscription from you.

This is all great, but my issue here is that I need to find out the relation between my device and the storage engine. Because it does not seem possible to use the storage engine all on it's own. For instance I cannot get channel lineup only by having reference to the storage engine. So it is my understanding that I need to know about both the device and the storage engine. And here's finally my question: shouldn't I be able to see what device is connected to which storage engine? As I write this it crosses my mind that maybe you can have multiple devices connected to the same storage engine? In my app I select one hdhr device at a time. Maybe the solution for me is to be able to select a storage engine per source in that case, or is there something else that I have missed?

nickk
Silicondust
Posts: 18199
Joined: Tue Jan 13, 2004 9:39 am
x 169

Re: Relation between device and storage engine

Post by nickk »

Hi,

Confirming, tuner sharing is supported when watching via the HDHomeRun record engine (storage engine).

If you have a HDHomeRun FLEX connect an USB hard drive to turn on the record engine. You may also need to click the format button on the device webpage if the hard drive isn't blank.
The HDHomeRun SCRIBE ships with the record engine enabled (built in 1TB hard drive).
The HDHomeRun SERVIO is a record engine with a 2TB hard drive.
Or you can install the HDHomeRun record engine for Windows, Mac, Linux, FreeBSD. We also have the record engine for Android but Android has poor disk performance related to Google forcing all disk access through FUSE.

You can have any number of record engines on your network - they find each other and work together.
Each record engine detects every tuner (tuners are not preassigned to a record engine).

At an app level you build the list of available channels by requesting lineup.json from every tuner (ie the same as when there is no record engine).
Then for Live TV you build a list of Play URLs to try until one works...
First each record engine: $BASEURL/auto/v2.1?ClientID=7a165758-d8c1-454c-b6a4-b5075ce02cdd&SessionID=0xc960b882
Then as a fallback each tuner directly - PlayURL from the lineup.json.

ClientID - generate a GUID once when the app launches and use this same ID on every request. If the user launches a second instance of the app the second instance needs to use a different GUID. If you do picture-in-picture then the second stream needs a different ClientID. Be sure to use the same ClientID each time when changing channel - required so the record engine knows the previous channel is no longer needed.

SessionID - generate a new 32-bit random number each time you change channel. This allows the record engine to detect if a request is a channel change (new SessionID) vs a seek (same SessionID).

Nick

signcarver
Expert
Posts: 10231
Joined: Wed Jan 24, 2007 1:04 am
Device ID: 10A05954 10802091 131B34B7 13231F92 1070A18E 1073ED6F 15300C36
x 27

Re: Relation between device and storage engine

Post by signcarver »

The storage engine can use any device with that channel and is available to all clients on the network (discovered at same time as tuners). You can see which ip the device is streaming to but you are overthinking it as you shouldn't care which tuner (typically the storage engine will choose the tuner with the virtual channel number that has the lowest device id)

Yes you do get the channel list from the tuners for your app but the engine discovers "all" tuners on the subnet and basically updates its list every 2 hours or so. As a result, when you tune with the engine it reaches out to a tuner that it believes should have the channel... no controlling which tuner and any tuner with that virtual number may be chosen (but as mentioned typically goes for lowest deviceid, though if engine is on a scribe/flex, rather than on a pc or nas, the scribe/flex typically chooses its own tuners first)

You should really be looking at either broadcast discovery (SD has occasionally mentioned http discovery may be going away as it's real purpose no longer works) or even allowing manual configuration. You only need one engine to serve multiple clients. I am not certain if engines get reported through http discovery when one doesn't have the dvr subscription. You may be able to check the status.json of either tuner or engine to do what you wish

ystad
Posts: 5
Joined: Thu Nov 19, 2020 4:31 am

Re: Relation between device and storage engine

Post by ystad »

Interesting, thank you both for the replies.

I never did think of a trial-and-error approach here. I was conviced that the correct approach was to select a tuner (based on discovery) and then extract lineup from that device. That explains also why the official hdhr app does not ask for which device or storage engine (dvr engine?) to use.
I cannot say I normally like the trial-and-error approach very much but since it's what you recommend I will give it a try. This will of course also make setup even more easy (for most users) since no device configuration at all needs to be done.

nickk
Silicondust
Posts: 18199
Joined: Tue Jan 13, 2004 9:39 am
x 169

Re: Relation between device and storage engine

Post by nickk »

ystad wrote: Sun May 15, 2022 4:24 am This will of course also make setup even more easy (for most users) since no device configuration at all needs to be done.
With the HDHomeRun you plug it in, run the app, and you get live TV complete with TV guide - no questions asked. Part of the magic is that we have automatic guide matching - we don't even ask for your zipcode.

Every other OTA DVR I have used (including WMC) has a setup wizard you have to go through to make things work.

Then add in the idea that you can have any number of tuners, any number of storage devices (record engines) and any number of clients and everything just works. No configuration required.

It also gives you full redundancy - if a tuner gets unplugged things keep recording using the other tuners. If a storage device gets unplugged things keep recording using the other storage devices (starting the next recording).

ystad
Posts: 5
Joined: Thu Nov 19, 2020 4:31 am

Re: Relation between device and storage engine

Post by ystad »

I have started to look at implementing this auto-mode for my app and a couple of questions came up regarding guide data. Guide data is fetched using a device's DeviceAuth. Since I currently only own one device myself I cannot determine if this value is unique to my device or to my account. Do I need to download guide data more than once since there are multiple DeviceAuth's or do I get the same data regardless of which DeviceAuth I use?

Post Reply