[FFmpeg-devel] [PATCH 16/22] lavfhttpd.c: Detect disconnected clients through amount of bytes written.

Stephan Holljes klaxa1337 at googlemail.com
Fri Jun 1 01:24:09 EEST 2018


Signed-off-by: Stephan Holljes <klaxa1337 at googlemail.com>
---
 lavfhttpd.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lavfhttpd.c b/lavfhttpd.c
index b1e8819..9f56620 100644
--- a/lavfhttpd.c
+++ b/lavfhttpd.c
@@ -120,8 +120,14 @@ int lavfhttpd_accept(void *server, struct HTTPClient **client, int reply_code)
 int lavfhttpd_write(void *server, struct HTTPClient *client, const unsigned char *buf, int size)
 {
     AVIOContext *client_ctx = (AVIOContext*) client->httpd_data;
+    int64_t old_written = client_ctx->written;
+    int64_t actual_written;
     avio_write(client_ctx, buf, size);
     avio_flush(client_ctx);
+    actual_written = client_ctx->written - old_written;
+    if (actual_written < size) {
+        return AVERROR_EOF;
+    }
     return size;
 }
 
-- 
2.16.2



More information about the ffmpeg-devel mailing list