为了克服Chromecast对从自认证的https服务器(在我的情况下为Subsonic音乐服务器)流式传输的限制,我利用了已作为Android应用程序的一部分运行的NanoHTTPD服务器实例。想法是从Subsonic服务器(SSL)进行流式传输,并将该流连接到NanoHTTP的新流(非SSL)。响应返回到Chromecast。我有从Subsonic服务器(它通过MediaPlayer播放)的输入流工作,但不知道如何重新流未加密的以下呼叫:new NanoHTTPD.Response(NanoHTTPD.Response.Status.OK, "audio/mpeg", newStream);
因此,简而言之,如何转换https加密音频流动解密音频流?NanoHTTPD - 将https流转换为http
2
A
回答
0
好吧,设法让所有这些工作。使用https的Subsonic服务器,可通过Android和Chromecast使用服务器的自签名证书进行访问。如果https处于打开状态,则Android和Chromecast都会使用在Android客户端上运行的nanohttpd代理服务器分别流向Android MediaPlayer和html5音频元素。在Android上运行nanohttpd服务器的服务功能覆盖包含以下代码: -
int filesize = .... obtained from Subsonic server for the track to be played
// establish the https connection using the self-signed certificate
// placed in the Android assets folder (code not shown here)
HttpURLConnection con = _getConnection(subsonic_url,"subsonic.cer")
// Establish the InputStream from the Subsonic server and
// the Piped Streams for re-serving the unencrypted data
// back to the requestor
final InputStream is = con.getInputStream();
PipedInputStream sink = new PipedInputStream();
final PipedOutputStream source = new PipedOutputStream(sink);
// On a separate thread, read from Subsonic and write to the pipe
Thread t = new Thread(new Runnable() {
public void run() {
try {
byte[] b = new byte[1024];
int len;
while ((len = is.read(b,0,1024)) != -1)
source.write(b, 0, len);
source.flush();
}
catch (IOException e) {
}
}});
t.start();
sleep(200); // just to let the PipedOutputStream start up
// Return the PipedInputStream to the requestor.
// Important to have the filesize argument
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.OK,
"audio/mpeg", sink, filesize);
我发现流FLAC文件与MP3转码给我的后手文件大小,但当然MP3流。这被证明很难处理html5音频元素,所以我恢复为将subsonic api调用格式=原始格式添加到流中。因此,无论用户通过https配置流式原始格式,它在测试中似乎都运行良好。
相关问题
- 1. https转换为http
- 2. 将rtsp流转换为http流
- 3. 将http流量转换为https的解决方案?代理? (relay)
- 4. Apache层问题将https转换为http
- 5. 将.net durandal SPA从http转换为https
- 6. 如何将http转换为https
- 7. 使用CherryPy将HTTPS转换为HTTP
- 8. 将http切换为https
- 9. 从https转换回http http
- 10. 将网站转换为HTTPS?
- 11. 在将WordPress转换为https
- 12. 转换为HTTPS
- 13. 什么是将http转为https?
- 14. 将现有的ASP.NET网站从HTTP转换为HTTPS
- 15. 通过apache将出站http呼叫转换为https
- 16. 将HTTP请求代码转换为HTTPS请求代码
- 17. 将Web应用程序从HTTP转换为OAS上的HTTPS
- 18. 将Rackspace Cloud文件转换为HTTP到HTTPS的CDN URL
- 19. 使用mod_rewrite将'https://'请求转换为'http://'
- 20. 将http服务器转换为https服务器需要什么?
- 21. 在android应用程序中将http转换为https后的SocketTimeoutException
- 22. 如何将http转换为https facebook应用程序
- 23. 将HTTP URL转换为HTTPS url(只有一个url)
- 24. 如何将Web服务从HTTP转换为HTTPS
- 25. 如何将wcf http web服务转换为https
- 26. Mod_rewrite将HTTP切换到HTTPS
- 27. 将cURL转换为angularjs $ http
- 28. 将回调转换为流
- 29. 将图像转换为流
- 30. 将XDocument转换为流
正如Ben Baron在这里指出的... https://groups.google.com/forum/#!topic/subsonic-app-developers/xpB14ZgZ75I 我可以在流调用中使用'estimateContentLength = true'内容标题具有转码大小以避免使用原始格式 – milleph