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-09-14 13:47:25 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
0d57ef93732489db0aec6a0e85d9f2f53352ce5b
0d57ef93
1 parent
6d50aa1a
fix #458, http hooks use source thread cid. 2.0.188
隐藏空白字符变更
内嵌
并排对比
正在显示
8 个修改的文件
包含
50 行增加
和
37 行删除
README.md
trunk/src/app/srs_app_dvr.cpp
trunk/src/app/srs_app_dvr.hpp
trunk/src/app/srs_app_hls.cpp
trunk/src/app/srs_app_hls.hpp
trunk/src/app/srs_app_http_hooks.cpp
trunk/src/app/srs_app_http_hooks.hpp
trunk/src/core/srs_core.hpp
README.md
查看文件 @
0d57ef9
...
...
@@ -343,6 +343,7 @@ Remark:
## History
*
v2.0, 2015-09-14, for
[
#458
][
bug #458
]
http hooks use source thread cid. 2.0.188
*
v2.0, 2015-09-14, for
[
#475
][
bug #475
]
fix http hooks crash for st context switch. 2.0.187
*
v2.0, 2015-09-09, support reload utc_time. 2.0.186
*
<strong>
v2.0, 2015-08-23,
[
2.0 alpha(2.0.185)
][
r2.0a0
]
released. 89022 lines.
</strong>
...
...
@@ -1026,6 +1027,7 @@ Winlin
[
bug #92
]:
https://github.com/simple-rtmp-server/srs/issues/92
[
bug #380
]:
https://github.com/simple-rtmp-server/srs/issues/380
[
bug #475
]:
https://github.com/simple-rtmp-server/srs/issues/475
[
bug #458
]:
https://github.com/simple-rtmp-server/srs/issues/458
[
bug #454
]:
https://github.com/simple-rtmp-server/srs/issues/454
[
bug #442
]:
https://github.com/simple-rtmp-server/srs/issues/442
[
bug #169
]:
https://github.com/simple-rtmp-server/srs/issues/169
...
...
trunk/src/app/srs_app_dvr.cpp
查看文件 @
0d57ef9
...
...
@@ -496,8 +496,9 @@ int SrsFlvSegment::on_reload_vhost_dvr(std::string /*vhost*/)
return
ret
;
}
SrsDvrAsyncCallOnDvr
::
SrsDvrAsyncCallOnDvr
(
SrsRequest
*
r
,
string
p
)
SrsDvrAsyncCallOnDvr
::
SrsDvrAsyncCallOnDvr
(
int
c
,
SrsRequest
*
r
,
string
p
)
{
cid
=
c
;
req
=
r
->
copy
();
path
=
p
;
}
...
...
@@ -534,7 +535,7 @@ int SrsDvrAsyncCallOnDvr::call()
for
(
int
i
=
0
;
i
<
(
int
)
hooks
.
size
();
i
++
)
{
std
::
string
url
=
hooks
.
at
(
i
);
if
((
ret
=
SrsHttpHooks
::
on_dvr
(
url
,
req
,
path
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
SrsHttpHooks
::
on_dvr
(
cid
,
url
,
req
,
path
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"hook client on_dvr failed. url=%s, ret=%d"
,
url
.
c_str
(),
ret
);
return
ret
;
}
...
...
@@ -638,7 +639,8 @@ int SrsDvrPlan::on_reap_segment()
{
int
ret
=
ERROR_SUCCESS
;
if
((
ret
=
async
->
execute
(
new
SrsDvrAsyncCallOnDvr
(
req
,
segment
->
get_path
())))
!=
ERROR_SUCCESS
)
{
int
cid
=
_srs_context
->
get_id
();
if
((
ret
=
async
->
execute
(
new
SrsDvrAsyncCallOnDvr
(
cid
,
req
,
segment
->
get_path
())))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
...
...
trunk/src/app/srs_app_dvr.hpp
查看文件 @
0d57ef9
...
...
@@ -181,10 +181,11 @@ public:
class
SrsDvrAsyncCallOnDvr
:
public
ISrsAsyncCallTask
{
private
:
int
cid
;
std
::
string
path
;
SrsRequest
*
req
;
public
:
SrsDvrAsyncCallOnDvr
(
SrsRequest
*
r
,
std
::
string
p
);
SrsDvrAsyncCallOnDvr
(
int
c
,
SrsRequest
*
r
,
std
::
string
p
);
virtual
~
SrsDvrAsyncCallOnDvr
();
public
:
virtual
int
call
();
...
...
trunk/src/app/srs_app_hls.cpp
查看文件 @
0d57ef9
...
...
@@ -177,9 +177,10 @@ void SrsHlsSegment::update_duration(int64_t current_frame_dts)
return
;
}
SrsDvrAsyncCallOnHls
::
SrsDvrAsyncCallOnHls
(
SrsRequest
*
r
,
string
p
,
string
t
,
string
m
,
string
mu
,
int
s
,
double
d
)
SrsDvrAsyncCallOnHls
::
SrsDvrAsyncCallOnHls
(
int
c
,
SrsRequest
*
r
,
string
p
,
string
t
,
string
m
,
string
mu
,
int
s
,
double
d
)
{
req
=
r
->
copy
();
cid
=
c
;
path
=
p
;
ts_url
=
t
;
m3u8
=
m
;
...
...
@@ -220,7 +221,7 @@ int SrsDvrAsyncCallOnHls::call()
for
(
int
i
=
0
;
i
<
(
int
)
hooks
.
size
();
i
++
)
{
std
::
string
url
=
hooks
.
at
(
i
);
if
((
ret
=
SrsHttpHooks
::
on_hls
(
url
,
req
,
path
,
ts_url
,
m3u8
,
m3u8_url
,
seq_no
,
duration
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
SrsHttpHooks
::
on_hls
(
cid
,
url
,
req
,
path
,
ts_url
,
m3u8
,
m3u8_url
,
seq_no
,
duration
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"hook client on_hls failed. url=%s, ret=%d"
,
url
.
c_str
(),
ret
);
return
ret
;
}
...
...
@@ -235,8 +236,9 @@ string SrsDvrAsyncCallOnHls::to_string()
return
"on_hls: "
+
path
;
}
SrsDvrAsyncCallOnHlsNotify
::
SrsDvrAsyncCallOnHlsNotify
(
SrsRequest
*
r
,
string
u
)
SrsDvrAsyncCallOnHlsNotify
::
SrsDvrAsyncCallOnHlsNotify
(
int
c
,
SrsRequest
*
r
,
string
u
)
{
cid
=
c
;
req
=
r
->
copy
();
ts_url
=
u
;
}
...
...
@@ -274,7 +276,7 @@ int SrsDvrAsyncCallOnHlsNotify::call()
int
nb_notify
=
_srs_config
->
get_vhost_hls_nb_notify
(
req
->
vhost
);
for
(
int
i
=
0
;
i
<
(
int
)
hooks
.
size
();
i
++
)
{
std
::
string
url
=
hooks
.
at
(
i
);
if
((
ret
=
SrsHttpHooks
::
on_hls_notify
(
url
,
req
,
ts_url
,
nb_notify
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
SrsHttpHooks
::
on_hls_notify
(
cid
,
url
,
req
,
ts_url
,
nb_notify
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"hook client on_hls_notify failed. url=%s, ret=%d"
,
url
.
c_str
(),
ret
);
return
ret
;
}
...
...
@@ -724,7 +726,8 @@ int SrsHlsMuxer::segment_close(string log_desc)
segments
.
push_back
(
current
);
// use async to call the http hooks, for it will cause thread switch.
if
((
ret
=
async
->
execute
(
new
SrsDvrAsyncCallOnHls
(
req
,
if
((
ret
=
async
->
execute
(
new
SrsDvrAsyncCallOnHls
(
_srs_context
->
get_id
(),
req
,
current
->
full_path
,
current
->
uri
,
m3u8
,
m3u8_url
,
current
->
sequence_no
,
current
->
duration
)))
!=
ERROR_SUCCESS
)
{
...
...
@@ -732,7 +735,7 @@ int SrsHlsMuxer::segment_close(string log_desc)
}
// use async to call the http hooks, for it will cause thread switch.
if
((
ret
=
async
->
execute
(
new
SrsDvrAsyncCallOnHlsNotify
(
req
,
current
->
uri
)))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
async
->
execute
(
new
SrsDvrAsyncCallOnHlsNotify
(
_srs_context
->
get_id
(),
req
,
current
->
uri
)))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
...
...
trunk/src/app/srs_app_hls.hpp
查看文件 @
0d57ef9
...
...
@@ -167,6 +167,7 @@ public:
class
SrsDvrAsyncCallOnHls
:
public
ISrsAsyncCallTask
{
private
:
int
cid
;
std
::
string
path
;
std
::
string
ts_url
;
std
::
string
m3u8
;
...
...
@@ -175,7 +176,7 @@ private:
SrsRequest
*
req
;
double
duration
;
public
:
SrsDvrAsyncCallOnHls
(
SrsRequest
*
r
,
std
::
string
p
,
std
::
string
t
,
std
::
string
m
,
std
::
string
mu
,
int
s
,
double
d
);
SrsDvrAsyncCallOnHls
(
int
c
,
SrsRequest
*
r
,
std
::
string
p
,
std
::
string
t
,
std
::
string
m
,
std
::
string
mu
,
int
s
,
double
d
);
virtual
~
SrsDvrAsyncCallOnHls
();
public
:
virtual
int
call
();
...
...
@@ -188,10 +189,11 @@ public:
class
SrsDvrAsyncCallOnHlsNotify
:
public
ISrsAsyncCallTask
{
private
:
int
cid
;
std
::
string
ts_url
;
SrsRequest
*
req
;
public
:
SrsDvrAsyncCallOnHlsNotify
(
SrsRequest
*
r
,
std
::
string
u
);
SrsDvrAsyncCallOnHlsNotify
(
int
c
,
SrsRequest
*
r
,
std
::
string
u
);
virtual
~
SrsDvrAsyncCallOnHlsNotify
();
public
:
virtual
int
call
();
...
...
trunk/src/app/srs_app_http_hooks.cpp
查看文件 @
0d57ef9
...
...
@@ -257,11 +257,11 @@ void SrsHttpHooks::on_stop(string url, SrsRequest* req)
return
;
}
int
SrsHttpHooks
::
on_dvr
(
string
url
,
SrsRequest
*
req
,
string
file
)
int
SrsHttpHooks
::
on_dvr
(
int
cid
,
string
url
,
SrsRequest
*
req
,
string
file
)
{
int
ret
=
ERROR_SUCCESS
;
int
client_id
=
_srs_context
->
get_id
()
;
int
client_id
=
cid
;
std
::
string
cwd
=
_srs_config
->
cwd
();
std
::
stringstream
ss
;
...
...
@@ -293,11 +293,11 @@ int SrsHttpHooks::on_dvr(string url, SrsRequest* req, string file)
return
ret
;
}
int
SrsHttpHooks
::
on_hls
(
string
url
,
SrsRequest
*
req
,
string
file
,
string
ts_url
,
string
m3u8
,
string
m3u8_url
,
int
sn
,
double
duration
)
int
SrsHttpHooks
::
on_hls
(
int
cid
,
string
url
,
SrsRequest
*
req
,
string
file
,
string
ts_url
,
string
m3u8
,
string
m3u8_url
,
int
sn
,
double
duration
)
{
int
ret
=
ERROR_SUCCESS
;
int
client_id
=
_srs_context
->
get_id
()
;
int
client_id
=
cid
;
std
::
string
cwd
=
_srs_config
->
cwd
();
std
::
stringstream
ss
;
...
...
@@ -334,11 +334,11 @@ int SrsHttpHooks::on_hls(string url, SrsRequest* req, string file, string ts_url
return
ret
;
}
int
SrsHttpHooks
::
on_hls_notify
(
std
::
string
url
,
SrsRequest
*
req
,
std
::
string
ts_url
,
int
nb_notify
)
int
SrsHttpHooks
::
on_hls_notify
(
int
cid
,
std
::
string
url
,
SrsRequest
*
req
,
std
::
string
ts_url
,
int
nb_notify
)
{
int
ret
=
ERROR_SUCCESS
;
int
client_id
=
_srs_context
->
get_id
()
;
int
client_id
=
cid
;
std
::
string
cwd
=
_srs_config
->
cwd
();
if
(
srs_string_starts_with
(
ts_url
,
"http://"
)
||
srs_string_starts_with
(
ts_url
,
"https://"
))
{
...
...
trunk/src/app/srs_app_http_hooks.hpp
查看文件 @
0d57ef9
...
...
@@ -90,32 +90,35 @@ public:
*/
static
void
on_stop
(
std
::
string
url
,
SrsRequest
*
req
);
/**
* on_dvr hook, when reap a dvr file.
* @param url the api server url, to process the event.
* ignore if empty.
* @param file the file path, can be relative or absolute path.
*/
static
int
on_dvr
(
std
::
string
url
,
SrsRequest
*
req
,
std
::
string
file
);
* on_dvr hook, when reap a dvr file.
* @param url the api server url, to process the event.
* ignore if empty.
* @param file the file path, can be relative or absolute path.
* @param cid the source connection cid, for the on_dvr is async call.
*/
static
int
on_dvr
(
int
cid
,
std
::
string
url
,
SrsRequest
*
req
,
std
::
string
file
);
/**
* when hls reap segment, callback.
* @param url the api server url, to process the event.
* ignore if empty.
* @param file the ts file path, can be relative or absolute path.
* @param ts_url the ts url, which used for m3u8.
* @param m3u8 the m3u8 file path, can be relative or absolute path.
* @param m3u8_url the m3u8 url, which is used for the http mount path.
* @param sn the seq_no, the sequence number of ts in hls/m3u8.
* @param duration the segment duration in seconds.
*/
static
int
on_hls
(
std
::
string
url
,
SrsRequest
*
req
,
std
::
string
file
,
std
::
string
ts_url
,
std
::
string
m3u8
,
std
::
string
m3u8_url
,
int
sn
,
double
duration
);
* when hls reap segment, callback.
* @param url the api server url, to process the event.
* ignore if empty.
* @param file the ts file path, can be relative or absolute path.
* @param ts_url the ts url, which used for m3u8.
* @param m3u8 the m3u8 file path, can be relative or absolute path.
* @param m3u8_url the m3u8 url, which is used for the http mount path.
* @param sn the seq_no, the sequence number of ts in hls/m3u8.
* @param duration the segment duration in seconds.
* @param cid the source connection cid, for the on_dvr is async call.
*/
static
int
on_hls
(
int
cid
,
std
::
string
url
,
SrsRequest
*
req
,
std
::
string
file
,
std
::
string
ts_url
,
std
::
string
m3u8
,
std
::
string
m3u8_url
,
int
sn
,
double
duration
);
/**
* when hls reap segment, callback.
* @param url the api server url, to process the event.
* ignore if empty.
* @param ts_url the ts uri, used to replace the variable [ts_url] in url.
* @param nb_notify the max bytes to read from notify server.
* @param cid the source connection cid, for the on_dvr is async call.
*/
static
int
on_hls_notify
(
std
::
string
url
,
SrsRequest
*
req
,
std
::
string
ts_url
,
int
nb_notify
);
static
int
on_hls_notify
(
int
cid
,
std
::
string
url
,
SrsRequest
*
req
,
std
::
string
ts_url
,
int
nb_notify
);
private
:
static
int
do_post
(
std
::
string
url
,
std
::
string
req
,
int
&
code
,
std
::
string
&
res
);
};
...
...
trunk/src/core/srs_core.hpp
查看文件 @
0d57ef9
...
...
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version
#define VERSION_MAJOR 2
#define VERSION_MINOR 0
#define VERSION_REVISION 18
7
#define VERSION_REVISION 18
8
// server info.
#define RTMP_SIG_SRS_KEY "SRS"
...
...
请
注册
或
登录
后发表评论