refine the hls, ignore packet when no sequence header. 2.0.179
正在显示
4 个修改的文件
包含
30 行增加
和
17 行删除
@@ -344,6 +344,7 @@ Remark: | @@ -344,6 +344,7 @@ Remark: | ||
344 | 344 | ||
345 | ### SRS 2.0 history | 345 | ### SRS 2.0 history |
346 | 346 | ||
347 | +* v2.0, 2015-07-20, refine the hls, ignore packet when no sequence header. 2.0.179 | ||
347 | * v2.0, 2015-07-16, for [#441](https://github.com/simple-rtmp-server/srs/issues/441) use 30s timeout for first msg. 2.0.178 | 348 | * v2.0, 2015-07-16, for [#441](https://github.com/simple-rtmp-server/srs/issues/441) use 30s timeout for first msg. 2.0.178 |
348 | * v2.0, 2015-07-14, refine hls disable the time jitter, support not mix monotonically increase. 2.0.177 | 349 | * v2.0, 2015-07-14, refine hls disable the time jitter, support not mix monotonically increase. 2.0.177 |
349 | * v2.0, 2015-07-01, fix [#433](https://github.com/simple-rtmp-server/srs/issues/433) fix the sps parse bug. 2.0.176 | 350 | * v2.0, 2015-07-01, fix [#433](https://github.com/simple-rtmp-server/srs/issues/433) fix the sps parse bug. 2.0.176 |
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
31 | // current release version | 31 | // current release version |
32 | #define VERSION_MAJOR 2 | 32 | #define VERSION_MAJOR 2 |
33 | #define VERSION_MINOR 0 | 33 | #define VERSION_MINOR 0 |
34 | -#define VERSION_REVISION 178 | 34 | +#define VERSION_REVISION 179 |
35 | 35 | ||
36 | // server info. | 36 | // server info. |
37 | #define RTMP_SIG_SRS_KEY "SRS" | 37 | #define RTMP_SIG_SRS_KEY "SRS" |
@@ -423,6 +423,16 @@ SrsAvcAacCodec::~SrsAvcAacCodec() | @@ -423,6 +423,16 @@ SrsAvcAacCodec::~SrsAvcAacCodec() | ||
423 | srs_freep(pictureParameterSetNALUnit); | 423 | srs_freep(pictureParameterSetNALUnit); |
424 | } | 424 | } |
425 | 425 | ||
426 | +bool SrsAvcAacCodec::is_avc_codec_ok() | ||
427 | +{ | ||
428 | + return avc_extra_size > 0 && avc_extra_data; | ||
429 | +} | ||
430 | + | ||
431 | +bool SrsAvcAacCodec::is_aac_codec_ok() | ||
432 | +{ | ||
433 | + return aac_extra_size > 0 && aac_extra_data; | ||
434 | +} | ||
435 | + | ||
426 | int SrsAvcAacCodec::audio_aac_demux(char* data, int size, SrsCodecSample* sample) | 436 | int SrsAvcAacCodec::audio_aac_demux(char* data, int size, SrsCodecSample* sample) |
427 | { | 437 | { |
428 | int ret = ERROR_SUCCESS; | 438 | int ret = ERROR_SUCCESS; |
@@ -441,7 +451,7 @@ int SrsAvcAacCodec::audio_aac_demux(char* data, int size, SrsCodecSample* sample | @@ -441,7 +451,7 @@ int SrsAvcAacCodec::audio_aac_demux(char* data, int size, SrsCodecSample* sample | ||
441 | // audio decode | 451 | // audio decode |
442 | if (!stream->require(1)) { | 452 | if (!stream->require(1)) { |
443 | ret = ERROR_HLS_DECODE_ERROR; | 453 | ret = ERROR_HLS_DECODE_ERROR; |
444 | - srs_error("audio codec decode sound_format failed. ret=%d", ret); | 454 | + srs_error("aac decode sound_format failed. ret=%d", ret); |
445 | return ret; | 455 | return ret; |
446 | } | 456 | } |
447 | 457 | ||
@@ -468,13 +478,13 @@ int SrsAvcAacCodec::audio_aac_demux(char* data, int size, SrsCodecSample* sample | @@ -468,13 +478,13 @@ int SrsAvcAacCodec::audio_aac_demux(char* data, int size, SrsCodecSample* sample | ||
468 | // only support aac | 478 | // only support aac |
469 | if (audio_codec_id != SrsCodecAudioAAC) { | 479 | if (audio_codec_id != SrsCodecAudioAAC) { |
470 | ret = ERROR_HLS_DECODE_ERROR; | 480 | ret = ERROR_HLS_DECODE_ERROR; |
471 | - srs_error("audio codec only support mp3/aac codec. actual=%d, ret=%d", audio_codec_id, ret); | 481 | + srs_error("aac only support mp3/aac codec. actual=%d, ret=%d", audio_codec_id, ret); |
472 | return ret; | 482 | return ret; |
473 | } | 483 | } |
474 | 484 | ||
475 | if (!stream->require(1)) { | 485 | if (!stream->require(1)) { |
476 | ret = ERROR_HLS_DECODE_ERROR; | 486 | ret = ERROR_HLS_DECODE_ERROR; |
477 | - srs_error("audio codec decode aac_packet_type failed. ret=%d", ret); | 487 | + srs_error("aac decode aac_packet_type failed. ret=%d", ret); |
478 | return ret; | 488 | return ret; |
479 | } | 489 | } |
480 | 490 | ||
@@ -497,16 +507,15 @@ int SrsAvcAacCodec::audio_aac_demux(char* data, int size, SrsCodecSample* sample | @@ -497,16 +507,15 @@ int SrsAvcAacCodec::audio_aac_demux(char* data, int size, SrsCodecSample* sample | ||
497 | } | 507 | } |
498 | } else if (aac_packet_type == SrsCodecAudioTypeRawData) { | 508 | } else if (aac_packet_type == SrsCodecAudioTypeRawData) { |
499 | // ensure the sequence header demuxed | 509 | // ensure the sequence header demuxed |
500 | - if (aac_extra_size <= 0 || !aac_extra_data) { | ||
501 | - ret = ERROR_HLS_DECODE_ERROR; | ||
502 | - srs_error("audio codec decode aac failed, sequence header not found. ret=%d", ret); | 510 | + if (!is_aac_codec_ok()) { |
511 | + srs_warn("aac ignore type=%d for no sequence header. ret=%d", aac_packet_type, ret); | ||
503 | return ret; | 512 | return ret; |
504 | } | 513 | } |
505 | 514 | ||
506 | // Raw AAC frame data in UI8 [] | 515 | // Raw AAC frame data in UI8 [] |
507 | // 6.3 Raw Data, aac-iso-13818-7.pdf, page 28 | 516 | // 6.3 Raw Data, aac-iso-13818-7.pdf, page 28 |
508 | if ((ret = sample->add_sample_unit(stream->data() + stream->pos(), stream->size() - stream->pos())) != ERROR_SUCCESS) { | 517 | if ((ret = sample->add_sample_unit(stream->data() + stream->pos(), stream->size() - stream->pos())) != ERROR_SUCCESS) { |
509 | - srs_error("audio codec add sample failed. ret=%d", ret); | 518 | + srs_error("aac add sample failed. ret=%d", ret); |
510 | return ret; | 519 | return ret; |
511 | } | 520 | } |
512 | } else { | 521 | } else { |
@@ -536,7 +545,7 @@ int SrsAvcAacCodec::audio_aac_demux(char* data, int size, SrsCodecSample* sample | @@ -536,7 +545,7 @@ int SrsAvcAacCodec::audio_aac_demux(char* data, int size, SrsCodecSample* sample | ||
536 | }; | 545 | }; |
537 | } | 546 | } |
538 | 547 | ||
539 | - srs_info("audio decoded, type=%d, codec=%d, asize=%d, rate=%d, format=%d, size=%d", | 548 | + srs_info("aac decoded, type=%d, codec=%d, asize=%d, rate=%d, format=%d, size=%d", |
540 | sound_type, audio_codec_id, sound_size, sound_rate, sound_format, size); | 549 | sound_type, audio_codec_id, sound_size, sound_rate, sound_format, size); |
541 | 550 | ||
542 | return ret; | 551 | return ret; |
@@ -636,7 +645,7 @@ int SrsAvcAacCodec::video_avc_demux(char* data, int size, SrsCodecSample* sample | @@ -636,7 +645,7 @@ int SrsAvcAacCodec::video_avc_demux(char* data, int size, SrsCodecSample* sample | ||
636 | // video decode | 645 | // video decode |
637 | if (!stream->require(1)) { | 646 | if (!stream->require(1)) { |
638 | ret = ERROR_HLS_DECODE_ERROR; | 647 | ret = ERROR_HLS_DECODE_ERROR; |
639 | - srs_error("video codec decode frame_type failed. ret=%d", ret); | 648 | + srs_error("avc decode frame_type failed. ret=%d", ret); |
640 | return ret; | 649 | return ret; |
641 | } | 650 | } |
642 | 651 | ||
@@ -650,21 +659,21 @@ int SrsAvcAacCodec::video_avc_demux(char* data, int size, SrsCodecSample* sample | @@ -650,21 +659,21 @@ int SrsAvcAacCodec::video_avc_demux(char* data, int size, SrsCodecSample* sample | ||
650 | // ignore info frame without error, | 659 | // ignore info frame without error, |
651 | // @see https://github.com/simple-rtmp-server/srs/issues/288#issuecomment-69863909 | 660 | // @see https://github.com/simple-rtmp-server/srs/issues/288#issuecomment-69863909 |
652 | if (sample->frame_type == SrsCodecVideoAVCFrameVideoInfoFrame) { | 661 | if (sample->frame_type == SrsCodecVideoAVCFrameVideoInfoFrame) { |
653 | - srs_warn("video codec igone the info frame, ret=%d", ret); | 662 | + srs_warn("avc igone the info frame, ret=%d", ret); |
654 | return ret; | 663 | return ret; |
655 | } | 664 | } |
656 | 665 | ||
657 | // only support h.264/avc | 666 | // only support h.264/avc |
658 | if (codec_id != SrsCodecVideoAVC) { | 667 | if (codec_id != SrsCodecVideoAVC) { |
659 | ret = ERROR_HLS_DECODE_ERROR; | 668 | ret = ERROR_HLS_DECODE_ERROR; |
660 | - srs_error("video codec only support video h.264/avc codec. actual=%d, ret=%d", codec_id, ret); | 669 | + srs_error("avc only support video h.264/avc codec. actual=%d, ret=%d", codec_id, ret); |
661 | return ret; | 670 | return ret; |
662 | } | 671 | } |
663 | video_codec_id = codec_id; | 672 | video_codec_id = codec_id; |
664 | 673 | ||
665 | if (!stream->require(4)) { | 674 | if (!stream->require(4)) { |
666 | ret = ERROR_HLS_DECODE_ERROR; | 675 | ret = ERROR_HLS_DECODE_ERROR; |
667 | - srs_error("video codec decode avc_packet_type failed. ret=%d", ret); | 676 | + srs_error("avc decode avc_packet_type failed. ret=%d", ret); |
668 | return ret; | 677 | return ret; |
669 | } | 678 | } |
670 | int8_t avc_packet_type = stream->read_1bytes(); | 679 | int8_t avc_packet_type = stream->read_1bytes(); |
@@ -680,9 +689,8 @@ int SrsAvcAacCodec::video_avc_demux(char* data, int size, SrsCodecSample* sample | @@ -680,9 +689,8 @@ int SrsAvcAacCodec::video_avc_demux(char* data, int size, SrsCodecSample* sample | ||
680 | } | 689 | } |
681 | } else if (avc_packet_type == SrsCodecVideoAVCTypeNALU){ | 690 | } else if (avc_packet_type == SrsCodecVideoAVCTypeNALU){ |
682 | // ensure the sequence header demuxed | 691 | // ensure the sequence header demuxed |
683 | - if (avc_extra_size <= 0 || !avc_extra_data) { | ||
684 | - ret = ERROR_HLS_DECODE_ERROR; | ||
685 | - srs_error("avc decode failed, sequence header not found. ret=%d", ret); | 692 | + if (!is_avc_codec_ok()) { |
693 | + srs_warn("avc ignore type=%d for no sequence header. ret=%d", avc_packet_type, ret); | ||
686 | return ret; | 694 | return ret; |
687 | } | 695 | } |
688 | 696 | ||
@@ -738,7 +746,7 @@ int SrsAvcAacCodec::video_avc_demux(char* data, int size, SrsCodecSample* sample | @@ -738,7 +746,7 @@ int SrsAvcAacCodec::video_avc_demux(char* data, int size, SrsCodecSample* sample | ||
738 | // ignored. | 746 | // ignored. |
739 | } | 747 | } |
740 | 748 | ||
741 | - srs_info("video decoded, type=%d, codec=%d, avc=%d, cts=%d, size=%d", | 749 | + srs_info("avc decoded, type=%d, codec=%d, avc=%d, cts=%d, size=%d", |
742 | frame_type, video_codec_id, avc_packet_type, composition_time, size); | 750 | frame_type, video_codec_id, avc_packet_type, composition_time, size); |
743 | 751 | ||
744 | return ret; | 752 | return ret; |
@@ -608,6 +608,10 @@ public: | @@ -608,6 +608,10 @@ public: | ||
608 | public: | 608 | public: |
609 | SrsAvcAacCodec(); | 609 | SrsAvcAacCodec(); |
610 | virtual ~SrsAvcAacCodec(); | 610 | virtual ~SrsAvcAacCodec(); |
611 | +public: | ||
612 | + // whether avc or aac codec sequence header or extra data is decoded ok. | ||
613 | + virtual bool is_avc_codec_ok(); | ||
614 | + virtual bool is_aac_codec_ok(); | ||
611 | // the following function used for hls to build the sample and codec. | 615 | // the following function used for hls to build the sample and codec. |
612 | public: | 616 | public: |
613 | /** | 617 | /** |
-
请 注册 或 登录 后发表评论