SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Github Development
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Github Development Discussion related to SageTV Open Source Development. Use this forum for development topics about the Open Source versions of SageTV, hosted on Github.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-05-2015, 07:01 PM
hornms hornms is offline
New Member
 
Join Date: Oct 2015
Location: PA
Posts: 2
Apple TV 3 Client

I've been lucky enough to get an early release of an Apple TV 3 which allows app development. There are 2 ways of doing development: 1) iOS-style using swift or objective C, or 2) TVML which is a combination of XML and Javascript served from a web server. I prefer the iOS-style because that is native code and should have the best performance.

I added a JSP file to the jetty folder in sage 7 to return the full recording list including the media IDs in json. I created a tvos app in swift to read this json from the jetty server and populate a table view of recordings. I then created a view to play a selected video using the media stream as is done from any iOS device (thru jetty). It plays nicely, but the quality is lower than expected. Obviously the ATV only supports a limited set of video codecs and my ts files are not supported directly, so I know it must transcode. Also, the playback seems finicky. If you try to scrub ahead, it kind of hangs the video and it never comes back. I see this too on my iPad using the jetty web browser interface.

Is there a better way to stream a transcoded stream to the ATV instead of using the jetty plugin? Is there a socket interface I can hook up to?

I'd like to ensure that I can get the commercial skip, jump ahead 30 and back 10 (why every video player does not do this I will never know) to work as good as the native java placeshifter. Sage is so smooth when it comes to jumping ahead and back through videos and I'd like to replicate that if I could in the ATV client.

Can you give me some design idea of how I could get a good quality video stream to the ATV that is transcoded with support for +30, -10, and CS? I have never written a Sage plugin, but I'm good to learn with some guidance. No sense writing the rest of the app unless I can get good reliable video working.

Thanks for your help,
Mike
Reply With Quote
  #2  
Old 10-06-2015, 01:12 AM
Fuzzy's Avatar
Fuzzy Fuzzy is offline
SageTVaholic
 
Join Date: Sep 2005
Location: Jurupa Valley, CA
Posts: 9,957
If there's a Plex app or the ATV3, that would be your best bet for now.
__________________
Buy Fuzzy a beer! (Fuzzy likes beer)

unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers.
Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA.
Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S
Other Clients: Mi Box in Master Bedroom, HD-200 in kids room
Reply With Quote
  #3  
Old 10-06-2015, 04:31 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Here are some thoughts/ideas....

1. You probably don't need to write any plugins for sagetv. You can use the sagex rest apis to get all the media related data, etc. If you have sagex services installed, then just open a browser an go to http://server/sagex/api, and you'll get a help page on how how to use the sagex apis. If you have phoenix core installed, then you can also use sagex apis to request fanart (posters, backgrounds, banners, etc). With sagex, you can do more than just read information, you have access to every sagetv api via a rest interface, so you can set/toggle watched status, add favorites, search, etc.

2. To do what you are asking, for the media playback, you need to use the sage minclient protocol (video server portion). The video server is a socket based protocol that supports "pull" and "push" modes for videos. It's quite easy conceptually, but if you are not a video person (I'm not) then it can be quite complex to wrap your head around it. I'm obviously struggling through it on the Android side, reimplementing a miniclient/placeshifter, natively, in Android.

I think Taddeauz (I probably didn't spell that right)... I working on something similar. You guys might want to team up and collaborate.
Reply With Quote
  #4  
Old 10-06-2015, 08:48 AM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 7,491
Is this for the Apple TV3, which was released in 2012, or the soon to be released Apple TV4?
__________________
New Server - Sage9 on unRAID 2xHD-PVR, HDHR for OTA
Old Server - Sage7 on Win7Pro-i660CPU with 4.6TB, HD-PVR, HDHR OTA, HVR-1850 OTA
Clients - 2xHD-300, 8xHD-200 Extenders, Client+2xPlaceshifter and a WHS which acts as a backup Sage server
Reply With Quote
  #5  
Old 10-06-2015, 02:20 PM
Vaskill Vaskill is offline
Sage User
 
Join Date: Feb 2007
Location: Ottawa, ON
Posts: 70
Quote:
Originally Posted by stuckless View Post
Here are some thoughts/ideas....

1. You probably don't need to write any plugins for sagetv. You can use the sagex rest apis to get all the media related data, etc. If you have sagex services installed, then just open a browser an go to http://server/sagex/api, and you'll get a help page on how how to use the sagex apis. If you have phoenix core installed, then you can also use sagex apis to request fanart (posters, backgrounds, banners, etc). With sagex, you can do more than just read information, you have access to every sagetv api via a rest interface, so you can set/toggle watched status, add favorites, search, etc.

2. To do what you are asking, for the media playback, you need to use the sage minclient protocol (video server portion). The video server is a socket based protocol that supports "pull" and "push" modes for videos. It's quite easy conceptually, but if you are not a video person (I'm not) then it can be quite complex to wrap your head around it. I'm obviously struggling through it on the Android side, reimplementing a miniclient/placeshifter, natively, in Android.

