ME_Kun_Han
Committed by winlin

fixed bug: video rendering in hls stream generates only vertical parttern (#841)

@@ -3039,6 +3039,7 @@ int SrsTsCache::do_cache_avc(SrsAvcAacCodec* codec, SrsCodecSample* sample) @@ -3039,6 +3039,7 @@ int SrsTsCache::do_cache_avc(SrsAvcAacCodec* codec, SrsCodecSample* sample)
3039 video->payload->append((const char*)default_aud_nalu, 2); 3039 video->payload->append((const char*)default_aud_nalu, 2);
3040 } 3040 }
3041 3041
  3042 + bool is_sps_pps_appended = false;
3042 // all sample use cont nalu header, except the sps-pps before IDR frame. 3043 // all sample use cont nalu header, except the sps-pps before IDR frame.
3043 for (int i = 0; i < sample->nb_sample_units; i++) { 3044 for (int i = 0; i < sample->nb_sample_units; i++) {
3044 SrsCodecSampleUnit* sample_unit = &sample->sample_units[i]; 3045 SrsCodecSampleUnit* sample_unit = &sample->sample_units[i];
@@ -3056,7 +3057,7 @@ int SrsTsCache::do_cache_avc(SrsAvcAacCodec* codec, SrsCodecSample* sample) @@ -3056,7 +3057,7 @@ int SrsTsCache::do_cache_avc(SrsAvcAacCodec* codec, SrsCodecSample* sample)
3056 3057
3057 // Insert sps/pps before IDR when there is no sps/pps in samples. 3058 // Insert sps/pps before IDR when there is no sps/pps in samples.
3058 // The sps/pps is parsed from sequence header(generally the first flv packet). 3059 // The sps/pps is parsed from sequence header(generally the first flv packet).
3059 - if (nal_unit_type == SrsAvcNaluTypeIDR && !sample->has_sps_pps) { 3060 + if (nal_unit_type == SrsAvcNaluTypeIDR && !sample->has_sps_pps && !is_sps_pps_appended) {
3060 if (codec->sequenceParameterSetLength > 0) { 3061 if (codec->sequenceParameterSetLength > 0) {
3061 srs_avc_insert_aud(video->payload, aud_inserted); 3062 srs_avc_insert_aud(video->payload, aud_inserted);
3062 video->payload->append(codec->sequenceParameterSetNALUnit, codec->sequenceParameterSetLength); 3063 video->payload->append(codec->sequenceParameterSetNALUnit, codec->sequenceParameterSetLength);
@@ -3065,6 +3066,7 @@ int SrsTsCache::do_cache_avc(SrsAvcAacCodec* codec, SrsCodecSample* sample) @@ -3065,6 +3066,7 @@ int SrsTsCache::do_cache_avc(SrsAvcAacCodec* codec, SrsCodecSample* sample)
3065 srs_avc_insert_aud(video->payload, aud_inserted); 3066 srs_avc_insert_aud(video->payload, aud_inserted);
3066 video->payload->append(codec->pictureParameterSetNALUnit, codec->pictureParameterSetLength); 3067 video->payload->append(codec->pictureParameterSetNALUnit, codec->pictureParameterSetLength);
3067 } 3068 }
  3069 + is_sps_pps_appended = true;
3068 } 3070 }
3069 3071
3070 // Insert the NALU to video in annexb. 3072 // Insert the NALU to video in annexb.