Commit 4e9a97bd authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Print the stream routes when stopping streaming if ICE has completed successfully.

parent bd4216cd
...@@ -490,6 +490,14 @@ void ice_handle_stun_packet(IceCheckList* cl, const RtpSession* rtp_session, con ...@@ -490,6 +490,14 @@ void ice_handle_stun_packet(IceCheckList* cl, const RtpSession* rtp_session, con
*/ */
MS2_PUBLIC void ice_get_remote_addr_and_ports_from_valid_pairs(const IceCheckList* cl, char* addr, int addr_len, int* rtp_port, int* rtcp_port); MS2_PUBLIC void ice_get_remote_addr_and_ports_from_valid_pairs(const IceCheckList* cl, char* addr, int addr_len, int* rtp_port, int* rtcp_port);
/**
* Print the route used to send the stream if the ICE process has finished successfully.
*
* @param cl A pointer to a check list
* @param message A message to print before the route
*/
MS2_PUBLIC void ice_check_list_print_route(const IceCheckList *cl, const char *message);
/** /**
* Dump an ICE session in the traces (debug function). * Dump an ICE session in the traces (debug function).
*/ */
......
...@@ -795,6 +795,7 @@ void audio_stream_stop(AudioStream * stream) ...@@ -795,6 +795,7 @@ void audio_stream_stop(AudioStream * stream)
ms_ticker_detach(stream->ticker,stream->soundread); ms_ticker_detach(stream->ticker,stream->soundread);
ms_ticker_detach(stream->ticker,stream->rtprecv); ms_ticker_detach(stream->ticker,stream->rtprecv);
if (stream->ice_check_list != NULL) ice_check_list_print_route(stream->ice_check_list, "Audio session's route");
rtp_stats_display(rtp_session_get_stats(stream->session),"Audio session's RTP statistics"); rtp_stats_display(rtp_session_get_stats(stream->session),"Audio session's RTP statistics");
/*dismantle the outgoing graph*/ /*dismantle the outgoing graph*/
......
...@@ -1991,7 +1991,7 @@ static MSList * ice_get_valid_pairs(const IceCheckList *cl) ...@@ -1991,7 +1991,7 @@ static MSList * ice_get_valid_pairs(const IceCheckList *cl)
return valid_pairs; return valid_pairs;
} }
static void ice_get_addr_and_ports_from_valid_pair(const IceCandidatePair *pair, Addr_Ports *addr_ports) static void ice_get_remote_addr_and_ports_from_valid_pair(const IceCandidatePair *pair, Addr_Ports *addr_ports)
{ {
if (pair->local->componentID == 1) { if (pair->local->componentID == 1) {
strncpy(addr_ports->addr, pair->remote->taddr.ip, addr_ports->addr_len); strncpy(addr_ports->addr, pair->remote->taddr.ip, addr_ports->addr_len);
...@@ -2001,17 +2001,57 @@ static void ice_get_addr_and_ports_from_valid_pair(const IceCandidatePair *pair, ...@@ -2001,17 +2001,57 @@ static void ice_get_addr_and_ports_from_valid_pair(const IceCandidatePair *pair,
} }
} }
void ice_get_remote_addr_and_ports_from_valid_pairs(const IceCheckList* cl, char* addr, int addr_len, int* rtp_port, int* rtcp_port) { void ice_get_remote_addr_and_ports_from_valid_pairs(const IceCheckList *cl, char *addr, int addr_len, int *rtp_port, int *rtcp_port)
{
Addr_Ports addr_ports; Addr_Ports addr_ports;
MSList *ice_pairs = ice_get_valid_pairs(cl); MSList *ice_pairs = ice_get_valid_pairs(cl);
addr_ports.addr = addr; addr_ports.addr = addr;
addr_ports.addr_len = addr_len; addr_ports.addr_len = addr_len;
addr_ports.rtp_port = rtp_port; addr_ports.rtp_port = rtp_port;
addr_ports.rtcp_port = rtcp_port; addr_ports.rtcp_port = rtcp_port;
ms_list_for_each2(ice_pairs, (void (*)(void*,void*))ice_get_addr_and_ports_from_valid_pair, &addr_ports); ms_list_for_each2(ice_pairs, (void (*)(void*,void*))ice_get_remote_addr_and_ports_from_valid_pair, &addr_ports);
ms_list_free(ice_pairs); ms_list_free(ice_pairs);
} }
static void ice_get_local_addr_and_ports_from_valid_pair(const IceCandidatePair *pair, Addr_Ports *addr_ports)
{
if (pair->local->componentID == 1) {
strncpy(addr_ports->addr, pair->local->taddr.ip, addr_ports->addr_len);
*(addr_ports->rtp_port) = pair->local->taddr.port;
} else if (pair->local->componentID == 2) {
*(addr_ports->rtcp_port) = pair->local->taddr.port;
}
}
static void ice_get_local_addr_and_ports_from_valid_pairs(const IceCheckList *cl, char *addr, int addr_len, int *rtp_port, int *rtcp_port)
{
Addr_Ports addr_ports;
MSList *ice_pairs = ice_get_valid_pairs(cl);
addr_ports.addr = addr;
addr_ports.addr_len = addr_len;
addr_ports.rtp_port = rtp_port;
addr_ports.rtcp_port = rtcp_port;
ms_list_for_each2(ice_pairs, (void (*)(void*,void*))ice_get_local_addr_and_ports_from_valid_pair, &addr_ports);
ms_list_free(ice_pairs);
}
void ice_check_list_print_route(const IceCheckList *cl, const char *message)
{
char local_addr[64];
char remote_addr[64];
int local_rtp_port, local_rtcp_port;
int remote_rtp_port, remote_rtcp_port;
if (cl->state == ICL_Completed) {
memset(local_addr, '\0', sizeof(local_addr));
memset(remote_addr, '\0', sizeof(remote_addr));
ice_get_remote_addr_and_ports_from_valid_pairs(cl, remote_addr, sizeof(remote_addr), &remote_rtp_port, &remote_rtcp_port);
ice_get_local_addr_and_ports_from_valid_pairs(cl, local_addr, sizeof(local_addr), &local_rtp_port, &local_rtcp_port);
ms_message("%s", message);
ms_message("\tRTP: %s:%u --> %s:%u", local_addr, local_rtp_port, remote_addr, remote_rtp_port);
ms_message("\tRTCP: %s:%u --> %s:%u", local_addr, local_rtcp_port, remote_addr, remote_rtcp_port);
}
}
/****************************************************************************** /******************************************************************************
* DEBUG FUNCTIONS * * DEBUG FUNCTIONS *
*****************************************************************************/ *****************************************************************************/
......
...@@ -594,6 +594,7 @@ video_stream_stop (VideoStream * stream) ...@@ -594,6 +594,7 @@ video_stream_stop (VideoStream * stream)
if (stream->rtprecv) if (stream->rtprecv)
ms_ticker_detach(stream->ticker,stream->rtprecv); ms_ticker_detach(stream->ticker,stream->rtprecv);
if (stream->ice_check_list != NULL) ice_check_list_print_route(stream->ice_check_list, "Video session's route");
rtp_stats_display(rtp_session_get_stats(stream->session),"Video session's RTP statistics"); rtp_stats_display(rtp_session_get_stats(stream->session),"Video session's RTP statistics");
if (stream->source){ if (stream->source){
......
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