Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2014-11-08 09:21:09 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
cd5c58ba5f3f272c4f59b1f035169e6c6fde96b2
cd5c58ba
1 parent
1074c8d9
for bug #66, refine the api and demo.
隐藏空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
22 行增加
和
25 行删除
trunk/research/librtmp/srs_h264_raw_publish.c
trunk/src/libs/srs_librtmp.cpp
trunk/src/libs/srs_librtmp.hpp
trunk/research/librtmp/srs_h264_raw_publish.c
查看文件 @
cd5c58b
...
...
@@ -37,26 +37,30 @@ gcc srs_h264_raw_publish.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_h
#define srs_trace(msg, ...) printf(msg, ##__VA_ARGS__);printf("\n")
int
read_h264_frame
(
char
*
data
,
int
size
,
char
**
p
,
int
fps
,
int
read_h264_frame
(
char
*
data
,
int
size
,
char
**
p
p
,
int
fps
,
char
**
frame
,
int
*
frame_size
,
int
*
dts
,
int
*
pts
)
{
char
*
p
=
*
pp
;
// @remark, for this demo, to publish h264 raw file to SRS,
// we search the h264 frame from the buffer which cached the h264 data.
// please get h264 raw data from device, it always a encoded frame.
int
pnb_start_code
=
0
;
if
(
!
srs_h264_startswith_annexb
(
*
p
,
size
-
(
*
p
-
data
),
&
pnb_start_code
))
{
if
(
!
srs_h264_startswith_annexb
(
p
,
size
-
(
p
-
data
),
&
pnb_start_code
))
{
srs_trace
(
"h264 raw data invalid."
);
return
-
1
;
}
*
p
+=
pnb_start_code
;
p
+=
pnb_start_code
;
*
frame
=
*
p
;
for
(;
*
p
<
data
+
size
;
*
p
=
*
p
+
1
)
{
if
(
srs_h264_startswith_annexb
(
*
p
,
size
-
(
*
p
-
data
),
&
pnb_start_code
))
{
*
frame
=
p
;
for
(;
p
<
data
+
size
;
p
++
)
{
if
(
srs_h264_startswith_annexb
(
p
,
size
-
(
p
-
data
),
&
pnb_start_code
))
{
break
;
}
}
*
frame_size
=
*
p
-
*
frame
;
*
pp
=
p
;
*
frame_size
=
p
-
*
frame
;
if
(
*
frame_size
<=
0
)
{
srs_trace
(
"h264 raw data invalid."
);
return
-
1
;
...
...
@@ -167,7 +171,7 @@ int main(int argc, char** argv)
// H.264-AVC-ISO_IEC_14496-10.pdf, page 44.
u_int8_t
nut
=
(
char
)
data
[
0
]
&
0x1f
;
srs_trace
(
"sent packet: type=%s, time=%d, size=%d, fps=%d, b[0]=%#x(%s)"
,
srs_type2string
(
SRS_RTMP_TYPE_VIDEO
),
dts
,
size
,
fps
,
nut
,
srs_type2string
(
SRS_RTMP_TYPE_VIDEO
),
dts
,
size
,
fps
,
(
char
)
data
[
0
]
,
(
nut
==
7
?
"SPS"
:
(
nut
==
8
?
"PPS"
:
(
nut
==
5
?
"I"
:
(
nut
==
1
?
"P"
:
"Unknown"
)))));
// @remark, when use encode device, it not need to sleep.
...
...
trunk/src/libs/srs_librtmp.cpp
查看文件 @
cd5c58b
...
...
@@ -70,9 +70,6 @@ struct Context
SimpleSocketStream
*
skt
;
int
stream_id
;
// for h264 raw stream
SrsStream
raw_stream
;
Context
()
{
rtmp
=
NULL
;
skt
=
NULL
;
...
...
@@ -1003,15 +1000,15 @@ int srs_write_h264_raw_frame(srs_rtmp_t rtmp, char* frame, int frame_size, u_int
{
int
ret
=
ERROR_SUCCESS
;
srs_assert
(
frame_size
>
0
);
srs_assert
(
frame_size
>
1
);
srs_assert
(
rtmp
!=
NULL
);
Context
*
context
=
(
Context
*
)
rtmp
;
if
((
ret
=
context
->
raw_stream
.
initialize
(
frame
,
frame_size
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// 5bits, 7.3.1 NAL unit syntax,
// H.264-AVC-ISO_IEC_14496-10.pdf, page 44.
// 7: SPS, 8: PPS, 5: I Frame, 1: P Frame
u_int8_t
nal_unit_type
=
(
char
)
frame
[
0
]
&
0x1f
;
/*// the timestamp in rtmp message header is dts.
u_int32_t timestamp = dts;
...
...
@@ -1025,11 +1022,6 @@ int srs_write_h264_raw_frame(srs_rtmp_t rtmp, char* frame, int frame_size, u_int
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.
// 7: SPS, 8: PPS, 5: I Frame, 1: P Frame
u_int8_t nal_unit_type = (char)h264_raw_data[0] & 0x1f;
// Frame Type, Type of video frame.
// @see: E.4.3 Video Tags, video_file_format_spec_v10_1.pdf, page 78
int8_t frame_type = SrsCodecVideoAVCFrameInterFrame;
...
...
trunk/src/libs/srs_librtmp.hpp
查看文件 @
cd5c58b
...
...
@@ -337,11 +337,12 @@ extern char* srs_amf0_human_print(srs_amf0_t amf0, char** pdata, int* psize);
**************************************************************
*************************************************************/
/**
* write h.264 raw frame to rtmp server.
* write h.264 raw frame
over RTMP
to rtmp server.
* @param frame the input h264 raw data, an encoded h.264 I/P/B frame data.
* it must be prefixed by h.264 annexb format, by N[00] 00 00 01, where N>=0,
* for instance, 00 00 00 01 67 42 80 29 95 A0 14 01 6E 40
* @paam frame_size the size of h264 raw data. assert frame_size > 0.
* the frame without h.264 annexb header, by N[00] 00 00 01, where N>=0,
* for instance, header(00 00 00 01) + frame(67 42 80 29 95 A0 14 01 6E 40)
* @paam frame_size the size of h264 raw data.
* assert frame_size > 1, at least has 1 bytes header.
* @param dts the dts of h.264 raw data.
* @param pts the pts of h.264 raw data.
*
...
...
请
注册
或
登录
后发表评论