aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libmgcp
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2013-12-05 12:02:15 +0100
committerJacob Erlbeck <jerlbeck@sysmocom.de>2013-12-10 11:13:22 +0100
commit30ce42250f56c930872228604edd7dd0836ec77a (patch)
tree94b4c7ad1d79d376838742182b30fe3637f22258 /openbsc/src/libmgcp
parentb35a77751b278c7c81e6cc012df2d113f10b3116 (diff)
mgcp/rtp: Compute default packet duration at state initialisiation
This patch adds a packet_duration field to mgcp_rtp_state which contains the RTP packet's duration in RTP timestamp units or 0, when the duration is unknown or not fixed. Sponsored-by: On-Waves ehf
Diffstat (limited to 'openbsc/src/libmgcp')
-rw-r--r--openbsc/src/libmgcp/mgcp_network.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/openbsc/src/libmgcp/mgcp_network.c b/openbsc/src/libmgcp/mgcp_network.c
index c14b9133b..f177339b4 100644
--- a/openbsc/src/libmgcp/mgcp_network.c
+++ b/openbsc/src/libmgcp/mgcp_network.c
@@ -236,15 +236,19 @@ void mgcp_patch_and_count(struct mgcp_endpoint *endp, struct mgcp_rtp_state *sta
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->out_stream = state->in_stream;
state->out_stream.last_timestamp = timestamp;
/* force output SSRC change */
state->out_stream.ssrc = rtp_hdr->ssrc - 1;
LOGP(DMGCP, LOGL_INFO,
"Initializing stream on 0x%x SSRC: %u timestamp: %u "
- "from %s:%d in %d\n",
+ "pkt-duration: %d, from %s:%d in %d\n",
ENDPOINT_NUMBER(endp), state->in_stream.ssrc,
- state->seq_offset,
+ state->seq_offset, state->packet_duration,
inet_ntoa(addr->sin_addr), ntohs(addr->sin_port),
endp->conn_mode);
} else if (state->in_stream.ssrc != rtp_hdr->ssrc) {
@@ -260,15 +264,14 @@ void mgcp_patch_and_count(struct mgcp_endpoint *endp, struct mgcp_rtp_state *sta
if (rtp_end->force_constant_ssrc) {
int32_t tsdelta = state->out_stream.last_tsdelta;
if (tsdelta == 0) {
- tsdelta = rtp_end->rate * rtp_end->frames_per_packet *
- rtp_end->frame_duration_num /
- rtp_end->frame_duration_den;
+ tsdelta = state->packet_duration;
LOGP(DMGCP, LOGL_NOTICE,
- "Computed timestamp delta %d based on "
- "rate %d, num frames %d, frame duration %d/%d\n",
- tsdelta, rtp_end->rate, rtp_end->frames_per_packet,
- rtp_end->frame_duration_num,
- rtp_end->frame_duration_den);
+ "Timestamp delta is not available on 0x%x, "
+ "using packet duration instead: %d "
+ "from %s:%d in %d\n",
+ ENDPOINT_NUMBER(endp), tsdelta,
+ inet_ntoa(addr->sin_addr), ntohs(addr->sin_port),
+ endp->conn_mode);
}
state->seq_offset =
(state->out_stream.last_seq + 1) - seq;