summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2014-07-14 14:56:01 (GMT)
committerNirbheek Chauhan <nirbheek@centricular.com>2014-07-14 14:56:01 (GMT)
commitfeee319e6b6cb4774cce72d90d1a60f5ecc9bbda (patch)
tree3145d7f145b1a064c2367a4ea3d55c443c68a38f /src/main.c
parent4ee70eec51b4b536567d570f5545894c9286e00b (diff)
downloadsoup-transcoding-proxy-feee319e6b6cb4774cce72d90d1a60f5ecc9bbda.zip
soup-transcoding-proxy-feee319e6b6cb4774cce72d90d1a60f5ecc9bbda.tar.gz
debug: Make the server less noisy
This is very spammy when we get content-length encoding PUT streams
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c48
1 files changed, 21 insertions, 27 deletions
diff --git a/src/main.c b/src/main.c
index 108b465..30e16c9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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;