aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2023-12-10 06:58:56 +0100
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2024-02-06 03:14:56 +0100
commitfd57bd5f6f8ef53f09dd0755b3244159a6aaf4c0 (patch)
tree120e6797a6f27e7909fef2e3219d5b1aa8099c49 /src
parentd0dbda4106c8edbe3c957e49ecf5a539e54e6f0c (diff)
mgcp_codec_decide: remove redundant lookup
We already did a lookup from conn_src[i] and found a matching codec_conn_dst, no need to do another reverse lookup to end up at the same conn_src[i] codec. Change-Id: Iecc7f22c551fd17b23db434fdb177266407d2621
Diffstat (limited to 'src')
-rw-r--r--src/libosmo-mgcp/mgcp_codec.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/libosmo-mgcp/mgcp_codec.c b/src/libosmo-mgcp/mgcp_codec.c
index d340e1106..4626d035d 100644
--- a/src/libosmo-mgcp/mgcp_codec.c
+++ b/src/libosmo-mgcp/mgcp_codec.c
@@ -431,13 +431,13 @@ int mgcp_codec_decide(struct mgcp_conn_rtp *conn_src, struct mgcp_conn_rtp *conn
* of a match set this codec on both connections. This would be an ideal selection since no codec conversion would be
* required. */
for (i = 0; i < conn_src->end.codecs_assigned; i++) {
- struct mgcp_rtp_codec *codec_conn_dst = mgcp_codec_find_same(conn_dst, &conn_src->end.codecs[i]);
+ struct mgcp_rtp_codec *codec_conn_src = &conn_src->end.codecs[i];
+ struct mgcp_rtp_codec *codec_conn_dst = mgcp_codec_find_same(conn_dst, codec_conn_src);
if (codec_conn_dst) {
/* We found the a codec that is exactly the same (same codec, same payload format etc.) on both
* sides. We now set this codec on both connections. */
conn_dst->end.codec = codec_conn_dst;
- conn_src->end.codec = mgcp_codec_find_same(conn_src, codec_conn_dst);
- OSMO_ASSERT(conn_src->end.codec);
+ conn_src->end.codec = codec_conn_src;
return 0;
}
}
@@ -445,13 +445,12 @@ int mgcp_codec_decide(struct mgcp_conn_rtp *conn_src, struct mgcp_conn_rtp *conn
/* In case we could not find a codec that is exactly the same, let's at least try to find a codec that we are able
* to convert. */
for (i = 0; i < conn_src->end.codecs_assigned; i++) {
- struct mgcp_rtp_codec *codec_conn_dst = codec_find_convertible(conn_dst, &conn_src->end.codecs[i]);
+ struct mgcp_rtp_codec *codec_conn_src = &conn_src->end.codecs[i];
+ struct mgcp_rtp_codec *codec_conn_dst = codec_find_convertible(conn_dst, codec_conn_src);
if (codec_conn_dst) {
- /* We found the a codec that we are able to convert on both sides. We now set this codec on both
- * connections. */
+ /* We found the a codec that we can convert to. Set each side to its codec. */
conn_dst->end.codec = codec_conn_dst;
- conn_src->end.codec = codec_find_convertible(conn_src, codec_conn_dst);
- OSMO_ASSERT(conn_src->end.codec);
+ conn_src->end.codec = codec_conn_src;
return 0;
}
}