diff --git a/libs/uni-rtsp/include/rtsp_stream.h b/libs/uni-rtsp/include/rtsp_stream.h index 3557b204..faf2905c 100644 --- a/libs/uni-rtsp/include/rtsp_stream.h +++ b/libs/uni-rtsp/include/rtsp_stream.h @@ -36,6 +36,9 @@ typedef struct rtsp_generator_t rtsp_generator_t; /** Create RTSP stream parser */ RTSP_DECLARE(rtsp_parser_t*) rtsp_parser_create(apr_pool_t *pool); +/** Set verbose mode for the parser */ +RTSP_DECLARE(void) rtsp_parser_verbose_set(rtsp_parser_t * parser, apt_bool_t verbose); + /** Parse RTSP stream */ RTSP_DECLARE(apt_message_status_e) rtsp_parser_run(rtsp_parser_t *parser, apt_text_stream_t *stream, rtsp_message_t **message); @@ -43,6 +46,9 @@ RTSP_DECLARE(apt_message_status_e) rtsp_parser_run(rtsp_parser_t *parser, apt_te /** Create RTSP stream generator */ RTSP_DECLARE(rtsp_generator_t*) rtsp_generator_create(apr_pool_t *pool); +/** Set verbose mode for the generator */ +RTSP_DECLARE(void) rtsp_generator_verbose_set(rtsp_generator_t * generator, apt_bool_t verbose); + /** Generate RTSP stream */ RTSP_DECLARE(apt_message_status_e) rtsp_generator_run(rtsp_generator_t *generator, rtsp_message_t *message, apt_text_stream_t *stream); diff --git a/libs/uni-rtsp/src/rtsp_client.c b/libs/uni-rtsp/src/rtsp_client.c index 5abc1046..9c8757a9 100644 --- a/libs/uni-rtsp/src/rtsp_client.c +++ b/libs/uni-rtsp/src/rtsp_client.c @@ -64,6 +64,11 @@ struct rtsp_client_connection_t { apr_pollfd_t sock_pfd; /** String identifier used for traces */ const char *id; + + /** Transparently dump whatever received/sent on transport layer, + if verbose is set to TRUE (default) */ + apt_bool_t verbose; + /** RTSP client, connection belongs to */ rtsp_client_t *client; @@ -369,6 +374,13 @@ static apt_bool_t rtsp_client_connect(rtsp_client_t *client, rtsp_client_connect return FALSE; } + if (apt_log_masking_get() != APT_LOG_MASKING_NONE) + { + connection->verbose = FALSE; + rtsp_parser_verbose_set(connection->parser, TRUE); + rtsp_generator_verbose_set(connection->generator, TRUE); + } + apt_log(RTSP_LOG_MARK,APT_PRIO_NOTICE,"Established RTSP Connection %s",connection->id); return TRUE; } @@ -398,6 +410,7 @@ static apt_bool_t rtsp_client_connection_create(rtsp_client_t *client, rtsp_clie rtsp_connection = apr_palloc(pool,sizeof(rtsp_client_connection_t)); rtsp_connection->pool = pool; rtsp_connection->sock = NULL; + rtsp_connection->verbose = TRUE; APR_RING_ELEM_INIT(rtsp_connection,link); if(rtsp_client_connect(client,rtsp_connection,session->server_ip.buf,session->server_port) == FALSE) { @@ -834,9 +847,10 @@ static apt_bool_t rtsp_client_message_send(rtsp_client_t *client, rtsp_client_co stream->text.length = stream->pos - stream->text.buf; *stream->pos = '\0'; - apt_log(RTSP_LOG_MARK,APT_PRIO_INFO,"Send RTSP Data %s [%"APR_SIZE_T_FMT" bytes]\n%s", + apt_log(RTSP_LOG_MARK,APT_PRIO_INFO,"Send RTSP Data %s [%"APR_SIZE_T_FMT" bytes]\n%.*s", rtsp_connection->id, stream->text.length, + rtsp_connection->verbose == TRUE ? stream->text.length : 0, stream->text.buf); if(apr_socket_send(rtsp_connection->sock,stream->text.buf,&stream->text.length) == APR_SUCCESS) { status = TRUE; @@ -932,9 +946,10 @@ static apt_bool_t rtsp_client_poller_signal_process(void *obj, const apr_pollfd_ /* calculate actual length of the stream */ stream->text.length = offset + length; stream->pos[length] = '\0'; - apt_log(RTSP_LOG_MARK,APT_PRIO_INFO,"Receive RTSP Data %s [%"APR_SIZE_T_FMT" bytes]\n%s", + apt_log(RTSP_LOG_MARK,APT_PRIO_INFO,"Receive RTSP Data %s [%"APR_SIZE_T_FMT" bytes]\n%.*s", rtsp_connection->id, length, + rtsp_connection->verbose == TRUE ? length : 0, stream->pos); /* reset pos */ diff --git a/libs/uni-rtsp/src/rtsp_server.c b/libs/uni-rtsp/src/rtsp_server.c index 43b36007..2b170f25 100644 --- a/libs/uni-rtsp/src/rtsp_server.c +++ b/libs/uni-rtsp/src/rtsp_server.c @@ -68,6 +68,10 @@ struct rtsp_server_connection_t { /** String identifier used for traces */ const char *id; + /** Transparently dump whatever received/sent on transport layer, + if verbose is set to TRUE (default) */ + apt_bool_t verbose; + /** RTSP server, connection belongs to */ rtsp_server_t *server; @@ -655,9 +659,10 @@ static apt_bool_t rtsp_server_message_send(rtsp_server_t *server, rtsp_server_co stream->text.length = stream->pos - stream->text.buf; *stream->pos = '\0'; - apt_log(RTSP_LOG_MARK,APT_PRIO_INFO,"Send RTSP Data %s [%"APR_SIZE_T_FMT" bytes]\n%s", + apt_log(RTSP_LOG_MARK,APT_PRIO_INFO,"Send RTSP Data %s [%"APR_SIZE_T_FMT" bytes]\n%.*s", rtsp_connection->id, stream->text.length, + rtsp_connection->verbose == TRUE ? stream->text.length : 0, stream->text.buf); if(apr_socket_send(rtsp_connection->sock,stream->text.buf,&stream->text.length) == APR_SUCCESS) { status = TRUE; @@ -782,6 +787,7 @@ static apt_bool_t rtsp_server_connection_accept(rtsp_server_t *server) rtsp_connection->pool = pool; rtsp_connection->sock = NULL; rtsp_connection->client_ip = NULL; + rtsp_connection->verbose = TRUE; APR_RING_ELEM_INIT(rtsp_connection,link); if(apr_socket_accept(&rtsp_connection->sock,server->listen_sock,rtsp_connection->pool) != APR_SUCCESS) { @@ -833,6 +839,13 @@ static apt_bool_t rtsp_server_connection_accept(rtsp_server_t *server) rtsp_connection->pool); } + if (apt_log_masking_get() != APT_LOG_MASKING_NONE) + { + rtsp_connection->verbose = FALSE; + rtsp_parser_verbose_set(rtsp_connection->parser, TRUE); + rtsp_generator_verbose_set(rtsp_connection->generator, TRUE); + } + APR_RING_INSERT_TAIL(&server->connection_list,rtsp_connection,rtsp_server_connection_t,link); if(rtsp_connection->inactivity_timer) { apt_timer_set(rtsp_connection->inactivity_timer,server->inactivity_timeout); @@ -927,9 +940,10 @@ static apt_bool_t rtsp_server_poller_signal_process(void *obj, const apr_pollfd_ /* calculate actual length of the stream */ stream->text.length = offset + length; stream->pos[length] = '\0'; - apt_log(RTSP_LOG_MARK,APT_PRIO_INFO,"Receive RTSP Data %s [%"APR_SIZE_T_FMT" bytes]\n%s", + apt_log(RTSP_LOG_MARK,APT_PRIO_INFO,"Receive RTSP Data %s [%"APR_SIZE_T_FMT" bytes]\n%.*s", rtsp_connection->id, length, + rtsp_connection->verbose == TRUE ? length : 0, stream->pos); /* reset pos */ diff --git a/libs/uni-rtsp/src/rtsp_stream.c b/libs/uni-rtsp/src/rtsp_stream.c index 5d15b137..bd6f21fa 100644 --- a/libs/uni-rtsp/src/rtsp_stream.c +++ b/libs/uni-rtsp/src/rtsp_stream.c @@ -57,6 +57,13 @@ RTSP_DECLARE(rtsp_parser_t*) rtsp_parser_create(apr_pool_t *pool) return parser; } +/** Set verbose mode for the parser */ +RTSP_DECLARE(void) rtsp_parser_verbose_set(rtsp_parser_t * parser, apt_bool_t verbose) +{ + apt_message_parser_verbose_set(parser->base, verbose); +} + + /** Parse RTSP stream */ RTSP_DECLARE(apt_message_status_e) rtsp_parser_run(rtsp_parser_t *parser, apt_text_stream_t *stream, rtsp_message_t **message) { @@ -105,6 +112,11 @@ RTSP_DECLARE(rtsp_generator_t*) rtsp_generator_create(apr_pool_t *pool) return generator; } +/** Set verbose mode for the generator */ +RTSP_DECLARE(void) rtsp_generator_verbose_set(rtsp_generator_t * generator, apt_bool_t verbose) +{ + apt_message_generator_verbose_set(generator->base, verbose); +} /** Generate RTSP stream */ RTSP_DECLARE(apt_message_status_e) rtsp_generator_run(rtsp_generator_t *generator, rtsp_message_t *message, apt_text_stream_t *stream)