aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libmgcp/mgcp_transcode.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-06-27 19:27:38 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-07-22 14:42:53 +0200
commitbd4109babcc810c680a76a5bb990a4dbb5264a58 (patch)
tree123e70863cd9e265c1a230de437d2971ae53f77c /openbsc/src/libmgcp/mgcp_transcode.c
parent91eeeae312b3dfc54fc577b437c481811ff60d4a (diff)
mgcp: Document transcoding semantic and follow it
Transcoding from GSM to PCMA can lead to the MGCP MGW sending two PCMA packages with the same sequence number and timestamp. Once with the encoded audio and once completely empty. This is because "state->dst_packet_duration" is 0 in most cases (unless a ptime is forced) and we attempt to encode audio even if there are not enough samples. The encode_audio return will return 0 in that case which is not trated as an error by the mgcp network code. Handle rc == 0 specially and document the semantic.
Diffstat (limited to 'openbsc/src/libmgcp/mgcp_transcode.c')
-rw-r--r--openbsc/src/libmgcp/mgcp_transcode.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/openbsc/src/libmgcp/mgcp_transcode.c b/openbsc/src/libmgcp/mgcp_transcode.c
index 296020c49..ff20fb891 100644
--- a/openbsc/src/libmgcp/mgcp_transcode.c
+++ b/openbsc/src/libmgcp/mgcp_transcode.c
@@ -488,7 +488,14 @@ int mgcp_transcoding_process_rtp(struct mgcp_endpoint *endp,
nsamples = state->sample_cnt;
rc = encode_audio(state, dst, buf_size, max_samples);
- if (rc <= 0)
+ /*
+ * There were no samples to encode?
+ * TODO: how does this work for comfort noise?
+ */
+ if (rc == 0)
+ return -ENOMSG;
+ /* Any other error during the encoding */
+ if (rc < 0)
return rc;
nsamples -= state->sample_cnt;