TT#128050 Squashed commit of the following:

commit b0c722da69ad088a2eddced12b37c0546a514890
Author: Daniel Hauptmann <dhauptmann@sipwise.com>
Date:   Mon Jul 26 15:35:51 2021 +0200

    changed flag bit length

    in call_interfaces.h changed bit length of reuse_codec from 0 to 1

commit 0313a747532d5987f25fa9edb202aa460bf98dd1
Author: Daniel Hauptmann <dhauptmann@sipwise.com>
Date:   Mon Jul 26 15:29:20 2021 +0200

    inversed reuse_codec logic

    in test-transcode.c and call.c, reuse_codec = 0 (default) will now result in using codec_store_populate instead of codec_store_populate_reuse

commit b876bd686bd30df21a5962aca16fc1c85574f554
Author: Daniel Hauptmann <dhauptmann@sipwise.com>
Date:   Mon Jul 26 15:18:19 2021 +0200

    adding option to minimalize changes in the codec_store_population

    added function codec_store_populate_reuse in codec.c which replaces codec_store_populate but makes fewer changes to the GLists with the old and new codecs
    added flag to enable this feature (disabled by default)

commit 6fd0b701c9589b2fae00300801e02a9b5cc397ab
Author: Daniel Hauptmann <dhauptmann@sipwise.com>
Date:   Mon Jul 26 14:44:42 2021 +0200

    Added Option to minimize change in the codecs

    In codec.c added function to populate codec store with the fewest changes between the old and new GList which contains the codecs.
    Added new testroutine in test-transcode.c line 1500
    Added flag to call_interfaces.h to optionally enable this feature

    Change-Id: If58d9a07d114b05dfb75553a87eb4372ae949fbb

commit 3bf554a8fbae7e948343699f40d935693618b764
Author: Daniel Hauptmann <dhauptmann@sipwise.com>
Date:   Fri Jul 23 13:58:02 2021 +0200

    changing codec-exchange behaviour

    in codec.c line 3288 function codec_store_populate now doesnt empty dst and copy new codec from src to it, instead codecs from src will be appended to dst and codec from dst, which are not
    being contained by src are being removed

Change-Id: Id6b7ee65595f9cc5c71ef557c7bac5ee38f97cbe
pull/1346/head
Daniel Hauptmann 4 years ago committed by Richard Fuchs
parent 08fee992d1
commit 4481c773ac