I think Taddeauz (I probably didn't spell that right)... I working on something similar. You guys might want to team up and collaborate.
That is the same approach I took with my prototype; using both SageX to get the metadata, Phenix plugin for art and SageTV MediaStreaming plugin. Works great, but it has been a decade since I have done any serious coding; and never really did any formal iOS development so that is a bit of a slog for me. My goal is not to replicate the SageTV interface but to make a very AppleTV feel interface for the sage media (video, music and photos). Since the API's/web services are there, it really is just about programming the AppleTV to push and pull the metadata.

We have a thread here:
http://forums.sagetv.com/forums/show...t=media+stream
Reply With Quote
  #6  
Old 10-06-2015, 02:53 PM
Vaskill Vaskill is offline
Sage User
 
Join Date: Feb 2007
Location: Ottawa, ON
Posts: 70
Quote:
Originally Posted by hornms View Post
I've been lucky enough to get an early release of an Apple TV 3 which allows app development. There are 2 ways of doing development: 1) iOS-style using swift or objective C, or 2) TVML which is a combination of XML and Javascript served from a web server. I prefer the iOS-style because that is native code and should have the best performance.

I added a JSP file to the jetty folder in sage 7 to return the full recording list including the media IDs in json. I created a tvos app in swift to read this json from the jetty server and populate a table view of recordings. I then created a view to play a selected video using the media stream as is done from any iOS device (thru jetty). It plays nicely, but the quality is lower than expected. Obviously the ATV only supports a limited set of video codecs and my ts files are not supported directly, so I know it must transcode. Also, the playback seems finicky. If you try to scrub ahead, it kind of hangs the video and it never comes back. I see this too on my iPad using the jetty web browser interface.

Is there a better way to stream a transcoded stream to the ATV instead of using the jetty plugin? Is there a socket interface I can hook up to?

I'd like to ensure that I can get the commercial skip, jump ahead 30 and back 10 (why every video player does not do this I will never know) to work as good as the native java placeshifter. Sage is so smooth when it comes to jumping ahead and back through videos and I'd like to replicate that if I could in the ATV client.

Can you give me some design idea of how I could get a good quality video stream to the ATV that is transcoded with support for +30, -10, and CS? I have never written a Sage plugin, but I'm good to learn with some guidance. No sense writing the rest of the app unless I can get good reliable video working.

Thanks for your help,
Mike
Mike, its exciting how simple this could be, right? See my last post regarding approach and not using TVML.

Regarding playback:
1) I know we can ask for a higher bitrate up to 1840; I think this is a configured property of an FFMPEG call; just need to find it to allow for better conversion.
2) The issue with the scrubbing/jumping in the video might be more on the app side; we might have to tell the AppleTV what type of stream it is so it knows how to handle FF/RW, skip, etc.

I would be happy to collaborate with you as I have a significant vision on how to approach from a UI design... my coding skills in iOS are weak.

PS. Technically I think it is an Apple TV 4.
Reply With Quote
  #7  
Old 10-06-2015, 03:11 PM
Taddeusz Taddeusz is offline
SageTVaholic
 
Join Date: Nov 2004
Location: Yukon, OK
Posts: 3,919
I've been slowly working on a native iOS client. Slowly is the key word there.

