diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.c | 16 | ||||
-rw-r--r-- | src/lib.h | 6 | ||||
-rw-r--r-- | src/main.c | 48 |
3 files changed, 35 insertions, 35 deletions
@@ -48,11 +48,11 @@ stp_on_gst_bus_message (GstBus *bus, g_hash_table_remove (ctx->parent_ctx_table, ctx->path); break; case GST_MESSAGE_EOS: - g_print ("End of file\n"); + g_debug ("End of file\n"); g_hash_table_remove (ctx->parent_ctx_table, ctx->path); break; default: - //g_print ("%s\n", gst_message_type_get_name (msg->type)); + //stp_print_status ("%s\n", gst_message_type_get_name (msg->type)); break; } @@ -65,7 +65,7 @@ stp_on_gst_bus_message (GstBus *bus, void stp_cleanup_transcode_server_ctx (TranscodeServerCtx *ctx) { - g_print (">>> Doing server cleanup\n"); + g_debug (">>> Doing server cleanup\n"); /* Disconnect and free the context for each client */ g_list_foreach (ctx->clients, (GFunc)stp_disconnect_cleanup_client, NULL); @@ -86,7 +86,7 @@ pad_blocked_cleanup_cb (GstPad *srcpad, GstElement *tee; GstElement *sinkbin = GST_ELEMENT (gst_element_get_parent (ctx->appsink)); - g_print ("."); + stp_print_status ("."); /* Remove the probe */ gst_pad_remove_probe (srcpad, GST_PAD_PROBE_INFO_ID (info)); @@ -101,7 +101,7 @@ pad_blocked_cleanup_cb (GstPad *srcpad, gst_object_unref (sinkbin); g_mutex_clear (&ctx->can_write_chunk); - g_print (" Client cleanup done!\n"); + stp_print_status (" Client cleanup done!\n"); return GST_PAD_PROBE_OK; } @@ -116,7 +116,7 @@ stp_cleanup_transcode_client_ctx (TranscodeClientCtx *ctx) TranscodeServerCtx *server_ctx = ctx->server_ctx; GstElement *sinkbin = GST_ELEMENT (gst_element_get_parent (ctx->appsink)); - g_print (">>> Doing client cleanup."); + stp_print_status (">>> Doing client cleanup."); g_source_remove (ctx->timeout_handler_id); @@ -129,7 +129,7 @@ stp_cleanup_transcode_client_ctx (TranscodeClientCtx *ctx) (GstPadProbeCallback) pad_blocked_cleanup_cb, ctx, (GDestroyNotify)g_free); gst_object_unref (sinkbin); - g_print ("."); + stp_print_status ("."); } /* When shutting down a client due to a server shutdown, @@ -138,7 +138,7 @@ stp_cleanup_transcode_client_ctx (TranscodeClientCtx *ctx) static void stp_disconnect_cleanup_client (TranscodeClientCtx *ctx) { - g_print (">>> Disconnecting client on server shutdown\n"); + stp_print_status (">>> Disconnecting client on server shutdown\n"); /* FIXME: This isn't actually setting the status for client * connections, and clients are just left hanging */ @@ -64,6 +64,12 @@ struct _TranscodeClientCtx { TranscodeServerCtx *server_ctx; }; +#ifdef ENCODE_DEBUG +#define stp_print_status(...) g_print(__VA_ARGS__) +#else +#define stp_print_status(...) do {} while (0) +#endif + void stp_cleanup_transcode_server_ctx (TranscodeServerCtx *ctx); void stp_cleanup_transcode_client_ctx (TranscodeClientCtx *ctx); @@ -27,12 +27,6 @@ #include "debug/local-play.h" #endif -#ifdef ENCODE_DEBUG -#define stp_print_status(...) g_print(__VA_ARGS__) -#else -#define stp_print_status(...) do {} while (0) -#endif - static int port = 8000; static int client_timeout = 10; static int server_timeout = 5; @@ -100,7 +94,7 @@ static void client_eos_cb (GstElement *appsink, TranscodeClientCtx *ctx) { - g_print ("Received EOS for client\n"); + g_debug ("Received EOS for client\n"); soup_message_set_status (ctx->msg, SOUP_STATUS_OK); soup_message_body_complete (ctx->msg->response_body); } @@ -139,7 +133,7 @@ write_client_chunk_cb (GstElement *appsink, stp_print_status ("*"); g_signal_emit_by_name (ctx->appsink, "pull-sample", &sample); if (!sample) { - g_print ("Null sample, ending stream\n"); + g_debug ("Null sample, ending stream\n"); g_object_get (ctx->appsink, "eos", &eos, NULL); if (eos) soup_message_set_status (ctx->msg, SOUP_STATUS_OK); @@ -168,7 +162,7 @@ static void client_finished_cb (SoupMessage *msg, TranscodeClientCtx *ctx) { - g_print ("Client finished/aborted, doing cleanup...\n"); + g_debug ("Client finished/aborted, doing cleanup...\n"); stp_cleanup_transcode_client_ctx (ctx); } @@ -178,7 +172,7 @@ stream_finished_cb (SoupMessage *msg, { gboolean ret; - g_print ("Stream finished/aborted, queueing EOS... "); + stp_print_status ("Stream finished/aborted, queueing EOS... "); ctx->stream_finished = TRUE; /* Incoming stream has ended */ @@ -186,7 +180,7 @@ stream_finished_cb (SoupMessage *msg, if (ret != GST_FLOW_OK) g_printerr ("\nUnable to emit end-of-stream after an aborted stream\n"); else - g_print ("Done.\n"); + stp_print_status ("Done.\n"); } /* This is called when the entire request body has been read */ @@ -203,7 +197,7 @@ handle_request_cb (SoupServer *server, if (!msg) return; - g_print ("Handling %s request on path %s\n", msg->method, path); + g_debug ("Handling %s request on path %s\n", msg->method, path); if (msg->method == SOUP_METHOD_PUT || msg->method == SOUP_METHOD_POST) @@ -302,7 +296,7 @@ GET: return; } - g_print ("appsink bin state synced successfully\n"); + g_debug ("appsink bin state synced successfully\n"); /* t. ! queue ! appsink */ gst_pad_link (srcpad, client_ctx->ghostsinkpad); @@ -326,7 +320,7 @@ GET: state_change = gst_element_get_state (server_ctx->pipeline, &state, NULL, 1); - g_print ("Pushed buffer. State was %s:%s.\n", + g_debug ("Pushed buffer. State was %s:%s.\n", gst_element_state_change_return_get_name (state_change), gst_element_state_get_name (state)); @@ -401,7 +395,7 @@ static void request_ended_no_body_cb (SoupMessage *msg, TranscodeServerCtx *ctx) { - g_print ("Request ended without a body!\n"); + g_printerr ("Request ended without a body!\n"); g_hash_table_remove (ctx->parent_ctx_table, ctx->path); g_free (ctx); } @@ -444,7 +438,7 @@ got_first_request_body_chunk (SoupMessage *msg, soup_message_set_status (msg, SOUP_STATUS_INTERNAL_SERVER_ERROR); g_hash_table_remove (ctx->parent_ctx_table, ctx->path); } else { - g_print ("Set pipeline to PLAYING\n"); + g_debug ("Set pipeline to PLAYING\n"); } /* Connect a different method for all further chunks */ @@ -472,11 +466,11 @@ got_request_headers (SoupMessage *msg, const char *name, *value; soup_message_headers_iter_init (&iter, msg->request_headers); while (soup_message_headers_iter_next (&iter, &name, &value)) - g_print ("%s: %s\n", name, value); + g_debug ("%s: %s\n", name, value); #endif g_object_get (msg, "uri", &uri, NULL); - g_print ("%s on uri %s\n", msg->method, soup_uri_get_path (uri)); + g_debug ("%s on uri %s\n", msg->method, soup_uri_get_path (uri)); if (msg->method == SOUP_METHOD_PUT || msg->method == SOUP_METHOD_POST) @@ -505,7 +499,7 @@ PUT: { encoding = soup_message_headers_get_encoding (msg->request_headers); switch (encoding) { case SOUP_ENCODING_CHUNKED: - g_print ("Chunked encoding detected!\n"); + g_debug ("Chunked encoding detected!\n"); if (connection_exists) { /* There's already a chunked request streaming on this path */ g_printerr ("Recv duplicate request on the same URI: %s\n", @@ -515,7 +509,7 @@ PUT: { } break; case SOUP_ENCODING_CONTENT_LENGTH: - g_print ("Content-Length encoding detected!\n"); + g_debug ("Content-Length encoding detected!\n"); content_range = soup_message_headers_get_one (msg->request_headers, "Content-Range"); /* TODO: Right now, we don't check if the Content-Range is valid, @@ -545,7 +539,7 @@ PUT: { soup_message_body_set_accumulate (msg->request_body, FALSE); if (connection_exists) { - g_print ("Stream already exists, connecting everything to that...\n"); + g_debug ("Stream already exists, connecting everything to that...\n"); ctx = get_server_ctx_from_msg (msg, ctx_table); if (ctx->stream_finished) { g_printerr ("Recv more data on '%s' after timeout\n", @@ -566,7 +560,7 @@ PUT: { ctx->parent_ctx_table = ctx_table; ctx->path = g_strdup (soup_uri_get_path (uri)); g_hash_table_insert (ctx_table, ctx->path, ctx); - g_print ("New stream on %s!\n", ctx->path); + g_debug ("New stream on %s!\n", ctx->path); g_signal_connect (msg, "got-chunk", G_CALLBACK (got_first_request_body_chunk), ctx); @@ -585,7 +579,7 @@ GET: { if (!g_hash_table_contains (ctx_table, soup_uri_get_path (uri))) { - g_print ("No stream on URI: %s\n", soup_uri_get_path (uri)); + g_printerr ("No stream on URI: %s\n", soup_uri_get_path (uri)); soup_message_set_status (msg, SOUP_STATUS_NOT_FOUND); goto out; } @@ -624,7 +618,7 @@ request_started_cb (SoupServer *server, SoupClientContext *client, GHashTable *ctx_table) { - g_print ("New %s request started\n", msg->method); + g_debug ("New %s request started\n", msg->method); /* SoupMessage is useful only once we have headers, * so we do all initialization there */ @@ -658,7 +652,7 @@ GET: /* Nothing to do */ } - g_print ("%s request read successfully\n", msg->method); + g_debug ("%s request read successfully\n", msg->method); } static void @@ -667,7 +661,7 @@ request_finished_cb (SoupServer *server, SoupClientContext *client, GHashTable *ctx_table) { - g_print ("%s request ended\n", msg->method); + g_debug ("%s request ended\n", msg->method); } static void @@ -676,7 +670,7 @@ request_aborted_cb (SoupServer *server, SoupClientContext *client, GHashTable *ctx_table) { - g_print ("%s request aborted!\n", msg->method); + g_debug ("%s request aborted!\n", msg->method); if (msg->method == SOUP_METHOD_PUT || msg->method == SOUP_METHOD_POST) goto PUT; |