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-11-11 17:54:02 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
133cc62b51c7eef01c2e6642aad9354fa12e874b
133cc62b
1 parent
efc85ed6
for bug #194, use play fd poll, create the singleton poll
显示空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
182 行增加
和
1 行删除
trunk/configure
trunk/src/app/srs_app_poll.cpp
trunk/src/app/srs_app_poll.hpp
trunk/src/app/srs_app_rtmp_conn.cpp
trunk/src/app/srs_app_server.cpp
trunk/src/srs/srs.upp
trunk/configure
查看文件 @
133cc62
...
...
@@ -388,7 +388,8 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
"srs_app_thread"
"srs_app_bandwidth"
"srs_app_st"
"srs_app_log"
"srs_app_config"
"srs_app_pithy_print"
"srs_app_reload"
"srs_app_http_api"
"srs_app_http_conn"
"srs_app_http_hooks"
"srs_app_json"
"srs_app_ingest"
"srs_app_ffmpeg"
"srs_app_utility"
"srs_app_dvr"
"srs_app_edge"
"srs_app_kbps"
"srs_app_heartbeat"
"srs_app_empty"
"srs_app_http_client"
"srs_app_avc_aac"
)
"srs_app_kbps"
"srs_app_heartbeat"
"srs_app_empty"
"srs_app_http_client"
"srs_app_avc_aac"
"srs_app_poll"
)
APP_INCS
=
"src/app"
;
MODULE_DIR
=
${
APP_INCS
}
. auto/modules.sh
APP_OBJS
=
"
${
MODULE_OBJS
[@]
}
"
fi
...
...
trunk/src/app/srs_app_poll.cpp
0 → 100644
查看文件 @
133cc62
/*
The MIT License (MIT)
Copyright (c) 2013-2014 winlin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_app_poll.hpp>
#include <srs_kernel_error.hpp>
SrsPoll
::
SrsPoll
()
{
pthread
=
new
SrsThread
(
this
,
0
,
false
);
}
SrsPoll
::~
SrsPoll
()
{
srs_freep
(
pthread
);
fds
.
clear
();
}
int
SrsPoll
::
start
()
{
return
pthread
->
start
();
}
int
SrsPoll
::
cycle
()
{
int
ret
=
ERROR_SUCCESS
;
// TODO: FIXME: implements it.
return
ret
;
}
SrsPoll
*
SrsPoll
::
_instance
=
new
SrsPoll
();
SrsPoll
*
SrsPoll
::
instance
()
{
return
_instance
;
}
SrsPollFD
::
SrsPollFD
()
{
_stfd
=
NULL
;
}
SrsPollFD
::~
SrsPollFD
()
{
}
int
SrsPollFD
::
initialize
(
st_netfd_t
stfd
)
{
int
ret
=
ERROR_SUCCESS
;
_stfd
=
stfd
;
return
ret
;
}
...
...
trunk/src/app/srs_app_poll.hpp
0 → 100644
查看文件 @
133cc62
/*
The MIT License (MIT)
Copyright (c) 2013-2014 winlin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef SRS_APP_POLL_HPP
#define SRS_APP_POLL_HPP
/*
#include <srs_app_poll.hpp>
*/
#include <srs_core.hpp>
#include <map>
#include <srs_app_st.hpp>
#include <srs_app_thread.hpp>
class
SrsPollFD
;
/**
* the poll for all play clients to finger the active fd out.
* for performance issue, @see: https://github.com/winlinvip/simple-rtmp-server/issues/194
* the poll is shared by all SrsPollFD, and we start an isolate thread to finger the active fds.
*/
class
SrsPoll
:
public
ISrsThreadHandler
{
private
:
SrsThread
*
pthread
;
std
::
map
<
st_netfd_t
,
SrsPollFD
*>
fds
;
public
:
SrsPoll
();
virtual
~
SrsPoll
();
public
:
/**
* start the poll thread.
*/
virtual
int
start
();
/**
* start an cycle thread.
*/
virtual
int
cycle
();
// singleton
private:
static
SrsPoll
*
_instance
;
public
:
static
SrsPoll
*
instance
();
};
/**
* the poll fd to check whether the specified fd is active.
*/
class
SrsPollFD
{
private
:
st_netfd_t
_stfd
;
public
:
SrsPollFD
();
virtual
~
SrsPollFD
();
public
:
/**
* initialize the poll.
* @param stfd the fd to poll.
*/
virtual
int
initialize
(
st_netfd_t
stfd
);
};
#endif
...
...
trunk/src/app/srs_app_rtmp_conn.cpp
查看文件 @
133cc62
...
...
@@ -48,6 +48,7 @@ using namespace std;
#include <srs_app_utility.hpp>
#include <srs_protocol_msg_array.hpp>
#include <srs_protocol_amf0.hpp>
#include <srs_app_poll.hpp>
// when stream is busy, for example, streaming is already
// publishing, when a new client to request to publish,
...
...
@@ -525,6 +526,11 @@ int SrsRtmpConn::playing(SrsSource* source)
bool
user_specified_duration_to_stop
=
(
req
->
duration
>
0
);
int64_t
starttime
=
-
1
;
SrsPollFD
poll
;
if
((
ret
=
poll
.
initialize
(
stfd
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
while
(
true
)
{
// collect elapse for pithy print.
pithy_print
.
elapse
();
...
...
trunk/src/app/srs_app_server.cpp
查看文件 @
133cc62
...
...
@@ -44,6 +44,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_app_source.hpp>
#include <srs_app_utility.hpp>
#include <srs_app_heartbeat.hpp>
#include <srs_app_poll.hpp>
// signal defines.
#define SIGNAL_RELOAD SIGHUP
...
...
@@ -664,6 +665,14 @@ int SrsServer::do_cycle()
{
int
ret
=
ERROR_SUCCESS
;
// start the poll for play clients.
// performance issue, @see: https://github.com/winlinvip/simple-rtmp-server/issues/194
SrsPoll
*
poll
=
SrsPoll
::
instance
();
if
((
ret
=
poll
->
start
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"start poll failed. ret=%d"
,
ret
);
return
ret
;
}
// find the max loop
int
max
=
srs_max
(
0
,
SRS_SYS_TIME_RESOLUTION_MS_TIMES
);
...
...
trunk/src/srs/srs.upp
查看文件 @
133cc62
...
...
@@ -92,6 +92,8 @@ file
..\app\srs_app_kbps.cpp,
..\app\srs_app_log.hpp,
..\app\srs_app_log.cpp,
..\app\srs_app_poll.hpp,
..\app\srs_app_poll.cpp,
..\app\srs_app_refer.hpp,
..\app\srs_app_refer.cpp,
..\app\srs_app_reload.hpp,
...
...
请
注册
或
登录
后发表评论