Skip to content

Commit

Permalink
fixed bug: video rendering in hls stream generates only vertical part…
Browse files Browse the repository at this point in the history
…tern (#841)
  • Loading branch information
SnailTowardThesun authored and winlinvip committed Apr 15, 2017
1 parent b11ddc7 commit bd2a1f9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion trunk/src/kernel/srs_kernel_ts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3039,6 +3039,7 @@ int SrsTsCache::do_cache_avc(SrsAvcAacCodec* codec, SrsCodecSample* sample)
video->payload->append((const char*)default_aud_nalu, 2);
}

bool is_sps_pps_appended = false;
// all sample use cont nalu header, except the sps-pps before IDR frame.
for (int i = 0; i < sample->nb_sample_units; i++) {
SrsCodecSampleUnit* sample_unit = &sample->sample_units[i];
Expand All @@ -3056,7 +3057,7 @@ int SrsTsCache::do_cache_avc(SrsAvcAacCodec* codec, SrsCodecSample* sample)

// Insert sps/pps before IDR when there is no sps/pps in samples.
// The sps/pps is parsed from sequence header(generally the first flv packet).
if (nal_unit_type == SrsAvcNaluTypeIDR && !sample->has_sps_pps) {
if (nal_unit_type == SrsAvcNaluTypeIDR && !sample->has_sps_pps && !is_sps_pps_appended) {
if (codec->sequenceParameterSetLength > 0) {
srs_avc_insert_aud(video->payload, aud_inserted);
video->payload->append(codec->sequenceParameterSetNALUnit, codec->sequenceParameterSetLength);
Expand All @@ -3065,6 +3066,7 @@ int SrsTsCache::do_cache_avc(SrsAvcAacCodec* codec, SrsCodecSample* sample)
srs_avc_insert_aud(video->payload, aud_inserted);
video->payload->append(codec->pictureParameterSetNALUnit, codec->pictureParameterSetLength);
}
is_sps_pps_appended = true;
}

// Insert the NALU to video in annexb.
Expand Down

0 comments on commit bd2a1f9

Please sign in to comment.