FAQ  •  Register  •  Login

[Problems] CDS Api -> Android App for Chromecast

<<

Laire

Serviio newbie

Posts: 17

Joined: Sat Oct 18, 2014 9:25 am

Post Thu Nov 06, 2014 12:57 am

[Problems] CDS Api -> Android App for Chromecast

Hello

I am working on a simple APP for streaming videos to Google Cast (e.g. Chromecast).

I am testing with three files, here the codecs and the result, without transcoding (these errors have Chromecast issues):

1. mkv
Video: H246 - MPEG-4 AVC
Audio: DTS Audio
Streaming: Video OK, but no Sound

2. ts
Video: H246 - MPEG-4 AVC
Audio: A52 Audio (aka AC3) (a52 )
Streaming: not possible

3. avi
Video: MPEG-4 Video (XVID)
Audio: MPEG Audio layer 1/2/3 (mpga)
Streaming: not possible

First try with "applehttp":

Result: No Casting possible.

appletv or HLS returns a m3u8 file, wich is like a playlist. The HLS format cut the stream in many pieces e.g. segment00000.ts
It seems like it is a problem, when I request the m3u8 file, the pieces in the playlist have no authToken, although the m3u8 request was sending one.
Here a snipet from the log file:

Everything is OK:
2014-11-06 01:45:22,637 INFO [LogService] 2014-11-06 01:45:22 192.168.188.31 - - 23424 GET /cds/resource/37/MANIFEST/HLS-0/ORIGINAL.m3u8 profile=gochromecast&authToken=624b9a951ca8404195e66a5836013851 200 - 0 196 http://192.168.188.26:23424 Mozilla/5.0 (Unknown; Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.0 Safari/537.36 CrKey/22062 -
2014-11-06 01:45:22,881 DEBUG [CDSRetrieveMediaServerResource] GET http://192.168.188.26:23424/cds/resourc ... ea9eafd4e6 HTTP/1.1, headers = [host: 192.168.188.26:23424,connection: keep-alive,user-agent: Mozilla/5.0 (Unknown; Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.0 Safari/537.36 CrKey/22062,origin: https://www.gstatic.com,accept: */*,accept-encoding: gzip,deflate,accept-language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4]
2014-11-06 01:45:22,884 DEBUG [CDSRetrieveMediaServerResource] Creating client with id '192.168.188.31'


then:

2014-11-06 01:45:25,790 INFO [LogService] 2014-11-06 01:45:25 192.168.188.31 - - 23424 GET /cds/resource/37/MEDIA_ITEM/HLS-0/segment00000.ts - 401 - 0 40 http://192.168.188.26:23424 Mozilla/5.0 (Unknown; Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.0 Safari/537.36 CrKey/22062 -
2014-11-06 01:45:27,485 WARN [ServiioStatusService] AuthenticationException occured. Returning error code 401 to the REST layer. Message: No authentication token has been provided for a restricted resource.
2014-11-06 01:45:27,486 DEBUG [ServiioStatusService] Detailed exception:
org.serviio.restlet.AuthenticationException: No authentication token has been provided for a restricted resource.


I add the whole log file as attachment, please have a look, perhaps is the error something else.
Attachments
serviio.log
Log File with HLS
(237.62 KiB) Downloaded 481 times
<<

Laire

Serviio newbie

Posts: 17

Joined: Sat Oct 18, 2014 9:25 am

Post Thu Nov 06, 2014 1:07 am

Re: [Problems] CDS Api -> Android App for Chromecast

Second try "mpeg"

Profile:

  Code:
        <Profile id="gochromecast" name="GoChromecast" extendsProfileId="1" alwaysEnableTranscoding="true" selectable="false">
                <Transcoding>
                        <Video targetContainer="mpeg" targetVCodec="h264" targetACodec="aac" maxHeight="720">
                                <Matches container="*" />
                        </Video>
                </Transcoding>
                <AllowedImageResolutions large="4096x4096" medium="1920x1920" small="1280x1280" />
                <ThumbnailsResolution>HD</ThumbnailsResolution>
                <AutomaticImageRotation>true</AutomaticImageRotation>
        </Profile>


Result: no casting possible

Could be a problem from chromecast supported media

I don't know why, but it seems like this the position in the log file:

