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-26 17:16:18 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b0951d36d3b5bd853b39c07594da86f283f11492
b0951d36
1 parent
a2f317a1
refine source, rename req to _req
隐藏空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
51 行增加
和
35 行删除
trunk/src/app/srs_app_edge.cpp
trunk/src/app/srs_app_edge.hpp
trunk/src/app/srs_app_rtmp_conn.cpp
trunk/src/app/srs_app_source.cpp
trunk/src/app/srs_app_source.hpp
trunk/src/app/srs_app_edge.cpp
查看文件 @
b0951d3
...
...
@@ -24,6 +24,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_app_edge.hpp>
#include <srs_kernel_error.hpp>
#include <srs_protocol_rtmp.hpp>
SrsEdge
::
SrsEdge
()
{
...
...
@@ -34,6 +35,15 @@ SrsEdge::~SrsEdge()
{
}
int
SrsEdge
::
initialize
(
SrsRequest
*
req
)
{
int
ret
=
ERROR_SUCCESS
;
_req
=
req
;
return
ret
;
}
int
SrsEdge
::
on_client_play
()
{
int
ret
=
ERROR_SUCCESS
;
...
...
trunk/src/app/srs_app_edge.hpp
查看文件 @
b0951d3
...
...
@@ -30,6 +30,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_core.hpp>
class
SrsRequest
;
/**
* the state of edge
*/
...
...
@@ -49,11 +51,13 @@ enum SrsEdgeState
class
SrsEdge
{
private
:
SrsRequest
*
_req
;
SrsEdgeState
state
;
public
:
SrsEdge
();
virtual
~
SrsEdge
();
public
:
virtual
int
initialize
(
SrsRequest
*
req
);
/**
* when client play stream on edge.
*/
...
...
trunk/src/app/srs_app_rtmp_conn.cpp
查看文件 @
b0951d3
...
...
@@ -515,7 +515,7 @@ int SrsRtmpConn::fmle_publish(SrsSource* source)
SrsPithyPrint
pithy_print
(
SRS_STAGE_PUBLISH_USER
);
// notify the hls to prepare when publish start.
if
((
ret
=
source
->
on_publish
(
req
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
source
->
on_publish
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"fmle hls on_publish failed. ret=%d"
,
ret
);
return
ret
;
}
...
...
@@ -584,7 +584,7 @@ int SrsRtmpConn::flash_publish(SrsSource* source)
SrsPithyPrint
pithy_print
(
SRS_STAGE_PUBLISH_USER
);
// notify the hls to prepare when publish start.
if
((
ret
=
source
->
on_publish
(
req
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
source
->
on_publish
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"flash hls on_publish failed. ret=%d"
,
ret
);
return
ret
;
}
...
...
trunk/src/app/srs_app_source.cpp
查看文件 @
b0951d3
...
...
@@ -437,9 +437,9 @@ int SrsSource::find(SrsRequest* req, SrsSource** ppsource)
return
ret
;
}
SrsSource
::
SrsSource
(
SrsRequest
*
_
req
)
SrsSource
::
SrsSource
(
SrsRequest
*
req
)
{
req
=
_
req
->
copy
();
_req
=
req
->
copy
();
#ifdef SRS_AUTO_HLS
hls
=
new
SrsHls
(
this
);
...
...
@@ -460,7 +460,7 @@ SrsSource::SrsSource(SrsRequest* _req)
gop_cache
=
new
SrsGopCache
();
_srs_config
->
subscribe
(
this
);
atc
=
_srs_config
->
get_atc
(
req
->
vhost
);
atc
=
_srs_config
->
get_atc
(
_
req
->
vhost
);
}
SrsSource
::~
SrsSource
()
...
...
@@ -502,7 +502,7 @@ SrsSource::~SrsSource()
srs_freep
(
encoder
);
#endif
srs_freep
(
req
);
srs_freep
(
_
req
);
}
int
SrsSource
::
initialize
()
...
...
@@ -510,10 +510,14 @@ int SrsSource::initialize()
int
ret
=
ERROR_SUCCESS
;
#ifdef SRS_AUTO_DVR
if
((
ret
=
dvr
->
initialize
(
req
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
dvr
->
initialize
(
_
req
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
#endif
if
((
ret
=
edge
->
initialize
(
_req
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
return
ret
;
}
...
...
@@ -522,7 +526,7 @@ int SrsSource::on_reload_vhost_atc(string vhost)
{
int
ret
=
ERROR_SUCCESS
;
if
(
req
->
vhost
!=
vhost
)
{
if
(
_
req
->
vhost
!=
vhost
)
{
return
ret
;
}
...
...
@@ -541,7 +545,7 @@ int SrsSource::on_reload_vhost_gop_cache(string vhost)
{
int
ret
=
ERROR_SUCCESS
;
if
(
req
->
vhost
!=
vhost
)
{
if
(
_
req
->
vhost
!=
vhost
)
{
return
ret
;
}
...
...
@@ -549,7 +553,7 @@ int SrsSource::on_reload_vhost_gop_cache(string vhost)
bool
enabled_cache
=
_srs_config
->
get_gop_cache
(
vhost
);
srs_trace
(
"vhost %s gop_cache changed to %d, source url=%s"
,
vhost
.
c_str
(),
enabled_cache
,
req
->
get_stream_url
().
c_str
());
vhost
.
c_str
(),
enabled_cache
,
_
req
->
get_stream_url
().
c_str
());
set_cache
(
enabled_cache
);
...
...
@@ -560,11 +564,11 @@ int SrsSource::on_reload_vhost_queue_length(string vhost)
{
int
ret
=
ERROR_SUCCESS
;
if
(
req
->
vhost
!=
vhost
)
{
if
(
_
req
->
vhost
!=
vhost
)
{
return
ret
;
}
double
queue_size
=
_srs_config
->
get_queue_length
(
req
->
vhost
);
double
queue_size
=
_srs_config
->
get_queue_length
(
_
req
->
vhost
);
if
(
true
)
{
std
::
vector
<
SrsConsumer
*>::
iterator
it
;
...
...
@@ -595,7 +599,7 @@ int SrsSource::on_reload_vhost_forward(string vhost)
{
int
ret
=
ERROR_SUCCESS
;
if
(
req
->
vhost
!=
vhost
)
{
if
(
_
req
->
vhost
!=
vhost
)
{
return
ret
;
}
...
...
@@ -615,13 +619,13 @@ int SrsSource::on_reload_vhost_hls(string vhost)
{
int
ret
=
ERROR_SUCCESS
;
if
(
req
->
vhost
!=
vhost
)
{
if
(
_
req
->
vhost
!=
vhost
)
{
return
ret
;
}
#ifdef SRS_AUTO_HLS
hls
->
on_unpublish
();
if
((
ret
=
hls
->
on_publish
(
req
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
hls
->
on_publish
(
_
req
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"hls publish failed. ret=%d"
,
ret
);
return
ret
;
}
...
...
@@ -635,7 +639,7 @@ int SrsSource::on_reload_vhost_dvr(string vhost)
{
int
ret
=
ERROR_SUCCESS
;
if
(
req
->
vhost
!=
vhost
)
{
if
(
_
req
->
vhost
!=
vhost
)
{
return
ret
;
}
...
...
@@ -644,12 +648,12 @@ int SrsSource::on_reload_vhost_dvr(string vhost)
dvr
->
on_unpublish
();
// reinitialize the dvr, update plan.
if
((
ret
=
dvr
->
initialize
(
req
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
dvr
->
initialize
(
_
req
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// start to publish by new plan.
if
((
ret
=
dvr
->
on_publish
(
req
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
dvr
->
on_publish
(
_
req
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"dvr publish failed. ret=%d"
,
ret
);
return
ret
;
}
...
...
@@ -664,13 +668,13 @@ int SrsSource::on_reload_vhost_transcode(string vhost)
{
int
ret
=
ERROR_SUCCESS
;
if
(
req
->
vhost
!=
vhost
)
{
if
(
_
req
->
vhost
!=
vhost
)
{
return
ret
;
}
#ifdef SRS_AUTO_TRANSCODE
encoder
->
on_unpublish
();
if
((
ret
=
encoder
->
on_publish
(
req
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
encoder
->
on_publish
(
_
req
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"start encoder failed. ret=%d"
,
ret
);
return
ret
;
}
...
...
@@ -1038,14 +1042,12 @@ int SrsSource::on_video(SrsCommonMessage* video)
return
ret
;
}
int
SrsSource
::
on_publish
(
SrsRequest
*
_req
)
int
SrsSource
::
on_publish
()
{
int
ret
=
ERROR_SUCCESS
;
// update the request object.
srs_freep
(
req
);
req
=
_req
->
copy
();
srs_assert
(
req
);
srs_assert
(
_req
);
_can_publish
=
false
;
...
...
@@ -1056,21 +1058,21 @@ int SrsSource::on_publish(SrsRequest* _req)
}
#ifdef SRS_AUTO_TRANSCODE
if
((
ret
=
encoder
->
on_publish
(
req
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
encoder
->
on_publish
(
_
req
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"start encoder failed. ret=%d"
,
ret
);
return
ret
;
}
#endif
#ifdef SRS_AUTO_HLS
if
((
ret
=
hls
->
on_publish
(
req
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
hls
->
on_publish
(
_
req
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"start hls failed. ret=%d"
,
ret
);
return
ret
;
}
#endif
#ifdef SRS_AUTO_DVR
if
((
ret
=
dvr
->
on_publish
(
req
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
dvr
->
on_publish
(
_
req
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"start dvr failed. ret=%d"
,
ret
);
return
ret
;
}
...
...
@@ -1116,7 +1118,7 @@ void SrsSource::on_unpublish()
consumer
=
new
SrsConsumer
(
this
);
consumers
.
push_back
(
consumer
);
double
queue_size
=
_srs_config
->
get_queue_length
(
req
->
vhost
);
double
queue_size
=
_srs_config
->
get_queue_length
(
_
req
->
vhost
);
consumer
->
set_queue_size
(
queue_size
);
if
(
cache_metadata
&&
(
ret
=
consumer
->
enqueue
(
cache_metadata
->
copy
(),
sample_rate
,
frame_rate
))
!=
ERROR_SUCCESS
)
{
...
...
@@ -1187,20 +1189,20 @@ int SrsSource::create_forwarders()
{
int
ret
=
ERROR_SUCCESS
;
SrsConfDirective
*
conf
=
_srs_config
->
get_forward
(
req
->
vhost
);
SrsConfDirective
*
conf
=
_srs_config
->
get_forward
(
_
req
->
vhost
);
for
(
int
i
=
0
;
conf
&&
i
<
(
int
)
conf
->
args
.
size
();
i
++
)
{
std
::
string
forward_server
=
conf
->
args
.
at
(
i
);
SrsForwarder
*
forwarder
=
new
SrsForwarder
(
this
);
forwarders
.
push_back
(
forwarder
);
double
queue_size
=
_srs_config
->
get_queue_length
(
req
->
vhost
);
double
queue_size
=
_srs_config
->
get_queue_length
(
_
req
->
vhost
);
forwarder
->
set_queue_size
(
queue_size
);
if
((
ret
=
forwarder
->
on_publish
(
req
,
forward_server
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
forwarder
->
on_publish
(
_
req
,
forward_server
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"start forwarder failed. "
"vhost=%s, app=%s, stream=%s, forward-to=%s"
,
req
->
vhost
.
c_str
(),
req
->
app
.
c_str
(),
req
->
stream
.
c_str
(),
_req
->
vhost
.
c_str
(),
_req
->
app
.
c_str
(),
_
req
->
stream
.
c_str
(),
forward_server
.
c_str
());
return
ret
;
}
...
...
trunk/src/app/srs_app_source.hpp
查看文件 @
b0951d3
...
...
@@ -220,7 +220,7 @@ public:
static
int
find
(
SrsRequest
*
req
,
SrsSource
**
ppsource
);
private
:
// deep copy of client request.
SrsRequest
*
req
;
SrsRequest
*
_
req
;
// to delivery stream to clients.
std
::
vector
<
SrsConsumer
*>
consumers
;
// hls handler.
...
...
@@ -272,7 +272,7 @@ public:
* @param _req the client request object,
* this object will deep copy it for reload.
*/
SrsSource
(
SrsRequest
*
_
req
);
SrsSource
(
SrsRequest
*
req
);
virtual
~
SrsSource
();
public
:
virtual
int
initialize
();
...
...
@@ -302,7 +302,7 @@ public:
* @param _req the request from client, the source will deep copy it,
* for when reload the request of client maybe invalid.
*/
virtual
int
on_publish
(
SrsRequest
*
_req
);
virtual
int
on_publish
();
virtual
void
on_unpublish
();
public
:
virtual
int
create_consumer
(
SrsConsumer
*&
consumer
);
...
...
请
注册
或
登录
后发表评论