@@ -659,7 +659,7 @@ int janus_sdp_get_codec_pt_full(janus_sdp *sdp, const char *codec, const char *p
659659 if (sdp == NULL || codec == NULL )
660660 return -1 ;
661661 /* Check the format string (note that we only parse what browsers can negotiate) */
662- gboolean video = FALSE, vp9 = FALSE, h264 = FALSE;
662+ gboolean video = FALSE, vp9 = FALSE, av1 = FALSE, h264 = FALSE;
663663 const char * format = NULL , * format2 = NULL ;
664664 if (!strcasecmp (codec , "opus" )) {
665665 format = "opus/48000/2" ;
@@ -734,7 +734,7 @@ int janus_sdp_get_codec_pt_full(janus_sdp *sdp, const char *codec, const char *p
734734 if (pt < 0 ) {
735735 JANUS_LOG (LOG_ERR , "Invalid payload type (%s)\n" , a -> value );
736736 } else if (strstr (a -> value , format ) || strstr (a -> value , format2 )) {
737- if (profile != NULL && (vp9 || h264 )) {
737+ if (profile != NULL && (vp9 || h264 || av1 )) {
738738 /* Let's keep track of this payload type */
739739 pts = g_list_append (pts , GINT_TO_POINTER (pt ));
740740 } else {
@@ -790,6 +790,15 @@ int janus_sdp_get_codec_pt_full(janus_sdp *sdp, const char *codec, const char *p
790790 g_list_free (pts );
791791 return pt ;
792792 }
793+ } else if (av1 ) {
794+ char av1_profile [20 ];
795+ g_snprintf (av1_profile , sizeof (profile ), "profile=%s" , profile );
796+ if (strstr (a -> value , av1_profile ) != NULL ) {
797+ /* Found */
798+ JANUS_LOG (LOG_VERB , "AV1 profile %s found --> %d\n" , profile , pt );
799+ g_list_free (pts );
800+ return pt ;
801+ }
793802 }
794803 }
795804 ma = ma -> next ;
@@ -1214,8 +1223,8 @@ janus_sdp *janus_sdp_generate_offer(const char *name, const char *address, ...)
12141223 gboolean do_audio = TRUE, do_video = TRUE, do_data = TRUE,
12151224 audio_dtmf = FALSE, video_rtcpfb = TRUE, data_legacy = TRUE;
12161225 const char * audio_codec = NULL , * video_codec = NULL ,
1217- * vp9_profile = NULL , * h264_profile = NULL ,
1218- * audio_fmtp = NULL , * video_fmtp = NULL ;
1226+ * vp9_profile = NULL , * av1_profile = NULL , * av1_level_idx = NULL ,
1227+ * av1_tier = NULL , * h264_profile = NULL , * audio_fmtp = NULL , * video_fmtp = NULL ;
12191228 int audio_pt = 111 , video_pt = 96 , opusred_pt = 0 ;
12201229 janus_sdp_mdirection audio_dir = JANUS_SDP_SENDRECV , video_dir = JANUS_SDP_SENDRECV ;
12211230 GHashTable * audio_extmaps = NULL , * audio_extids = NULL ,
@@ -1238,6 +1247,12 @@ janus_sdp *janus_sdp_generate_offer(const char *name, const char *address, ...)
12381247 video_codec = va_arg (args , char * );
12391248 } else if (property == JANUS_SDP_OA_VP9_PROFILE ) {
12401249 vp9_profile = va_arg (args , char * );
1250+ } else if (property == JANUS_SDP_OA_AV1_PROFILE ) {
1251+ av1_profile = va_arg (args , char * );
1252+ } else if (property == JANUS_SDP_OA_AV1_LEVEL_IDX ) {
1253+ av1_level_idx = va_arg (args , char * );
1254+ } else if (property == JANUS_SDP_OA_AV1_TIER ) {
1255+ av1_tier = va_arg (args , char * );
12411256 } else if (property == JANUS_SDP_OA_H264_PROFILE ) {
12421257 h264_profile = va_arg (args , char * );
12431258 } else if (property == JANUS_SDP_OA_AUDIO_PT ) {
@@ -1430,6 +1445,13 @@ janus_sdp *janus_sdp_generate_offer(const char *name, const char *address, ...)
14301445 /* Add a profile-id fmtp attribute */
14311446 a = janus_sdp_attribute_create ("fmtp" , "%d profile-id=%s" , video_pt , vp9_profile );
14321447 m -> attributes = g_list_append (m -> attributes , a );
1448+ } else if (!strcasecmp (video_codec , "av1" )) {
1449+ /* Add a profile fmtp attribute */
1450+ a = janus_sdp_attribute_create ("fmtp" , "%d profile=%s;level-idx=%s;tier=%s" ,
1451+ video_pt , av1_profile ? av1_profile : "0" , /* If not present, it MUST be inferred to be 0 ("Main" profile). */
1452+ av1_level_idx ? av1_level_idx : "5" , /* If not present, it MUST be inferred to be 5. */
1453+ av1_tier ? av1_tier : "0" ); /* If not present, it MUST be inferred to be 0. */
1454+ m -> attributes = g_list_append (m -> attributes , a );
14331455 } else if (!strcasecmp (video_codec , "h264" ) && h264_profile ) {
14341456 /* Add a profile-level-id fmtp attribute */
14351457 a = janus_sdp_attribute_create ("fmtp" , "%d profile-level-id=%s;packetization-mode=1" , video_pt , h264_profile );
@@ -1484,8 +1506,8 @@ janus_sdp *janus_sdp_generate_answer(janus_sdp *offer, ...) {
14841506 gboolean do_audio = TRUE, do_video = TRUE, do_data = TRUE,
14851507 audio_dtmf = FALSE, audio_opusred = FALSE, video_rtcpfb = TRUE;
14861508 const char * audio_codec = NULL , * video_codec = NULL ,
1487- * vp9_profile = NULL , * h264_profile = NULL ,
1488- * audio_fmtp = NULL , * video_fmtp = NULL ;
1509+ * vp9_profile = NULL , * av1_profile = NULL , * av1_level_idx = NULL , * av1_tier = NULL ,
1510+ * h264_profile = NULL , * audio_fmtp = NULL , * video_fmtp = NULL ;
14891511 char * custom_audio_fmtp = NULL ;
14901512 GList * extmaps = NULL ;
14911513 janus_sdp_mdirection audio_dir = JANUS_SDP_SENDRECV , video_dir = JANUS_SDP_SENDRECV ;
@@ -1507,6 +1529,12 @@ janus_sdp *janus_sdp_generate_answer(janus_sdp *offer, ...) {
15071529 video_codec = va_arg (args , char * );
15081530 } else if (property == JANUS_SDP_OA_VP9_PROFILE ) {
15091531 vp9_profile = va_arg (args , char * );
1532+ } else if (property == JANUS_SDP_OA_AV1_PROFILE ) {
1533+ av1_profile = va_arg (args , char * );
1534+ } else if (property == JANUS_SDP_OA_AV1_LEVEL_IDX ) {
1535+ av1_level_idx = va_arg (args , char * );
1536+ } else if (property == JANUS_SDP_OA_AV1_TIER ) {
1537+ av1_tier = va_arg (args , char * );
15101538 } else if (property == JANUS_SDP_OA_H264_PROFILE ) {
15111539 h264_profile = va_arg (args , char * );
15121540 } else if (property == JANUS_SDP_OA_AUDIO_DTMF ) {
@@ -1704,6 +1732,8 @@ janus_sdp *janus_sdp_generate_answer(janus_sdp *offer, ...) {
17041732 const char * video_profile = NULL ;
17051733 if (codec && !strcasecmp (codec , "vp9" ))
17061734 video_profile = vp9_profile ;
1735+ else if (codec && !strcasecmp (codec , "av1" ))
1736+ video_profile = av1_profile ;
17071737 else if (codec && !strcasecmp (codec , "h264" ))
17081738 video_profile = h264_profile ;
17091739 int pt = janus_sdp_get_codec_pt_full (offer , codec , video_profile );
@@ -1802,6 +1832,13 @@ janus_sdp *janus_sdp_generate_answer(janus_sdp *offer, ...) {
18021832 /* Add a profile-id fmtp attribute */
18031833 a = janus_sdp_attribute_create ("fmtp" , "%d profile-id=%s" , pt , vp9_profile );
18041834 am -> attributes = g_list_append (am -> attributes , a );
1835+ } else if (!strcasecmp (codec , "av1" )) {
1836+ /* Add a profile fmtp attribute */
1837+ a = janus_sdp_attribute_create ("fmtp" , "%d profile=%s;level-idx=%s;tier=%s" , pt ,
1838+ av1_profile ? av1_profile : "0" ,
1839+ av1_level_idx ? av1_level_idx : "5" ,
1840+ av1_tier ? av1_tier : "0" );
1841+ am -> attributes = g_list_append (am -> attributes , a );
18051842 } else if (!strcasecmp (codec , "h264" ) && h264_profile ) {
18061843 /* Add a profile-level-id fmtp attribute */
18071844 a = janus_sdp_attribute_create ("fmtp" , "%d profile-level-id=%s;packetization-mode=1" , pt , h264_profile );
@@ -1856,6 +1893,7 @@ janus_sdp *janus_sdp_generate_answer(janus_sdp *offer, ...) {
18561893 /* Check if we need to copy the fmtp attribute too */
18571894 if (((!strcasecmp (codec , "vp8" ) && video_fmtp == NULL )) ||
18581895 ((!strcasecmp (codec , "vp9" ) && vp9_profile == NULL && video_fmtp == NULL )) ||
1896+ ((!strcasecmp (codec , "av1" ) && av1_profile == NULL && av1_tier == NULL && av1_level_idx == NULL && video_fmtp == NULL )) ||
18591897 ((!strcasecmp (codec , "h264" ) && h264_profile == NULL && video_fmtp == NULL ))) {
18601898 /* FIXME Copy the fmtp attribute (we should check if we support it) */
18611899 a = janus_sdp_attribute_create ("fmtp" , "%s" , a -> value );
0 commit comments