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

for bug #66, use new api to directly sendout h264 raw data.

This commit is contained in:
winlin 2014-11-08 09:12:52 +08:00
parent 496f4246f4
commit 1074c8d9b2
3 changed files with 34 additions and 34 deletions

View file

@ -70,6 +70,9 @@ struct Context
SimpleSocketStream* skt;
int stream_id;
// for h264 raw stream
SrsStream raw_stream;
Context() {
rtmp = NULL;
skt = NULL;
@ -996,22 +999,31 @@ char* srs_amf0_human_print(srs_amf0_t amf0, char** pdata, int* psize)
return any->human_print(pdata, psize);
}
int srs_h264_to_rtmp(char* h264_raw_data, int h264_raw_size, u_int32_t dts, u_int32_t pts, char** prtmp_data, int* prtmp_size, u_int32_t* ptimestamp)
int srs_write_h264_raw_frame(srs_rtmp_t rtmp, char* frame, int frame_size, u_int32_t dts, u_int32_t pts)
{
srs_assert(h264_raw_size > 0);
int ret = ERROR_SUCCESS;
// the timestamp in rtmp message header is dts.
*ptimestamp = dts;
srs_assert(frame_size > 0);
srs_assert(rtmp != NULL);
Context* context = (Context*)rtmp;
if ((ret = context->raw_stream.initialize(frame, frame_size)) != ERROR_SUCCESS) {
return ret;
}
/*// the timestamp in rtmp message header is dts.
u_int32_t timestamp = dts;
// for h264 in RTMP video payload, there is 5bytes header:
// 1bytes, FrameType | CodecID
// 1bytes, AVCPacketType
// 3bytes, CompositionTime, the cts.
// @see: E.4.3 Video Tags, video_file_format_spec_v10_1.pdf, page 78
*prtmp_size = h264_raw_size + 5;
char* p = new char[*prtmp_size];
memcpy(p + 5, h264_raw_data, h264_raw_size);
*prtmp_data = p;
int size = h264_raw_size + 5;
char* data = new char[size];
memcpy(data + 5, h264_raw_data, h264_raw_size);
// 5bits, 7.3.1 NAL unit syntax,
// H.264-AVC-ISO_IEC_14496-10.pdf, page 44.
@ -1044,9 +1056,9 @@ int srs_h264_to_rtmp(char* h264_raw_data, int h264_raw_size, u_int32_t dts, u_in
char* pp = (char*)&cts;
*p++ = pp[2];
*p++ = pp[1];
*p++ = pp[0];
*p++ = pp[0];*/
return 0;
return ret;
}
int srs_h264_startswith_annexb(char* h264_raw_data, int h264_raw_size, int* pnb_start_code)