Browse Source

MT#55283 add option `allow no codec media`

Change-Id: I516972d85a26d68b9f9c2a9613294a02448391b6
pull/1870/head
Richard Fuchs 1 year ago
parent
commit
c4b81b644c
9 changed files with 113 additions and 8 deletions
  1. +3
    -3
      daemon/call.c
  2. +6
    -0
      daemon/call_interfaces.c
  3. +4
    -1
      daemon/codec.c
  4. +13
    -2
      daemon/sdp.c
  5. +12
    -0
      docs/ng_control_protocol.md
  6. +1
    -0
      include/call_interfaces.h
  7. +2
    -2
      include/codec.h
  8. +71
    -0
      t/auto-daemon-tests.pl
  9. +1
    -0
      utils/rtpengine-ng-client

+ 3
- 3
daemon/call.c View File

@ -2456,7 +2456,7 @@ static void codecs_offer(struct call_media *media, struct call_media *other_medi
codec_store_offer(&other_media->codecs, &flags->codec_offer, &sp->codecs); codec_store_offer(&other_media->codecs, &flags->codec_offer, &sp->codecs);
if (!other_media->codecs.strip_full) if (!other_media->codecs.strip_full)
codec_store_offer(&other_media->codecs, &flags->codec_transcode, &sp->codecs); codec_store_offer(&other_media->codecs, &flags->codec_transcode, &sp->codecs);
codec_store_check_empty(&other_media->codecs, &sp->codecs);
codec_store_check_empty(&other_media->codecs, &sp->codecs, flags);
codec_store_accept(&other_media->codecs, &flags->codec_accept, NULL); codec_store_accept(&other_media->codecs, &flags->codec_accept, NULL);
codec_store_accept(&other_media->codecs, &flags->codec_consume, &sp->codecs); codec_store_accept(&other_media->codecs, &flags->codec_consume, &sp->codecs);
codec_store_track(&other_media->codecs, &flags->codec_mask); codec_store_track(&other_media->codecs, &flags->codec_mask);
@ -2489,7 +2489,7 @@ static void codecs_offer(struct call_media *media, struct call_media *other_medi
codec_store_strip(&media->codecs, &flags->codec_mask, flags->codec_except); codec_store_strip(&media->codecs, &flags->codec_mask, flags->codec_except);
codec_store_offer(&media->codecs, &flags->codec_offer, &sp->codecs); codec_store_offer(&media->codecs, &flags->codec_offer, &sp->codecs);
codec_store_transcode(&media->codecs, &flags->codec_transcode, &sp->codecs); codec_store_transcode(&media->codecs, &flags->codec_transcode, &sp->codecs);
codec_store_check_empty(&media->codecs, &sp->codecs);
codec_store_check_empty(&media->codecs, &sp->codecs, flags);
codec_store_synthesise(&media->codecs, &other_media->codecs); codec_store_synthesise(&media->codecs, &other_media->codecs);
// update supp codecs based on actions so far // update supp codecs based on actions so far
@ -2535,7 +2535,7 @@ static void codecs_answer(struct call_media *media, struct call_media *other_med
.allow_asymmetric = !!flags->allow_asymmetric_codecs); .allow_asymmetric = !!flags->allow_asymmetric_codecs);
codec_store_strip(&other_media->codecs, &flags->codec_strip, flags->codec_except); codec_store_strip(&other_media->codecs, &flags->codec_strip, flags->codec_except);
codec_store_offer(&other_media->codecs, &flags->codec_offer, &sp->codecs); codec_store_offer(&other_media->codecs, &flags->codec_offer, &sp->codecs);
codec_store_check_empty(&other_media->codecs, &sp->codecs);
codec_store_check_empty(&other_media->codecs, &sp->codecs, flags);
// update callee side codec handlers again (second pass after the offer) as we // update callee side codec handlers again (second pass after the offer) as we
// might need to update some handlers, e.g. when supplemental codecs have been // might need to update some handlers, e.g. when supplemental codecs have been


+ 6
- 0
daemon/call_interfaces.c View File

@ -976,6 +976,12 @@ void call_ng_flags_flags(str *s, unsigned int idx, helper_arg arg) {
case CSH_LOOKUP("allow-asymmetric-codec"): case CSH_LOOKUP("allow-asymmetric-codec"):
out->allow_asymmetric_codecs = 1; out->allow_asymmetric_codecs = 1;
break; break;
case CSH_LOOKUP("allow-no-codec-media"):
case CSH_LOOKUP("allow-no-codec-medias"):
case CSH_LOOKUP("allow-empty-codec-media"):
case CSH_LOOKUP("allow-empty-codec-medias"):
out->allow_no_codec_media = 1;
break;
case CSH_LOOKUP("allow-transcoding"): case CSH_LOOKUP("allow-transcoding"):
out->allow_transcoding = 1; out->allow_transcoding = 1;
break; break;


+ 4
- 1
daemon/codec.c View File

@ -5160,10 +5160,13 @@ void __codec_store_populate_reuse(struct codec_store *dst, struct codec_store *s
} }
} }
void codec_store_check_empty(struct codec_store *dst, struct codec_store *src) {
void codec_store_check_empty(struct codec_store *dst, struct codec_store *src, sdp_ng_flags *flags) {
if (dst->codec_prefs.length) if (dst->codec_prefs.length)
return; return;
if (flags->allow_no_codec_media)
return;
ilog(LOG_WARN, "Usage error: List of codecs empty. Restoring original list of codecs. " ilog(LOG_WARN, "Usage error: List of codecs empty. Restoring original list of codecs. "
"Results may be unexpected."); "Results may be unexpected.");


+ 13
- 2
daemon/sdp.c View File

@ -2032,8 +2032,11 @@ static void print_codec_list(GString *s, struct call_media *media) {
return; return;
} }
if (media->codecs.codec_prefs.length == 0)
return; // legacy protocol or usage error
if (media->codecs.codec_prefs.length == 0) {
// legacy protocol, usage error, or allow-no-codec-media set. Print something and bail
g_string_append(s, "0");
return;
}
for (__auto_type l = media->codecs.codec_prefs.head; l; l = l->next) { for (__auto_type l = media->codecs.codec_prefs.head; l; l = l->next) {
rtp_payload_type *pt = l->data; rtp_payload_type *pt = l->data;
@ -3052,6 +3055,14 @@ static struct call_media *sdp_out_set_source_media_address(struct call_media *me
return source_media; return source_media;
} }
// handle special case: allow-no-codec-media
if (flags->allow_no_codec_media && media->codecs.codec_prefs.length == 0
&& proto_is_rtp(media->protocol))
{
// convert to rejected/removed stream
*sdp_address = NULL;
}
return NULL; return NULL;
} }


