从iOS到Chromecast直播.m3u8

时间:2015-11-24 14:09:41

标签: ios video-streaming chromecast

根据Google的文档,我可以将.mp4和.m3u8点播流传输到我的Chromecast。当我尝试投射直播视频流时,“投射”图标逐渐消失,然后再次出现。

这是一个有效的按需流:

GCKMediaInformation *mediaInformation =
    [[GCKMediaInformation alloc] initWithContentID:
     @"http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8"
                                        streamType:GCKMediaStreamTypeLive
                                       contentType:@"application/x-mpegURL"
                                          metadata:[self getMetadata]
                                    streamDuration:INFINITY
                                        customData:nil];

这是一个非工作的直播流。

GCKMediaInformation *mediaInformation =
    [[GCKMediaInformation alloc] initWithContentID:
     @"http://vevoplaylist-live.hls.adaptive.level3.net/vevo/ch1/appleman.m3u8"
                                        streamType:GCKMediaStreamTypeLive
                                       contentType:@"application/x-mpegURL"
                                          metadata:[self getMetadata]
                                    streamDuration:INFINITY
                                        customData:nil];

我已经在VLC中对这两个进行了测试,以确保流实际上是活动的。

1 个答案:

答案 0 :(得分:3)

第二个流没有CORS标头,这是Chromecast上自适应内容的要求。您可以通过调用curl -v <url>然后检查标题来检查:

$ curl -v http://vevoplaylist-live.hls.adaptive.level3.net/vevo/ch1/appleman.m3u8
*   Trying 8.253.43.126...
* Connected to vevoplaylist-live.hls.adaptive.level3.net (8.253.43.126) port 80 (#0)
> GET /vevo/ch1/appleman.m3u8 HTTP/1.1
> Host: vevoplaylist-live.hls.adaptive.level3.net
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Cache-Control: max-age=2
< Date: Tue, 24 Nov 2015 15:44:12 GMT
< Content-Length: 427
< Content-Type: application/vnd.apple.mpegurl
< ETag: "6880298-1ab-51c1fc3e9da00"
< Last-Modified: Thu, 30 Jul 2015 23:07:20 GMT
< Accept-Ranges: bytes
< Server: Footprint Distributor V4.11
< Vary: Accept-Encoding
< Expires: Tue, 24 Nov 2015 15:44:14 GMT
< Connection: keep-alive

如果你对第一个(有效)做同样的事情,你会得到:

$ curl -v http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8
*   Trying 23.67.247.168...
* Connected to qthttp.apple.com.edgesuite.net (23.67.247.168) port 80 (#0)
> GET /1010qwoeiuryfg/sl.m3u8 HTTP/1.1
> Host: qthttp.apple.com.edgesuite.net
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: Apache
< ETag: "2b476bddec5a6410f01593dd3244bb86:1299516757"
< Last-Modified: Mon, 07 Mar 2011 16:52:37 GMT
< Content-Length: 940
< Expires: Tue, 24 Nov 2015 15:47:02 GMT
< Cache-Control: max-age=0, no-cache, no-store
< Pragma: no-cache
< Date: Tue, 24 Nov 2015 15:47:02 GMT
< Connection: keep-alive
< Set-Cookie: AKID=650047DEB61A8134C38CECC9EC836DF8;expires=Fri, 11-27-2015 00:00:00 GMT; path=/; domain=qthttp.apple.com.edgesuite.net
< Content-Type: application/x-mpegURL
< Access-Control-Allow-Origin: *
< Set-Cookie: CLIENT_SESSION_COOKIE=csid=235AB97C3466663B398A6EC6DA38428C#ct=1448380022#master=sl.m3u8; path=/1010qwoeiuryfg; domain=qthttp.apple.com.edgesuite.net
< Set-Cookie: CLIENT_VIEWER_COOKIE=78FCBFC2DF7B7BD10F99EEC583042328;expires=Tue, 10-06-2014 00:00:00 GMT; path=/; domain=qthttp.apple.com.edgesuite.net

请注意第二个中存在Access-Control-Allow-Origin: *,而不是第一个中存在。