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
2016-08-10 22:29:56 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
304ff02aef3b81b1832b3436c12260daf7b3d8d3
304ff02a
1 parent
02fb0779
default to 30s timeout for librtmp
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
43 行增加
和
17 行删除
trunk/src/libs/srs_librtmp.cpp
trunk/src/libs/srs_librtmp.hpp
trunk/src/libs/srs_librtmp.cpp
查看文件 @
304ff02
...
...
@@ -53,6 +53,9 @@ using namespace std;
ISrsLog
*
_srs_log
=
new
ISrsLog
();
ISrsThreadContext
*
_srs_context
=
new
ISrsThreadContext
();
// use this default timeout in us, if user not set.
#define SRS_SOCKET_DEFAULT_TIMEOUT 30 * 1000 * 1000LL
/**
* export runtime context.
*/
...
...
@@ -104,6 +107,10 @@ struct Context
// the aac sequence header.
std
::
string
aac_specific_config
;
// user set timeout, in us.
int64_t
stimeout
;
int64_t
rtimeout
;
Context
()
{
rtmp
=
NULL
;
skt
=
NULL
;
...
...
@@ -112,6 +119,7 @@ struct Context
h264_sps_pps_sent
=
false
;
h264_sps_changed
=
false
;
h264_pps_changed
=
false
;
rtimeout
=
stimeout
=
-
1
;
}
virtual
~
Context
()
{
srs_freep
(
req
);
...
...
@@ -577,9 +585,12 @@ int srs_rtmp_set_timeout(srs_rtmp_t rtmp, int recv_timeout_ms, int send_timeout_
}
Context
*
context
=
(
Context
*
)
rtmp
;
context
->
stimeout
=
send_timeout_ms
*
1000
;
context
->
rtimeout
=
recv_timeout_ms
*
1000
;
context
->
skt
->
set_recv_timeout
(
recv_timeout_ms
*
1000LL
);
context
->
skt
->
set_send_timeout
(
send_timeout_ms
*
1000LL
);
context
->
skt
->
set_recv_timeout
(
context
->
rtimeout
);
context
->
skt
->
set_send_timeout
(
context
->
stimeout
);
return
ret
;
}
...
...
@@ -640,6 +651,16 @@ int srs_rtmp_connect_server(srs_rtmp_t rtmp)
srs_assert
(
rtmp
!=
NULL
);
Context
*
context
=
(
Context
*
)
rtmp
;
// set timeout if user not set.
if
(
context
->
stimeout
==
-
1
)
{
context
->
stimeout
=
SRS_SOCKET_DEFAULT_TIMEOUT
;
context
->
skt
->
set_send_timeout
(
context
->
stimeout
);
}
if
(
context
->
rtimeout
==
-
1
)
{
context
->
rtimeout
=
SRS_SOCKET_DEFAULT_TIMEOUT
;
context
->
skt
->
set_recv_timeout
(
context
->
rtimeout
);
}
if
((
ret
=
srs_librtmp_context_connect
(
context
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
...
...
trunk/src/libs/srs_librtmp.hpp
查看文件 @
304ff02
...
...
@@ -88,29 +88,34 @@ extern int srs_version_revision();
// the RTMP handler.
typedef
void
*
srs_rtmp_t
;
typedef
void
*
srs_amf0_t
;
/**
* create/destroy a rtmp protocol stack.
* @url rtmp url, for example:
* rtmp://localhost/live/livestream
*
* @return a rtmp handler, or NULL if error occured.
*/
* create/destroy a rtmp protocol stack.
* @url rtmp url, for example:
* rtmp://localhost/live/livestream
* @remark default timeout to 30s if not set by srs_rtmp_set_timeout.
*
* @return a rtmp handler, or NULL if error occured.
*/
extern
srs_rtmp_t
srs_rtmp_create
(
const
char
*
url
);
/**
* create rtmp with url, used for connection specified application.
* @param url the tcUrl, for exmple:
* rtmp://localhost/live
* @remark this is used to create application connection-oriented,
* for example, the bandwidth client used this, no stream specified.
*
* @return a rtmp handler, or NULL if error occured.
*/
* create rtmp with url, used for connection specified application.
* @param url the tcUrl, for exmple:
* rtmp://localhost/live
* @remark this is used to create application connection-oriented,
* for example, the bandwidth client used this, no stream specified.
* @remark default timeout to 30s if not set by srs_rtmp_set_timeout.
*
* @return a rtmp handler, or NULL if error occured.
*/
extern
srs_rtmp_t
srs_rtmp_create2
(
const
char
*
url
);
/**
* set socket timeout
* @param recv_timeout_ms the timeout for receiving messages in ms.
* @param send_timeout_ms the timeout for sending message in ms.
* @remark user can set timeout once srs_rtmp_create/srs_rtmp_create2,
* or before srs_rtmp_handshake or srs_rtmp_dns_resolve to connect to server.
* @remark default timeout to 30s if not set by srs_rtmp_set_timeout.
*
* @return 0, success; otherswise, failed.
*/
...
...
请
注册
或
登录
后发表评论