+ 12
- 0
docs/ng_control_protocol.md View File

@ -883,6 +883,18 @@ Spaces in each string may be replaced by hyphens.
Note that payload type number translation will not be performed in this Note that payload type number translation will not be performed in this
situation. situation.
* `allow no codec media`
Enables special handling for SDP media sections (`m=` lines) that are left
without any codecs after codec manipulation operations (in particular codec
stripping) have been performed. By default without this option set, a media
section without any codecs would be considered a usage error, and the
original list of codecs would be restored so that media flow can be
established. With this option set, a media section without any codecs would
be considered intentionally so, and would be converted to a rejected or
removed media section, that is a media section with a zero port, a dummy
format list, and further attributes.
* `allow transcoding` * `allow transcoding`
This flag is only useful in commands that provide an explicit answer SDP to *rtpengine* This flag is only useful in commands that provide an explicit answer SDP to *rtpengine*


+ 1
- 0
include/call_interfaces.h View File

@ -190,6 +190,7 @@ struct sdp_ng_flags {
single_codec:1, single_codec:1,
reuse_codec:1, reuse_codec:1,
static_codecs:1, static_codecs:1,
allow_no_codec_media:1,
allow_transcoding:1, allow_transcoding:1,
allow_asymmetric_codecs:1, allow_asymmetric_codecs:1,
early_media:1, early_media:1,


+ 2
- 2
include/codec.h View File

@ -141,8 +141,8 @@ __attribute__((nonnull(1, 2)))
void codec_store_strip(struct codec_store *, str_q *strip, str_case_ht except); void codec_store_strip(struct codec_store *, str_q *strip, str_case_ht except);
__attribute__((nonnull(1, 2, 3))) __attribute__((nonnull(1, 2, 3)))
void codec_store_offer(struct codec_store *, str_q *, struct codec_store *); void codec_store_offer(struct codec_store *, str_q *, struct codec_store *);
__attribute__((nonnull(1, 2)))
void codec_store_check_empty(struct codec_store *, struct codec_store *);
__attribute__((nonnull(1, 2, 3)))
void codec_store_check_empty(struct codec_store *, struct codec_store *, sdp_ng_flags *);
__attribute__((nonnull(1, 2))) __attribute__((nonnull(1, 2)))
void codec_store_accept(struct codec_store *, str_q *, struct codec_store *); void codec_store_accept(struct codec_store *, str_q *, struct codec_store *);
__attribute__((nonnull(1, 2))) __attribute__((nonnull(1, 2)))


+ 71
- 0
t/auto-daemon-tests.pl View File

@ -24672,5 +24672,76 @@ $resp = rtpe_req('offer', 'blank line in SDP', { 'from-tag' => ft(), SDP => "v=0
like($resp->{sdp}, qr/\r\na=foobar\r\na=sendrecv\r\na=rtcp:\d+\r\n$/s, 'SDP matches'); like($resp->{sdp}, qr/\r\na=foobar\r\na=sendrecv\r\na=rtcp:\d+\r\n$/s, 'SDP matches');
new_call;
offer('allow-no-codec-media control', {
codec => { strip => ['all'], except => ['PCMA'] },
}, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio 2000 RTP/AVP 8
c=IN IP4 198.51.100.1
a=rtpmap:8 PCMA/8000
a=sendrecv
m=video 3000 RTP/AVP 97
c=IN IP4 198.51.100.1
a=rtpmap:97 H264/90000
a=fmtp:97 profile-level-id=428016;packetization-mode=0;max-mbps=490000;max-fs=8160;max-cpb=200;max-dpb=16320;max-br=5000;max-smbps=490000;max-fps=6000
a=sendrecv
----------------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio PORT RTP/AVP 8
c=IN IP4 203.0.113.1
a=rtpmap:8 PCMA/8000
a=sendrecv
a=rtcp:PORT
m=video PORT RTP/AVP 97
c=IN IP4 203.0.113.1
a=rtpmap:97 H264/90000
a=fmtp:97 profile-level-id=428016;packetization-mode=0;max-mbps=490000;max-fs=8160;max-cpb=200;max-dpb=16320;max-br=5000;max-smbps=490000;max-fps=6000
a=sendrecv
a=rtcp:PORT
SDP
new_call;
offer('allow-no-codec-media control', {
codec => { strip => ['all'], except => ['PCMA'] },
flags => ['allow no codec media'],
}, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio 2000 RTP/AVP 8
c=IN IP4 198.51.100.1
a=rtpmap:8 PCMA/8000
a=sendrecv
m=video 3000 RTP/AVP 97
c=IN IP4 198.51.100.1
a=rtpmap:97 H264/90000
a=fmtp:97 profile-level-id=428016;packetization-mode=0;max-mbps=490000;max-fs=8160;max-cpb=200;max-dpb=16320;max-br=5000;max-smbps=490000;max-fps=6000
a=sendrecv
----------------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio PORT RTP/AVP 8
c=IN IP4 203.0.113.1
a=rtpmap:8 PCMA/8000
a=sendrecv
a=rtcp:PORT
m=video 0 RTP/AVP 0
c=IN IP4 0.0.0.0
SDP
#done_testing;NGCP::Rtpengine::AutoTest::terminate('f00');exit; #done_testing;NGCP::Rtpengine::AutoTest::terminate('f00');exit;
done_testing(); done_testing();

+ 1
- 0
utils/rtpengine-ng-client View File

@ -54,6 +54,7 @@ my @flags = qw(
recording-vsc recording-vsc
block-egress block-egress
directional directional
allow-no-codec-media
); );
my @string_opts = qw( my @string_opts = qw(


Loading…
Cancel
Save