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
2015-04-10 13:45:21 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1f93fb3399d92a9ea0cb2eae0e90a3843170da6d
1f93fb33
1 parent
d8988da0
refine hls notify, support timeout.
显示空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
19 行增加
和
10 行删除
trunk/src/app/srs_app_http_client.cpp
trunk/src/app/srs_app_http_client.hpp
trunk/src/app/srs_app_http_hooks.cpp
trunk/src/kernel/srs_kernel_utility.cpp
trunk/src/app/srs_app_http_client.cpp
查看文件 @
1f93fb3
...
...
@@ -37,15 +37,13 @@ using namespace std;
#include <srs_app_utility.hpp>
#include <srs_core_autofree.hpp>
// when error, http client sleep for a while and retry.
#define SRS_HTTP_CLIENT_SLEEP_US (int64_t)(3*1000*1000LL)
SrsHttpClient
::
SrsHttpClient
()
{
connected
=
false
;
stfd
=
NULL
;
skt
=
NULL
;
parser
=
NULL
;
timeout_us
=
0
;
}
SrsHttpClient
::~
SrsHttpClient
()
...
...
@@ -54,7 +52,7 @@ SrsHttpClient::~SrsHttpClient()
srs_freep
(
parser
);
}
int
SrsHttpClient
::
initialize
(
string
h
,
int
p
)
int
SrsHttpClient
::
initialize
(
string
h
,
int
p
,
int64_t
t_us
)
{
int
ret
=
ERROR_SUCCESS
;
...
...
@@ -68,6 +66,7 @@ int SrsHttpClient::initialize(string h, int p)
host
=
h
;
port
=
p
;
timeout_us
=
t_us
;
return
ret
;
}
...
...
@@ -183,10 +182,9 @@ int SrsHttpClient::connect()
disconnect
();
// open socket.
int64_t
timeout
=
SRS_HTTP_CLIENT_SLEEP_US
;
if
((
ret
=
srs_socket_connect
(
host
,
port
,
timeout
,
&
stfd
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
srs_socket_connect
(
host
,
port
,
timeout_us
,
&
stfd
))
!=
ERROR_SUCCESS
)
{
srs_warn
(
"http client failed, server=%s, port=%d, timeout=%"
PRId64
", ret=%d"
,
host
.
c_str
(),
port
,
timeout
,
ret
);
host
.
c_str
(),
port
,
timeout
_us
,
ret
);
return
ret
;
}
srs_info
(
"connect to server success. server=%s, port=%d"
,
host
,
port
);
...
...
@@ -195,6 +193,10 @@ int SrsHttpClient::connect()
skt
=
new
SrsStSocket
(
stfd
);
connected
=
true
;
// set the recv/send timeout in us.
skt
->
set_recv_timeout
(
timeout_us
);
skt
->
set_send_timeout
(
timeout_us
);
return
ret
;
}
...
...
trunk/src/app/srs_app_http_client.hpp
查看文件 @
1f93fb3
...
...
@@ -40,6 +40,9 @@ class SrsHttpParser;
class
SrsHttpMessage
;
class
SrsStSocket
;
// the default timeout for http client.
#define SRS_HTTP_CLIENT_TIMEOUT_US (int64_t)(30*1000*1000LL)
/**
* http client to GET/POST/PUT/DELETE uri
*/
...
...
@@ -51,6 +54,7 @@ private:
SrsStSocket
*
skt
;
SrsHttpParser
*
parser
;
private
:
int64_t
timeout_us
;
// host name or ip.
std
::
string
host
;
int
port
;
...
...
@@ -61,7 +65,7 @@ public:
/**
* initialize the client, connect to host and port.
*/
virtual
int
initialize
(
std
::
string
h
,
int
p
);
virtual
int
initialize
(
std
::
string
h
,
int
p
,
int64_t
t_us
=
SRS_HTTP_CLIENT_TIMEOUT_US
);
public
:
/**
* to post data to the uri.
...
...
trunk/src/app/srs_app_http_hooks.cpp
查看文件 @
1f93fb3
...
...
@@ -44,6 +44,9 @@ using namespace std;
#define SRS_HTTP_HEADER_BUFFER 1024
#define SRS_HTTP_BODY_BUFFER 32 * 1024
// the timeout for hls notify, in us.
#define SRS_HLS_NOTIFY_TIMEOUT_US (int64_t)(10*1000*1000LL)
SrsHttpHooks
::
SrsHttpHooks
()
{
}
...
...
@@ -350,7 +353,7 @@ int SrsHttpHooks::on_hls_notify(std::string url, SrsRequest* req, std::string ts
}
SrsHttpClient
http
;
if
((
ret
=
http
.
initialize
(
uri
.
get_host
(),
uri
.
get_port
()))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
http
.
initialize
(
uri
.
get_host
(),
uri
.
get_port
()
,
SRS_HLS_NOTIFY_TIMEOUT_US
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
...
...
trunk/src/kernel/srs_kernel_utility.cpp
查看文件 @
1f93fb3
...
...
@@ -390,7 +390,7 @@ bool srs_aac_startswith_adts(SrsStream* stream)
char
*
bytes
=
stream
->
data
()
+
stream
->
pos
();
char
*
p
=
bytes
;
if
(
!
stream
->
require
(
p
-
bytes
+
2
))
{
if
(
!
stream
->
require
(
(
int
)(
p
-
bytes
)
+
2
))
{
return
false
;
}
...
...
请
注册
或
登录
后发表评论