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-04-30 11:56:19 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
30bb3ff704d13196e1060f81c4bc01a202f75707
30bb3ff7
1 parent
aebff659
add dvr_plan hss to full.conf
隐藏空白字符变更
内嵌
并排对比
正在显示
8 个修改的文件
包含
48 行增加
和
45 行删除
trunk/conf/full.conf
trunk/research/librtmp/srs_ingest_rtmp.c
trunk/src/app/srs_app_config.cpp
trunk/src/app/srs_app_config.hpp
trunk/src/app/srs_app_dvr.cpp
trunk/src/app/srs_app_dvr.hpp
trunk/src/app/srs_app_http_hooks.cpp
trunk/src/app/srs_app_http_hooks.hpp
trunk/conf/full.conf
查看文件 @
30bb3ff
...
...
@@ -122,7 +122,7 @@ vhost dvr.srs.com {
# start to record to file when encoder publish,
# reap flv according by specified dvr_plan.
# http callbacks:
# @see http callback on_dvr_reap_flv on http_hooks section.
# @see http callback on_dvr_
hss_
reap_flv on http_hooks section.
dvr
{
# whether enabled dvr features
# default: off
...
...
@@ -142,6 +142,7 @@ vhost dvr.srs.com {
# the dvr plan. canbe:
# session reap flv when session end(unpublish).
# segment reap flv when flv duration exceed the specified dvr_duration.
# hss reap flv required by bravo(chnvideo.com) p2p system.
# default: session
dvr_plan
session
;
# the param for plan(segment), in seconds.
...
...
@@ -347,10 +348,12 @@ vhost hooks.callback.srs.com {
# support multiple api hooks, format:
# on_stop http://xxx/api0 http://xxx/api1 http://xxx/apiN
on_stop
http
://
127
.
0
.
0
.
1
:
8085
/
api
/
v1
/
sessions
http
://
localhost
:
8085
/
api
/
v1
/
sessions
;
#
# for dvr(dvr_plan is hss).
# when dvr got flv header, call the hook,
# the request in the POST data string is a object encode by json:
# {
# "action": "on_dvr_reap_flv_header",
# "action": "on_dvr_
hss_
reap_flv_header",
# "vhost": "video.test.com", "app": "live",
# "stream": "livestream",
# "segment": {
...
...
@@ -361,7 +364,7 @@ vhost hooks.callback.srs.com {
# when dvr reap flv file, call the hook,
# the request in the POST data string is a object encode by json:
# {
# "action": "on_dvr_reap_flv",
# "action": "on_dvr_
hss_
reap_flv",
# "vhost": "video.test.com", "app": "live",
# "stream": "livestream",
# "segment": {
...
...
@@ -376,7 +379,7 @@ vhost hooks.callback.srs.com {
# 0
# support multiple api hooks, format:
# on_stop http://xxx/api0 http://xxx/api1 http://xxx/apiN
on_dvr_reap_flv
http
://
127
.
0
.
0
.
1
:
8085
/
api
/
v1
/
dvrs
http
://
localhost
:
8085
/
api
/
v1
/
dvrs
;
on_dvr_
hss_
reap_flv
http
://
127
.
0
.
0
.
1
:
8085
/
api
/
v1
/
dvrs
http
://
localhost
:
8085
/
api
/
v1
/
dvrs
;
}
}
...
...
trunk/research/librtmp/srs_ingest_rtmp.c
查看文件 @
30bb3ff
...
...
@@ -113,14 +113,14 @@ int proxy(srs_rtmp_t irtmp, srs_rtmp_t ortmp)
trace
(
"irtmp get packet failed. ret=%d"
,
ret
);
return
ret
;
}
verbos
e
(
"irtmp got packet: type=%s, time=%d, size=%d"
,
trac
e
(
"irtmp got packet: type=%s, time=%d, size=%d"
,
srs_type2string
(
type
),
timestamp
,
size
);
if
((
ret
=
srs_write_packet
(
ortmp
,
type
,
timestamp
,
data
,
size
))
!=
0
)
{
trace
(
"irtmp get packet failed. ret=%d"
,
ret
);
return
ret
;
}
verbos
e
(
"ortmp sent packet: type=%s, time=%d, size=%d"
,
trac
e
(
"ortmp sent packet: type=%s, time=%d, size=%d"
,
srs_type2string
(
type
),
timestamp
,
size
);
}
...
...
trunk/src/app/srs_app_config.cpp
查看文件 @
30bb3ff
...
...
@@ -1587,7 +1587,7 @@ SrsConfDirective* SrsConfig::get_vhost_on_stop(string vhost)
return
conf
->
get
(
"on_stop"
);
}
SrsConfDirective
*
SrsConfig
::
get_vhost_on_dvr_reap_flv
(
string
vhost
)
SrsConfDirective
*
SrsConfig
::
get_vhost_on_dvr_
hss_
reap_flv
(
string
vhost
)
{
SrsConfDirective
*
conf
=
get_vhost
(
vhost
);
...
...
@@ -1605,7 +1605,7 @@ SrsConfDirective* SrsConfig::get_vhost_on_dvr_reap_flv(string vhost)
return
NULL
;
}
return
conf
->
get
(
"on_dvr_reap_flv"
);
return
conf
->
get
(
"on_dvr_
hss_
reap_flv"
);
}
bool
SrsConfig
::
get_vhost_enabled
(
string
vhost
)
...
...
trunk/src/app/srs_app_config.hpp
查看文件 @
30bb3ff
...
...
@@ -177,7 +177,7 @@ public:
virtual
SrsConfDirective
*
get_vhost_on_unpublish
(
std
::
string
vhost
);
virtual
SrsConfDirective
*
get_vhost_on_play
(
std
::
string
vhost
);
virtual
SrsConfDirective
*
get_vhost_on_stop
(
std
::
string
vhost
);
virtual
SrsConfDirective
*
get_vhost_on_dvr_reap_flv
(
std
::
string
vhost
);
virtual
SrsConfDirective
*
get_vhost_on_dvr_
hss_
reap_flv
(
std
::
string
vhost
);
virtual
bool
get_gop_cache
(
std
::
string
vhost
);
virtual
bool
get_atc
(
std
::
string
vhost
);
virtual
double
get_queue_length
(
std
::
string
vhost
);
...
...
trunk/src/app/srs_app_dvr.cpp
查看文件 @
30bb3ff
...
...
@@ -565,7 +565,7 @@ int SrsDvrPlan::flv_close()
}
#ifdef SRS_AUTO_HTTP_CALLBACK
if
((
ret
=
on_dvr_reap_flv
())
!=
ERROR_SUCCESS
)
{
if
((
ret
=
on_dvr_
hss_
reap_flv
())
!=
ERROR_SUCCESS
)
{
return
ret
;
}
#endif
...
...
@@ -612,21 +612,21 @@ int SrsDvrPlan::write_flv_header()
return
ret
;
}
int
SrsDvrPlan
::
on_dvr_reap_flv
()
int
SrsDvrPlan
::
on_dvr_
hss_
reap_flv
()
{
int
ret
=
ERROR_SUCCESS
;
#ifdef SRS_AUTO_HTTP_CALLBACK
// HTTP: on_dvr_reap_flv
SrsConfDirective
*
on_dvr_reap_flv
=
_srs_config
->
get_vhost_on_dvr_reap_flv
(
_req
->
vhost
);
if
(
!
on_dvr_reap_flv
)
{
srs_info
(
"ignore the empty http callback: on_dvr_reap_flv"
);
// HTTP: on_dvr_hss_reap_flv
SrsConfDirective
*
on_dvr_hss_reap_flv
=
_srs_config
->
get_vhost_on_dvr_hss_reap_flv
(
_req
->
vhost
);
if
(
!
on_dvr_hss_reap_flv
)
{
srs_info
(
"ignore the empty http callback: on_dvr_hss_reap_flv"
);
return
ret
;
}
for
(
int
i
=
0
;
i
<
(
int
)
on_dvr_reap_flv
->
args
.
size
();
i
++
)
{
std
::
string
url
=
on_dvr_reap_flv
->
args
.
at
(
i
);
SrsHttpHooks
::
on_dvr_reap_flv
(
url
,
_req
,
segment
);
for
(
int
i
=
0
;
i
<
(
int
)
on_dvr_hss_reap_flv
->
args
.
size
();
i
++
)
{
std
::
string
url
=
on_dvr_hss_reap_flv
->
args
.
at
(
i
);
SrsHttpHooks
::
on_dvr_hss_reap_flv
(
url
,
_req
,
segment
);
}
#endif
...
...
@@ -842,7 +842,7 @@ int SrsDvrHssPlan::on_meta_data(SrsOnMetaDataPacket* metadata)
}
#ifdef SRS_AUTO_HTTP_CALLBACK
if
((
ret
=
on_dvr_reap_flv_header
(
path
.
str
()))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
on_dvr_
hss_
reap_flv_header
(
path
.
str
()))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
#endif
...
...
@@ -882,21 +882,21 @@ int64_t SrsDvrHssPlan::filter_timestamp(int64_t timestamp)
return
segment
->
stream_starttime
+
timestamp
;
}
int
SrsDvrHssPlan
::
on_dvr_reap_flv_header
(
string
path
)
int
SrsDvrHssPlan
::
on_dvr_
hss_
reap_flv_header
(
string
path
)
{
int
ret
=
ERROR_SUCCESS
;
#ifdef SRS_AUTO_HTTP_CALLBACK
// HTTP: on_dvr_reap_flv_header
SrsConfDirective
*
on_dvr_reap_flv
=
_srs_config
->
get_vhost_on_dvr_reap_flv
(
_req
->
vhost
);
if
(
!
on_dvr_reap_flv
)
{
srs_info
(
"ignore the empty http callback: on_dvr_reap_flv"
);
// HTTP: on_dvr_hss_reap_flv_header
SrsConfDirective
*
on_dvr_hss_reap_flv
=
_srs_config
->
get_vhost_on_dvr_hss_reap_flv
(
_req
->
vhost
);
if
(
!
on_dvr_hss_reap_flv
)
{
srs_info
(
"ignore the empty http callback: on_dvr_hss_reap_flv"
);
return
ret
;
}
for
(
int
i
=
0
;
i
<
(
int
)
on_dvr_reap_flv
->
args
.
size
();
i
++
)
{
std
::
string
url
=
on_dvr_reap_flv
->
args
.
at
(
i
);
SrsHttpHooks
::
on_dvr_reap_flv_header
(
url
,
_req
,
path
);
for
(
int
i
=
0
;
i
<
(
int
)
on_dvr_hss_reap_flv
->
args
.
size
();
i
++
)
{
std
::
string
url
=
on_dvr_hss_reap_flv
->
args
.
at
(
i
);
SrsHttpHooks
::
on_dvr_hss_reap_flv_header
(
url
,
_req
,
path
);
}
#endif
...
...
trunk/src/app/srs_app_dvr.hpp
查看文件 @
30bb3ff
...
...
@@ -200,7 +200,7 @@ private:
/**
* when srs reap the flv(close the segment), notice the api.
*/
virtual
int
on_dvr_reap_flv
();
virtual
int
on_dvr_
hss_
reap_flv
();
public
:
static
SrsDvrPlan
*
create_plan
(
std
::
string
vhost
);
};
...
...
@@ -259,7 +259,7 @@ protected:
virtual
int
on_video_keyframe
();
virtual
int64_t
filter_timestamp
(
int64_t
timestamp
);
private
:
virtual
int
on_dvr_reap_flv_header
(
std
::
string
path
);
virtual
int
on_dvr_
hss_
reap_flv_header
(
std
::
string
path
);
virtual
int
update_duration
(
SrsSharedPtrMessage
*
msg
);
};
...
...
trunk/src/app/srs_app_http_hooks.cpp
查看文件 @
30bb3ff
...
...
@@ -459,7 +459,7 @@ void SrsHttpHooks::on_stop(string url, int client_id, string ip, SrsRequest* req
return
;
}
void
SrsHttpHooks
::
on_dvr_reap_flv_header
(
std
::
string
url
,
SrsRequest
*
req
,
std
::
string
header_file
)
void
SrsHttpHooks
::
on_dvr_
hss_
reap_flv_header
(
std
::
string
url
,
SrsRequest
*
req
,
std
::
string
header_file
)
{
int
ret
=
ERROR_SUCCESS
;
...
...
@@ -467,14 +467,14 @@ void SrsHttpHooks::on_dvr_reap_flv_header(std::string url, SrsRequest* req, std:
SrsHttpUri
uri
;
if
((
ret
=
uri
.
initialize
(
url
))
!=
ERROR_SUCCESS
)
{
srs_warn
(
"http uri parse on_dvr_reap_flv_header url failed, ignored. "
srs_warn
(
"http uri parse on_dvr_
hss_
reap_flv_header url failed, ignored. "
"url=%s, ret=%d"
,
url
.
c_str
(),
ret
);
return
;
}
std
::
stringstream
ss
;
ss
<<
JOBJECT_START
<<
JFIELD_STR
(
"action"
,
"on_dvr_reap_flv_header"
)
<<
JFIELD_CONT
<<
JFIELD_STR
(
"action"
,
"on_dvr_
hss_
reap_flv_header"
)
<<
JFIELD_CONT
<<
JFIELD_STR
(
"vhost"
,
req
->
vhost
)
<<
JFIELD_CONT
<<
JFIELD_STR
(
"app"
,
req
->
app
)
<<
JFIELD_CONT
<<
JFIELD_STR
(
"stream"
,
req
->
stream
)
<<
JFIELD_CONT
...
...
@@ -488,7 +488,7 @@ void SrsHttpHooks::on_dvr_reap_flv_header(std::string url, SrsRequest* req, std:
SrsHttpClient
http
;
if
((
ret
=
http
.
post
(
&
uri
,
data
,
res
))
!=
ERROR_SUCCESS
)
{
srs_warn
(
"http post on_dvr_reap_flv_header uri failed, ignored. "
srs_warn
(
"http post on_dvr_
hss_
reap_flv_header uri failed, ignored. "
"url=%s, request=%s, response=%s, ret=%d"
,
url
.
c_str
(),
data
.
c_str
(),
res
.
c_str
(),
ret
);
return
;
...
...
@@ -496,19 +496,19 @@ void SrsHttpHooks::on_dvr_reap_flv_header(std::string url, SrsRequest* req, std:
if
(
res
.
empty
()
||
res
!=
SRS_HTTP_RESPONSE_OK
)
{
ret
=
ERROR_HTTP_DATA_INVLIAD
;
srs_warn
(
"http hook on_dvr_reap_flv_header validate failed, ignored. "
srs_warn
(
"http hook on_dvr_
hss_
reap_flv_header validate failed, ignored. "
"res=%s, ret=%d"
,
res
.
c_str
(),
ret
);
return
;
}
srs_info
(
"http hook on_dvr_reap_flv_header success. "
srs_info
(
"http hook on_dvr_
hss_
reap_flv_header success. "
"url=%s, request=%s, response=%s, ret=%d"
,
url
.
c_str
(),
data
.
c_str
(),
res
.
c_str
(),
ret
);
return
;
}
void
SrsHttpHooks
::
on_dvr_reap_flv
(
string
url
,
SrsRequest
*
req
,
SrsFlvSegment
*
segment
)
void
SrsHttpHooks
::
on_dvr_
hss_
reap_flv
(
string
url
,
SrsRequest
*
req
,
SrsFlvSegment
*
segment
)
{
int
ret
=
ERROR_SUCCESS
;
...
...
@@ -520,14 +520,14 @@ void SrsHttpHooks::on_dvr_reap_flv(string url, SrsRequest* req, SrsFlvSegment* s
SrsHttpUri
uri
;
if
((
ret
=
uri
.
initialize
(
url
))
!=
ERROR_SUCCESS
)
{
srs_warn
(
"http uri parse on_dvr_reap_flv url failed, ignored. "
srs_warn
(
"http uri parse on_dvr_
hss_
reap_flv url failed, ignored. "
"url=%s, ret=%d"
,
url
.
c_str
(),
ret
);
return
;
}
std
::
stringstream
ss
;
ss
<<
JOBJECT_START
<<
JFIELD_STR
(
"action"
,
"on_dvr_reap_flv"
)
<<
JFIELD_CONT
<<
JFIELD_STR
(
"action"
,
"on_dvr_
hss_
reap_flv"
)
<<
JFIELD_CONT
<<
JFIELD_STR
(
"vhost"
,
req
->
vhost
)
<<
JFIELD_CONT
<<
JFIELD_STR
(
"app"
,
req
->
app
)
<<
JFIELD_CONT
<<
JFIELD_STR
(
"stream"
,
req
->
stream
)
<<
JFIELD_CONT
...
...
@@ -545,7 +545,7 @@ void SrsHttpHooks::on_dvr_reap_flv(string url, SrsRequest* req, SrsFlvSegment* s
SrsHttpClient
http
;
if
((
ret
=
http
.
post
(
&
uri
,
data
,
res
))
!=
ERROR_SUCCESS
)
{
srs_warn
(
"http post on_dvr_reap_flv uri failed, ignored. "
srs_warn
(
"http post on_dvr_
hss_
reap_flv uri failed, ignored. "
"url=%s, request=%s, response=%s, ret=%d"
,
url
.
c_str
(),
data
.
c_str
(),
res
.
c_str
(),
ret
);
return
;
...
...
@@ -553,12 +553,12 @@ void SrsHttpHooks::on_dvr_reap_flv(string url, SrsRequest* req, SrsFlvSegment* s
if
(
res
.
empty
()
||
res
!=
SRS_HTTP_RESPONSE_OK
)
{
ret
=
ERROR_HTTP_DATA_INVLIAD
;
srs_warn
(
"http hook on_dvr_reap_flv validate failed, ignored. "
srs_warn
(
"http hook on_dvr_
hss_
reap_flv validate failed, ignored. "
"res=%s, ret=%d"
,
res
.
c_str
(),
ret
);
return
;
}
srs_info
(
"http hook on_dvr_reap_flv success. "
srs_info
(
"http hook on_dvr_
hss_
reap_flv success. "
"url=%s, request=%s, response=%s, ret=%d"
,
url
.
c_str
(),
data
.
c_str
(),
res
.
c_str
(),
ret
);
...
...
trunk/src/app/srs_app_http_hooks.hpp
查看文件 @
30bb3ff
...
...
@@ -124,19 +124,19 @@ public:
static
void
on_stop
(
std
::
string
url
,
int
client_id
,
std
::
string
ip
,
SrsRequest
*
req
);
public
:
/**
* on_dvr_reap_flv_header hook, when dvr write flv file header.
* on_dvr_
hss_
reap_flv_header hook, when dvr write flv file header.
* @param url the api server url, to process the event.
* ignore if empty.
* @param header_file the flv header file.
*/
static
void
on_dvr_reap_flv_header
(
std
::
string
url
,
SrsRequest
*
req
,
std
::
string
header_file
);
static
void
on_dvr_
hss_
reap_flv_header
(
std
::
string
url
,
SrsRequest
*
req
,
std
::
string
header_file
);
/**
* on_dvr_reap_flv hook, when dvr close flv file.
* on_dvr_
hss_
reap_flv hook, when dvr close flv file.
* @param url the api server url, to process the event.
* ignore if empty.
* @param segment the current flv segment.
*/
static
void
on_dvr_reap_flv
(
std
::
string
url
,
SrsRequest
*
req
,
SrsFlvSegment
*
segment
);
static
void
on_dvr_
hss_
reap_flv
(
std
::
string
url
,
SrsRequest
*
req
,
SrsFlvSegment
*
segment
);
};
#endif
...
...
请
注册
或
登录
后发表评论