mgcp/rtp: Refactored packet_duration computation

Since the packet duration is given in ms with the 'ptime' RTP media
attribute and also with the 'p' MGCP local connection option, the
computation is changed to use this value (if present). The
computation assumes, that there are N complete frames in a packet and
takes into account, that the ptime value possibly had been rounded
towards the next ms value (which is never the case with a frame length
of exact 20ms).

Sponsored-by: On-Waves ehf
diff --git a/openbsc/src/libmgcp/mgcp_network.c b/openbsc/src/libmgcp/mgcp_network.c
index 6463ae0..bf205d1 100644
--- a/openbsc/src/libmgcp/mgcp_network.c
+++ b/openbsc/src/libmgcp/mgcp_network.c
@@ -237,10 +237,7 @@
 		state->initialized = 1;
 		state->jitter = 0;
 		state->transit = arrival_time - timestamp;
-		state->packet_duration =
-			rtp_end->rate * rtp_end->frames_per_packet *
-			rtp_end->frame_duration_num /
-			rtp_end->frame_duration_den;
+		state->packet_duration = mgcp_rtp_packet_duration(endp, rtp_end);
 		state->out_stream = state->in_stream;
 		state->out_stream.last_timestamp = timestamp;
 		state->out_stream.ssrc = ssrc - 1; /* force output SSRC change */