mgcp/rtp: Only update RTP header field offsets if enabled

Currently seq_offset and timestamp_offset are updated on each SSRC
change even when SSRC patching is not allowed.

This patch fixes this by changing mgcp_patch_and_count() to only
update these fields when SSRC patching is allowed.

Sponsored-by: On-Waves ehf
This commit is contained in:
Jacob Erlbeck 2013-12-05 11:33:20 +01:00
parent 5e9549e6a9
commit b35a77751b
1 changed files with 29 additions and 17 deletions

View File

@ -248,8 +248,6 @@ void mgcp_patch_and_count(struct mgcp_endpoint *endp, struct mgcp_rtp_state *sta
inet_ntoa(addr->sin_addr), ntohs(addr->sin_port),
endp->conn_mode);
} else if (state->in_stream.ssrc != rtp_hdr->ssrc) {
int32_t tsdelta = state->out_stream.last_tsdelta;
LOGP(DMGCP, LOGL_NOTICE,
"The SSRC changed on 0x%x: %u -> %u "
"from %s:%d in %d\n",
@ -258,22 +256,36 @@ void mgcp_patch_and_count(struct mgcp_endpoint *endp, struct mgcp_rtp_state *sta
inet_ntoa(addr->sin_addr), ntohs(addr->sin_port),
endp->conn_mode);
if (tsdelta == 0) {
tsdelta = rtp_end->rate * rtp_end->frames_per_packet *
rtp_end->frame_duration_num /
rtp_end->frame_duration_den;
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);
}
state->in_stream.ssrc = rtp_hdr->ssrc;
state->seq_offset = (state->out_stream.last_seq + 1) - seq;
state->timestamp_offset =
(state->out_stream.last_timestamp + tsdelta) - timestamp;
state->patch = rtp_end->force_constant_ssrc;
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;
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);
}
state->seq_offset =
(state->out_stream.last_seq + 1) - seq;
state->timestamp_offset =
(state->out_stream.last_timestamp + tsdelta) -
timestamp;
state->patch = 1;
LOGP(DMGCP, LOGL_NOTICE,
"SSRC patching enabled on 0x%x SSRC: %u "
"offset: %d tsdelta: %d "
"from %s:%d in %d\n",
ENDPOINT_NUMBER(endp), state->in_stream.ssrc,
state->seq_offset, tsdelta,
inet_ntoa(addr->sin_addr), ntohs(addr->sin_port),
endp->conn_mode);
}
state->in_stream.last_tsdelta = 0;
} else {