爲了克服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. 將rtsp流轉換爲http流
- 2. 將rtsp視頻流轉換爲http流
- 3. 將http流量轉換爲https的解決方案?代理? (relay)
- 4. 如何將http轉換爲https
- 5. 使用CherryPy將HTTPS轉換爲HTTP
- 6. 將.net durandal SPA從http轉換爲https
- 7. 在將WordPress轉換爲https
- 8. 將網站轉換爲HTTPS?
- 9. 什麼是將http轉爲https?
- 10. 將Web應用程序從HTTP轉換爲OAS上的HTTPS
- 11. 將HTTP請求代碼轉換爲HTTPS請求代碼
- 12. 通過apache將出站http呼叫轉換爲https
- 13. 在android應用程序中將http轉換爲https後的SocketTimeoutException
- 14. 如何將Web服務從HTTP轉換爲HTTPS
- 15. 將HTTP URL轉換爲HTTPS url(只有一個url)
- 16. 將Rackspace Cloud文件轉換爲HTTP到HTTPS的CDN URL
- 17. 將http服務器轉換爲https服務器需要什麼?
- 18. 將cURL轉換爲angularjs $ http
- 19. 將文件轉換爲流
- 20. 將DataTable轉換爲CSV流
- 21. Silverlight:將WriteableBitmap轉換爲流
- 22. 將流轉換爲IRandomAccessStream
- 23. 將回調轉換爲流
- 24. 將流轉換爲對象?
- 25. 將XDocument轉換爲流
- 26. 將JSON流轉換爲CSV
- 27. 將圖像轉換爲流
- 28. 如何將java流轉換爲scala流?
- 29. http轉換爲https轉到無限循環
- 30. 將http更改爲https後,wordpress down https
正如Ben Baron在這裏指出的... https://groups.google.com/forum/#!topic/subsonic-app-developers/xpB14ZgZ75I 我可以在流調用中使用'estimateContentLength = true'內容標題具有轉碼大小以避免使用原始格式 – milleph