neels has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-msc/+/35050?usp=email )

 (

1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted 
one.
 )Change subject: add sdp_audio_codec_to_speech_codec_list()
......................................................................

add sdp_audio_codec_to_speech_codec_list()

Used by I8760feaa8598047369ef8c3ab2673013bac8ac8a to add just a single
codec to a speech codec list, instead of a list.

Change-Id: I6ac23c54bc26939e048ff2df06eb987421cfb1c5
---
M include/osmocom/msc/codec_mapping.h
M src/libmsc/codec_mapping.c
2 files changed, 33 insertions(+), 9 deletions(-)

Approvals:
  fixeria: Looks good to me, but someone else must approve
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified
  laforge: Looks good to me, but someone else must approve
  neels: Looks good to me, approved




diff --git a/include/osmocom/msc/codec_mapping.h 
b/include/osmocom/msc/codec_mapping.h
index 1232d2d..3b502a9 100644
--- a/include/osmocom/msc/codec_mapping.h
+++ b/include/osmocom/msc/codec_mapping.h
@@ -56,6 +56,7 @@
 struct sdp_audio_codec *sdp_audio_codecs_add_mgcp_codec(struct 
sdp_audio_codecs *ac, enum mgcp_codecs mgcp_codec);
 void sdp_audio_codecs_from_bearer_cap(struct sdp_audio_codecs *ac, const 
struct gsm_mncc_bearer_cap *bc);

+int sdp_audio_codec_to_speech_codec_list(struct gsm0808_speech_codec_list 
*scl, const struct sdp_audio_codec *codec);
 void sdp_audio_codecs_to_speech_codec_list(struct gsm0808_speech_codec_list 
*cl, const struct sdp_audio_codecs *ac);
 void sdp_audio_codecs_from_speech_codec_list(struct sdp_audio_codecs *ac, 
const struct gsm0808_speech_codec_list *cl);

diff --git a/src/libmsc/codec_mapping.c b/src/libmsc/codec_mapping.c
index 114abaa..4063514 100644
--- a/src/libmsc/codec_mapping.c
+++ b/src/libmsc/codec_mapping.c
@@ -414,6 +414,24 @@
        }
 }

+/* Append an entry for the given sdp_audio_codec to the 
gsm0808_speech_codec_list.
+ * Return 0 if an entry was added, -ENOENT when there is no mapping to 
gsm0808_speech_codec for the given
+ * sdp_audio_codec, and -ENOSPC when scl is full and nothing could be added. */
+int sdp_audio_codec_to_speech_codec_list(struct gsm0808_speech_codec_list 
*scl, const struct sdp_audio_codec *codec)
+{
+       const struct codec_mapping *m = 
codec_mapping_by_subtype_name(codec->subtype_name);
+       if (!m)
+               return -ENOENT;
+       if (!m->has_gsm0808_speech_codec)
+               return -ENOENT;
+       if (scl->len >= ARRAY_SIZE(scl->codec))
+               return -ENOSPC;
+       scl->codec[scl->len] = m->gsm0808_speech_codec;
+       /* FIXME: apply AMR configuration according to codec->fmtp */
+       scl->len++;
+       return 0;
+}
+
 void sdp_audio_codecs_to_speech_codec_list(struct gsm0808_speech_codec_list 
*scl, const struct sdp_audio_codecs *ac)
 {
        const struct sdp_audio_codec *codec;
@@ -421,16 +439,9 @@
        *scl = (struct gsm0808_speech_codec_list){};

        foreach_sdp_audio_codec(codec, ac) {
-               const struct codec_mapping *m = 
codec_mapping_by_subtype_name(codec->subtype_name);
-               if (!m)
-                       continue;
-               if (!m->has_gsm0808_speech_codec)
-                       continue;
-               if (scl->len >= ARRAY_SIZE(scl->codec))
+               int rc = sdp_audio_codec_to_speech_codec_list(scl, codec);
+               if (rc == -ENOSPC)
                        break;
-               scl->codec[scl->len] = m->gsm0808_speech_codec;
-               /* FIXME: apply AMR configuration according to codec->fmtp */
-               scl->len++;
        }
 }


--
To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/35050?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Change-Id: I6ac23c54bc26939e048ff2df06eb987421cfb1c5
Gerrit-Change-Number: 35050
Gerrit-PatchSet: 4
Gerrit-Owner: neels <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: neels <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to