I decided I wanted to give the option to use the locator to get the IP address. Just finished up that code. The first time I've done anything directly writing to and reading from TCP sockets. Used to using JSON or XML web services for that sort of thing.

I haven't decided yet whether I'm going to open source my client. But if you plan on using the locator in your Apple TV client I'd be happy to share that piece of code. Why duplicate effort?
__________________
Server: i5 8400, ASUS Prime H370M-Plus/CSM, 16GB RAM, 15TB drive array + 500GB cache, 2 HDHR's, SageTV 9, unRAID 6.6.3
Client 1: HD300 (latest FW), HDMI to an Insignia 65" 1080p LCD and optical SPDIF to a Sony Receiver
Client 2: HD200 (latest FW), HDMI to an Insignia NS-LCD42HD-09 1080p LCD
Reply With Quote
  #8  
Old 10-06-2015, 07:47 PM
hornms hornms is offline
New Member
 
Join Date: Oct 2015
Location: PA
Posts: 2
My mistake, it is the ATV4.

My mistake, I have the ATV4. Thanks for all your replies. I did not see the other thread otherwise I would have just posted there.

My swift code was hard coded with an IP address and port number of the sage jetty server. I did not use the locator, but if you are willing to share, I'd be happy to add it to my code. Would that find the running sage server so the user would not have to enter the IP address (like the HD clients do now)? That would be so great!

Thanks to everyone for suggesting sagex. I never really knew what that did, but I will give it a try. Much better to use a mature and tested interface than my own hacked together JSP. What port number do I use? 8080? Is it hosted by jetty? I got a 404 error when I tried just /sagex/api? Once I get the listing through sagex, then I will move back to the streaming/jumping video.

