TT#128050 parse and document `reuse codecs` flag

Change-Id: I335ed8f699722c568566076190d1a255a6e57211
pull/1346/head
Richard Fuchs 4 years ago
parent 4481c773ac
commit de85d4b674

@ -742,6 +742,13 @@ Optionally included keys are:
and will remove all others from the list. Useful for RTP clients which get confused if
more than one codec is listed in an answer.
- `reuse codecs` or `no codec renegotiation`
Instructs *rtpengine* to prevent endpoints from switching codecs during call run-time
if possible. Codecs that were listed as preferred in the past will be kept as preferred
even if the re-offer lists other codecs as preferred, or in a different order. Recommended
to be combined with `single codec`.
- `all`
Only relevant to the `unblock media` message. Instructs *rtpengine* to remove not only a

@ -2181,11 +2181,10 @@ void codecs_offer_answer(struct call_media *media, struct call_media *other_medi
STR_FMT(&other_media->monologue->tag),
other_media->index);
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);
}
if (flags->reuse_codec)
codec_store_populate_reuse(&other_media->codecs, &sp->codecs, flags->codec_set);
else
codec_store_populate(&other_media->codecs, &sp->codecs, flags->codec_set);
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)
@ -2193,9 +2192,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);
}
} else
codec_store_populate(&other_media->codecs, &sp->codecs, NULL);
// we don't update the answerer side if the offer is not RTP but is going
// to RTP (i.e. T.38 transcoding) - instead we leave the existing codec list
@ -2209,7 +2207,10 @@ void codecs_offer_answer(struct call_media *media, struct call_media *other_medi
ilogs(codec, LOG_DEBUG, "Updating receiver side codecs for answerer " STR_FORMAT " #%u",
STR_FMT(&media->monologue->tag),
media->index);
codec_store_populate(&media->codecs, &sp->codecs, NULL);
if (flags && flags->reuse_codec)
codec_store_populate_reuse(&media->codecs, &sp->codecs, NULL);
else
codec_store_populate(&media->codecs, &sp->codecs, NULL);
}
if (flags) {
codec_store_strip(&media->codecs, &flags->codec_strip, flags->codec_except);
@ -2237,7 +2238,10 @@ void codecs_offer_answer(struct call_media *media, struct call_media *other_medi
ilogs(codec, LOG_DEBUG, "Updating receiver side codecs for answerer " STR_FORMAT " #%u",
STR_FMT(&other_media->monologue->tag),
other_media->index);
codec_store_populate(&other_media->codecs, &sp->codecs, flags->codec_set);
if (flags->reuse_codec)
codec_store_populate_reuse(&other_media->codecs, &sp->codecs, flags->codec_set);
else
codec_store_populate(&other_media->codecs, &sp->codecs, flags->codec_set);
codec_store_strip(&other_media->codecs, &flags->codec_strip, flags->codec_except);
codec_store_offer(&other_media->codecs, &flags->codec_offer, &sp->codecs);

@ -862,6 +862,12 @@ static void call_ng_flags_flags(struct sdp_ng_flags *out, str *s, void *dummy) {
case CSH_LOOKUP("reorder-codecs"):
ilog(LOG_INFO, "Ignoring obsolete flag `reorder-codecs`");
break;
case CSH_LOOKUP("reuse-codecs"):
out->reuse_codec = 1;
break;
case CSH_LOOKUP("no-codec-renegotiation"):
out->reuse_codec = 1;
break;
case CSH_LOOKUP("single-codec"):
out->single_codec = 1;
break;

@ -1459,29 +1459,122 @@ int main(void) {
end();
//reusing_codecs test
flags.reuse_codec = 1;
start();
sdp_pt(0, PCMA, 8000);
sdp_pt(8, PCMU, 8000);
sdp_pt(0, PCMU, 8000);
sdp_pt(8, PCMA, 8000);
sdp_pt(9, PCMA, 8000);
offer();
expect(A, "0/PCMA/8000 8/PCMU/8000 9/PCMA/8000");
expect(A, "0/PCMU/8000 8/PCMA/8000 9/PCMA/8000");
sdp_pt(7, PCMA, 8000);
sdp_pt(0, PCMA, 8000);
sdp_pt(8, PCMU, 8000);
sdp_pt(0, PCMU, 8000);
sdp_pt(8, PCMA, 8000);
answer();
expect(B, "7/PCMA/8000 0/PCMA/8000 8/PCMU/8000");
sdp_pt(0, PCMA, 8000);
sdp_pt(8, PCMU, 8000);
expect(B, "7/PCMA/8000 0/PCMU/8000 8/PCMA/8000");
sdp_pt(0, PCMU, 8000);
sdp_pt(8, PCMA, 8000);
sdp_pt(9, PCMA, 8000);
offer();
expect(A, "0/PCMA/8000 8/PCMU/8000 9/PCMA/8000");
expect(A, "0/PCMU/8000 8/PCMA/8000 9/PCMA/8000");
sdp_pt(7, PCMA, 8000);
sdp_pt(0, PCMA, 8000);
sdp_pt(8, PCMU, 8000);
sdp_pt(0, PCMU, 8000);
sdp_pt(8, PCMA, 8000);
answer();
expect(B, "7/PCMA/8000 0/PCMU/8000 8/PCMA/8000");
end();
start();
sdp_pt(0, PCMU, 8000);
sdp_pt(8, PCMA, 8000);
sdp_pt(9, G722, 8000);
offer();
expect(A, "0/PCMU/8000 8/PCMA/8000 9/G722/8000");
expect(B, "0/PCMU/8000 8/PCMA/8000 9/G722/8000");
sdp_pt(0, PCMU, 8000);
sdp_pt(8, PCMA, 8000);
sdp_pt(9, G722, 8000);
answer();
expect(A, "0/PCMU/8000 8/PCMA/8000 9/G722/8000");
expect(B, "0/PCMU/8000 8/PCMA/8000 9/G722/8000");
sdp_pt(9, G722, 8000);
sdp_pt(8, PCMA, 8000);
sdp_pt(0, PCMU, 8000);
offer();
expect(A, "9/G722/8000 8/PCMA/8000 0/PCMU/8000");
expect(B, "9/G722/8000 8/PCMA/8000 0/PCMU/8000");
sdp_pt(9, G722, 8000);
sdp_pt(8, PCMA, 8000);
sdp_pt(0, PCMU, 8000);
answer();
expect(B, "7/PCMA/8000 0/PCMA/8000 8/PCMU/8000");
expect(A, "9/G722/8000 8/PCMA/8000 0/PCMU/8000");
expect(B, "9/G722/8000 8/PCMA/8000 0/PCMU/8000");
end();
start();
sdp_pt(0, PCMU, 8000);
sdp_pt(8, PCMA, 8000);
sdp_pt(9, G722, 8000);
flags.reuse_codec = 1;
offer();
expect(A, "0/PCMU/8000 8/PCMA/8000 9/G722/8000");
expect(B, "0/PCMU/8000 8/PCMA/8000 9/G722/8000");
sdp_pt(0, PCMU, 8000);
sdp_pt(8, PCMA, 8000);
sdp_pt(9, G722, 8000);
flags.reuse_codec = 1;
answer();
expect(A, "0/PCMU/8000 8/PCMA/8000 9/G722/8000");
expect(B, "0/PCMU/8000 8/PCMA/8000 9/G722/8000");
sdp_pt(9, G722, 8000);
sdp_pt(8, PCMA, 8000);
sdp_pt(0, PCMU, 8000);
flags.reuse_codec = 1;
offer();
expect(A, "0/PCMU/8000 8/PCMA/8000 9/G722/8000");
expect(B, "0/PCMU/8000 8/PCMA/8000 9/G722/8000");
sdp_pt(9, G722, 8000);
sdp_pt(8, PCMA, 8000);
sdp_pt(0, PCMU, 8000);
flags.reuse_codec = 1;
answer();
expect(A, "0/PCMU/8000 8/PCMA/8000 9/G722/8000");
expect(B, "0/PCMU/8000 8/PCMA/8000 9/G722/8000");
end();
start();
sdp_pt(0, PCMU, 8000);
sdp_pt(8, PCMA, 8000);
sdp_pt(9, G722, 8000);
flags.reuse_codec = 1;
flags.single_codec = 1;
offer();
expect(A, "0/PCMU/8000 8/PCMA/8000 9/G722/8000");
expect(B, "0/PCMU/8000 8/PCMA/8000 9/G722/8000");
sdp_pt(0, PCMU, 8000);
sdp_pt(8, PCMA, 8000);
sdp_pt(9, G722, 8000);
flags.reuse_codec = 1;
flags.single_codec = 1;
answer();
expect(A, "0/PCMU/8000");
expect(B, "0/PCMU/8000 8/PCMA/8000 9/G722/8000");
sdp_pt(9, G722, 8000);
sdp_pt(8, PCMA, 8000);
sdp_pt(0, PCMU, 8000);
flags.reuse_codec = 1;
flags.single_codec = 1;
offer();
expect(A, "0/PCMU/8000 9/G722/8000 8/PCMA/8000");
expect(B, "0/PCMU/8000 8/PCMA/8000 9/G722/8000");
sdp_pt(9, G722, 8000);
sdp_pt(8, PCMA, 8000);
sdp_pt(0, PCMU, 8000);
flags.reuse_codec = 1;
flags.single_codec = 1;
answer();
expect(A, "0/PCMU/8000");
expect(B, "0/PCMU/8000 8/PCMA/8000 9/G722/8000");
end();
return 0;
}

Loading…
Cancel
Save