2014-11-06 02:00:55,872 INFO [LogService] 2014-11-06 02:00:55 192.168.188.31 - - 23424 GET /cds/resource/37/MEDIA_ITEM/MPEG_PS_PAL-0/ORIGINAL profile=gochromecast&authToken=bb71cb99dc154e57902549f9faba4090 200 - 0 784 http://192.168.188.26:23424 Mozilla/5.0 (Unknown; Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.0 Safari/537.36 CrKey/22062 -
2014-11-06 02:00:56,107 DEBUG [DiscoverySSDPMessageListener] Received a valid M-SEARCH message for search target urn:schemas-upnp-org:device:avm-aha:1 from address /192.168.188.1:47344s
2014-11-06 02:00:58,800 DEBUG [FeedUpdaterThread] Checking for new and expired online resources
2014-11-06 02:00:58,801 DEBUG [OnlineRepositoryDAOImpl] Reading all OnlineRepositories
2014-11-06 02:00:59,386 WARN [InternalRouter] Exception while writing the message body.
java.net.SocketException: Socket closed
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:121)
at java.net.SocketOutputStream.write(SocketOutputStream.java:159)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.write(BufferedOutputStream.java:126)
at org.restlet.engine.http.io.ChunkedOutputStream.writeChunk(ChunkedOutputStream.java:149)
at org.restlet.engine.http.io.ChunkedOutputStream.write(ChunkedOutputStream.java:129)
at java.io.OutputStream.write(OutputStream.java:116)
at org.restlet.engine.io.BioUtils.copy(BioUtils.java:75)
at org.serviio.upnp.service.contentdirectory.rest.representation.ClosingInputRepresentation.write(ClosingInputRepresentation.java:132)
at org.restlet.engine.http.connector.Connection.writeMessageBody(Connection.java:874)
at org.restlet.engine.http.connector.Connection.writeMessage(Connection.java:819)
at org.restlet.engine.http.connector.ServerConnection.writeMessage(ServerConnection.java:333)
at org.restlet.engine.http.connector.Connection.writeMessages(Connection.java:955)
at org.restlet.engine.http.connector.BaseServerHelper.handleOutbound(BaseServerHelper.java:201)
at org.restlet.engine.http.connector.BaseHelper.handleNextOutbound(BaseHelper.java:425)
at org.restlet.engine.http.connector.BaseServerHelper.handleInbound(BaseServerHelper.java:174)
at org.restlet.engine.http.connector.BaseHelper.handleNextInbound(BaseHelper.java:418)
at org.restlet.engine.http.connector.Connection.readMessages(Connection.java:696)
at org.restlet.engine.http.connector.Controller$2.run(Controller.java:95)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
2014-11-06 02:00:59,392 WARN [InternalRouter] Exception while writing the message headers.
java.net.SocketException: Socket closed
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:121)
at java.net.SocketOutputStream.write(SocketOutputStream.java:159)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at org.restlet.engine.http.connector.Connection.writeMessageHead(Connection.java:908)
at org.restlet.engine.http.connector.Connection.writeMessageHead(Connection.java:922)
at org.restlet.engine.http.connector.Connection.writeMessage(Connection.java:797)
at org.restlet.engine.http.connector.ServerConnection.writeMessage(ServerConnection.java:342)
at org.restlet.engine.http.connector.Connection.writeMessages(Connection.java:955)
at org.restlet.engine.http.connector.BaseServerHelper.handleOutbound(BaseServerHelper.java:201)
at org.restlet.engine.http.connector.BaseHelper.handleNextOutbound(BaseHelper.java:425)
at org.restlet.engine.http.connector.BaseServerHelper.handleInbound(BaseServerHelper.java:174)
at org.restlet.engine.http.connector.BaseHelper.handleNextInbound(BaseHelper.java:418)
at org.restlet.engine.http.connector.Connection.readMessages(Connection.java:696)
at org.restlet.engine.http.connector.Controller$2.run(Controller.java:95)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)


The whole log file as attachment
Attachments
serviio.log
mpeg log
(180.51 KiB) Downloaded 475 times
<<

will

DLNA master

Posts: 2138

Joined: Mon Aug 30, 2010 11:18 am

Location: UK

Post Thu Nov 06, 2014 7:44 am