I agree with Vaskill, I was not trying to duplicate the sage look-n-feel (which is great BTW and stuckless's work is simply amazing on android), but to make it fit the atv style. Actually, truth be told, I just want it to work...no telling when my HD client boxes are going to die and sage has been the center of my family's TV watching for so long, I can't think of doing anything else. Live TV, Recorded TV with CS, and DVD ISO playback are the major features we use.

I'm sure Plex will be available on ATV4 when the App store is ready, so I can give that a try to see how responsive it is on iOS. I will install the server and try it on my iPad for now. I will try to stream just a 100% compatible movie file from a simple web server to ATV to see how it handles the jumping around, including +30, -10 and some fake CS. If it can handle that, then we just need to work on the Sage transcoding end to be better. If it is a recorded show, then I could just convert it before it gets played (lots of space). If it is live tv, then maybe we can run ffmpeg to convert the stream as the ts stream is getting recorded (not sure if you can keep them in sync or if the ffmpeg could read the file as it is being written)? I'm not a video guy, so I have no clue what is possible.

BTW, I streamed these file formats from a simple web server (IIS not jetty). MP4 plays, but no sound. M4V plays, but no video or sound. TS (this is the main file I have) shows an ERROR. MKV shows an ERROR. AVI shows an ERROR.

Finally, I could look at the placeshifter socket interface as stuckless suggested and see how far I get there. That might be stretching my abilities a bit.

Thanks again...I will let you know my progress.
Reply With Quote
  #9  
Old 10-07-2015, 05:50 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
As for sagex... assuming that you have jetty server installed, and that you have sagex-services installed, then it's just

http://your_server_addres:8080/sagex/api

If you have phoenix-core installed, then you can can can access the media/fanart apis by using

http://your_server_address:8080/sagex/media?help=true

Be sure to look at all the examples, etc, and I don't mind answering questions. Their is a lot to the sagex apis, including the ability to filter the amount of data coming back, etc. for example when you get a list of media files, it will, by default it returns EVERYTHING about the mediafile... but you can use the "filter" parameter to specify which fields of the media file to return, limiting the amount of data that comes back.

For fanart, you can use the simplified api calls where you just pass the mediafile id, and it figures out the poster, etc, or you can use the /sagex/media/fanart call, and pass very explicit information, like series name, season number, etc.

And keep in mind that when using the sagex apis, the EvaluateExpression command (which is a sagetv api) is a powerapi, since it enables you are nest calls to do things like, get a list of mediafiles, group it, sort, etc, and then return the results... all the work being done on the server.

Code:
EvaluateExpression&1=Sort(GetMediaFiles("T"),false,"Intelligent")
And finally, sagex supports the ability for you to deply a .js service file on the server for doing thing a little more complex. The plex integration uses this, if I recall. The wiki page for the sagex api has some brief information on this. https://github.com/stuckless/sagetv-...sing-sagex-api

*** Aded SageTV API Link ***
Any of these APIs, can be called from sagex apis. (with a few minor exceptions)
http://sagetv.com/api/sage/api/package-summary.html

Last edited by stuckless; 10-07-2015 at 05:56 AM. Reason: Added SageTV api guide
Reply With Quote
  #10  
Old 10-07-2015, 07:13 AM
Taddeusz Taddeusz is offline
SageTVaholic
 
Join Date: Nov 2004
Location: Yukon, OK
Posts: 3,919
Quote:
Originally Posted by hornms View Post
My swift code was hard coded with an IP address and port number of the sage jetty server. I did not use the locator, but if you are willing to share, I'd be happy to add it to my code. Would that find the running sage server so the user would not have to enter the IP address (like the HD clients do now)? That would be so great!
The Locator usefulness depends on where you plan on using the client.

Locator is used kind of like a DynDNS service but specifically for SageTV. It records the public IP address and Placeshifter port for your SageTV server.

Basically you look in your SageTV server configuration and find your Locator ID. You enter that into your client and where ever you are you can connect to your SageTV server.

I still have details to work out. For my purposes, and probably your's, the port number is superfluous. I'll have to somehow figure out if the device is on the user's local network or roaming. I'm going to try and automate as much as possible. Crazy how much work has to go into just getting the information needed to connect. But without some kind of service like Plex uses all this information needs to be entered into the app for it to work as seemlessly.
__________________
Server: i5 8400, ASUS Prime H370M-Plus/CSM, 16GB RAM, 15TB drive array + 500GB cache, 2 HDHR's, SageTV 9, unRAID 6.6.3
Client 1: HD300 (latest FW), HDMI to an Insignia 65" 1080p LCD and optical SPDIF to a Sony Receiver
Client 2: HD200 (latest FW), HDMI to an Insignia NS-LCD42HD-09 1080p LCD
Reply With Quote
  #11  
Old 10-07-2015, 01:10 PM
fidget's Avatar
fidget fidget is offline
Sage Icon
 
Join Date: Jun 2003
Location: Cedar Rapids, Iowa, USA
Posts: 1,186
It looks like apps on the AppleTV will be able to participate in universal search. It would be nice to look for a show or movie and be able to find it in SageTV.
__________________
Server: i5-2405S (4 core @ 2.5 GHz), 8GB RAM, NORCO RPC-4220 4U case
Tuners: 2 SiliconDust HDHomeRun , 2 Hauppauge HD-PVR Connected to 1 Pace700X and 1 TiVo Series 4
DVD Storage: 24 TB
TV Storage: 11 TB (4x1.5TB for recording, 5TB for archive)
Clients: 3
SageTV Extenders:5
Reply With Quote
  #12  
Old 10-07-2015, 10:27 PM
Vaskill Vaskill is offline
Sage User
 
Join Date: Feb 2007
Location: Ottawa, ON
Posts: 70
Quote:
Originally Posted by fidget View Post
It looks like apps on the AppleTV will be able to participate in universal search. It would be nice to look for a show or movie and be able to find it in SageTV.
It's in the (my) plans to do just that... Three scenes to start, Recordings, Program Guide and Search.

Then eventually grow to all the admin stuff one can do, Manage Fav, playlists, etc.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
apple itunes? bjkiller SageTV Customizations 0 04-01-2011 05:42 PM
Apple questions pjpjpjpj The SageTV Community 4 03-15-2010 03:04 PM
M2TS AVCHD playback on Apple Macbook Client benjatelcom SageTV Beta Test Software 4 01-05-2009 11:12 AM
Sage HD-100 vs. Apple TV TimmyToo SageTV Media Extender 17 06-13-2008 11:52 AM
Apple remote on client brewston SageTV Mac Edition 6 02-24-2008 05:55 PM


All times are GMT -6. The time now is 12:55 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.