mirror of
https://github.com/ossrs/srs.git
synced 2025-02-14 12:21:55 +00:00
for #299, refine docs.
This commit is contained in:
parent
e8353cba3b
commit
136a7ef488
22 changed files with 73 additions and 70 deletions
BIN
trunk/doc/ISO_IEC_14496-14-MP4-2003.pdf
Normal file
BIN
trunk/doc/ISO_IEC_14496-14-MP4-2003.pdf
Normal file
Binary file not shown.
|
@ -22,6 +22,9 @@ H.264-AVC-ISO_IEC_14496-10.pdf
|
|||
H.264-AVC-ISO_IEC_14496-12_2012-mp4.pdf
|
||||
mp4标准。
|
||||
|
||||
ISO_14496-14_2003_mp4-file-format.pdf
|
||||
mp4文件格式。
|
||||
|
||||
MPEG-DASH-ISO_IEC_23009-1_2012.pdf
|
||||
MPEG-DASH标准。
|
||||
|
||||
|
|
|
@ -181,7 +181,7 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
// 5bits, 7.3.1 NAL unit syntax,
|
||||
// H.264-AVC-ISO_IEC_14496-10.pdf, page 44.
|
||||
// ISO_IEC_14496-10-AVC-2003.pdf, page 44.
|
||||
// 7: SPS, 8: PPS, 5: I Frame, 1: P Frame, 9: AUD, 6: SEI
|
||||
u_int8_t nut = (char)data[nb_start_code] & 0x1f;
|
||||
srs_human_trace("sent packet: type=%s, time=%d, size=%d, fps=%.2f, b[%d]=%#x(%s)",
|
||||
|
|
|
@ -259,8 +259,8 @@ int SrsMpegtsOverUdp::on_ts_message(SrsTsMessage* msg)
|
|||
// for example, when SrsTsStream of SrsTsChannel indicates stream_type is SrsTsStreamVideoMpeg4 and SrsTsStreamAudioMpeg4,
|
||||
// the elementary stream can be mux in "2.11 Carriage of ISO/IEC 14496 data" in hls-mpeg-ts-iso13818-1.pdf, page 103
|
||||
// @remark, the most popular stream_id is 0xe0 for h.264 over mpegts, which indicates the stream_id is video and
|
||||
// stream_number is 0, where I guess the elementary is specified in annexb format(H.264-AVC-ISO_IEC_14496-10.pdf, page 211).
|
||||
// because when audio stream_number is 0, the elementary is ADTS(aac-mp4a-format-ISO_IEC_14496-3+2001.pdf, page 75, 1.A.2.2 ADTS).
|
||||
// stream_number is 0, where I guess the elementary is specified in annexb format(ISO_IEC_14496-10-AVC-2003.pdf, page 211).
|
||||
// because when audio stream_number is 0, the elementary is ADTS(ISO_IEC_14496-3-AAC-2001.pdf, page 75, 1.A.2.2 ADTS).
|
||||
|
||||
// about the bytes of PES_packet_data_byte, defined in hls-mpeg-ts-iso13818-1.pdf, page 58
|
||||
// PES_packet_data_byte "C PES_packet_data_bytes shall be contiguous bytes of data from the elementary stream
|
||||
|
@ -361,7 +361,7 @@ int SrsMpegtsOverUdp::on_ts_video(SrsTsMessage* msg, SrsBuffer* avs)
|
|||
}
|
||||
|
||||
// 5bits, 7.3.1 NAL unit syntax,
|
||||
// H.264-AVC-ISO_IEC_14496-10.pdf, page 44.
|
||||
// ISO_IEC_14496-10-AVC-2003.pdf, page 44.
|
||||
// 7: SPS, 8: PPS, 5: I Frame, 1: P Frame
|
||||
SrsAvcNaluType nal_unit_type = (SrsAvcNaluType)(frame[0] & 0x1f);
|
||||
|
||||
|
@ -471,7 +471,7 @@ int SrsMpegtsOverUdp::write_h264_ipb_frame(char* frame, int frame_size, u_int32_
|
|||
}
|
||||
|
||||
// 5bits, 7.3.1 NAL unit syntax,
|
||||
// H.264-AVC-ISO_IEC_14496-10.pdf, page 44.
|
||||
// ISO_IEC_14496-10-AVC-2003.pdf, page 44.
|
||||
// 7: SPS, 8: PPS, 5: I Frame, 1: P Frame
|
||||
SrsAvcNaluType nal_unit_type = (SrsAvcNaluType)(frame[0] & 0x1f);
|
||||
|
||||
|
|
|
@ -581,7 +581,7 @@ int SrsRtspConn::write_h264_ipb_frame(char* frame, int frame_size, u_int32_t dts
|
|||
int ret = ERROR_SUCCESS;
|
||||
|
||||
// 5bits, 7.3.1 NAL unit syntax,
|
||||
// H.264-AVC-ISO_IEC_14496-10.pdf, page 44.
|
||||
// ISO_IEC_14496-10-AVC-2003.pdf, page 44.
|
||||
// 7: SPS, 8: PPS, 5: I Frame, 1: P Frame
|
||||
SrsAvcNaluType nal_unit_type = (SrsAvcNaluType)(frame[0] & 0x1f);
|
||||
|
||||
|
|
|
@ -81,9 +81,9 @@ public:
|
|||
public:
|
||||
bool has_video;
|
||||
SrsCodecVideo vcodec;
|
||||
// profile_idc, H.264-AVC-ISO_IEC_14496-10.pdf, page 45.
|
||||
// profile_idc, ISO_IEC_14496-10-AVC-2003.pdf, page 45.
|
||||
SrsAvcProfile avc_profile;
|
||||
// level_idc, H.264-AVC-ISO_IEC_14496-10.pdf, page 45.
|
||||
// level_idc, ISO_IEC_14496-10-AVC-2003.pdf, page 45.
|
||||
SrsAvcLevel avc_level;
|
||||
// the width and height in codec info.
|
||||
int width;
|
||||
|
@ -97,7 +97,7 @@ public:
|
|||
* audio specified
|
||||
* audioObjectType, in 1.6.2.1 AudioSpecificConfig, page 33,
|
||||
* 1.5.1.1 Audio object type definition, page 23,
|
||||
* in aac-mp4a-format-ISO_IEC_14496-3+2001.pdf.
|
||||
* in ISO_IEC_14496-3-AAC-2001.pdf.
|
||||
*/
|
||||
SrsAacObjectType aac_object;
|
||||
public:
|
||||
|
|
|
@ -114,7 +114,7 @@ int SrsAacEncoder::write_audio(int64_t timestamp, char* data, int size)
|
|||
SrsCodecAudioType aac_packet_type = (SrsCodecAudioType)stream->read_1bytes();
|
||||
if (aac_packet_type == SrsCodecAudioTypeSequenceHeader) {
|
||||
// AudioSpecificConfig
|
||||
// 1.6.2.1 AudioSpecificConfig, in aac-mp4a-format-ISO_IEC_14496-3+2001.pdf, page 33.
|
||||
// 1.6.2.1 AudioSpecificConfig, in ISO_IEC_14496-3-AAC-2001.pdf, page 33.
|
||||
//
|
||||
// only need to decode the first 2bytes:
|
||||
// audioObjectType, 5bits.
|
||||
|
@ -150,7 +150,7 @@ int SrsAacEncoder::write_audio(int64_t timestamp, char* data, int size)
|
|||
int16_t aac_raw_length = stream->size() - stream->pos();
|
||||
|
||||
// write the ADTS header.
|
||||
// @see aac-mp4a-format-ISO_IEC_14496-3+2001.pdf, page 75,
|
||||
// @see ISO_IEC_14496-3-AAC-2001.pdf, page 75,
|
||||
// 1.A.2.2 Audio_Data_Transport_Stream frame, ADTS
|
||||
// @see https://github.com/ossrs/srs/issues/212#issuecomment-64145885
|
||||
// byte_alignment()
|
||||
|
|
|
@ -500,7 +500,7 @@ int SrsAvcAacCodec::audio_aac_demux(char* data, int size, SrsCodecSample* sample
|
|||
|
||||
if (aac_packet_type == SrsCodecAudioTypeSequenceHeader) {
|
||||
// AudioSpecificConfig
|
||||
// 1.6.2.1 AudioSpecificConfig, in aac-mp4a-format-ISO_IEC_14496-3+2001.pdf, page 33.
|
||||
// 1.6.2.1 AudioSpecificConfig, in ISO_IEC_14496-3-AAC-2001.pdf, page 33.
|
||||
aac_extra_size = stream->size() - stream->pos();
|
||||
if (aac_extra_size > 0) {
|
||||
srs_freepa(aac_extra_data);
|
||||
|
@ -721,7 +721,7 @@ int SrsAvcAacCodec::video_nalu_demux(SrsBuffer* stream, SrsCodecSample* sample)
|
|||
// guess for the first time.
|
||||
if (payload_format == SrsAvcPayloadFormatGuess) {
|
||||
// One or more NALUs (Full frames are required)
|
||||
// try "AnnexB" from H.264-AVC-ISO_IEC_14496-10.pdf, page 211.
|
||||
// try "AnnexB" from ISO_IEC_14496-10-AVC-2003.pdf, page 211.
|
||||
if ((ret = avc_demux_annexb_format(stream, sample)) != ERROR_SUCCESS) {
|
||||
// stop try when system error.
|
||||
if (ret != ERROR_HLS_AVC_TRY_OTHERS) {
|
||||
|
@ -729,7 +729,7 @@ int SrsAvcAacCodec::video_nalu_demux(SrsBuffer* stream, SrsCodecSample* sample)
|
|||
return ret;
|
||||
}
|
||||
|
||||
// try "ISO Base Media File Format" from H.264-AVC-ISO_IEC_14496-15.pdf, page 20
|
||||
// try "ISO Base Media File Format" from ISO_IEC_14496-15-AVC-format-2012.pdf, page 20
|
||||
if ((ret = avc_demux_ibmf_format(stream, sample)) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
} else {
|
||||
|
@ -741,14 +741,14 @@ int SrsAvcAacCodec::video_nalu_demux(SrsBuffer* stream, SrsCodecSample* sample)
|
|||
srs_info("hls guess avc payload is annexb format.");
|
||||
}
|
||||
} else if (payload_format == SrsAvcPayloadFormatIbmf) {
|
||||
// try "ISO Base Media File Format" from H.264-AVC-ISO_IEC_14496-15.pdf, page 20
|
||||
// try "ISO Base Media File Format" from ISO_IEC_14496-15-AVC-format-2012.pdf, page 20
|
||||
if ((ret = avc_demux_ibmf_format(stream, sample)) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
srs_info("hls decode avc payload in ibmf format.");
|
||||
} else {
|
||||
// One or more NALUs (Full frames are required)
|
||||
// try "AnnexB" from H.264-AVC-ISO_IEC_14496-10.pdf, page 211.
|
||||
// try "AnnexB" from ISO_IEC_14496-10-AVC-2003.pdf, page 211.
|
||||
if ((ret = avc_demux_annexb_format(stream, sample)) != ERROR_SUCCESS) {
|
||||
// ok, we guess out the payload is annexb, but maybe changed to ibmf.
|
||||
if (ret != ERROR_HLS_AVC_TRY_OTHERS) {
|
||||
|
@ -756,7 +756,7 @@ int SrsAvcAacCodec::video_nalu_demux(SrsBuffer* stream, SrsCodecSample* sample)
|
|||
return ret;
|
||||
}
|
||||
|
||||
// try "ISO Base Media File Format" from H.264-AVC-ISO_IEC_14496-15.pdf, page 20
|
||||
// try "ISO Base Media File Format" from ISO_IEC_14496-15-AVC-format-2012.pdf, page 20
|
||||
if ((ret = avc_demux_ibmf_format(stream, sample)) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
} else {
|
||||
|
@ -775,7 +775,7 @@ int SrsAvcAacCodec::avc_demux_sps_pps(SrsBuffer* stream)
|
|||
int ret = ERROR_SUCCESS;
|
||||
|
||||
// AVCDecoderConfigurationRecord
|
||||
// 5.2.4.1.1 Syntax, H.264-AVC-ISO_IEC_14496-15.pdf, page 16
|
||||
// 5.2.4.1.1 Syntax, ISO_IEC_14496-15-AVC-format-2012.pdf, page 16
|
||||
avc_extra_size = stream->size() - stream->pos();
|
||||
if (avc_extra_size > 0) {
|
||||
srs_freepa(avc_extra_data);
|
||||
|
@ -802,7 +802,7 @@ int SrsAvcAacCodec::avc_demux_sps_pps(SrsBuffer* stream)
|
|||
lengthSizeMinusOne &= 0x03;
|
||||
NAL_unit_length = lengthSizeMinusOne;
|
||||
|
||||
// 5.3.4.2.1 Syntax, H.264-AVC-ISO_IEC_14496-15.pdf, page 16
|
||||
// 5.3.4.2.1 Syntax, ISO_IEC_14496-15-AVC-format-2012.pdf, page 16
|
||||
// 5.2.4.1 AVC decoder configuration record
|
||||
// 5.2.4.1.2 Semantics
|
||||
// The value of this field shall be one of 0, 1, or 3 corresponding to a
|
||||
|
@ -814,7 +814,7 @@ int SrsAvcAacCodec::avc_demux_sps_pps(SrsBuffer* stream)
|
|||
}
|
||||
|
||||
// 1 sps, 7.3.2.1 Sequence parameter set RBSP syntax
|
||||
// H.264-AVC-ISO_IEC_14496-10.pdf, page 45.
|
||||
// ISO_IEC_14496-10-AVC-2003.pdf, page 45.
|
||||
if (!stream->require(1)) {
|
||||
ret = ERROR_HLS_DECODE_ERROR;
|
||||
srs_error("avc decode sequenc header sps failed. ret=%d", ret);
|
||||
|
@ -890,7 +890,7 @@ int SrsAvcAacCodec::avc_demux_sps()
|
|||
}
|
||||
|
||||
// for NALU, 7.3.1 NAL unit syntax
|
||||
// H.264-AVC-ISO_IEC_14496-10-2012.pdf, page 61.
|
||||
// ISO_IEC_14496-10-AVC-2012.pdf, page 61.
|
||||
if (!stream.require(1)) {
|
||||
ret = ERROR_HLS_DECODE_ERROR;
|
||||
srs_error("avc decode sps failed. ret=%d", ret);
|
||||
|
@ -916,7 +916,7 @@ int SrsAvcAacCodec::avc_demux_sps()
|
|||
}
|
||||
|
||||
// 7.4.1 NAL unit semantics
|
||||
// H.264-AVC-ISO_IEC_14496-10-2012.pdf, page 61.
|
||||
// ISO_IEC_14496-10-AVC-2012.pdf, page 61.
|
||||
// nal_unit_type specifies the type of RBSP data structure contained in the NAL unit as specified in Table 7-1.
|
||||
SrsAvcNaluType nal_unit_type = (SrsAvcNaluType)(nutv & 0x1f);
|
||||
if (nal_unit_type != 7) {
|
||||
|
@ -970,7 +970,7 @@ int SrsAvcAacCodec::avc_demux_sps_rbsp(char* rbsp, int nb_rbsp)
|
|||
}
|
||||
|
||||
// for SPS, 7.3.2.1.1 Sequence parameter set data syntax
|
||||
// H.264-AVC-ISO_IEC_14496-10-2012.pdf, page 62.
|
||||
// ISO_IEC_14496-10-AVC-2012.pdf, page 62.
|
||||
if (!stream.require(3)) {
|
||||
ret = ERROR_HLS_DECODE_ERROR;
|
||||
srs_error("sps shall atleast 3bytes. ret=%d", ret);
|
||||
|
@ -1143,7 +1143,7 @@ int SrsAvcAacCodec::avc_demux_annexb_format(SrsBuffer* stream, SrsCodecSample* s
|
|||
|
||||
// AnnexB
|
||||
// B.1.1 Byte stream NAL unit syntax,
|
||||
// H.264-AVC-ISO_IEC_14496-10.pdf, page 211.
|
||||
// ISO_IEC_14496-10-AVC-2003.pdf, page 211.
|
||||
while (!stream->empty()) {
|
||||
// find start code
|
||||
int nb_start_code = 0;
|
||||
|
@ -1191,14 +1191,14 @@ int SrsAvcAacCodec::avc_demux_ibmf_format(SrsBuffer* stream, SrsCodecSample* sam
|
|||
|
||||
int PictureLength = stream->size() - stream->pos();
|
||||
|
||||
// 5.3.4.2.1 Syntax, H.264-AVC-ISO_IEC_14496-15.pdf, page 16
|
||||
// 5.3.4.2.1 Syntax, ISO_IEC_14496-15-AVC-format-2012.pdf, page 16
|
||||
// 5.2.4.1 AVC decoder configuration record
|
||||
// 5.2.4.1.2 Semantics
|
||||
// The value of this field shall be one of 0, 1, or 3 corresponding to a
|
||||
// length encoded with 1, 2, or 4 bytes, respectively.
|
||||
srs_assert(NAL_unit_length != 2);
|
||||
|
||||
// 5.3.4.2.1 Syntax, H.264-AVC-ISO_IEC_14496-15.pdf, page 20
|
||||
// 5.3.4.2.1 Syntax, ISO_IEC_14496-15-AVC-format-2012.pdf, page 20
|
||||
for (int i = 0; i < PictureLength;) {
|
||||
// unsigned int((NAL_unit_length+1)*8) NALUnitLength;
|
||||
if (!stream->require(NAL_unit_length + 1)) {
|
||||
|
@ -1229,7 +1229,7 @@ int SrsAvcAacCodec::avc_demux_ibmf_format(SrsBuffer* stream, SrsCodecSample* sam
|
|||
srs_error("avc decode NALU data failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
// 7.3.1 NAL unit syntax, H.264-AVC-ISO_IEC_14496-10.pdf, page 44.
|
||||
// 7.3.1 NAL unit syntax, ISO_IEC_14496-10-AVC-2003.pdf, page 44.
|
||||
if ((ret = sample->add_sample_unit(stream->data() + stream->pos(), NALUnitLength)) != ERROR_SUCCESS) {
|
||||
srs_error("avc add video sample failed. ret=%d", ret);
|
||||
return ret;
|
||||
|
|
|
@ -283,7 +283,7 @@ enum SrsCodecAudioSoundType
|
|||
|
||||
/**
|
||||
* Table 7-1 - NAL unit type codes, syntax element categories, and NAL unit type classes
|
||||
* H.264-AVC-ISO_IEC_14496-10-2012.pdf, page 83.
|
||||
* ISO_IEC_14496-10-AVC-2012.pdf, page 83.
|
||||
*/
|
||||
enum SrsAvcNaluType
|
||||
{
|
||||
|
@ -452,15 +452,15 @@ std::string srs_codec_aac_profile2str(SrsAacProfile aac_profile);
|
|||
|
||||
/**
|
||||
* the aac object type, for RTMP sequence header
|
||||
* for AudioSpecificConfig, @see aac-mp4a-format-ISO_IEC_14496-3+2001.pdf, page 33
|
||||
* for audioObjectType, @see aac-mp4a-format-ISO_IEC_14496-3+2001.pdf, page 23
|
||||
* for AudioSpecificConfig, @see ISO_IEC_14496-3-AAC-2001.pdf, page 33
|
||||
* for audioObjectType, @see ISO_IEC_14496-3-AAC-2001.pdf, page 23
|
||||
*/
|
||||
enum SrsAacObjectType
|
||||
{
|
||||
SrsAacObjectTypeReserved = 0,
|
||||
|
||||
// Table 1.1 - Audio Object Type definition
|
||||
// @see @see aac-mp4a-format-ISO_IEC_14496-3+2001.pdf, page 23
|
||||
// @see @see ISO_IEC_14496-3-AAC-2001.pdf, page 23
|
||||
SrsAacObjectTypeAacMain = 1,
|
||||
SrsAacObjectTypeAacLC = 2,
|
||||
SrsAacObjectTypeAacSSR = 3,
|
||||
|
@ -478,7 +478,7 @@ SrsAacProfile srs_codec_aac_rtmp2ts(SrsAacObjectType object_type);
|
|||
|
||||
/**
|
||||
* the profile for avc/h.264.
|
||||
* @see Annex A Profiles and levels, H.264-AVC-ISO_IEC_14496-10.pdf, page 205.
|
||||
* @see Annex A Profiles and levels, ISO_IEC_14496-10-AVC-2003.pdf, page 205.
|
||||
*/
|
||||
enum SrsAvcProfile
|
||||
{
|
||||
|
@ -504,7 +504,7 @@ std::string srs_codec_avc_profile2str(SrsAvcProfile profile);
|
|||
|
||||
/**
|
||||
* the level for avc/h.264.
|
||||
* @see Annex A Profiles and levels, H.264-AVC-ISO_IEC_14496-10.pdf, page 207.
|
||||
* @see Annex A Profiles and levels, ISO_IEC_14496-10-AVC-2003.pdf, page 207.
|
||||
*/
|
||||
enum SrsAvcLevel
|
||||
{
|
||||
|
@ -565,11 +565,11 @@ public:
|
|||
/**
|
||||
* video specified
|
||||
*/
|
||||
// profile_idc, H.264-AVC-ISO_IEC_14496-10.pdf, page 45.
|
||||
// profile_idc, ISO_IEC_14496-10-AVC-2003.pdf, page 45.
|
||||
SrsAvcProfile avc_profile;
|
||||
// level_idc, H.264-AVC-ISO_IEC_14496-10.pdf, page 45.
|
||||
// level_idc, ISO_IEC_14496-10-AVC-2003.pdf, page 45.
|
||||
SrsAvcLevel avc_level;
|
||||
// lengthSizeMinusOne, H.264-AVC-ISO_IEC_14496-15.pdf, page 16
|
||||
// lengthSizeMinusOne, ISO_IEC_14496-15-AVC-format-2012.pdf, page 16
|
||||
int8_t NAL_unit_length;
|
||||
u_int16_t sequenceParameterSetLength;
|
||||
char* sequenceParameterSetNALUnit;
|
||||
|
@ -583,7 +583,7 @@ public:
|
|||
* audio specified
|
||||
* audioObjectType, in 1.6.2.1 AudioSpecificConfig, page 33,
|
||||
* 1.5.1.1 Audio object type definition, page 23,
|
||||
* in aac-mp4a-format-ISO_IEC_14496-3+2001.pdf.
|
||||
* in ISO_IEC_14496-3-AAC-2001.pdf.
|
||||
*/
|
||||
SrsAacObjectType aac_object;
|
||||
/**
|
||||
|
@ -658,12 +658,12 @@ private:
|
|||
virtual int avc_demux_sps_rbsp(char* rbsp, int nb_rbsp);
|
||||
/**
|
||||
* demux the avc NALU in "AnnexB"
|
||||
* from H.264-AVC-ISO_IEC_14496-10.pdf, page 211.
|
||||
* from ISO_IEC_14496-10-AVC-2003.pdf, page 211.
|
||||
*/
|
||||
virtual int avc_demux_annexb_format(SrsBuffer* stream, SrsCodecSample* sample);
|
||||
/**
|
||||
* demux the avc NALU in "ISO Base Media File Format"
|
||||
* from H.264-AVC-ISO_IEC_14496-15.pdf, page 20
|
||||
* from ISO_IEC_14496-15-AVC-format-2012.pdf, page 20
|
||||
*/
|
||||
virtual int avc_demux_ibmf_format(SrsBuffer* stream, SrsCodecSample* sample);
|
||||
};
|
||||
|
|
|
@ -2942,7 +2942,7 @@ int SrsTsCache::do_cache_aac(SrsAvcAacCodec* codec, SrsCodecSample* sample)
|
|||
void srs_avc_insert_aud(SrsSimpleStream* payload, bool& aud_inserted)
|
||||
{
|
||||
// mux the samples in annexb format,
|
||||
// H.264-AVC-ISO_IEC_14496-10-2012.pdf, page 324.
|
||||
// ISO_IEC_14496-10-AVC-2012.pdf, page 324.
|
||||
/**
|
||||
* 00 00 00 01 // header
|
||||
* xxxxxxx // data bytes
|
||||
|
@ -2951,7 +2951,7 @@ void srs_avc_insert_aud(SrsSimpleStream* payload, bool& aud_inserted)
|
|||
*
|
||||
* nal_unit_type specifies the type of RBSP data structure contained in the NAL unit as specified in Table 7-1.
|
||||
* Table 7-1 - NAL unit type codes, syntax element categories, and NAL unit type classes
|
||||
* H.264-AVC-ISO_IEC_14496-10-2012.pdf, page 83.
|
||||
* ISO_IEC_14496-10-AVC-2012.pdf, page 83.
|
||||
* 1, Coded slice of a non-IDR picture slice_layer_without_partitioning_rbsp( )
|
||||
* 2, Coded slice data partition A slice_data_partition_a_layer_rbsp( )
|
||||
* 3, Coded slice data partition B slice_data_partition_b_layer_rbsp( )
|
||||
|
@ -3006,7 +3006,7 @@ int SrsTsCache::do_cache_avc(SrsAvcAacCodec* codec, SrsCodecSample* sample)
|
|||
if (!sample->has_aud) {
|
||||
// the aud(access unit delimiter) before each frame.
|
||||
// 7.3.2.4 Access unit delimiter RBSP syntax
|
||||
// H.264-AVC-ISO_IEC_14496-10-2012.pdf, page 66.
|
||||
// ISO_IEC_14496-10-AVC-2012.pdf, page 66.
|
||||
//
|
||||
// primary_pic_type u(3), the first 3bits, primary_pic_type indicates that the slice_type values
|
||||
// for all slices of the primary coded picture are members of the set listed in Table 7-5 for
|
||||
|
@ -3020,7 +3020,7 @@ int SrsTsCache::do_cache_avc(SrsAvcAacCodec* codec, SrsCodecSample* sample)
|
|||
// 6, slice_type 0, 2, 3, 4, 5, 7, 8, 9
|
||||
// 7, slice_type 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
|
||||
// 7.4.2.4 Access unit delimiter RBSP semantics
|
||||
// H.264-AVC-ISO_IEC_14496-10-2012.pdf, page 102.
|
||||
// ISO_IEC_14496-10-AVC-2012.pdf, page 102.
|
||||
//
|
||||
// slice_type specifies the coding type of the slice according to Table 7-6.
|
||||
// 0, P (P slice)
|
||||
|
@ -3033,7 +3033,7 @@ int SrsTsCache::do_cache_avc(SrsAvcAacCodec* codec, SrsCodecSample* sample)
|
|||
// 7, I (I slice)
|
||||
// 8, SP (SP slice)
|
||||
// 9, SI (SI slice)
|
||||
// H.264-AVC-ISO_IEC_14496-10-2012.pdf, page 105.
|
||||
// ISO_IEC_14496-10-AVC-2012.pdf, page 105.
|
||||
static u_int8_t default_aud_nalu[] = { 0x09, 0xf0};
|
||||
srs_avc_insert_aud(video->payload, aud_inserted);
|
||||
video->payload->append((const char*)default_aud_nalu, 2);
|
||||
|
@ -3051,7 +3051,7 @@ int SrsTsCache::do_cache_avc(SrsAvcAacCodec* codec, SrsCodecSample* sample)
|
|||
}
|
||||
|
||||
// 5bits, 7.3.1 NAL unit syntax,
|
||||
// H.264-AVC-ISO_IEC_14496-10-2012.pdf, page 83.
|
||||
// ISO_IEC_14496-10-AVC-2012.pdf, page 83.
|
||||
SrsAvcNaluType nal_unit_type = (SrsAvcNaluType)(sample_unit->bytes[0] & 0x1f);
|
||||
|
||||
// Insert sps/pps before IDR when there is no sps/pps in samples.
|
||||
|
|
|
@ -58,7 +58,7 @@ int srs_avc_nalu_read_uev(SrsBitBuffer* stream, int32_t& v)
|
|||
}
|
||||
|
||||
// ue(v) in 9.1 Parsing process for Exp-Golomb codes
|
||||
// H.264-AVC-ISO_IEC_14496-10-2012.pdf, page 227.
|
||||
// ISO_IEC_14496-10-AVC-2012.pdf, page 227.
|
||||
// Syntax elements coded as ue(v), me(v), or se(v) are Exp-Golomb-coded.
|
||||
// leadingZeroBits = -1;
|
||||
// for( b = 0; !b; leadingZeroBits++ )
|
||||
|
|
|
@ -112,7 +112,7 @@ extern std::string srs_path_filext(std::string path);
|
|||
|
||||
/**
|
||||
* whether stream starts with the avc NALU in "AnnexB"
|
||||
* from H.264-AVC-ISO_IEC_14496-10.pdf, page 211.
|
||||
* from ISO_IEC_14496-10-AVC-2003.pdf, page 211.
|
||||
* start code must be "N[00] 00 00 01" where N>=0
|
||||
* @param pnb_start_code output the size of start code, must >=3.
|
||||
* NULL to ignore.
|
||||
|
@ -121,7 +121,7 @@ extern bool srs_avc_startswith_annexb(SrsBuffer* stream, int* pnb_start_code = N
|
|||
|
||||
/**
|
||||
* whether stream starts with the aac ADTS
|
||||
* from aac-mp4a-format-ISO_IEC_14496-3+2001.pdf, page 75, 1.A.2.2 ADTS.
|
||||
* from ISO_IEC_14496-3-AAC-2001.pdf, page 75, 1.A.2.2 ADTS.
|
||||
* start code must be '1111 1111 1111'B, that is 0xFFF
|
||||
*/
|
||||
extern bool srs_aac_startswith_adts(SrsBuffer* stream);
|
||||
|
|
|
@ -92,7 +92,7 @@ struct Context
|
|||
// for h264 raw stream,
|
||||
// @see: https://github.com/ossrs/srs/issues/66#issuecomment-62240521
|
||||
SrsBuffer h264_raw_stream;
|
||||
// about SPS, @see: 7.3.2.1.1, H.264-AVC-ISO_IEC_14496-10-2012.pdf, page 62
|
||||
// about SPS, @see: 7.3.2.1.1, ISO_IEC_14496-10-AVC-2012.pdf, page 62
|
||||
std::string h264_sps;
|
||||
std::string h264_pps;
|
||||
// whether the sps and pps sent,
|
||||
|
@ -1326,7 +1326,7 @@ int srs_write_h264_ipb_frame(Context* context,
|
|||
}
|
||||
|
||||
// 5bits, 7.3.1 NAL unit syntax,
|
||||
// H.264-AVC-ISO_IEC_14496-10.pdf, page 44.
|
||||
// ISO_IEC_14496-10-AVC-2003.pdf, page 44.
|
||||
// 5: I Frame, 1: P/B Frame
|
||||
// @remark we already group sps/pps to sequence header frame;
|
||||
// for I/P NALU, we send them in isolate frame, each NALU in a frame;
|
||||
|
@ -1445,7 +1445,7 @@ int srs_write_h264_raw_frame(Context* context,
|
|||
|
||||
// ignore others.
|
||||
// 5bits, 7.3.1 NAL unit syntax,
|
||||
// H.264-AVC-ISO_IEC_14496-10.pdf, page 44.
|
||||
// ISO_IEC_14496-10-AVC-2003.pdf, page 44.
|
||||
// 7: SPS, 8: PPS, 5: I Frame, 1: P Frame, 9: AUD
|
||||
SrsAvcNaluType nut = (SrsAvcNaluType)(frame[0] & 0x1f);
|
||||
if (nut != SrsAvcNaluTypeSPS && nut != SrsAvcNaluTypePPS
|
||||
|
|
|
@ -360,9 +360,9 @@ extern srs_bool srs_rtmp_is_onMetaData(char type, char* data, int size);
|
|||
* @example /trunk/research/librtmp/srs_audio_raw_publish.c
|
||||
*
|
||||
* @remark for aac, the frame must be in ADTS format.
|
||||
* @see aac-mp4a-format-ISO_IEC_14496-3+2001.pdf, page 75, 1.A.2.2 ADTS
|
||||
* @see ISO_IEC_14496-3-AAC-2001.pdf, page 75, 1.A.2.2 ADTS
|
||||
* @remark for aac, only support profile 1-4, AAC main/LC/SSR/LTP,
|
||||
* @see aac-mp4a-format-ISO_IEC_14496-3+2001.pdf, page 23, 1.5.1.1 Audio object type
|
||||
* @see ISO_IEC_14496-3-AAC-2001.pdf, page 23, 1.5.1.1 Audio object type
|
||||
*
|
||||
* @see https://github.com/ossrs/srs/issues/212
|
||||
* @see E.4.2.1 AUDIODATA of video_file_format_spec_v10_1.pdf
|
||||
|
@ -381,7 +381,7 @@ extern int srs_audio_write_raw_frame(srs_rtmp_t rtmp,
|
|||
* @param ac_raw_size the size of aac raw data.
|
||||
*
|
||||
* @reamrk used to check whether current frame is in adts format.
|
||||
* @see aac-mp4a-format-ISO_IEC_14496-3+2001.pdf, page 75, 1.A.2.2 ADTS
|
||||
* @see ISO_IEC_14496-3-AAC-2001.pdf, page 75, 1.A.2.2 ADTS
|
||||
* @example /trunk/research/librtmp/srs_aac_raw_publish.c
|
||||
*
|
||||
* @return 0 false; otherwise, true.
|
||||
|
@ -409,7 +409,7 @@ extern int srs_aac_adts_frame_size(char* aac_raw_data, int ac_raw_size);
|
|||
* frames can be one or more than one frame,
|
||||
* each frame prefixed h.264 annexb header, by N[00] 00 00 01, where N>=0,
|
||||
* for instance, frame = header(00 00 00 01) + payload(67 42 80 29 95 A0 14 01 6E 40)
|
||||
* about annexb, @see H.264-AVC-ISO_IEC_14496-10.pdf, page 211.
|
||||
* about annexb, @see ISO_IEC_14496-10-AVC-2003.pdf, page 211.
|
||||
* @param frames_size the size of h264 raw data.
|
||||
* assert frames_size > 0, at least has 1 bytes header.
|
||||
* @param dts the dts of h.264 raw data.
|
||||
|
|
|
@ -711,8 +711,8 @@ int SrsIngestSrsOutput::on_ts_message(SrsTsMessage* msg)
|
|||
// for example, when SrsTsStream of SrsTsChannel indicates stream_type is SrsTsStreamVideoMpeg4 and SrsTsStreamAudioMpeg4,
|
||||
// the elementary stream can be mux in "2.11 Carriage of ISO/IEC 14496 data" in hls-mpeg-ts-iso13818-1.pdf, page 103
|
||||
// @remark, the most popular stream_id is 0xe0 for h.264 over mpegts, which indicates the stream_id is video and
|
||||
// stream_number is 0, where I guess the elementary is specified in annexb format(H.264-AVC-ISO_IEC_14496-10.pdf, page 211).
|
||||
// because when audio stream_number is 0, the elementary is ADTS(aac-mp4a-format-ISO_IEC_14496-3+2001.pdf, page 75, 1.A.2.2 ADTS).
|
||||
// stream_number is 0, where I guess the elementary is specified in annexb format(ISO_IEC_14496-10-AVC-2003.pdf, page 211).
|
||||
// because when audio stream_number is 0, the elementary is ADTS(ISO_IEC_14496-3-AAC-2001.pdf, page 75, 1.A.2.2 ADTS).
|
||||
|
||||
// about the bytes of PES_packet_data_byte, defined in hls-mpeg-ts-iso13818-1.pdf, page 58
|
||||
// PES_packet_data_byte ¨C PES_packet_data_bytes shall be contiguous bytes of data from the elementary stream
|
||||
|
@ -970,7 +970,7 @@ int SrsIngestSrsOutput::on_ts_video(SrsTsMessage* msg, SrsBuffer* avs)
|
|||
}
|
||||
|
||||
// 5bits, 7.3.1 NAL unit syntax,
|
||||
// H.264-AVC-ISO_IEC_14496-10.pdf, page 44.
|
||||
// ISO_IEC_14496-10-AVC-2003.pdf, page 44.
|
||||
// 7: SPS, 8: PPS, 5: I Frame, 1: P Frame
|
||||
SrsAvcNaluType nal_unit_type = (SrsAvcNaluType)(frame[0] & 0x1f);
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ int SrsRawH264Stream::annexb_demux(SrsBuffer* stream, char** pframe, int* pnb_fr
|
|||
|
||||
while (!stream->empty()) {
|
||||
// each frame must prefixed by annexb format.
|
||||
// about annexb, @see H.264-AVC-ISO_IEC_14496-10.pdf, page 211.
|
||||
// about annexb, @see ISO_IEC_14496-10-AVC-2003.pdf, page 211.
|
||||
int pnb_start_code = 0;
|
||||
if (!srs_avc_startswith_annexb(stream, &pnb_start_code)) {
|
||||
return ERROR_H264_API_NO_PREFIXED;
|
||||
|
@ -80,7 +80,7 @@ bool SrsRawH264Stream::is_sps(char* frame, int nb_frame)
|
|||
srs_assert(nb_frame > 0);
|
||||
|
||||
// 5bits, 7.3.1 NAL unit syntax,
|
||||
// H.264-AVC-ISO_IEC_14496-10.pdf, page 44.
|
||||
// ISO_IEC_14496-10-AVC-2003.pdf, page 44.
|
||||
// 7: SPS, 8: PPS, 5: I Frame, 1: P Frame
|
||||
u_int8_t nal_unit_type = (char)frame[0] & 0x1f;
|
||||
|
||||
|
@ -92,7 +92,7 @@ bool SrsRawH264Stream::is_pps(char* frame, int nb_frame)
|
|||
srs_assert(nb_frame > 0);
|
||||
|
||||
// 5bits, 7.3.1 NAL unit syntax,
|
||||
// H.264-AVC-ISO_IEC_14496-10.pdf, page 44.
|
||||
// ISO_IEC_14496-10-AVC-2003.pdf, page 44.
|
||||
// 7: SPS, 8: PPS, 5: I Frame, 1: P Frame
|
||||
u_int8_t nal_unit_type = (char)frame[0] & 0x1f;
|
||||
|
||||
|
@ -166,12 +166,12 @@ int SrsRawH264Stream::mux_sequence_header(string sps, string pps, u_int32_t dts,
|
|||
}
|
||||
|
||||
// decode the SPS:
|
||||
// @see: 7.3.2.1.1, H.264-AVC-ISO_IEC_14496-10-2012.pdf, page 62
|
||||
// @see: 7.3.2.1.1, ISO_IEC_14496-10-AVC-2012.pdf, page 62
|
||||
if (true) {
|
||||
srs_assert((int)sps.length() >= 4);
|
||||
char* frame = (char*)sps.data();
|
||||
|
||||
// @see: Annex A Profiles and levels, H.264-AVC-ISO_IEC_14496-10.pdf, page 205
|
||||
// @see: Annex A Profiles and levels, ISO_IEC_14496-10-AVC-2003.pdf, page 205
|
||||
// Baseline profile profile_idc is 66(0x42).
|
||||
// Main profile profile_idc is 77(0x4d).
|
||||
// Extended profile profile_idc is 88(0x58).
|
||||
|
@ -180,7 +180,7 @@ int SrsRawH264Stream::mux_sequence_header(string sps, string pps, u_int32_t dts,
|
|||
u_int8_t level_idc = frame[3];
|
||||
|
||||
// generate the sps/pps header
|
||||
// 5.3.4.2.1 Syntax, H.264-AVC-ISO_IEC_14496-15.pdf, page 16
|
||||
// 5.3.4.2.1 Syntax, ISO_IEC_14496-15-AVC-format-2012.pdf, page 16
|
||||
// configurationVersion
|
||||
stream.write_1bytes(0x01);
|
||||
// AVCProfileIndication
|
||||
|
@ -196,7 +196,7 @@ int SrsRawH264Stream::mux_sequence_header(string sps, string pps, u_int32_t dts,
|
|||
|
||||
// sps
|
||||
if (true) {
|
||||
// 5.3.4.2.1 Syntax, H.264-AVC-ISO_IEC_14496-15.pdf, page 16
|
||||
// 5.3.4.2.1 Syntax, ISO_IEC_14496-15-AVC-format-2012.pdf, page 16
|
||||
// numOfSequenceParameterSets, always 1
|
||||
stream.write_1bytes(0x01);
|
||||
// sequenceParameterSetLength
|
||||
|
@ -207,7 +207,7 @@ int SrsRawH264Stream::mux_sequence_header(string sps, string pps, u_int32_t dts,
|
|||
|
||||
// pps
|
||||
if (true) {
|
||||
// 5.3.4.2.1 Syntax, H.264-AVC-ISO_IEC_14496-15.pdf, page 16
|
||||
// 5.3.4.2.1 Syntax, ISO_IEC_14496-15-AVC-format-2012.pdf, page 16
|
||||
// numOfPictureParameterSets, always 1
|
||||
stream.write_1bytes(0x01);
|
||||
// pictureParameterSetLength
|
||||
|
@ -217,7 +217,7 @@ int SrsRawH264Stream::mux_sequence_header(string sps, string pps, u_int32_t dts,
|
|||
}
|
||||
|
||||
// TODO: FIXME: for more profile.
|
||||
// 5.3.4.2.1 Syntax, H.264-AVC-ISO_IEC_14496-15.pdf, page 16
|
||||
// 5.3.4.2.1 Syntax, ISO_IEC_14496-15-AVC-format-2012.pdf, page 16
|
||||
// profile_idc == 100 || profile_idc == 110 || profile_idc == 122 || profile_idc == 144
|
||||
|
||||
sh = "";
|
||||
|
@ -244,12 +244,12 @@ int SrsRawH264Stream::mux_ipb_frame(char* frame, int nb_frame, string& ibp)
|
|||
return ret;
|
||||
}
|
||||
|
||||
// 5.3.4.2.1 Syntax, H.264-AVC-ISO_IEC_14496-15.pdf, page 16
|
||||
// 5.3.4.2.1 Syntax, ISO_IEC_14496-15-AVC-format-2012.pdf, page 16
|
||||
// lengthSizeMinusOne, or NAL_unit_length, always use 4bytes size
|
||||
u_int32_t NAL_unit_length = nb_frame;
|
||||
|
||||
// mux the avc NALU in "ISO Base Media File Format"
|
||||
// from H.264-AVC-ISO_IEC_14496-15.pdf, page 20
|
||||
// from ISO_IEC_14496-15-AVC-format-2012.pdf, page 20
|
||||
// NALUnitLength
|
||||
stream.write_4bytes(NAL_unit_length);
|
||||
// NALUnit
|
||||
|
@ -488,7 +488,7 @@ int SrsRawAacStream::mux_sequence_header(SrsRawAacStreamCodec* codec, string& sh
|
|||
sh = "";
|
||||
|
||||
char ch = 0;
|
||||
// @see aac-mp4a-format-ISO_IEC_14496-3+2001.pdf
|
||||
// @see ISO_IEC_14496-3-AAC-2001.pdf
|
||||
// AudioSpecificConfig (), page 33
|
||||
// 1.6.2.1 AudioSpecificConfig
|
||||
// audioObjectType; 5 bslbf
|
||||
|
|
Loading…
Reference in a new issue