mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 03:41:55 +00:00
Merge branch 'srs.master'
This commit is contained in:
commit
0346355f5d
8 changed files with 177 additions and 77 deletions
|
@ -445,11 +445,12 @@ Supported operating systems and hardware:
|
|||
[CN](https://github.com/winlinvip/simple-rtmp-server/wiki/v2_CN_SrsLibrtmp#publish-h264-raw-data),
|
||||
[EN](https://github.com/winlinvip/simple-rtmp-server/wiki/v2_EN_SrsLibrtmp#publish-h264-raw-data)
|
||||
) by srs-librtmp.
|
||||
1. Support [6k+ clients](https://github.com/winlinvip/simple-rtmp-server/issues/194), 4Gbps per process.
|
||||
1. Support [6k+ clients](https://github.com/winlinvip/simple-rtmp-server/issues/194), 3Gbps per process.
|
||||
1. Suppport [English wiki](https://github.com/winlinvip/simple-rtmp-server/wiki/v1_EN_Home).
|
||||
1. Research and simplify st, [bug #182](https://github.com/winlinvip/simple-rtmp-server/issues/182).
|
||||
1. Support compile [srs-librtmp on windows](https://github.com/winlinvip/srs.librtmp),
|
||||
[bug #213](https://github.com/winlinvip/simple-rtmp-server/issues/213).
|
||||
1. Support [7.5k+ clients](https://github.com/winlinvip/simple-rtmp-server/issues/217), 4Gbps per process.
|
||||
1. [no-plan] Support <500ms latency, FRSC(Fast RTMP-compatible Stream Channel tech).
|
||||
1. [no-plan] Support RTMP 302 redirect [#92](https://github.com/winlinvip/simple-rtmp-server/issues/92).
|
||||
1. [no-plan] Support multiple processes, for both origin and edge
|
||||
|
@ -482,6 +483,7 @@ Supported operating systems and hardware:
|
|||
* 2013-10-17, Created.<br/>
|
||||
|
||||
## History
|
||||
* v2.0, 2014-11-22, fix [#217](https://github.com/winlinvip/simple-rtmp-server/issues/217), remove timeout recv, support 7.5k+ 250kbps clients. 2.0.30.
|
||||
* v2.0, 2014-11-21, srs-librtmp add rtmp prefix for rtmp/utils/human apis. 2.0.29.
|
||||
* v2.0, 2014-11-21, refine examples of srs-librtmp, add srs_print_rtmp_packet. 2.0.28.
|
||||
* v2.0, 2014-11-20, fix [#212](https://github.com/winlinvip/simple-rtmp-server/issues/212), support publish audio raw frames. 2.0.27
|
||||
|
@ -700,6 +702,7 @@ Performance benchmark history, on virtual box:
|
|||
* 2014-11-12, SRS 2.0.14, 2700clients, 69%CPU, 59MB.
|
||||
* 2014-11-12, SRS 2.0.14, 3500clients, 95%CPU, 78MB.
|
||||
* 2014-11-13, SRS 2.0.15, 6000clients, 82%CPU, 203MB. (500 publishers).
|
||||
* 2014-11-22, SRS 2.0.30, 7500clients, 87%CPU, 320MB.
|
||||
|
||||
Latest benchmark(2014-07-12):
|
||||
|
||||
|
|
3
trunk/configure
vendored
3
trunk/configure
vendored
|
@ -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_recv_thread")
|
||||
APP_INCS="src/app"; MODULE_DIR=${APP_INCS} . auto/modules.sh
|
||||
APP_OBJS="${MODULE_OBJS[@]}"
|
||||
fi
|
||||
|
|
98
trunk/src/app/srs_app_recv_thread.cpp
Normal file
98
trunk/src/app/srs_app_recv_thread.cpp
Normal file
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
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_recv_thread.hpp>
|
||||
|
||||
#include <srs_protocol_rtmp.hpp>
|
||||
#include <srs_protocol_stack.hpp>
|
||||
|
||||
SrsRecvThread::SrsRecvThread(SrsRtmpServer* rtmp_sdk)
|
||||
{
|
||||
rtmp = rtmp_sdk;
|
||||
trd = new SrsThread(this, 0, true);
|
||||
}
|
||||
|
||||
SrsRecvThread::~SrsRecvThread()
|
||||
{
|
||||
// stop recv thread.
|
||||
stop();
|
||||
|
||||
// destroy the thread.
|
||||
srs_freep(trd);
|
||||
|
||||
// clear all messages.
|
||||
std::vector<SrsMessage*>::iterator it;
|
||||
for (it = queue.begin(); it != queue.end(); ++it) {
|
||||
SrsMessage* msg = *it;
|
||||
srs_freep(msg);
|
||||
}
|
||||
queue.clear();
|
||||
}
|
||||
|
||||
bool SrsRecvThread::empty()
|
||||
{
|
||||
return queue.empty();
|
||||
}
|
||||
|
||||
SrsMessage* SrsRecvThread::pump()
|
||||
{
|
||||
srs_assert(!queue.empty());
|
||||
|
||||
SrsMessage* msg = *queue.begin();
|
||||
|
||||
queue.erase(queue.begin());
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
int SrsRecvThread::start()
|
||||
{
|
||||
return trd->start();
|
||||
}
|
||||
|
||||
void SrsRecvThread::stop()
|
||||
{
|
||||
trd->stop();
|
||||
}
|
||||
|
||||
int SrsRecvThread::cycle()
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
SrsMessage* msg = NULL;
|
||||
|
||||
if ((ret = rtmp->recv_message(&msg)) != ERROR_SUCCESS) {
|
||||
if (!srs_is_client_gracefully_close(ret)) {
|
||||
srs_error("recv client control message failed. ret=%d", ret);
|
||||
}
|
||||
|
||||
// we use no timeout to recv, should never got any error.
|
||||
trd->stop_loop();
|
||||
|
||||
return ret;
|
||||
}
|
||||
srs_verbose("play loop recv message. ret=%d", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
65
trunk/src/app/srs_app_recv_thread.hpp
Normal file
65
trunk/src/app/srs_app_recv_thread.hpp
Normal file
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
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_RECV_THREAD_HPP
|
||||
#define SRS_APP_RECV_THREAD_HPP
|
||||
|
||||
/*
|
||||
#include <srs_app_recv_thread.hpp>
|
||||
*/
|
||||
|
||||
#include <srs_core.hpp>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <srs_app_thread.hpp>
|
||||
|
||||
class SrsRtmpServer;
|
||||
class SrsMessage;
|
||||
|
||||
/**
|
||||
* the recv thread used to replace the timeout recv,
|
||||
* which hurt performance for the epoll_ctrl is frequently used.
|
||||
* @see: SrsRtmpConn::playing
|
||||
* @see: https://github.com/winlinvip/simple-rtmp-server/issues/217
|
||||
*/
|
||||
class SrsRecvThread : public ISrsThreadHandler
|
||||
{
|
||||
private:
|
||||
SrsThread* trd;
|
||||
SrsRtmpServer* rtmp;
|
||||
std::vector<SrsMessage*> queue;
|
||||
public:
|
||||
SrsRecvThread(SrsRtmpServer* rtmp_sdk);
|
||||
virtual ~SrsRecvThread();
|
||||
public:
|
||||
virtual bool empty();
|
||||
virtual SrsMessage* pump();
|
||||
public:
|
||||
virtual int start();
|
||||
virtual void stop();
|
||||
virtual int cycle();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -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_recv_thread.hpp>
|
||||
|
||||
// when stream is busy, for example, streaming is already
|
||||
// publishing, when a new client to request to publish,
|
||||
|
@ -493,76 +494,6 @@ int SrsRtmpConn::check_vhost()
|
|||
return ret;
|
||||
}
|
||||
|
||||
class IsolateRecvThread : public ISrsThreadHandler
|
||||
{
|
||||
private:
|
||||
SrsThread* trd;
|
||||
SrsRtmpServer* rtmp;
|
||||
std::vector<SrsMessage*> queue;
|
||||
public:
|
||||
IsolateRecvThread(SrsRtmpServer* rtmp_sdk)
|
||||
{
|
||||
rtmp = rtmp_sdk;
|
||||
trd = new SrsThread(this, 0, true);
|
||||
}
|
||||
virtual ~IsolateRecvThread()
|
||||
{
|
||||
// stop recv thread.
|
||||
stop();
|
||||
|
||||
// destroy the thread.
|
||||
srs_freep(trd);
|
||||
|
||||
// clear all messages.
|
||||
std::vector<SrsMessage*>::iterator it;
|
||||
for (it = queue.begin(); it != queue.end(); ++it) {
|
||||
SrsMessage* msg = *it;
|
||||
srs_freep(msg);
|
||||
}
|
||||
queue.clear();
|
||||
}
|
||||
public:
|
||||
virtual bool empty()
|
||||
{
|
||||
return queue.empty();
|
||||
}
|
||||
virtual SrsMessage* pump()
|
||||
{
|
||||
SrsMessage* msg = *queue.begin();
|
||||
queue.erase(queue.begin());
|
||||
return msg;
|
||||
}
|
||||
public:
|
||||
virtual int start()
|
||||
{
|
||||
return trd->start();
|
||||
}
|
||||
virtual void stop()
|
||||
{
|
||||
trd->stop();
|
||||
}
|
||||
virtual int cycle()
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
SrsMessage* msg = NULL;
|
||||
|
||||
if ((ret = rtmp->recv_message(&msg)) != ERROR_SUCCESS) {
|
||||
if (!srs_is_client_gracefully_close(ret)) {
|
||||
srs_error("recv client control message failed. ret=%d", ret);
|
||||
}
|
||||
|
||||
// we use no timeout to recv, should never got any error.
|
||||
trd->stop_loop();
|
||||
|
||||
return ret;
|
||||
}
|
||||
srs_verbose("play loop recv message. ret=%d", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
int SrsRtmpConn::playing(SrsSource* source)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
@ -581,7 +512,7 @@ int SrsRtmpConn::playing(SrsSource* source)
|
|||
|
||||
// use isolate thread to recv,
|
||||
// start isolate recv thread.
|
||||
IsolateRecvThread trd(rtmp);
|
||||
SrsRecvThread trd(rtmp);
|
||||
if ((ret = trd.start()) != ERROR_SUCCESS) {
|
||||
srs_error("start isolate recv thread failed. ret=%d", ret);
|
||||
return ret;
|
||||
|
@ -600,7 +531,7 @@ int SrsRtmpConn::playing(SrsSource* source)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int SrsRtmpConn::do_playing(SrsSource* source, IsolateRecvThread* trd)
|
||||
int SrsRtmpConn::do_playing(SrsSource* source, SrsRecvThread* trd)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ class SrsBandwidth;
|
|||
class SrsKbps;
|
||||
class SrsRtmpClient;
|
||||
class SrsSharedPtrMessage;
|
||||
class IsolateRecvThread;
|
||||
class SrsRecvThread;
|
||||
|
||||
/**
|
||||
* the client provides the main logic control for RTMP clients.
|
||||
|
@ -89,7 +89,7 @@ private:
|
|||
virtual int stream_service_cycle();
|
||||
virtual int check_vhost();
|
||||
virtual int playing(SrsSource* source);
|
||||
virtual int do_playing(SrsSource* source, IsolateRecvThread* trd);
|
||||
virtual int do_playing(SrsSource* source, SrsRecvThread* trd);
|
||||
virtual int fmle_publishing(SrsSource* source);
|
||||
virtual int do_fmle_publishing(SrsSource* source);
|
||||
virtual int flash_publishing(SrsSource* source);
|
||||
|
|
|
@ -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 29
|
||||
#define VERSION_REVISION 30
|
||||
// server info.
|
||||
#define RTMP_SIG_SRS_KEY "SRS"
|
||||
#define RTMP_SIG_SRS_ROLE "origin/edge server"
|
||||
|
|
|
@ -92,6 +92,8 @@ file
|
|||
..\app\srs_app_kbps.cpp,
|
||||
..\app\srs_app_log.hpp,
|
||||
..\app\srs_app_log.cpp,
|
||||
..\app\srs_app_recv_thread.hpp,
|
||||
..\app\srs_app_recv_thread.cpp,
|
||||
..\app\srs_app_refer.hpp,
|
||||
..\app\srs_app_refer.cpp,
|
||||
..\app\srs_app_reload.hpp,
|
||||
|
|
Loading…
Reference in a new issue