投射音频流时投射设备冻结

Posted

技术标签:

【中文标题】投射音频流时投射设备冻结【英文标题】:Cast devices freeze when casting audio streams 【发布时间】:2017-03-20 10:59:49 【问题描述】:

我在投射一些第三方音频流时遇到问题。我非常依赖https://developers.google.com/cast/docs/player,并按照这些说明来创建用于播放流的自定义接收器。

在开始流式传输后大约一秒钟后(我没有听到任何声音),Cast 设备冻结并且它们停止响应通过 Chrome 进行的调试,并且它们对停止 Cast 会话没有反应。通常它们被锁定,即使通过 Home 应用程序重新启动也不起作用;我必须物理断开电源。

Chromecast v2 (1.22.79313)、Chromecast Ultra (1.22.78017) 和 Google Home (1.22.78295) 上的行为相同。

冻结的原因可能是什么?这是由一些非常破碎的流引起的吗?这是一个已知问题吗?有什么解决方法吗?难道不应该期望 Cast 设备能够处理这个问题并给出一些错误消息而不是像这样崩溃吗?

这是我在重置连接之前从 Chrome 开发者工具获得的日志:

cast_receiver.js:67  [  0.268s] [cast.receiver.IpcChannel] Opening platform websocket
cast_receiver.js:67  [  0.292s] [cast.receiver.CastReceiverManager] Version: 2.0.0.0049
cast_receiver.js:67  [  0.305s] [cast.receiver.MediaManager] Using default Player
cast_receiver.js:67  [  0.314s] [cast.receiver.IpcChannel] Opening message bus websocket
cast_receiver.js:67  [  0.322s] [cast.receiver.IpcChannel] IpcChannel opened
cast_receiver.js:67  [  0.326s] [cast.receiver.CastMessageBus] Dispatching CastMessageBus message
cast_receiver.js:67  [  0.333s] [cast.receiver.CastReceiverManager] Underlying message bus is open
[...]
media_player.js:25  [  0.628s] [cast.player.api.Player] Version: 1.0.0.40
[...]
media_player.js:25  [  6.682s] [cast.player.api.Player] load
media_player.js:25  [  6.707s] [goog.net.XhrIo] Opening Xhr [GET http://thirdpartyserver.example.com/playlist.m3u8 -1]
media_player.js:25  [  6.721s] [goog.net.XhrIo] Will abort after 30000ms if incomplete, xhr2 false [GET http://thirdpartyserver.example.com/playlist.m3u8 -1]
media_player.js:25  [  6.725s] [goog.net.XhrIo] Sending request [GET http://thirdpartyserver.example.com/playlist.m3u8 -1]
media_player.js:51 Mixed Content: The page at 'https://example.com/custom_receiver.html?debug=true' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://thirdpartyserver.example.com/playlist.m3u8'. This content should also be served over HTTPS.
media_player.js:25  [  6.735s] [cast.player.core.MediaSourceManager] open
media_player.js:25  [  6.923s] [goog.net.XhrIo] Request complete [GET http://thirdpartyserver.example.com/playlist.m3u8 200]
media_player.js:25  [  6.975s] [cast.player.core.QualityManager] 0: initial 82625
media_player.js:25  [  6.986s] [cast.player.hls.Playlist] update: http://thirdpartyserver.example.com/chunklist_w941582493.m3u8
media_player.js:25  [  6.993s] [goog.net.XhrIo] Opening Xhr [GET http://thirdpartyserver.example.com/chunklist_w941582493.m3u8 -1]
media_player.js:25  [  6.999s] [goog.net.XhrIo] Will abort after 30000ms if incomplete, xhr2 false [GET http://thirdpartyserver.example.com/chunklist_w941582493.m3u8 -1]
media_player.js:25  [  7.004s] [goog.net.XhrIo] Sending request [GET http://thirdpartyserver.example.com/chunklist_w941582493.m3u8 -1]
media_player.js:51 Mixed Content: The page at 'https://example.com/custom_receiver.html?debug=true' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://thirdpartyserver.example.com/chunklist_w941582493.m3u8'. This content should also be served over HTTPS.
media_player.js:25  [  7.127s] [goog.net.XhrIo] Request complete [GET http://thirdpartyserver.example.com/chunklist_w941582493.m3u8 200]
media_player.js:25  [  7.140s] [cast.player.hls.Playlist] update in: 3000
media_player.js:25  [  7.161s] [cast.player.core.SegmentManager] 0: seek success 0
media_player.js:25  [  7.169s] [goog.net.XhrIo] Opening Xhr [GET http://thirdpartyserver.example.com/media_w941582493_4220443.aac -1]
media_player.js:25  [  7.174s] [goog.net.XhrIo] Will abort after 10000ms if incomplete, xhr2 false [GET http://thirdpartyserver.example.com/media_w941582493_4220443.aac -1]
media_player.js:25  [  7.180s] [goog.net.XhrIo] Sending request [GET http://thirdpartyserver.example.com/media_w941582493_4220443.aac -1]
media_player.js:51 Mixed Content: The page at 'https://example.com/custom_receiver.html?debug=true' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://thirdpartyserver.example.com/media_w941582493_4220443.aac'. This content should also be served over HTTPS.
media_player.js:25  [  7.311s] [goog.net.XhrIo] Request complete [GET http://thirdpartyserver.example.com/media_w941582493_4220443.aac 200]
media_player.js:25  [  7.322s] [cast.player.core.QualityManager] 0: current=1018961.04, average=1444314.43
media_player.js:25  [  7.330s] [cast.player.core.SegmentManager] 0: process segment
media_player.js:25  [  7.338s] [cast.player.hls.Adaptation] process segment
media_player.js:25  [  7.357s] [cast.player.core.SegmentManager] 0: segment processed
media_player.js:25  [  7.363s] [cast.player.core.SourceBufferManager] 0: queue append
media_player.js:25  [  7.382s] [goog.net.XhrIo] Opening Xhr [GET http://thirdpartyserver.example.com/media_w941582493_4220444.aac -1]
media_player.js:25  [  7.387s] [goog.net.XhrIo] Will abort after 10000ms if incomplete, xhr2 false [GET http://thirdpartyserver.example.com/media_w941582493_4220444.aac -1]
media_player.js:25  [  7.392s] [goog.net.XhrIo] Sending request [GET http://thirdpartyserver.example.com/media_w941582493_4220444.aac -1]
media_player.js:51 Mixed Content: The page at 'https://example.com/custom_receiver.html?debug=true' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://thirdpartyserver.example.com/media_w941582493_4220444.aac'. This content should also be served over HTTPS.
media_player.js:25  [  7.515s] [goog.net.XhrIo] Request complete [GET http://thirdpartyserver.example.com/media_w941582493_4220444.aac 200]
media_player.js:25  [  7.521s] [cast.player.core.QualityManager] 0: current=1113553.96, average=1179706.05
media_player.js:25  [  7.528s] [cast.player.core.SegmentManager] 0: process segment
media_player.js:25  [  7.533s] [cast.player.hls.Adaptation] process segment

更新 - 更多信息:

第一个请求 (playlist.m3u8) 的响应标头如下:

Accept-Ranges:bytes
Access-Control-Allow-Credentials:true
Access-Control-Allow-Headers:Content-Type, User-Agent, If-Modified-Since, Cache-Control, Range
Access-Control-Allow-Methods:OPTIONS, GET, POST, HEAD
Access-Control-Allow-Origin:*
Access-Control-Expose-Headers:Date, Server, Content-Type, Content-Length
Cache-Control:no-cache
Content-Length:105
Content-Type:application/vnd.apple.mpegurl
Date:Tue, 21 Mar 2017 13:44:37 GMT
Server:WowzaStreamingEngine/4.5.0

第一个请求 (playlist.m3u8) 的响应正文如下:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:BANDWIDTH=80053,CODECS="mp4a.40.2"
chunklist_w941582493.m3u8

第二个请求 (chunklist_w941582493.m3u8) 的响应标头如下:

Accept-Ranges:bytes
Access-Control-Allow-Credentials:true
Access-Control-Allow-Headers:Content-Type, User-Agent, If-Modified-Since, Cache-Control, Range
Access-Control-Allow-Methods:OPTIONS, GET, POST, HEAD
Access-Control-Allow-Origin:*
Access-Control-Expose-Headers:Date, Server, Content-Type, Content-Length
Cache-Control:no-cache
Content-Length:213
Content-Type:application/vnd.apple.mpegurl
Date:Tue, 21 Mar 2017 13:44:37 GMT
Server:WowzaStreamingEngine/4.5.0

第二个请求 (chunklist_w941582493.m3u8) 的响应正文如下所示:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:3
#EXT-X-MEDIA-SEQUENCE:4272014
#EXTINF:1.95,
media_w1552860397_4272014.aac
#EXTINF:2.09,
media_w1552860397_4272015.aac
#EXTINF:1.95,
media_w1552860397_4272016.aac

第二个请求 (media_w941582493_4220443.aac) 的响应标头如下:

Accept-Ranges:bytes
Access-Control-Allow-Credentials:true
Access-Control-Allow-Headers:Content-Type, User-Agent, If-Modified-Since, Cache-Control, Range
Access-Control-Allow-Methods:OPTIONS, GET, POST, HEAD
Access-Control-Allow-Origin:*
Access-Control-Expose-Headers:Date, Server, Content-Type, Content-Length
Cache-Control:no-cache
Content-Length:19757
Content-Type:audio/x-aac
Date:Tue, 21 Mar 2017 13:44:37 GMT
Server:WowzaStreamingEngine/4.5.0

【问题讨论】:

样式接收器或默认接收器也会发生这种情况吗? 实际上,使用样式化的媒体接收器我只得到日志语句“[cast.receiver.MediaManager] 加载元数据错误:[object Object] cast_receiver.js:67”。根据 Chrome 开发工具中的网络选项卡,只有一个对流的网络调用,它返回 HTTP 200。接收器没有播放任何内容,但它没有冻结,它仍然让我断开连接。 我建议您在我们的 sdk 问题跟踪器上打开一个工单,并包含一个可以产生结果的示例流。 谢谢你,@AliNaddaf。我会去做的。我只是想验证服务器软件是否是最新的并且应该能够工作并且一切都已按应有的方式设置。但是,我现在添加了更多标题和正文信息。你没有看到任何可疑的东西,是吗? 什么都不会跳到我身上 【参考方案1】:

搜索the bug tracker for the Google Cast SDK我找到了一个相关的bug report。

我所要做的就是将cast.player.api.HlsSegmentFormat.MPEG_AUDIO_ES 添加到cast.player.api.CreateHlsStreamingProtocol()。现在流工作正常,Cast 设备不会崩溃或冻结。

【讨论】:

以上是关于投射音频流时投射设备冻结的主要内容,如果未能解决你的问题,请参考以下文章

Chromecast 是不是支持从 Android 设备进行屏幕投射?

如何从 Android 应用程序中发现 Roku 设备以进行投射

Android - 检测投射设备的类型

从发送方应用程序连接投射设备后如何放置自定义图像? (安卓应用)

是否可以将来自电话麦克风的输入投射到接收器?

如何从颤振应用程序中投射屏幕?