summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib.c35
-rw-r--r--src/main.c11
2 files changed, 22 insertions, 24 deletions
diff --git a/src/lib.c b/src/lib.c
index 4a3d4df..f252d1f 100644
--- a/src/lib.c
+++ b/src/lib.c
@@ -22,8 +22,7 @@
#include "lib.h"
-static void
-stp_shutdown_client (TranscodeClientCtx *ctx);
+static void stp_disconnect_cleanup_client (TranscodeClientCtx *ctx);
gboolean
stp_on_gst_bus_message (GstBus *bus,
@@ -67,13 +66,13 @@ stp_cleanup_transcode_server_ctx (TranscodeServerCtx *ctx)
{
g_print (">>> Doing server cleanup\n");
- g_list_foreach (ctx->clients, (GFunc)stp_shutdown_client, NULL);
+ /* Disconnect and free the context for each client */
+ g_list_foreach (ctx->clients, (GFunc)stp_disconnect_cleanup_client, NULL);
g_list_free (ctx->clients);
/* Cleanup gstreamer pipeline */
gst_element_set_state (ctx->pipeline, GST_STATE_NULL);
gst_object_unref (ctx->pipeline);
- g_free (ctx->path);
g_free (ctx);
}
@@ -92,16 +91,15 @@ pad_blocked_cleanup_cb (GstPad *srcpad,
tee = gst_pad_get_parent_element (srcpad);
gst_pad_unlink (srcpad, ctx->ghostsinkpad);
- gst_element_remove_pad (tee, srcpad);
+ gst_element_release_request_pad (tee, srcpad);
gst_object_unref (srcpad);
gst_object_unref (tee);
gst_element_set_state (sinkbin, GST_STATE_NULL);
gst_bin_remove (GST_BIN (ctx->server_ctx->pipeline), sinkbin);
gst_object_unref (sinkbin);
- gst_object_unref (ctx->appsink);
- g_free (ctx);
+ g_mutex_clear (&ctx->can_write_chunk);
g_print (" Client cleanup done!\n");
return GST_PAD_PROBE_OK;
}
@@ -128,27 +126,26 @@ stp_cleanup_transcode_client_ctx (TranscodeClientCtx *ctx)
gst_pad_add_probe (srcpad, GST_PAD_PROBE_TYPE_BLOCK,
(GstPadProbeCallback) pad_blocked_cleanup_cb,
- ctx, NULL);
+ ctx, (GDestroyNotify)g_free);
gst_object_unref (sinkbin);
g_print (".");
}
-/* When shutting down a client due to a server shutdown, we
- * don't need to bother with removing the appsink branch of
- * the pipeline, and the response is set by the "eos" callback
- * on the appsink, so we just free the context */
+/* When shutting down a client due to a server shutdown,
+ * we just need to remove the client timeout handler and
+ * free the context. The rest is owned by the pipeline. */
static void
-stp_shutdown_client (TranscodeClientCtx *ctx)
+stp_disconnect_cleanup_client (TranscodeClientCtx *ctx)
{
- TranscodeServerCtx *server_ctx = ctx->server_ctx;
+ g_print (">>> Disconnecting client on server shutdown\n");
- g_print (">>> Doing client cleanup on server shutdown\n");
+ /* FIXME: This isn't actually setting the status for client
+ * connections, and clients are just left hanging */
+ soup_message_set_status (ctx->msg, SOUP_STATUS_GONE);
+ soup_message_body_complete (ctx->msg->response_body);
g_source_remove (ctx->timeout_handler_id);
-
- server_ctx->clients = g_list_remove (server_ctx->clients, ctx);
-
- gst_object_unref (ctx->appsink);
+ g_mutex_clear (&ctx->can_write_chunk);
g_free (ctx);
}
diff --git a/src/main.c b/src/main.c
index 10aa6d9..067a34a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -348,9 +348,10 @@ GET:
gst_pad_add_probe (srcpad, GST_PAD_PROBE_TYPE_BLOCK,
(GstPadProbeCallback) tee_src_pad_blocked_cb,
client_ctx, NULL);
+ gst_object_unref (template);
gst_object_unref (srcpad);
+ gst_object_unref (tee);
- gst_object_ref (appsink);
client_ctx->appsink = appsink;
g_signal_connect (appsink, "new-sample",
@@ -399,7 +400,7 @@ got_request_body_chunk (SoupMessage *msg,
if (ret != GST_FLOW_OK) {
g_critical ("Unable to push buffer\n");
soup_message_set_status (msg, SOUP_STATUS_INTERNAL_SERVER_ERROR);
- stp_cleanup_transcode_server_ctx (ctx);
+ g_hash_table_remove (ctx->parent_ctx_table, ctx->path);
return;
}
}
@@ -449,7 +450,7 @@ got_first_request_body_chunk (SoupMessage *msg,
GST_STATE_CHANGE_FAILURE) {
g_critical ("Unable to set pipeline to PLAYING\n");
soup_message_set_status (msg, SOUP_STATUS_INTERNAL_SERVER_ERROR);
- stp_cleanup_transcode_server_ctx (ctx);
+ g_hash_table_remove (ctx->parent_ctx_table, ctx->path);
} else {
g_print ("Set pipeline to PLAYING\n");
}
@@ -605,10 +606,10 @@ GET: {
if (!server_ctx->stream_finished) {
/* Close the PUT stream if necessary */
server_ctx->stream_finished = TRUE;
- soup_message_set_status (server_ctx->msg, SOUP_STATUS_OK);
+ soup_message_set_status (server_ctx->msg, SOUP_STATUS_GONE);
}
/* Disconnect all clients, and shut down the stream */
- stp_cleanup_transcode_server_ctx (server_ctx);
+ g_hash_table_remove (ctx_table, server_ctx->path);
soup_message_set_status (msg, SOUP_STATUS_OK);
goto out;
}