@ -2180,8 +2180,12 @@ void codecs_offer_answer(struct call_media *media, struct call_media *other_medi
ilogs(codec, LOG_DEBUG, "Updating receiver side codecs for offerer " STR_FORMAT " #%u",
STR_FMT(&other_media->monologue->tag),
other_media->index);
codec_store_populate(&other_media->codecs, &sp->codecs, flags ? flags->codec_set : NULL);
if (flags) {
if (flags->reuse_codec){
codec_store_populate(&other_media->codecs, &sp->codecs, flags ? flags->codec_set : NULL);
}else{
codec_store_populate_reuse(&other_media->codecs, &sp->codecs, flags ? flags->codec_set : NULL);
}
codec_store_strip(&other_media->codecs, &flags->codec_strip, flags->codec_except);
codec_store_offer(&other_media->codecs, &flags->codec_offer, &sp->codecs);
if (!other_media->codecs.strip_full)
@ -2189,6 +2193,8 @@ void codecs_offer_answer(struct call_media *media, struct call_media *other_medi
codec_store_accept(&other_media->codecs, &flags->codec_accept, NULL);
codec_store_accept(&other_media->codecs, &flags->codec_consume, &sp->codecs);
codec_store_track(&other_media->codecs, &flags->codec_mask);
}else{
codec_store_populate(&other_media->codecs, &sp->codecs, flags ? flags->codec_set : NULL);
}
// we don't update the answerer side if the offer is not RTP but is going

@ -3285,6 +3285,38 @@ static void codec_store_add_end(struct codec_store *cs, struct rtp_payload_type
codec_store_add_link(cs, pt, NULL);
}
void codec_store_populate_reuse(struct codec_store *dst, struct codec_store *src, GHashTable *codec_set) {
// start fresh
struct call_media *media = dst->media;
struct call *call = media ? media->call : NULL;
for (GList *l = src->codec_prefs.head; l; l = l->next) {
struct rtp_payload_type *pt = l->data;
struct rtp_payload_type *orig_pt = g_hash_table_lookup(dst->codecs,
GINT_TO_POINTER(pt->payload_type));
ilogs(codec, LOG_DEBUG, "Adding codec " STR_FORMAT " (%i)",
STR_FMT(&pt->encoding_with_params),
pt->payload_type);
if (!orig_pt) {
__codec_options_set(call, pt, codec_set);
codec_store_add_end(dst, pt);
}
}
if(dst->codec_prefs.head){
for (GList *l = dst->codec_prefs.head; l;) {
struct rtp_payload_type *pt = l->data;
struct rtp_payload_type *orig_pt = g_hash_table_lookup(src->codecs,
GINT_TO_POINTER(pt->payload_type));
if(!orig_pt){
l = __codec_store_delete_link(l, dst);
}else{
l = l->next;
}
}
}
}
void codec_store_populate(struct codec_store *dst, struct codec_store *src, GHashTable *codec_set) {
// start fresh
struct codec_store orig_dst;

@ -110,6 +110,7 @@ struct sdp_ng_flags {
loop_protect:1,
original_sendrecv:1,
single_codec:1,
reuse_codec:1,
inject_dtmf:1,
t38_decode:1,
t38_force:1,

@ -88,6 +88,7 @@ void codec_calc_jitter(struct ssrc_ctx *, unsigned long ts, unsigned int clockra
void codec_store_cleanup(struct codec_store *cs);
void codec_store_init(struct codec_store *cs, struct call_media *);
void codec_store_populate(struct codec_store *, struct codec_store *, GHashTable *);
void codec_store_populate_reuse(struct codec_store *, struct codec_store *, GHashTable *);
void codec_store_add_raw(struct codec_store *cs, struct rtp_payload_type *pt);
void codec_store_strip(struct codec_store *, GQueue *strip, GHashTable *except);
void codec_store_offer(struct codec_store *, GQueue *, struct codec_store *);

@ -163,7 +163,6 @@ void config_load(int *argc, char ***argv, GOptionEntry *app_entries, const char
};
#undef ll
// prepend shared CLI options
unsigned int shared_len = options_length(shared_options);
unsigned int app_len = options_length(app_entries);
@ -172,7 +171,6 @@ void config_load(int *argc, char ***argv, GOptionEntry *app_entries, const char
AUTO_CLEANUP(GOptionEntry *entries, free_gopte) = malloc(entries_size);
memcpy(entries, shared_options, sizeof(*entries) * shared_len);
memcpy(&entries[shared_len], app_entries, sizeof(*entries) * (app_len + 1));
AUTO_CLEANUP(GOptionEntry *entries_copy, free_gopte) = malloc(entries_size);
memcpy(entries_copy, entries, entries_size);
@ -180,13 +178,11 @@ void config_load(int *argc, char ***argv, GOptionEntry *app_entries, const char
g_option_context_add_main_entries(c, entries, NULL);
if (!g_option_context_parse(c, argc, argv, &er))
goto err;
if (rtpe_common_config_ptr->config_section) {
use_section = g_strdup(rtpe_common_config_ptr->config_section);
} else {
use_section = g_strdup(default_section);
}
// is there a config file to load?
use_config = default_config;
if (rtpe_common_config_ptr->config_file) {
@ -195,18 +191,15 @@ void config_load(int *argc, char ***argv, GOptionEntry *app_entries, const char
goto out;
fatal = 1;
}
if (!g_key_file_load_from_file(kf, use_config, G_KEY_FILE_NONE, &er)) {
if (!fatal && (g_error_matches(er, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_NOT_FOUND)
|| g_error_matches(er, G_FILE_ERROR, G_FILE_ERROR_NOENT)))
goto out;
goto err;
}
// destroy the option context to reset - we'll do it again later
g_option_context_free(c);
c = NULL;
// iterate the options list and see if the config file defines any.
// free any strings we come across, as we'll load argv back in.
// also keep track of any returned strings so we can free them if

@ -1458,6 +1458,30 @@ int main(void) {
packet_seq(B, 101, "\x05\x07\x07\x80", 4000, 10, 102, "\x05\x07\x2d\x00");
end();
//reusing_codecs test
flags.reuse_codec = 1;
start();
sdp_pt(0, PCMA, 8000);
sdp_pt(8, PCMU, 8000);
sdp_pt(9, PCMA, 8000);
offer();
expect(A, "0/PCMA/8000 8/PCMU/8000 9/PCMA/8000");
sdp_pt(7, PCMA, 8000);
sdp_pt(0, PCMA, 8000);
sdp_pt(8, PCMU, 8000);
answer();
expect(B, "7/PCMA/8000 0/PCMA/8000 8/PCMU/8000");
sdp_pt(0, PCMA, 8000);
sdp_pt(8, PCMU, 8000);
sdp_pt(9, PCMA, 8000);
offer();
expect(A, "0/PCMA/8000 8/PCMU/8000 9/PCMA/8000");
sdp_pt(7, PCMA, 8000);
sdp_pt(0, PCMA, 8000);
sdp_pt(8, PCMU, 8000);
answer();
expect(B, "7/PCMA/8000 0/PCMA/8000 8/PCMU/8000");
end();
return 0;
}

Loading…
Cancel
Save