从 iOS 向 Chromecast 直播 .m3u8

Streaming live .m3u8 from iOS to 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 中测试了这两个以确保流实际上是活动的。

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

来检查
$ 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: * 在第二个而不是在第一个。