From 6a59214ddcdd63f7576e379834237d1ec0b92430 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Wed, 9 Jul 2014 19:59:55 +0530 Subject: appsrc: Queue an EOS when aborted too --- src/main.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/main.c b/src/main.c index 1ee754c..1a710ed 100644 --- a/src/main.c +++ b/src/main.c @@ -114,6 +114,7 @@ write_next_client_chunk_cb (SoupMessage *msg, GstMemory *memory; gboolean eos; + g_print ("*"); g_signal_emit_by_name (ctx->appsink, "pull-sample", &sample); if (!sample) { g_print ("Null sample, ending stream\n"); @@ -160,10 +161,26 @@ static void client_finished_cb (SoupMessage *msg, TranscodeClientCtx *ctx) { + g_print ("Client finished/aborted, doing cleanup...\n"); stp_cleanup_transcode_client_ctx (ctx); } static void +stream_finished_cb (SoupMessage *msg, + TranscodeServerCtx *ctx) +{ + gboolean ret; + + g_print ("Stream finished/aborted, sending EOS...\n"); + + ctx->request_finished = TRUE; + /* Incoming stream has ended */ + g_signal_emit_by_name (ctx->appsrc, "end-of-stream", &ret); + if (!ret) + g_printerr ("Unable to emit end-of-stream after an aborted stream\n"); +} + +static void handle_request_cb (SoupServer *server, SoupMessage *msg, const char *path, @@ -404,6 +421,10 @@ PUT: { g_signal_connect (msg, "got-chunk", G_CALLBACK (got_request_body_chunk), ctx); + /* This will also be called when the client sending + * the PUT request disconnects prematurely */ + g_signal_connect (msg, "finished", + G_CALLBACK (stream_finished_cb), ctx); goto out; } -- cgit v0.11.2-2-gd1dd