@@ -205,6 +205,7 @@ typedef struct WHIPContext {
205
205
/* Parameters for the input audio and video codecs. */
206
206
AVCodecParameters * audio_par ;
207
207
AVCodecParameters * video_par ;
208
+ uint8_t constraint_set_flags ;
208
209
209
210
/**
210
211
* The h264_mp4toannexb Bitstream Filter (BSF) bypasses the AnnexB packet;
@@ -440,45 +441,30 @@ static av_cold int initialize(AVFormatContext *s)
440
441
static int parse_profile_level (AVFormatContext * s , AVCodecParameters * par )
441
442
{
442
443
int ret = 0 ;
443
- const uint8_t * r = par -> extradata , * r1 , * end = par -> extradata + par -> extradata_size ;
444
- H264SPS seq , * const sps = & seq ;
445
- uint32_t state ;
444
+ const uint8_t * r = par -> extradata ;
446
445
WHIPContext * whip = s -> priv_data ;
447
446
448
447
if (par -> codec_id != AV_CODEC_ID_H264 )
449
448
return ret ;
450
449
451
- if (par -> profile != AV_PROFILE_UNKNOWN && par -> level != AV_LEVEL_UNKNOWN )
452
- return ret ;
453
-
454
450
if (!par -> extradata || par -> extradata_size <= 0 ) {
455
451
av_log (whip , AV_LOG_ERROR , "WHIP: Unable to parse profile from empty extradata=%p, size=%d\n" ,
456
452
par -> extradata , par -> extradata_size );
457
453
return AVERROR (EINVAL );
458
454
}
459
455
460
- while (1 ) {
461
- r = avpriv_find_start_code (r , end , & state );
462
- if (r >= end )
463
- break ;
464
-
465
- r1 = ff_nal_find_startcode (r , end );
466
- if ((state & 0x1f ) == H264_NAL_SPS ) {
467
- ret = ff_avc_decode_sps (sps , r , r1 - r );
468
- if (ret < 0 ) {
469
- av_log (whip , AV_LOG_ERROR , "WHIP: Failed to decode SPS, state=%x, size=%d\n" ,
470
- state , (int )(r1 - r ));
471
- return ret ;
472
- }
473
-
474
- av_log (whip , AV_LOG_VERBOSE , "WHIP: Parse profile=%d, level=%d from SPS\n" ,
475
- sps -> profile_idc , sps -> level_idc );
476
- par -> profile = sps -> profile_idc ;
477
- par -> level = sps -> level_idc ;
478
- }
456
+ if (AV_RB32 (r ) == 0x00000001 && (r [4 ] & 0x1F ) == 7 )
457
+ r = & r [5 ];
458
+ else if (AV_RB24 (r ) == 0x000001 && (r [3 ] & 0x1F ) == 7 )
459
+ r = & r [4 ];
460
+ else if (r [0 ] == 0x01 ) // avcC
461
+ r = & r [1 ];
462
+ else
463
+ return AVERROR (EINVAL );
479
464
480
- r = r1 ;
481
- }
465
+ if (par -> profile == AV_PROFILE_UNKNOWN ) par -> profile = r [0 ];
466
+ whip -> constraint_set_flags = r [1 ];
467
+ if (par -> level == AV_LEVEL_UNKNOWN ) par -> level = r [2 ];
482
468
483
469
return ret ;
484
470
}
@@ -589,7 +575,7 @@ static int parse_codec(AVFormatContext *s)
589
575
*/
590
576
static int generate_sdp_offer (AVFormatContext * s )
591
577
{
592
- int ret = 0 , profile , level , profile_iop ;
578
+ int ret = 0 , profile , level ;
593
579
const char * acodec_name = NULL , * vcodec_name = NULL ;
594
580
AVBPrint bp ;
595
581
WHIPContext * whip = s -> priv_data ;
@@ -657,11 +643,10 @@ static int generate_sdp_offer(AVFormatContext *s)
657
643
}
658
644
659
645
if (whip -> video_par ) {
660
- profile_iop = profile = whip -> video_par -> profile ;
646
+ profile = whip -> video_par -> profile ;
661
647
level = whip -> video_par -> level ;
662
648
if (whip -> video_par -> codec_id == AV_CODEC_ID_H264 ) {
663
649
vcodec_name = "H264" ;
664
- profile_iop = (whip -> video_par -> profile & AV_PROFILE_H264_CONSTRAINED ) ? (1 <<6 ) : 0 ;
665
650
profile &= (~AV_PROFILE_H264_CONSTRAINED );
666
651
}
667
652
@@ -689,7 +674,7 @@ static int generate_sdp_offer(AVFormatContext *s)
689
674
vcodec_name ,
690
675
whip -> video_payload_type ,
691
676
profile ,
692
- profile_iop ,
677
+ whip -> constraint_set_flags ,
693
678
level ,
694
679
whip -> video_ssrc ,
695
680
whip -> video_ssrc );
0 commit comments