Commit 7f2a62ba authored by Ghislain MARY's avatar Ghislain MARY

Add collection of some statistics in TURN.

parent 4f58b90a
......@@ -199,6 +199,10 @@ typedef struct {
struct sockaddr *turn_server_addr;
socklen_t turn_server_addrlen;
bool_t force_rtp_sending_via_relay;
uint32_t stats_nb_send_indication;
uint32_t stats_nb_data_indication;
uint32_t stats_nb_received_channel_msg;
uint32_t stats_nb_sent_channel_msg;
} MSTurnContext;
......
......@@ -1370,6 +1370,7 @@ static int ms_turn_rtp_endpoint_recvfrom(RtpTransport *rtptp, mblk_t *msg, int f
uint16_t datasize = ntohs(*(((uint16_t *)msg->b_rptr) + 1));
if ((channel == ms_turn_context_get_channel_number(context)) && (msgsize >= (datasize + 4))) {
msg->b_rptr += 4; /* Unpack the TURN ChannelData message */
context->stats_nb_received_channel_msg++;
}
} else {
/* This is not a RTP packet and not a TURN ChannelData message, try to see if it is a STUN one */
......@@ -1405,6 +1406,7 @@ static int ms_turn_rtp_endpoint_recvfrom(RtpTransport *rtptp, mblk_t *msg, int f
}
/* Overwrite the source address of the packet so that it uses the peer address instead of the TURN server one */
ms_stun_address_to_sockaddr(stun_addr, from, fromlen);
if (msgsize > 0) context->stats_nb_data_indication++;
}
}
ms_stun_message_destroy(stun_msg);
......@@ -1453,6 +1455,7 @@ static int ms_turn_rtp_endpoint_sendto(RtpTransport *rtptp, mblk_t *msg, int fla
mblk_meta_copy(msg, new_msg);
concatb(new_msg, msg);
msg = new_msg;
context->stats_nb_sent_channel_msg++;
} else {
/* Use a TURN send indication to encapsulate the data to be sent */
MSStunAddress stun_addr;
......@@ -1471,6 +1474,7 @@ static int ms_turn_rtp_endpoint_sendto(RtpTransport *rtptp, mblk_t *msg, int fla
len = ms_stun_message_encode(stun_msg, &buf);
msgappend(msg, buf, len, FALSE);
ms_free(buf);
context->stats_nb_send_indication++;
}
to = (const struct sockaddr *)context->turn_server_addr;
tolen = context->turn_server_addrlen;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment