@@ -3651,6 +3651,19 @@ static void sdp_out_add_media_connection(GString *out, struct call_media *media,
3651
3651
media_conn_address );
3652
3652
}
3653
3653
3654
+ static void sdp_out_add_osrtp_media (GString * out , struct call_media * media ,
3655
+ const struct transport_protocol * prtp , unsigned int port )
3656
+ {
3657
+ g_string_append_printf (out , "m=" STR_FORMAT " %d %s " ,
3658
+ STR_FMT (& media -> type ),
3659
+ port ,
3660
+ prtp -> name );
3661
+
3662
+ /* print codecs and add newline */
3663
+ print_codec_list (out , media );
3664
+ g_string_append_printf (out , "\r\n" );
3665
+ }
3666
+
3654
3667
/**
3655
3668
* TODO: after sdp_replace() is deprecated, move the content of this func
3656
3669
* to `print_sdp_media_section()`.
@@ -3683,6 +3696,7 @@ int sdp_create(str *out, struct call_monologue *monologue, sdp_ng_flags *flags)
3683
3696
{
3684
3697
const char * err = NULL ;
3685
3698
GString * s = NULL ;
3699
+ const struct transport_protocol * prtp = NULL ;
3686
3700
3687
3701
err = "Need at least one media" ;
3688
3702
if (!monologue -> medias -> len )
@@ -3741,6 +3755,25 @@ int sdp_create(str *out, struct call_monologue *monologue, sdp_ng_flags *flags)
3741
3755
if (!rtp_ps -> selected_sfd )
3742
3756
goto err ;
3743
3757
3758
+ prtp = NULL ;
3759
+ if (media -> protocol && media -> protocol -> srtp )
3760
+ prtp = & transport_protocols [media -> protocol -> rtp_proto ];
3761
+
3762
+ if (prtp ) {
3763
+ if (MEDIA_ISSET (media , LEGACY_OSRTP ) && !MEDIA_ISSET (media , LEGACY_OSRTP_REV ))
3764
+ /* generate rejected m= line for accepted legacy OSRTP */
3765
+ sdp_out_add_osrtp_media (s , media , prtp , 0 );
3766
+ else if (flags -> osrtp_offer_legacy && (flags -> opmode == OP_OFFER || flags -> opmode == OP_REQUEST )) {
3767
+ const struct transport_protocol * proto = media -> protocol ;
3768
+ media -> protocol = prtp ;
3769
+
3770
+ sdp_out_add_osrtp_media (s , media , prtp , rtp_ps -> selected_sfd -> socket .local .port );
3771
+ handle_sdp_media_attributes (s , media , rtp_ps , rtp_ps_link , flags );
3772
+
3773
+ media -> protocol = proto ;
3774
+ }
3775
+ }
3776
+
3744
3777
/* set: media type, port, protocol (e.g. RTP/SAVP) */
3745
3778
err = "Unknown media protocol" ;
3746
3779
if (media -> protocol )
@@ -3761,6 +3794,10 @@ int sdp_create(str *out, struct call_monologue *monologue, sdp_ng_flags *flags)
3761
3794
g_string_append_printf (s , "\r\n" );
3762
3795
3763
3796
handle_sdp_media_attributes (s , media , rtp_ps , rtp_ps_link , flags );
3797
+
3798
+ if (prtp && MEDIA_ISSET (media , LEGACY_OSRTP ) && MEDIA_ISSET (media , LEGACY_OSRTP_REV ))
3799
+ /* generate rejected m= line for accepted legacy OSRTP */
3800
+ sdp_out_add_osrtp_media (s , media , prtp , 0 );
3764
3801
}
3765
3802
3766
3803
/* The SDP version gets increased in case:
0 commit comments