Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support log masking for MRCPv1 #318

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions libs/uni-rtsp/include/rtsp_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,19 @@ 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);


/** 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);

Expand Down
19 changes: 17 additions & 2 deletions libs/uni-rtsp/src/rtsp_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down
18 changes: 16 additions & 2 deletions libs/uni-rtsp/src/rtsp_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 */
Expand Down
12 changes: 12 additions & 0 deletions libs/uni-rtsp/src/rtsp_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down