# At last: the Keys to the Kingdom



## davidblackledge

I found it... 7 years later than we should have.

It's been right under our noses since day one.
HME SDK 1.4
com/tivo/hme/sim/SimStreamResource.java
line 102: 


Code:


if (url.startsWith("livetv:") || url.startsWith("loopset:") || url.startsWith("recording:")) {

We could have built an entirely new UI in HME using this feature ever since we learned about SETCH. I bet we could have viewed live/recorded video (maybe even with events) in a SERIES TWO since 2005 for goodness sake.

This is freaking embarrassing. I bet TiVo has been laughing their asses off every time we say "why can't we do HME over TV?" - I'm actually angry at them, now... that's not simply "we're too busy."


"livetv:" as your entire URL for a stream resource means you'll be "streaming a video" from the tuner.
"loopset:" - probably the looping video backgrounds they use in menus... "loopset:" gets you something like "play failed"... "loopset:something" gets you "resource unavailable." It probably needs a specific known file string like "bonk.snd"
"recording:" is obviously actual recordings as video streams... this one always gives you "resource unavailable." Hopefully this is some simple translation from the RSS feed entry for the recording. ("recording:idNumber" doesn't work)

We need some heavy experimentation/digging to figure out the proper URLs of those last two. I'm hoping maybe loopset: will let you specify an arbitrary recording reference (or even a streamed video URL) to use as your loop. If we're really lucky, "recording:" is also part of the secret to built-in streaming over 1Gig.

As I said during the old Streaming Video discussions, you can scale a video with its view's size... so we could build the Premiere's interface that shows PIP if we wanted.

woohoo!

Note: you may have to pass an mp4 content type when you create the "livetv:" stream to make it work... my quick tests I replaced some code which passed that. Also, in some tests I ended up with a black screen... I might have been passing an mpeg2 content type in that case.

*As my reward for finding this, I ask for your help* figuring out some other things I want to do in my awesome upcoming HME app.

0. POST ON THE WIKI what you learn, dammit! (http://hmedev.wikidot.com, instant access password: ILoveHME)

1. On the TiVo Underground forum I asked for help sniffing out what parameters and TeDict the YouTube app sends to the VideoPlayer app to start it up. I REALLY REALLY REALLY want to be able to do this in my upcoming app.

2. I have a stream that won't load because (I believe) the server expects a cookie header sent with the URL request. I strongly suspect I can create the stream with a TeDict containing the cookies (and other headers?) and the TiVo will request the stream "properly." Maybe somebody could spend a little time trying out combinations to see if you can get the TiVo to include something on its request? I do NOT want to proxy the stream.

3. I also have an mp3 stream on the Internet where I know its duration, normally supplied in the X-TiVo-Accurate-Duration response header, but I again do NOT want to proxy it - somebody surmised when TeDict was introduced that it could pass that information in. Could somebody please figure out how to pass in X-TiVo-Accurate-Duration through the TeDict when creating an mp3 stream? I haven't tried anything, yet, it might be crazy obvious.

4. I have realized that FontInfo is broken in SD displays if you use HME v45 or above (all the character widths are whole numbers with no decimal precision). Seems OK in v41 and looks fine in HD displays in v45. You can see it on e.g. the swivel search details page - actor names are cut off at the end. I think I'll just have to cache correct FontInfo stuff for that case... Nothing really to ask of you here, just wanted to vent. Hey, TIVO... freakin fix that, it's stupid!

What? you want a hint about my app? Well, without giving anything away: as a SIDE EFFECT it will work as a replacement for apps.tv (R.I.P.)


----------



## moyekj

Interesting. So since you can get hold of livetv stream via HME is it also possible to save the stream bytes to a file? If possible this may be a way to circumvent the CCI byte protection. Likely the HME SDK source would have to be extended to allow it though, and then there's the pesky encryption business to deal with.


----------



## davidblackledge

Well, it's not passing the data to HME, just the stream status events. (playing, position, paused, speed, etc) and accepting changes to them. I suspect this doesn't get you any closer to the actual bytes than you were before, sorry. 
It's the same as streaming video from a URL - the data doesn't ever go to the HME application, only the TiVo actually sees that, and the TiVo sends the status to the HME application.


----------



## moyekj

OK I see, it's basically a fake URL, but you have some control over the stream so you can pause, resume, ff, resize, overlay text etc. just like streaming. Pretty cool, but I don't think many TiVo users care about live tv too much so live tv in HME also probably has limited appeal.

The 1.1GB streaming limitation has always been biggest issue which makes streaming virtually useless. I've always wondered if perhaps one could get around that by implementing some kind of stream with circular buffer of fixed size below the 1.1GB limit. I had hopes the new Flash SDK would provide for a better streaming option but currently it seems limited to what Flash players can play and only 720p resolution which makes it pretty worthless as well. I posed a question in SDK forums about how to overcome those limitations (since obviously Netflix can do it properly) but no answers given.


----------



## davidblackledge

moyekj said:


> Pretty cool, but I don't think many TiVo users care about live tv too much so live tv in HME also probably has limited appeal.


I suppose so, but non-Video apps would benefit from having Picture-in-Picture TV, since the limited abilities of HME apps make them an iffy destination if you have to "stop using your TV" to get there.

But the cool thing to me is: anything you don't like about the TiVo interface? (like no quick access to apps, or you want your twitter notices to appear while you watch TV)... Just build a "livetv" app that recreates the whole TiVo interface plus your changes using this feature and the Telnet interface features like SETCH.

Also, even if you don't care about live tv, you care about your recordings, and "recording:" will give access to that once we figure it out.



moyekj said:


> The 1.1GB streaming limitation has always been biggest issue which makes streaming virtually useless.


99% chance that both livetv: and recording: don't suffer from that problem.

And I'm hoping that recording: (or some secret other fake protocol we still don't know about) will solve the 1.1GB problem... like maybe the Netflix app uses "recording:http://netflix..." as a stream URL or its own "netflix:..." protocol or whatever.


----------



## wmcbrine

Thanks David, but I have to say, I regard this as more "mildly interesting" than "keys to the kingdom".  Yes, I would like to do HME outside its little box; but no, I have no desire to reimplement the whole UI.

I doubt this will work on a Series 2, but I haven't tested that yet. Also, in my previous testing with video streams, I don't think I was able to resize video by fiddling with the View -- I could only mask off different portions of the video background, which stayed the size of the screen. Are you actually seeing something different?

Re: MIME types, "video/x-tivo-mpeg" works for me. I haven't tried others.


----------



## moyekj

davidblackledge said:


> 99% chance that both livetv: and recording: don't suffer from that problem.
> 
> And I'm hoping that recording: (or some secret other fake protocol we still don't know about) will solve the 1.1GB problem... like maybe the Netflix app uses "recording:http://netflix..." as a stream URL or its own "netflix:..." protocol or whatever.


"livetv:" indeed doesn't have the 1.1GB limit. I left an HD channel playing for > 1 hour via HME and it consistently showed a 30 min buffer available the whole time and didn't kick me out. I suspect "recording:" is for recordings on TiVo only but hard to know as there is no reference anywhere else in the SDK to it so it's a mystery. I'm wondering if livetv: has access to background tuners as well. I didn't try "livetv:0", "livetv:1" etc.
(As wmcbrine mentioned "video/x-tivo-mpeg" worked for me as well for livetv mime as did "video/mp4")


----------



## davidblackledge

wmcbrine said:


> Thanks David, but I have to say, I regard this as more "mildly interesting" than "keys to the kingdom".  Yes, I would like to do HME outside its little box; but no, I have no desire to reimplement the whole UI.


Ok, true, I don't much want to reimplement the UI either, but that's the extreme version. My biggest problem with HME has always been the fact that it has to be a "destination" app, but HME isn't advanced enough to make compelling destinations. 
With this discovery, you can make a "casual" app that allows the user to continue to use the TiVo pretty much as they normally do. I can see a e.g. "Social Updates over TiVo" app that just looks like you're back at LiveTV (or a selected recording) but when an update comes in, it pops up over your video. It could even be a chat-while-you-watch-TV app. Those apps without livetv or recordings would go unused. And doing a PIP livetv for a game gives you something unique compared to a tablet or website.

In my eyes it's keys to the kingdom because it goes from "mildly interesting" apps to doing what most people want their TV apps to do... notifications and casual quick checks of information while you're watching TV.

If we were to pool our resources we could at least build a good framework for this with a "notifications plugin API" like the iPad pull-down notification area.



wmcbrine said:


> Also, in my previous testing with video streams, I don't think I was able to resize video by fiddling with the View -- I could only mask off different portions of the video background, which stayed the size of the screen. Are you actually seeing something different?


Hmm... I thought I posted about this sometime but can't find it off-hand. Remember my silly "NowPlaying" app? It was a pseudo-UI based on streaming the TiVo files from the web interface, and I included the ability to run another HME app picture-in-picture (scaled down) while you're streaming a video. Well, when I ran another video app that way, it "stole" my video stream and displayed it scaled down. I don't recall offhand what other combinations I tried, but I think a View's scale feature and/or the RSRC_IMAGE_BESTFIT flag would be enough. Otherwise a scaled app-as-stream-resource will definitely do it.



moyekj said:


> I suspect "recording:" is for recordings on TiVo only but hard to know as there is no reference anywhere else in the SDK to it so it's a mystery. I'm wondering if livetv: has access to background tuners as well. I didn't try "livetv:0", "livetv:1" etc.


I'm hoping we can use "recording:" like "recording:tivo/123456789.TiVo" or something to access an ID'd recording, then if we're really lucky something like "recording:external/www.mysite.com/longerthan1GB.mp4" to bypass the 1.1GB limit. Pipe dream.

I did try livetv:0 and livetv:1 before the post... didn't do anything... I think it ignores anything after the "protocol" and instead you access the other tuner with the Telnet commands (as I recall, there are commands to switch tuners and to set the channel on the current or on the "other" tuner)


----------



## davidblackledge

Found my scaled video post (from my "NowPlayingV2" post):


davidblackledge said:


> Bonus: Run a video-streaming application in a non-full-screen mode while viewing a video and stream a second video ... (e.g. select the "Video" app that comes with this)
> Voila! Scaled-down video! It immediately steals the video-viewing port and the application scaling also scales down the video viewing port somehow... Careful, though. It immediately switches the CURRENT video stream to the shrunken port... the fact that it is now trying to stream ANOTHER video could cause you trouble...so I recommend quitting shortly after you start this and see the effect... I think it just pauses until the first/parent video stream is done, though.
> The point is, if you open a Video stream resource in a streamed application (maybe even if you just open it in a simpler circumstance, I'm not sure) it will steal the port and apply an scaling, even if that resource is not really valid, so you could purposely open a bogus one to force the video to be small for the moment. (or just make that 2nd application your primary video-runner)


----------



## lrhorer

davidblackledge said:


> In my eyes it's keys to the kingdom because it goes from "mildly interesting" apps to doing what most people want their TV apps to do... notifications and casual quick checks of information while you're watching TV.


That is the very last thing I would ever want to do with my TV. No offense, but so far what you are describing is not the keys to the kingdom, it is the keys to hell.

Now the ability from within an app like vidmgr to jump directly into viewing the downloading video, or at least to the NPL, would be very cool. Crap like P in P or pop-ups over the playing video are anathema. When I am watching TV, I am watching TV. I don't want anything else to intrude.



davidblackledge said:


> I did try livetv:0 and livetv:1 before the post... didn't do anything... I think it ignores anything after the "protocol" and instead you access the other tuner with the Telnet commands (as I recall, there are commands to switch tuners and to set the channel on the current or on the "other" tuner)


Like many TiVo owners, I never watch live TV.


----------



## davidblackledge

davidblackledge said:


> "loopset:" - probably the looping video backgrounds they use in menus... "loopset:" gets you something like "play failed"... "loopset:something" gets you "resource unavailable." It probably needs a specific known file string like "bonk.snd"



 "loopset:Central" - Red loopset (TiVo Central)
 "loopset:Showcases" - Purple loopset (Showcases, Suggestions)
 "loopset:Setup" - Blue loopset (Messages & Settings, Music Photos & More, Network Now Playing Lists)
 "loopset:NowPlaying" - Green loopset (Now Playing, everything else not mentioned above)
(did I miss anything?)

It plays the initial "swoosh" of the box area, then does the standard loop... including the TiVo guy, so I don't know how happy TiVo would be if we used it.
You can pause it and otherwise mess with the speed. speed 3 works...TiVo guy looks a little frantic. Speed 18 just immediately pauses. Reverse (e.g. -3) eventually hits the start of the loop and switches to normal play with speed 1. 
However, as far as all of this is concerned, the "swoosh" is not part of the video stream after it first plays... you can never see that again.

As for "recording:'... I've tried a lot of combinations with no luck.
Starting from an XML entry under a folder with the unique ID of "/NowPlaying/1996606" I tried a lot of combinations starting from just the download URL appended to "recording:" ...
"recording:download/MAD.TiVo?Container=%2FNowPlaying&id=4515045",
to using the container unique ID...
"recording:/NowPlaying/1996606/4515045"
to ignoring the specific container like the download URL does...
"recording:/NowPlaying/4515045"
to just the id
"recording:4515045"
with no luck...including various combinations with "recording://" etc.

You guys may not give a crap, but this is cool, and I'm very happy with the livetv: picture in picture... it's just what I needed to make my apps a less "abrupt" difference in the experience. (oh...did I tell you? it definitely works with just "scale" set on the view... however I've found it's flakey... sometimes you end up with a clipped area for a few tries on my TiVoHD+HD... I don't think I have that problem on my TiVoS3+SD combination)
However it ends up you are "always" taken to the tip of the playing livetv stream, not the spot you were at when you entered the app, even if it was paused. (one time it seemed to be at the "tail" of the stream... when it had gotten there from a paused state when live tv buffer filled up, haven't recreated the case yet though)

Is there a way I didn't hear about to find out the live tv state? (paused or not, position in the buffer)


----------



## wmcbrine

davidblackledge said:


> "loopset:Central" - Red loopset (TiVo Central)
> "loopset:Showcases" - Purple loopset (Showcases, Suggestions)
> "loopset:Setup" - Blue loopset (Messages & Settings, Music Photos & More, Network Now Playing Lists)
> "loopset:NowPlaying" - Green loopset (Now Playing, everything else not mentioned above)


On the Premiere, not surprisingly, these all appear as the same still blue background that it uses for all the SD menus now.


----------



## Dan203

So this allows you to overlay live video on your HME app and even control it? That's pretty cool!

If you can figure out how to do it with a recording I might be able to do something cool with VideoReDo. I'm thinking about an app where you could "edit" a show right on the TiVo. You could mark the in/out points on the TiVo via the HME app, then it would transfer the program to the PC, do the actual cuts, and automatically transfer it back or perhaps recode it and add it to your iTunes library.

Dan


----------



## jhilla

I opened the port on the router and software firewall, but the app hangs in black screen on the tivo Please wait screen and nothing occurs. What do I still neeed to release?

C:\apps\NowPlayingv2>java -cp "jmdns-1.0.jar;hme-host-sample.jar;cbd.tivo.hmo.ja
r;cbd.tivo.widgetsGadgets.jar;cbd.tivo.video.jar;cbd.tivo.jar;cbd.tivo.video.jar
;hme.jar;bananas.jar" com.tivo.hme.host.sample.Main --launcher launcher.txt
Instance ID = 0001692733768350
hme-host-sample version: 1.4.1 threadsafe-experimental
debug: Loaded factory: com.blackledge.david.tivo.video.Video
debug: Class loader for com.blackledge.david.tivo.video.Video: sun.misc.Launcher
$AppClassLoader
debug: Context class loader: sun.misc.Launcher$AppClassLoader
debug: Loaded factory: com.blackledge.david.tivo.nowplaying.NowPlaying
debug: Class loader for com.blackledge.david.tivo.nowplaying.NowPlaying: sun.mis
c.Launcher$AppClassLoader
debug: Context class loader: sun.misc.Launcher$AppClassLoader
added factory
added factory
MDNS ADD: http://192.168.0.3:7288/video/
Contacting mDNS localhost daemon at 127.0.0.1:5354
mDNS localhost daemon: register [start]: http://192.168.0.3:7288/video/
Registering service with mDNS daemon at 127.0.0.1:5354 : Video, _tivo-hme._tcp,
7288
mDNS localhost daemon: registration failed: java.net.SocketException: Connection
reset
mDNS localhost daemon: register [FAIL]: http://192.168.0.3:7288/video/
jmdns library: register [start]: http://192.168.0.3:7288/video/
jmdns library: register [done]: http://192.168.0.3:7288/video/
MDNS ADD: http://192.168.0.3:7288/nowplaying/
Contacting mDNS localhost daemon at 127.0.0.1:5354
mDNS localhost daemon: register [start]: http://192.168.0.3:7288/nowplaying/
Registering service with mDNS daemon at 127.0.0.1:5354 : NowPlaying, _tivo-hme._
tcp, 7288
mDNS localhost daemon: registration failed: java.net.SocketException: Connection
reset
mDNS localhost daemon: register [FAIL]: http://192.168.0.3:7288/nowplaying/
jmdns library: register [start]: http://192.168.0.3:7288/nowplaying/
jmdns library: register [done]: http://192.168.0.3:7288/nowplaying/


----------



## davidblackledge

davidblackledge said:


> "loopset:Central" - Red loopset (TiVo Central)
> "loopset:Showcases" - Purple loopset (Showcases, Suggestions)
> "loopset:Setup" - Blue loopset (Messages & Settings, Music Photos & More, Network Now Playing Lists)
> "loopset:NowPlaying" - Green loopset (Now Playing, everything else not mentioned above)
> (did I miss anything?)
> 
> It plays the initial "swoosh" of the box area, then does the standard loop...


A recent post (http://www.tivocommunity.com/tivo-vb/showthread.php?p=10447169#post10447169) linked back to an archived thread that had a file listing of videos on a Series 1 (http://archive2.tivocommunity.com/tivo-vb/showthread.php?p=2546876&&#post2546876). I saw the linkage to my loopset discovery and as a result have found 3 more loopsets available. Here's what they were on my TiVoHD:

"loopsetrograms" - identical to loopset:NowPlaying (green)
"loopset:Suggests" - identical to loopset:Showcases (purple)
"loopsetickByName" - NEW - green like NowPlaying, but includes a permanent black area at the top of the boxed section (with an orange outline, hangs off the left side) apparently to act as background for the text entered in search by title. This does NOT appear to actually be USED though, as the real page slides that black area in along with the keyboard, therefore it's an overlay, not the background.
All three, like all the other loopsets, are of course just a single blue background non-animated image in series 4 and later.

Interesting things:

The filename for the series 1 was NowShowing, not NowPlaying (but I tried, and NowShowing doesn't work in the series 3)
the loopsets had two files each...one ending in "WriteOn" and one ending in "0"... but PickByName doesn't have a "WriteOn" which I think is the initial 'swoosh' effect.
there were two other files: "LongOpen" and "NoSignal" (with no suffixes). Trying those with "loopset:" or "recording:" got me nothing (and for the record, trying the loopset complete 0/WriteOn filenames with either loopset: or recording: didn't work either)
Just noticed s2kdave was the first to post about the Simulator code this thread is about http://www.tivocommunity.com/tivo-vb/showthread.php?p=5921390#post5921390 - I'm going to explore the other information from that thread a little more when I get a chance.

I can't help but think there may be some other things out there that would work... especially if some file names changed. Certainly the NoSignal has to be accessible somehow.

I could try a few more experiments, but the HD is my wife's bedroom machine and I already made it reboot once experimenting with this which didn't make her happy.


----------