Re: [Problems] CDS Api -> Android App for Chromecast

Just to clarify the problem, it looks like newer versions of ffmpeg not include the url params in the generated manifiest, and as such the client is not able to fetch the segments.
Will

ServiiDroid (Android Console) Developer: Download | Home | Support
ServiiGo (Android 3G/4G/WiFi Playback App) Developer: Download | Home | Support
<<

Laire

Serviio newbie

Posts: 17

Joined: Sat Oct 18, 2014 9:25 am

Post Thu Nov 06, 2014 11:27 pm

Re: [Problems] CDS Api -> Android App for Chromecast

Now is the question how to resolve the problem
<<

will

DLNA master

Posts: 2138

Joined: Mon Aug 30, 2010 11:18 am

Location: UK

Post Fri Nov 07, 2014 7:49 am

Re: [Problems] CDS Api -> Android App for Chromecast

Until Serviio adds support, you need to use an older version of ffmpeg, or re-write the urls in the Chromecast receiver app (but this requires a custom receiver).
Will

ServiiDroid (Android Console) Developer: Download | Home | Support
ServiiGo (Android 3G/4G/WiFi Playback App) Developer: Download | Home | Support
<<

Laire

Serviio newbie

Posts: 17

Joined: Sat Oct 18, 2014 9:25 am

Post Fri Nov 07, 2014 12:19 pm

Re: [Problems] CDS Api -> Android App for Chromecast

Two Ideas for other solutions, but they can only implement by the Serviio developers:

1. Possibility to turn of the AuthToken in the API (choosing by user)
2. Add devices (IP's) to a list wich doesn't need a authtoken
<<

will

DLNA master

Posts: 2138

Joined: Mon Aug 30, 2010 11:18 am

Location: UK

Post Sat Nov 08, 2014 11:48 am

Re: [Problems] CDS Api -> Android App for Chromecast

Laire wrote:Two Ideas for other solutions, but they can only implement by the Serviio developers:

1. Possibility to turn of the AuthToken in the API (choosing by user)
2. Add devices (IP's) to a list wich doesn't need a authtoken


I've just built a new version of ffmpeg from the latest source and this problem seems to be fixed.

As a side note, 1.5 will let you turn off authetication for the CDS API.
Will

ServiiDroid (Android Console) Developer: Download | Home | Support
ServiiGo (Android 3G/4G/WiFi Playback App) Developer: Download | Home | Support
<<

Laire

Serviio newbie

Posts: 17

Joined: Sat Oct 18, 2014 9:25 am

Post Sat Nov 08, 2014 12:23 pm

Re: [Problems] CDS Api -> Android App for Chromecast

will wrote:
Laire wrote:Two Ideas for other solutions, but they can only implement by the Serviio developers:

1. Possibility to turn of the AuthToken in the API (choosing by user)
2. Add devices (IP's) to a list wich doesn't need a authtoken


I've just built a new version of ffmpeg from the latest source and this problem seems to be fixed.

As a side note, 1.5 will let you turn off authetication for the CDS API.


I am not so experienced with linux and building source from git. I used this manuel to install it: http://wiki.serviio.org/doku.php?id=build_ffmpeg_linux, should i get the latest version this way?
<<

will

DLNA master

Posts: 2138

Joined: Mon Aug 30, 2010 11:18 am

Location: UK

Post Sat Nov 08, 2014 12:26 pm

Re: [Problems] CDS Api -> Android App for Chromecast

Laire wrote:
will wrote:
Laire wrote:Two Ideas for other solutions, but they can only implement by the Serviio developers:

1. Possibility to turn of the AuthToken in the API (choosing by user)
2. Add devices (IP's) to a list wich doesn't need a authtoken


I've just built a new version of ffmpeg from the latest source and this problem seems to be fixed.

As a side note, 1.5 will let you turn off authetication for the CDS API.


I am not so experienced with linux and building source from git. I used this manuel to install it: http://wiki.serviio.org/doku.php?id=build_ffmpeg_linux, should i get the latest version this way?


Just re-do the build ffmpeg part, but instead of re-downloading the source, use the following to update the ffmpeg source first

  Code:
cd ffmpeg
git pull


then run as usual to re-configure, build and install.
  Code:
./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb \
    --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 \
    --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab --enable-librtmp \
    --enable-libxvid --enable-libass
make
sudo checkinstall --pkgname=ffmpeg --pkgversion="99:$(date +%Y%m%d%H%M)-git" --backup=no \
  --deldoc=yes --fstrans=no --default
Will

ServiiDroid (Android Console) Developer: Download | Home | Support
ServiiGo (Android 3G/4G/WiFi Playback App) Developer: Download | Home | Support
<<

Laire

Serviio newbie

Posts: 17

Joined: Sat Oct 18, 2014 9:25 am

Post Sun Nov 09, 2014 3:39 am

Re: [Problems] CDS Api -> Android App for Chromecast

Ok i rebuild it but have still problems...

I don't know where to find the error. Looks same as above. In the moment I don't try to send the stream to the chromecast, just play the file local in my App.

The first request for the m3u8 files works without problems, in this case i request:

http://192.168.188.26:23424/cds/resource/37/MANIFEST/HLS-0/ORIGINAL.m3u8?profile=chromecast&authToken=5caa1c99934740829c7b74fefa00bcc8


The Logfile shows:
  Code:
2014-11-09 04:13:12,418 INFO  [LogService] 2014-11-09   04:13:12   192.168.188.30   -   -   23424   GET   /cds/resource/37/MANIFEST/HLS-0/ORIGINAL.m3u8   profile=chromecast&authToken=5caa1c99934740829c7b74fefa00bcc8   200   -   0   186   http://192.168.188.26:23424   HTC Streaming Player htc / 1.0 / htc_europe / 4.4.3   -

2014-11-09 04:13:12,487 DEBUG [CDSRetrieveMediaServerResource] GET http://192.168.188.26:23424/cds/resource/37/MEDIA_ITEM/HLS-0/ORIGINAL.m3u8?profile=chromecast&authToken=8cfd9fe350054a1681f0cb9c17db93ba HTTP/1.1, headers = [host: 192.168.188.26:23424,connection: keep-alive,bandwidth: 11000000,user-agent: HTC Streaming Player htc / 1.0 / htc_europe / 4.4.3,x-network-type: WIFI,x-wap-profile: http://www.htcmms.com.tw/Android/Common/PN071/ua-profile.xml,accept-encoding: gzip,deflate,accept: */*,x-getzip: supported,cache-control: no-cache]

2014-11-09 04:13:12,490 DEBUG [CDSRetrieveMediaServerResource] Creating client with id '192.168.188.30'


No Problems. But what I see, is I request MANIFEST and in the Log File he change from MANIFEST to MEDIA_ITEM -> don't know if that should be so

In the requested m3u8 file is now the link to same content:

http://192.168.188.26:23424/cds/resource/37/MEDIA_ITEM/HLS-0/ORIGINAL.m3u8?profile=chromecast&authToken=8cfd9fe350054a1681f0cb9c17db93ba


But when the player try to request, the authentication token seems to be invalid:

  Code:
2014-11-09 04:13:15,233 INFO  [LogService] 2014-11-09   04:13:15   192.168.188.30   -   -   23424   GET   /cds/resource/37/MEDIA_ITEM/HLS-0/ORIGINAL.m3u8   profile=chromecast&authToken=8cfd9fe350054a1681f0cb9c17db93ba   200   -   0   2756   http://192.168.188.26:23424   HTC Streaming Player htc / 1.0 / htc_europe / 4.4.3   -

2014-11-09 04:13:15,346 WARN  [ServiioStatusService] AuthenticationException occured. Returning error code 401 to the REST layer. Message: No authentication token has been provided for a restricted resource.

2014-11-09 04:13:15,346 DEBUG [ServiioStatusService] Detailed exception:
org.serviio.restlet.AuthenticationException: No authentication token has been provided for a restricted resource.


The player try to continue the request and call the first segment:

  Code:
2014-11-09 04:13:15,384 INFO  [LogService] 2014-11-09   04:13:15   192.168.188.30   -   -   23424   GET   /cds/resource/37/MEDIA_ITEM/HLS-0/segment00000.ts   -   401   -   0   41   http://192.168.188.26:23424   HTC Streaming Player htc / 1.0 / htc_europe / 4.4.3   -

2014-11-09 04:13:15,407 WARN  [ServiioStatusService] AuthenticationException occured. Returning error code 401 to the REST layer. Message: No authentication token has been provided for a restricted resource.

2014-11-09 04:13:15,407 DEBUG [ServiioStatusService] Detailed exception:
org.serviio.restlet.AuthenticationException: No authentication token has been provided for a restricted resource.


And again:

  Code:
2014-11-09 04:13:15,464 INFO  [LogService] 2014-11-09   04:13:15   192.168.188.30   -   -   23424   GET   /cds/resource/37/MEDIA_ITEM/HLS-0/segment00000.ts   -   401   -   0   11   http://192.168.188.26:23424   HTC Streaming Player htc / 1.0 / htc_europe / 4.4.3   -

2014-11-09 04:13:17,198 WARN  [InternalRouter] Exception while writing the message headers.
java.net.SocketException: Socket closed


I attached the log file
Attachments
serviio.log
(177.2 KiB) Downloaded 491 times
<<

will

DLNA master

Posts: 2138

Joined: Mon Aug 30, 2010 11:18 am

Location: UK

Post Sun Nov 09, 2014 7:49 am

Re: [Problems] CDS Api -> Android App for Chromecast

I would use something like MX Player rather than the built in player, its usually pretty buggy.

So you are going to need to manually check what the server is returning.

So first download (or view in your browser) the master playlist
  Code:
http://192.168.188.26:23424/cds/resource/37/MANIFEST/HLS-0/ORIGINAL.m3u8?profile=chromecast&authToken=5caa1c99934740829c7b74fefa00bcc8



That should then point to another playlist, this is the file that I would pass to the video player
  Code:
http://192.168.188.26:23424/cds/resource/37/MEDIA_ITEM/HLS-0/ORIGINAL.m3u8?profile=chromecast&authToken=5caa1c99934740829c7b74fefa00bcc8


You want to open that up, and check to see if the auth tokens are added to the urls.
Will

ServiiDroid (Android Console) Developer: Download | Home | Support
ServiiGo (Android 3G/4G/WiFi Playback App) Developer: Download | Home | Support
<<

Laire

Serviio newbie

Posts: 17

Joined: Sat Oct 18, 2014 9:25 am

Post Tue Nov 11, 2014 12:40 am

Re: [Problems] CDS Api -> Android App for Chromecast

will wrote:I would use something like MX Player rather than the built in player, its usually pretty buggy.

So you are going to need to manually check what the server is returning.

So first download (or view in your browser) the master playlist
  Code:
http://192.168.188.26:23424/cds/resource/37/MANIFEST/HLS-0/ORIGINAL.m3u8?profile=chromecast&authToken=5caa1c99934740829c7b74fefa00bcc8



That should then point to another playlist, this is the file that I would pass to the video player
  Code:
http://192.168.188.26:23424/cds/resource/37/MEDIA_ITEM/HLS-0/ORIGINAL.m3u8?profile=chromecast&authToken=5caa1c99934740829c7b74fefa00bcc8


You want to open that up, and check to see if the auth tokens are added to the urls.


No auth token in the second m3u8 files with the segment.ts
<<

will

DLNA master

Posts: 2138

Joined: Mon Aug 30, 2010 11:18 am

Location: UK

Post Tue Nov 11, 2014 7:42 am

Re: [Problems] CDS Api -> Android App for Chromecast

And Serviio is definitely using the new version of ffmpeg? (it's shown at the start of the log).
Will

ServiiDroid (Android Console) Developer: Download | Home | Support
ServiiGo (Android 3G/4G/WiFi Playback App) Developer: Download | Home | Support
<<

Laire

Serviio newbie

Posts: 17

Joined: Sat Oct 18, 2014 9:25 am

Post Tue Nov 11, 2014 3:16 pm

Re: [Problems] CDS Api -> Android App for Chromecast

This is the version in the log:

[FFMPEGWrapper] Found FFmpeg: ffmpeg version N-41182-g41ad87a Copyright (c) 2000-2014 the FFmpeg developers


Attached the last log file
Attachments
serviio.log
(187.4 KiB) Downloaded 479 times

Return to Third-party tools integration

Who is online

Users browsing this forum: No registered users and 15 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.