1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

fix #203, srs-librtmp drop any video before sps/pps(sequence header). 2.0.21.

This commit is contained in:
winlin 2014-11-15 16:30:37 +08:00
parent ecfbcd68d8
commit 278ff845d3
6 changed files with 50 additions and 13 deletions

View file

@ -424,6 +424,7 @@ extern char* srs_amf0_human_print(srs_amf0_t amf0, char** pdata, int* psize);
* h264 raw codec
**************************************************************
*************************************************************/
typedef int srs_h264_bool;
/**
* write h.264 raw frame over RTMP to rtmp server.
* @param frames the input h264 raw data, encoded h.264 I/P/B frames data.
@ -441,8 +442,10 @@ extern char* srs_amf0_human_print(srs_amf0_t amf0, char** pdata, int* psize);
* @remark, cts = pts - dts
* @remark, use srs_h264_startswith_annexb to check whether frame is annexb format.
* @example /trunk/research/librtmp/srs_h264_raw_publish.c
* @see https://github.com/winlinvip/simple-rtmp-server/issues/66
*
* @return 0, success; otherswise, failed.
* for dvbsp error, check by srs_h264_is_dvbsp_error(error_code).
*/
/**
For the example file:
@ -458,25 +461,36 @@ The data sequence is:
0000000141E02041F8CDDC562BBDEFAD2F.....
User can send the SPS+PPS, then each frame:
// SPS+PPS
srs_write_h264_raw_frame('000000016742802995A014016E400000000168CE3880', size, dts, pts)
srs_h264_write_raw_frames('000000016742802995A014016E400000000168CE3880', size, dts, pts)
// IFrame
srs_write_h264_raw_frame('0000000165B8041014C038008B0D0D3A071......', size, dts, pts)
srs_h264_write_raw_frames('0000000165B8041014C038008B0D0D3A071......', size, dts, pts)
// PFrame
srs_write_h264_raw_frame('0000000141E02041F8CDDC562BBDEFAD2F......', size, dts, pts)
srs_h264_write_raw_frames('0000000141E02041F8CDDC562BBDEFAD2F......', size, dts, pts)
User also can send one by one:
// SPS
srs_write_h264_raw_frame('000000016742802995A014016E4', size, dts, pts)
srs_h264_write_raw_frames('000000016742802995A014016E4', size, dts, pts)
// PPS
srs_write_h264_raw_frame('00000000168CE3880', size, dts, pts)
srs_h264_write_raw_frames('00000000168CE3880', size, dts, pts)
// IFrame
srs_write_h264_raw_frame('0000000165B8041014C038008B0D0D3A071......', size, dts, pts)
srs_h264_write_raw_frames('0000000165B8041014C038008B0D0D3A071......', size, dts, pts)
// PFrame
srs_write_h264_raw_frame('0000000141E02041F8CDDC562BBDEFAD2F......', size, dts, pts)
srs_h264_write_raw_frames('0000000141E02041F8CDDC562BBDEFAD2F......', size, dts, pts)
*/
extern int srs_write_h264_raw_frames(srs_rtmp_t rtmp,
extern int srs_h264_write_raw_frames(srs_rtmp_t rtmp,
char* frames, int frames_size, u_int32_t dts, u_int32_t pts
);
/**
* whether error_code is dvbsp(drop video before sps/pps/sequence-header) error.
*
* @see https://github.com/winlinvip/simple-rtmp-server/issues/203
* @example /trunk/research/librtmp/srs_h264_raw_publish.c
* @remark why drop video?
* some encoder, for example, ipcamera, will send sps/pps before each IFrame,
* so, when error and reconnect the rtmp, the first video is not sps/pps(sequence header),
* this will cause SRS server to disable HLS.
*/
extern srs_h264_bool srs_h264_is_dvbsp_error(int error_code);
/**
* whether h264 raw data starts with the annexb,
* which bytes sequence matches N[00] 00 00 01, where N>=0.
* @param h264_raw_data the input h264 raw data, a encoded h.264 I/P/B frame data.