library/RTP_Emulation: Close previous socket after rebind

If test calls RTPEM_bind twice, the previous socket is kept open
(ConnId 1) while the new one is assigned to the the expected ConnId for
RTP/RTCP packets received (ConnId), however, if remote was already
sending packets, it may happen that the port still receives those with
ConnId=1, which may make test fail with message:
"Received unexpected type from RTP"

Change-Id: I73f4af4e590dd3958e3f4d1dba0496c0750d642d
This commit is contained in:
Pau Espin 2020-09-08 13:16:14 +02:00 committed by laforge
parent 833174e7fb
commit 08005d7475
2 changed files with 16 additions and 1 deletions

View File

@ -451,6 +451,11 @@ function f_main() runs on OSMUX_Emulation_CT
[] CTRL.getcall(OsmuxEM_bind:{?,?}) -> param(g_local_host, g_local_port) {
g_tx_connected := false; /* will set it back to true upon next connect() call */
if (g_osmux_conn_id != -1) {
res := OSMUX_CodecPort_CtrlFunct.f_IPL4_close(OSMUX, g_osmux_conn_id, {udp := {}});
g_osmux_conn_id := -1;
}
res := OSMUX_CodecPort_CtrlFunct.f_IPL4_listen(OSMUX, g_local_host,
g_local_port, {udp:={}});
if (not ispresent(res.connId)) {

View File

@ -4,7 +4,7 @@ module RTP_Emulation {
* * act as a RTP source that generates a RTP Stream
* * act asaa RTP sink that consumes a RTP Stream
*
* for all of the above, we want to be able to
* for all of the above, we want to be able to
* * specify the payload type
* * specify the interval / sample rate
* * create drop-outs in the stream
@ -387,6 +387,11 @@ function f_main() runs on RTP_Emulation_CT
}
g_tx_connected := false; /* will set it back to true upon next connect() call */
if (g_rtp_conn_id != -1) {
res := RTP_CodecPort_CtrlFunct.f_IPL4_close(RTP, g_rtp_conn_id, {udp := {}});
g_rtp_conn_id := -1;
}
res := RTP_CodecPort_CtrlFunct.f_IPL4_listen(RTP, g_local_host,
g_local_port, {udp:={}});
if (not ispresent(res.connId)) {
@ -395,6 +400,11 @@ function f_main() runs on RTP_Emulation_CT
}
g_rtp_conn_id := res.connId;
tr_rtp.connId := g_rtp_conn_id;
if (g_rtcp_conn_id != -1) {
res := RTP_CodecPort_CtrlFunct.f_IPL4_close(RTCP, g_rtcp_conn_id, {udp := {}});
g_rtcp_conn_id := -1;
}
res := RTP_CodecPort_CtrlFunct.f_IPL4_listen(RTCP, g_local_host,
g_local_port+1, {udp:={}});
if (not ispresent(res.connId)) {