@@ -659,7 +659,7 @@ int janus_sdp_get_codec_pt_full(janus_sdp *sdp, const char *codec, const char *p
659
659
if (sdp == NULL || codec == NULL )
660
660
return -1 ;
661
661
/* 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;
663
663
const char * format = NULL , * format2 = NULL ;
664
664
if (!strcasecmp (codec , "opus" )) {
665
665
format = "opus/48000/2" ;
@@ -734,7 +734,7 @@ int janus_sdp_get_codec_pt_full(janus_sdp *sdp, const char *codec, const char *p
734
734
if (pt < 0 ) {
735
735
JANUS_LOG (LOG_ERR , "Invalid payload type (%s)\n" , a -> value );
736
736
} else if (strstr (a -> value , format ) || strstr (a -> value , format2 )) {
737
- if (profile != NULL && (vp9 || h264 )) {
737
+ if (profile != NULL && (vp9 || h264 || av1 )) {
738
738
/* Let's keep track of this payload type */
739
739
pts = g_list_append (pts , GINT_TO_POINTER (pt ));
740
740
} else {
@@ -790,6 +790,15 @@ int janus_sdp_get_codec_pt_full(janus_sdp *sdp, const char *codec, const char *p
790
790
g_list_free (pts );
791
791
return pt ;
792
792
}
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
+ }
793
802
}
794
803
}
795
804
ma = ma -> next ;
@@ -1214,8 +1223,8 @@ janus_sdp *janus_sdp_generate_offer(const char *name, const char *address, ...)
1214
1223
gboolean do_audio = TRUE, do_video = TRUE, do_data = TRUE,
1215
1224
audio_dtmf = FALSE, video_rtcpfb = TRUE, data_legacy = TRUE;
1216
1225
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 ;
1219
1228
int audio_pt = 111 , video_pt = 96 , opusred_pt = 0 ;
1220
1229
janus_sdp_mdirection audio_dir = JANUS_SDP_SENDRECV , video_dir = JANUS_SDP_SENDRECV ;
1221
1230
GHashTable * audio_extmaps = NULL , * audio_extids = NULL ,
@@ -1238,6 +1247,12 @@ janus_sdp *janus_sdp_generate_offer(const char *name, const char *address, ...)
1238
1247
video_codec = va_arg (args , char * );
1239
1248
} else if (property == JANUS_SDP_OA_VP9_PROFILE ) {
1240
1249
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 * );
1241
1256
} else if (property == JANUS_SDP_OA_H264_PROFILE ) {
1242
1257
h264_profile = va_arg (args , char * );
1243
1258
} else if (property == JANUS_SDP_OA_AUDIO_PT ) {
@@ -1430,6 +1445,13 @@ janus_sdp *janus_sdp_generate_offer(const char *name, const char *address, ...)
1430
1445
/* Add a profile-id fmtp attribute */
1431
1446
a = janus_sdp_attribute_create ("fmtp" , "%d profile-id=%s" , video_pt , vp9_profile );
1432
1447
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 );
1433
1455
} else if (!strcasecmp (video_codec , "h264" ) && h264_profile ) {
1434
1456
/* Add a profile-level-id fmtp attribute */
1435
1457
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, ...) {
1484
1506
gboolean do_audio = TRUE, do_video = TRUE, do_data = TRUE,
1485
1507
audio_dtmf = FALSE, audio_opusred = FALSE, video_rtcpfb = TRUE;
1486
1508
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 ;
1489
1511
char * custom_audio_fmtp = NULL ;
1490
1512
GList * extmaps = NULL ;
1491
1513
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, ...) {
1507
1529
video_codec = va_arg (args , char * );
1508
1530
} else if (property == JANUS_SDP_OA_VP9_PROFILE ) {
1509
1531
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 * );
1510
1538
} else if (property == JANUS_SDP_OA_H264_PROFILE ) {
1511
1539
h264_profile = va_arg (args , char * );
1512
1540
} else if (property == JANUS_SDP_OA_AUDIO_DTMF ) {
@@ -1704,6 +1732,8 @@ janus_sdp *janus_sdp_generate_answer(janus_sdp *offer, ...) {
1704
1732
const char * video_profile = NULL ;
1705
1733
if (codec && !strcasecmp (codec , "vp9" ))
1706
1734
video_profile = vp9_profile ;
1735
+ else if (codec && !strcasecmp (codec , "av1" ))
1736
+ video_profile = av1_profile ;
1707
1737
else if (codec && !strcasecmp (codec , "h264" ))
1708
1738
video_profile = h264_profile ;
1709
1739
int pt = janus_sdp_get_codec_pt_full (offer , codec , video_profile );
@@ -1802,6 +1832,10 @@ janus_sdp *janus_sdp_generate_answer(janus_sdp *offer, ...) {
1802
1832
/* Add a profile-id fmtp attribute */
1803
1833
a = janus_sdp_attribute_create ("fmtp" , "%d profile-id=%s" , pt , vp9_profile );
1804
1834
am -> attributes = g_list_append (am -> attributes , a );
1835
+ } else if (!strcasecmp (codec , "av1" ) && av1_profile ) {
1836
+ /* Add a profile fmtp attribute */
1837
+ a = janus_sdp_attribute_create ("fmtp" , "%d profile=%s" , pt , av1_profile );
1838
+ am -> attributes = g_list_append (am -> attributes , a );
1805
1839
} else if (!strcasecmp (codec , "h264" ) && h264_profile ) {
1806
1840
/* Add a profile-level-id fmtp attribute */
1807
1841
a = janus_sdp_attribute_create ("fmtp" , "%d profile-level-id=%s;packetization-mode=1" , pt , h264_profile );
@@ -1856,6 +1890,7 @@ janus_sdp *janus_sdp_generate_answer(janus_sdp *offer, ...) {
1856
1890
/* Check if we need to copy the fmtp attribute too */
1857
1891
if (((!strcasecmp (codec , "vp8" ) && video_fmtp == NULL )) ||
1858
1892
((!strcasecmp (codec , "vp9" ) && vp9_profile == NULL && video_fmtp == NULL )) ||
1893
+ ((!strcasecmp (codec , "av1" ) && av1_profile == NULL && av1_tier == NULL && av1_level_idx == NULL && video_fmtp == NULL )) ||
1859
1894
((!strcasecmp (codec , "h264" ) && h264_profile == NULL && video_fmtp == NULL ))) {
1860
1895
/* FIXME Copy the fmtp attribute (we should check if we support it) */
1861
1896
a = janus_sdp_attribute_create ("fmtp" , "%s" , a -> value );
0 commit comments