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-21 14:09:17 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
10bc5399ecbd62d21d11d73d86a1cd90c2ea2c55
10bc5399
1 parent
b3bb2cdf
refine librtmp api, add prefix utils for utilities.
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
36 行增加
和
31 行删除
trunk/research/librtmp/srs_detect_rtmp.c
trunk/research/librtmp/srs_ingest_flv.c
trunk/src/libs/srs_librtmp.cpp
trunk/src/libs/srs_librtmp.hpp
trunk/research/librtmp/srs_detect_rtmp.c
查看文件 @
10bc539
...
...
@@ -35,7 +35,7 @@ int main(int argc, char** argv)
srs_rtmp_t
rtmp
;
// time
int64_t
time_startup
=
srs_get_time_ms
();
int64_t
time_startup
=
srs_
utils_
get_time_ms
();
int64_t
time_dns_resolve
=
0
;
int64_t
time_socket_connect
=
0
;
int64_t
time_play_stream
=
0
;
...
...
@@ -95,14 +95,14 @@ int main(int argc, char** argv)
goto
rtmp_destroy
;
}
srs_human_trace
(
"dns resolve success"
);
time_dns_resolve
=
srs_get_time_ms
();
time_dns_resolve
=
srs_
utils_
get_time_ms
();
if
((
ret
=
__srs_connect_server
(
rtmp
))
!=
0
)
{
srs_human_trace
(
"socket connect failed. ret=%d"
,
ret
);
goto
rtmp_destroy
;
}
srs_human_trace
(
"socket connect success"
);
time_socket_connect
=
srs_get_time_ms
();
time_socket_connect
=
srs_
utils_
get_time_ms
();
if
((
ret
=
__srs_do_simple_handshake
(
rtmp
))
!=
0
)
{
srs_human_trace
(
"do simple handshake failed. ret=%d"
,
ret
);
...
...
@@ -121,7 +121,7 @@ int main(int argc, char** argv)
goto
rtmp_destroy
;
}
srs_human_trace
(
"play stream success"
);
time_play_stream
=
srs_get_time_ms
();
time_play_stream
=
srs_
utils_
get_time_ms
();
for
(;;)
{
if
((
ret
=
srs_read_packet
(
rtmp
,
&
type
,
&
timestamp
,
&
data
,
&
size
))
!=
0
)
{
...
...
@@ -133,7 +133,7 @@ int main(int argc, char** argv)
if
(
SRS_RTMP_TYPE_VIDEO
==
type
||
SRS_RTMP_TYPE_AUDIO
==
type
)
{
if
(
time_first_packet
<=
0
)
{
time_first_packet
=
srs_get_time_ms
();
time_first_packet
=
srs_
utils_
get_time_ms
();
}
if
(
basetime
<=
0
)
{
basetime
=
timestamp
;
...
...
@@ -142,7 +142,7 @@ int main(int argc, char** argv)
free
(
data
);
if
(
srs_get_time_ms
()
-
time_startup
>
timeout
*
1000
)
{
if
(
srs_
utils_
get_time_ms
()
-
time_startup
>
timeout
*
1000
)
{
srs_human_trace
(
"timeout, terminate."
);
goto
rtmp_destroy
;
}
...
...
@@ -154,11 +154,11 @@ int main(int argc, char** argv)
}
rtmp_destroy:
bytes_nsend
=
srs_get_nsend_bytes
(
rtmp
);
bytes_nrecv
=
srs_get_nrecv_bytes
(
rtmp
);
bytes_nsend
=
srs_utils_get_send_bytes
(
rtmp
);
bytes_nrecv
=
srs_utils_get_recv_bytes
(
rtmp
);
srs_rtmp_destroy
(
rtmp
);
time_cleanup
=
srs_get_time_ms
();
time_cleanup
=
srs_
utils_
get_time_ms
();
time_duration
=
(
int
)(
time_cleanup
-
time_startup
);
// print result to stderr.
...
...
trunk/research/librtmp/srs_ingest_flv.c
查看文件 @
10bc539
...
...
@@ -48,7 +48,7 @@ int main(int argc, char** argv)
int
ret
=
0
;
// main function
tools_main_entrance_startup_time
=
srs_get_time_ms
();
tools_main_entrance_startup_time
=
srs_
utils_
get_time_ms
();
// user option parse index.
int
opt
=
0
;
...
...
@@ -215,7 +215,7 @@ int connect_oc(srs_rtmp_t ortmp)
int64_t
re_create
()
{
// if not very precise, we can directly use this as re.
int64_t
re
=
srs_get_time_ms
();
int64_t
re
=
srs_
utils_
get_time_ms
();
// use the starttime to get the deviation
int64_t
deviation
=
re
-
tools_main_entrance_startup_time
;
...
...
@@ -236,7 +236,7 @@ int64_t re_create()
void
re_update
(
int64_t
re
,
int32_t
starttime
,
u_int32_t
time
)
{
// send by pulse algorithm.
int64_t
now
=
srs_get_time_ms
();
int64_t
now
=
srs_
utils_
get_time_ms
();
int64_t
diff
=
time
-
starttime
-
(
now
-
re
);
if
(
diff
>
RE_PULSE_MS
)
{
usleep
(
diff
*
1000
);
...
...
@@ -246,7 +246,7 @@ void re_cleanup(int64_t re, int32_t starttime, u_int32_t time)
{
// for the last pulse, always sleep.
// for the virtual live encoder long time publishing.
int64_t
now
=
srs_get_time_ms
();
int64_t
now
=
srs_
utils_
get_time_ms
();
int64_t
diff
=
time
-
starttime
-
(
now
-
re
);
if
(
diff
>
0
)
{
srs_human_trace
(
"re_cleanup, diff=%d, start=%d, last=%d ms"
,
...
...
trunk/src/libs/srs_librtmp.cpp
查看文件 @
10bc539
...
...
@@ -858,27 +858,27 @@ int srs_version_revision()
return
VERSION_REVISION
;
}
int64_t
srs_get_time_ms
()
int64_t
srs_
utils_
get_time_ms
()
{
srs_update_system_time_ms
();
return
srs_get_system_time_ms
();
}
int64_t
srs_
get_n
send_bytes
(
srs_rtmp_t
rtmp
)
int64_t
srs_
utils_get_
send_bytes
(
srs_rtmp_t
rtmp
)
{
srs_assert
(
rtmp
!=
NULL
);
Context
*
context
=
(
Context
*
)
rtmp
;
return
context
->
rtmp
->
get_send_bytes
();
}
int64_t
srs_
get_n
recv_bytes
(
srs_rtmp_t
rtmp
)
int64_t
srs_
utils_get_
recv_bytes
(
srs_rtmp_t
rtmp
)
{
srs_assert
(
rtmp
!=
NULL
);
Context
*
context
=
(
Context
*
)
rtmp
;
return
context
->
rtmp
->
get_recv_bytes
();
}
int
srs_parse_timestamp
(
int
srs_
utils_
parse_timestamp
(
u_int32_t
time
,
char
type
,
char
*
data
,
int
size
,
u_int32_t
*
ppts
)
{
...
...
@@ -919,7 +919,7 @@ int srs_parse_timestamp(
return
ret
;
}
char
srs_
get
_codec_id
(
char
*
data
,
int
size
)
char
srs_
utils_get_flv_video
_codec_id
(
char
*
data
,
int
size
)
{
if
(
size
<
1
)
{
return
0
;
...
...
@@ -931,7 +931,7 @@ char srs_get_codec_id(char* data, int size)
return
codec_id
;
}
char
srs_
get
_avc_packet_type
(
char
*
data
,
int
size
)
char
srs_
utils_get_flv_video
_avc_packet_type
(
char
*
data
,
int
size
)
{
if
(
size
<
2
)
{
return
-
1
;
...
...
@@ -950,7 +950,7 @@ char srs_get_avc_packet_type(char* data, int size)
return
avc_packet_type
;
}
char
srs_
get
_frame_type
(
char
*
data
,
int
size
)
char
srs_
utils_get_flv_video
_frame_type
(
char
*
data
,
int
size
)
{
if
(
size
<
1
)
{
return
-
1
;
...
...
@@ -1526,16 +1526,16 @@ int srs_human_print_rtmp_packet(char type, u_int32_t timestamp, char* data, int
int
ret
=
ERROR_SUCCESS
;
u_int32_t
pts
;
if
(
srs_parse_timestamp
(
timestamp
,
type
,
data
,
size
,
&
pts
)
!=
0
)
{
if
(
srs_
utils_
parse_timestamp
(
timestamp
,
type
,
data
,
size
,
&
pts
)
!=
0
)
{
return
ret
;
}
if
(
type
==
SRS_RTMP_TYPE_VIDEO
)
{
srs_human_trace
(
"Video packet type=%s, dts=%d, pts=%d, size=%d, %s(%s,%s)"
,
srs_human_flv_tag_type2string
(
type
),
timestamp
,
pts
,
size
,
srs_human_flv_video_codec_id2string
(
srs_get_codec_id
(
data
,
size
)),
srs_human_flv_video_avc_packet_type2string
(
srs_get_avc_packet_type
(
data
,
size
)),
srs_human_flv_video_frame_type2string
(
srs_get_frame_type
(
data
,
size
))
srs_human_flv_video_codec_id2string
(
srs_utils_get_flv_video_codec_id
(
data
,
size
)),
srs_human_flv_video_avc_packet_type2string
(
srs_utils_get_flv_video_avc_packet_type
(
data
,
size
)),
srs_human_flv_video_frame_type2string
(
srs_utils_get_flv_video_frame_type
(
data
,
size
))
);
}
else
if
(
type
==
SRS_RTMP_TYPE_AUDIO
)
{
srs_human_trace
(
"Audio packet type=%s, dts=%d, pts=%d, size=%d"
,
...
...
trunk/src/libs/srs_librtmp.hpp
查看文件 @
10bc539
...
...
@@ -253,6 +253,11 @@ extern int srs_write_packet(srs_rtmp_t rtmp,
char
type
,
u_int32_t
timestamp
,
char
*
data
,
int
size
);
/*************************************************************
**************************************************************
* version apis
**************************************************************
*************************************************************/
// get protocol stack version
extern
int
srs_version_major
();
extern
int
srs_version_minor
();
...
...
@@ -267,17 +272,17 @@ extern int srs_version_revision();
* get the current system time in ms.
* use gettimeofday() to get system time.
*/
extern
int64_t
srs_get_time_ms
();
extern
int64_t
srs_
utils_
get_time_ms
();
/**
* get the send bytes.
*/
extern
int64_t
srs_
get_n
send_bytes
(
srs_rtmp_t
rtmp
);
extern
int64_t
srs_
utils_get_
send_bytes
(
srs_rtmp_t
rtmp
);
/**
* get the recv bytes.
*/
extern
int64_t
srs_
get_n
recv_bytes
(
srs_rtmp_t
rtmp
);
extern
int64_t
srs_
utils_get_
recv_bytes
(
srs_rtmp_t
rtmp
);
/**
* parse the dts and pts by time in header and data in tag,
...
...
@@ -294,7 +299,7 @@ extern int64_t srs_get_nrecv_bytes(srs_rtmp_t rtmp);
* @remark, the pts=dts for audio or data.
* @remark, video only support h.264.
*/
extern
int
srs_parse_timestamp
(
extern
int
srs_
utils_
parse_timestamp
(
u_int32_t
time
,
char
type
,
char
*
data
,
int
size
,
u_int32_t
*
ppts
);
...
...
@@ -310,7 +315,7 @@ extern int srs_parse_timestamp(
* 7 = AVC
* @return the code id. 0 for error.
*/
extern
char
srs_
get
_codec_id
(
char
*
data
,
int
size
);
extern
char
srs_
utils_get_flv_video
_codec_id
(
char
*
data
,
int
size
);
/**
* get the AVCPacketType of video tag.
...
...
@@ -321,7 +326,7 @@ extern char srs_get_codec_id(char* data, int size);
* not required or supported)
* @return the avc packet type. -1(0xff) for error.
*/
extern
char
srs_
get
_avc_packet_type
(
char
*
data
,
int
size
);
extern
char
srs_
utils_get_flv_video
_avc_packet_type
(
char
*
data
,
int
size
);
/**
* get the FrameType of video tag.
...
...
@@ -333,7 +338,7 @@ extern char srs_get_avc_packet_type(char* data, int size);
* 5 = video info/command frame
* @return the frame type. 0 for error.
*/
extern
char
srs_
get
_frame_type
(
char
*
data
,
int
size
);
extern
char
srs_
utils_get_flv_video
_frame_type
(
char
*
data
,
int
size
);
/*************************************************************
**************************************************************
...
...
请
注册
或
登录
后发表评论