mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2026-05-16 04:52:39 +02:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0a8e96cac8 | |||
| 1e941cf6c5 |
+3
-2
@@ -46,7 +46,8 @@ class HttpFileHandler(method: String, path: String, private val contentType: Str
|
||||
}
|
||||
|
||||
var totalBytesSent = 0
|
||||
val contentLength = end - start + 1
|
||||
val byteReadOffset = if (contentType == "video/webm" && end == 8192L) 0 else 1;
|
||||
val contentLength = end - start + byteReadOffset
|
||||
responseHeaders["Content-Length"] = contentLength.toString()
|
||||
Logger.i(TAG, "Sending $contentLength bytes (start: $start, end: $end)")
|
||||
|
||||
@@ -59,7 +60,7 @@ class HttpFileHandler(method: String, path: String, private val contentType: Str
|
||||
|
||||
val outputStream = responseStream
|
||||
while (true) {
|
||||
val expectedBytesRead = (end - current + 1).coerceAtMost(buffer.size.toLong());
|
||||
val expectedBytesRead = (end - current + byteReadOffset).coerceAtMost(buffer.size.toLong());
|
||||
val bytesRead = inputStream.read(buffer);
|
||||
if (bytesRead < 0) {
|
||||
Logger.i(TAG, "End of file reached")
|
||||
|
||||
@@ -501,14 +501,15 @@ class StateCasting {
|
||||
val id = UUID.randomUUID();
|
||||
val videoPath = "/video-${id}"
|
||||
val videoUrl = url + videoPath;
|
||||
val videoContainer = if (videoSource.container == "application/vnd.apple.mpegurl") "video/mp4" else videoSource.container;
|
||||
|
||||
_castServer.addHandlerWithAllowAllOptions(
|
||||
HttpFileHandler("GET", videoPath, videoSource.container, videoSource.filePath)
|
||||
HttpFileHandler("GET", videoPath, videoContainer, videoSource.filePath)
|
||||
.withHeader("Access-Control-Allow-Origin", "*"), true
|
||||
).withTag("cast");
|
||||
|
||||
Logger.i(TAG, "Casting local video (videoUrl: $videoUrl).");
|
||||
ad.loadVideo("BUFFERED", videoSource.container, videoUrl, resumePosition, video.duration.toDouble(), speed);
|
||||
ad.loadVideo("BUFFERED", videoContainer, videoUrl, resumePosition, video.duration.toDouble(), speed);
|
||||
|
||||
return listOf(videoUrl);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user