winlin

ensure sequence header is ok when parse avc/aac data

@@ -116,6 +116,13 @@ int SrsCodec::audio_aac_demux(int8_t* data, int size) @@ -116,6 +116,13 @@ int SrsCodec::audio_aac_demux(int8_t* data, int size)
116 memcpy(aac_extra_data, data + stream->pos(), aac_extra_size); 116 memcpy(aac_extra_data, data + stream->pos(), aac_extra_size);
117 } 117 }
118 } else if (aac_packet_type == SrsCodecAudioTypeRawData) { 118 } else if (aac_packet_type == SrsCodecAudioTypeRawData) {
  119 + // ensure the sequence header demuxed
  120 + if (aac_extra_size <= 0 || !aac_extra_data) {
  121 + ret = ERROR_HLS_DECODE_ERROR;
  122 + srs_error("hls decode audio aac failed, sequence header not found. ret=%d", ret);
  123 + return ret;
  124 + }
  125 +
119 // Raw AAC frame data in UI8 [] 126 // Raw AAC frame data in UI8 []
120 // 6.3 Raw Data, aac-iso-13818-7.pdf, page 28 127 // 6.3 Raw Data, aac-iso-13818-7.pdf, page 28
121 } else { 128 } else {
@@ -206,6 +213,13 @@ int SrsCodec::video_avc_demux(int8_t* data, int size) @@ -206,6 +213,13 @@ int SrsCodec::video_avc_demux(int8_t* data, int size)
206 * pictureParameterSetNALUnit 213 * pictureParameterSetNALUnit
207 */ 214 */
208 } else if (avc_packet_type == SrsCodecVideoAVCTypeNALU){ 215 } else if (avc_packet_type == SrsCodecVideoAVCTypeNALU){
  216 + // ensure the sequence header demuxed
  217 + if (avc_extra_size <= 0 || !avc_extra_data) {
  218 + ret = ERROR_HLS_DECODE_ERROR;
  219 + srs_error("hls decode video avc failed, sequence header not found. ret=%d", ret);
  220 + return ret;
  221 + }
  222 +
209 // One or more NALUs (Full frames are required) 223 // One or more NALUs (Full frames are required)
210 // 5.3.4.2.1 Syntax, H.264-AVC-ISO_IEC_14496-15.pdf, page 20 224 // 5.3.4.2.1 Syntax, H.264-AVC-ISO_IEC_14496-15.pdf, page 20
211 int PictureLength = size - stream->pos(); 225 int PictureLength = size - stream->pos();