mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Merge branch '2.0release' into develop
This commit is contained in:
commit
210d0a67cb
11 changed files with 180 additions and 118 deletions
|
@ -55,11 +55,98 @@ using namespace _srs_internal;
|
||||||
#define SRS_CONF_PERFER_FALSE(conf_arg) conf_arg == "on"
|
#define SRS_CONF_PERFER_FALSE(conf_arg) conf_arg == "on"
|
||||||
#define SRS_CONF_PERFER_TRUE(conf_arg) conf_arg != "off"
|
#define SRS_CONF_PERFER_TRUE(conf_arg) conf_arg != "off"
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// default consts values
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
#define SRS_CONF_DEFAULT_PID_FILE "./objs/srs.pid"
|
||||||
|
#define SRS_CONF_DEFAULT_LOG_FILE "./objs/srs.log"
|
||||||
|
#define SRS_CONF_DEFAULT_LOG_LEVEL "trace"
|
||||||
|
#define SRS_CONF_DEFAULT_LOG_TANK_CONSOLE "console"
|
||||||
|
#define SRS_CONF_DEFAULT_COFNIG_FILE "conf/srs.conf"
|
||||||
|
#define SRS_CONF_DEFAULT_FF_LOG_DIR "./objs"
|
||||||
|
#define SRS_CONF_DEFAULT_UTC_TIME false
|
||||||
|
|
||||||
|
#define SRS_CONF_DEFAULT_MAX_CONNECTIONS 1000
|
||||||
|
#define SRS_CONF_DEFAULT_HLS_PATH "./objs/nginx/html"
|
||||||
|
#define SRS_CONF_DEFAULT_HLS_M3U8_FILE "[app]/[stream].m3u8"
|
||||||
|
#define SRS_CONF_DEFAULT_HLS_TS_FILE "[app]/[stream]-[seq].ts"
|
||||||
|
#define SRS_CONF_DEFAULT_HLS_TS_FLOOR false
|
||||||
|
#define SRS_CONF_DEFAULT_HLS_FRAGMENT 10
|
||||||
|
#define SRS_CONF_DEFAULT_HLS_TD_RATIO 1.5
|
||||||
|
#define SRS_CONF_DEFAULT_HLS_AOF_RATIO 2.0
|
||||||
|
#define SRS_CONF_DEFAULT_HLS_WINDOW 60
|
||||||
|
#define SRS_CONF_DEFAULT_HLS_ON_ERROR_IGNORE "ignore"
|
||||||
|
#define SRS_CONF_DEFAULT_HLS_ON_ERROR_DISCONNECT "disconnect"
|
||||||
|
#define SRS_CONF_DEFAULT_HLS_ON_ERROR_CONTINUE "continue"
|
||||||
|
#define SRS_CONF_DEFAULT_HLS_ON_ERROR SRS_CONF_DEFAULT_HLS_ON_ERROR_IGNORE
|
||||||
|
#define SRS_CONF_DEFAULT_HLS_STORAGE "disk"
|
||||||
|
#define SRS_CONF_DEFAULT_HLS_MOUNT "[vhost]/[app]/[stream].m3u8"
|
||||||
|
#define SRS_CONF_DEFAULT_HLS_ACODEC "aac"
|
||||||
|
#define SRS_CONF_DEFAULT_HLS_VCODEC "h264"
|
||||||
|
#define SRS_CONF_DEFAULT_HLS_CLEANUP true
|
||||||
|
#define SRS_CONF_DEFAULT_HLS_WAIT_KEYFRAME true
|
||||||
|
#define SRS_CONF_DEFAULT_HLS_NB_NOTIFY 64
|
||||||
|
#define SRS_CONF_DEFAULT_DVR_PATH "./objs/nginx/html/[app]/[stream].[timestamp].flv"
|
||||||
|
#define SRS_CONF_DEFAULT_DVR_PLAN_SESSION "session"
|
||||||
|
#define SRS_CONF_DEFAULT_DVR_PLAN_SEGMENT "segment"
|
||||||
|
#define SRS_CONF_DEFAULT_DVR_PLAN_APPEND "append"
|
||||||
|
#define SRS_CONF_DEFAULT_DVR_PLAN SRS_CONF_DEFAULT_DVR_PLAN_SESSION
|
||||||
|
#define SRS_CONF_DEFAULT_DVR_DURATION 30
|
||||||
|
#define SRS_CONF_DEFAULT_TIME_JITTER "full"
|
||||||
|
#define SRS_CONF_DEFAULT_ATC_AUTO true
|
||||||
|
#define SRS_CONF_DEFAULT_MIX_CORRECT false
|
||||||
|
// in seconds, the paused queue length.
|
||||||
|
#define SRS_CONF_DEFAULT_PAUSED_LENGTH 10
|
||||||
|
// the interval in seconds for bandwidth check
|
||||||
|
#define SRS_CONF_DEFAULT_BANDWIDTH_INTERVAL 30
|
||||||
|
// the interval in seconds for bandwidth check
|
||||||
|
#define SRS_CONF_DEFAULT_BANDWIDTH_LIMIT_KBPS 1000
|
||||||
|
|
||||||
|
#define SRS_CONF_DEFAULT_HTTP_MOUNT "[vhost]/"
|
||||||
|
#define SRS_CONF_DEFAULT_HTTP_REMUX_MOUNT "[vhost]/[app]/[stream].flv"
|
||||||
|
#define SRS_CONF_DEFAULT_HTTP_DIR SRS_CONF_DEFAULT_HLS_PATH
|
||||||
|
#define SRS_CONF_DEFAULT_HTTP_AUDIO_FAST_CACHE 0
|
||||||
|
|
||||||
|
#define SRS_CONF_DEFAULT_HTTP_STREAM_PORT "8080"
|
||||||
|
#define SRS_CONF_DEFAULT_HTTP_API_PORT "1985"
|
||||||
|
#define SRS_CONF_DEFAULT_HTTP_API_CROSSDOMAIN true
|
||||||
|
|
||||||
|
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_ENABLED false
|
||||||
|
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_INTERVAL 9.9
|
||||||
|
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_URL "http://"SRS_CONSTS_LOCALHOST":8085/api/v1/servers"
|
||||||
|
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_SUMMARIES false
|
||||||
|
|
||||||
|
#define SRS_CONF_DEFAULT_SECURITY_ENABLED false
|
||||||
|
|
||||||
|
#define SRS_CONF_DEFAULT_STREAM_CASTER_ENABLED false
|
||||||
|
#define SRS_CONF_DEFAULT_STREAM_CASTER_MPEGTS_OVER_UDP "mpegts_over_udp"
|
||||||
|
#define SRS_CONF_DEFAULT_STREAM_CASTER_RTSP "rtsp"
|
||||||
|
#define SRS_CONF_DEFAULT_STREAM_CASTER_FLV "flv"
|
||||||
|
|
||||||
|
#define SRS_CONF_DEFAULT_STATS_NETWORK_DEVICE_INDEX 0
|
||||||
|
|
||||||
|
#define SRS_CONF_DEFAULT_PITHY_PRINT_MS 10000
|
||||||
|
|
||||||
|
#define SRS_CONF_DEFAULT_INGEST_TYPE_FILE "file"
|
||||||
|
#define SRS_CONF_DEFAULT_INGEST_TYPE_STREAM "stream"
|
||||||
|
|
||||||
|
#define SRS_CONF_DEFAULT_TRANSCODE_IFORMAT "flv"
|
||||||
|
#define SRS_CONF_DEFAULT_TRANSCODE_OFORMAT "flv"
|
||||||
|
|
||||||
|
#define SRS_CONF_DEFAULT_EDGE_MODE false
|
||||||
|
#define SRS_CONF_DEFAULT_EDGE_TOKEN_TRAVERSE false
|
||||||
|
#define SRS_CONF_DEFAULT_EDGE_TRANSFORM_VHOST "[vhost]"
|
||||||
|
|
||||||
|
// hds default value
|
||||||
|
#define SRS_CONF_DEFAULT_HDS_PATH "./objs/nginx/html"
|
||||||
|
#define SRS_CONF_DEFAULT_HDS_WINDOW (60)
|
||||||
|
#define SRS_CONF_DEFAULT_HDS_FRAGMENT (10)
|
||||||
|
|
||||||
// '\n'
|
// '\n'
|
||||||
#define SRS_LF (char)0x0a
|
#define SRS_LF (char)SRS_CONSTS_LF
|
||||||
|
|
||||||
// '\r'
|
// '\r'
|
||||||
#define SRS_CR (char)0x0d
|
#define SRS_CR (char)SRS_CONSTS_CR
|
||||||
|
|
||||||
bool is_common_space(char ch)
|
bool is_common_space(char ch)
|
||||||
{
|
{
|
||||||
|
@ -4284,3 +4371,37 @@ bool srs_directive_equals(SrsConfDirective* a, SrsConfDirective* b)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool srs_config_hls_is_on_error_ignore(string strategy)
|
||||||
|
{
|
||||||
|
return strategy == SRS_CONF_DEFAULT_HLS_ON_ERROR_IGNORE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool srs_config_hls_is_on_error_continue(string strategy)
|
||||||
|
{
|
||||||
|
return strategy == SRS_CONF_DEFAULT_HLS_ON_ERROR_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool srs_config_ingest_is_file(string type)
|
||||||
|
{
|
||||||
|
return type == SRS_CONF_DEFAULT_INGEST_TYPE_FILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool srs_config_ingest_is_stream(string type)
|
||||||
|
{
|
||||||
|
return type == SRS_CONF_DEFAULT_INGEST_TYPE_STREAM;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool srs_config_dvr_is_plan_segment(string plan)
|
||||||
|
{
|
||||||
|
return plan == SRS_CONF_DEFAULT_DVR_PLAN_SEGMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool srs_config_dvr_is_plan_session(string plan)
|
||||||
|
{
|
||||||
|
return plan == SRS_CONF_DEFAULT_DVR_PLAN_SESSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool srs_config_dvr_is_plan_append(string plan)
|
||||||
|
{
|
||||||
|
return plan == SRS_CONF_DEFAULT_DVR_PLAN_APPEND;
|
||||||
|
}
|
||||||
|
|
|
@ -34,93 +34,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#include <srs_app_reload.hpp>
|
#include <srs_app_reload.hpp>
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
|
||||||
// default consts values
|
|
||||||
///////////////////////////////////////////////////////////
|
|
||||||
#define SRS_CONF_DEFAULT_PID_FILE "./objs/srs.pid"
|
|
||||||
#define SRS_CONF_DEFAULT_LOG_FILE "./objs/srs.log"
|
|
||||||
#define SRS_CONF_DEFAULT_LOG_LEVEL "trace"
|
|
||||||
#define SRS_CONF_DEFAULT_LOG_TANK_CONSOLE "console"
|
|
||||||
#define SRS_CONF_DEFAULT_COFNIG_FILE "conf/srs.conf"
|
|
||||||
#define SRS_CONF_DEFAULT_FF_LOG_DIR "./objs"
|
|
||||||
#define SRS_CONF_DEFAULT_UTC_TIME false
|
|
||||||
|
|
||||||
#define SRS_CONF_DEFAULT_MAX_CONNECTIONS 1000
|
|
||||||
#define SRS_CONF_DEFAULT_HLS_PATH "./objs/nginx/html"
|
|
||||||
#define SRS_CONF_DEFAULT_HLS_M3U8_FILE "[app]/[stream].m3u8"
|
|
||||||
#define SRS_CONF_DEFAULT_HLS_TS_FILE "[app]/[stream]-[seq].ts"
|
|
||||||
#define SRS_CONF_DEFAULT_HLS_TS_FLOOR false
|
|
||||||
#define SRS_CONF_DEFAULT_HLS_FRAGMENT 10
|
|
||||||
#define SRS_CONF_DEFAULT_HLS_TD_RATIO 1.5
|
|
||||||
#define SRS_CONF_DEFAULT_HLS_AOF_RATIO 2.0
|
|
||||||
#define SRS_CONF_DEFAULT_HLS_WINDOW 60
|
|
||||||
#define SRS_CONF_DEFAULT_HLS_ON_ERROR_IGNORE "ignore"
|
|
||||||
#define SRS_CONF_DEFAULT_HLS_ON_ERROR_DISCONNECT "disconnect"
|
|
||||||
#define SRS_CONF_DEFAULT_HLS_ON_ERROR_CONTINUE "continue"
|
|
||||||
#define SRS_CONF_DEFAULT_HLS_ON_ERROR SRS_CONF_DEFAULT_HLS_ON_ERROR_IGNORE
|
|
||||||
#define SRS_CONF_DEFAULT_HLS_STORAGE "disk"
|
|
||||||
#define SRS_CONF_DEFAULT_HLS_MOUNT "[vhost]/[app]/[stream].m3u8"
|
|
||||||
#define SRS_CONF_DEFAULT_HLS_ACODEC "aac"
|
|
||||||
#define SRS_CONF_DEFAULT_HLS_VCODEC "h264"
|
|
||||||
#define SRS_CONF_DEFAULT_HLS_CLEANUP true
|
|
||||||
#define SRS_CONF_DEFAULT_HLS_WAIT_KEYFRAME true
|
|
||||||
#define SRS_CONF_DEFAULT_HLS_NB_NOTIFY 64
|
|
||||||
#define SRS_CONF_DEFAULT_DVR_PATH "./objs/nginx/html/[app]/[stream].[timestamp].flv"
|
|
||||||
#define SRS_CONF_DEFAULT_DVR_PLAN_SESSION "session"
|
|
||||||
#define SRS_CONF_DEFAULT_DVR_PLAN_SEGMENT "segment"
|
|
||||||
#define SRS_CONF_DEFAULT_DVR_PLAN_APPEND "append"
|
|
||||||
#define SRS_CONF_DEFAULT_DVR_PLAN SRS_CONF_DEFAULT_DVR_PLAN_SESSION
|
|
||||||
#define SRS_CONF_DEFAULT_DVR_DURATION 30
|
|
||||||
#define SRS_CONF_DEFAULT_TIME_JITTER "full"
|
|
||||||
#define SRS_CONF_DEFAULT_ATC_AUTO true
|
|
||||||
#define SRS_CONF_DEFAULT_MIX_CORRECT false
|
|
||||||
// in seconds, the paused queue length.
|
|
||||||
#define SRS_CONF_DEFAULT_PAUSED_LENGTH 10
|
|
||||||
// the interval in seconds for bandwidth check
|
|
||||||
#define SRS_CONF_DEFAULT_BANDWIDTH_INTERVAL 30
|
|
||||||
// the interval in seconds for bandwidth check
|
|
||||||
#define SRS_CONF_DEFAULT_BANDWIDTH_LIMIT_KBPS 1000
|
|
||||||
|
|
||||||
#define SRS_CONF_DEFAULT_HTTP_MOUNT "[vhost]/"
|
|
||||||
#define SRS_CONF_DEFAULT_HTTP_REMUX_MOUNT "[vhost]/[app]/[stream].flv"
|
|
||||||
#define SRS_CONF_DEFAULT_HTTP_DIR SRS_CONF_DEFAULT_HLS_PATH
|
|
||||||
#define SRS_CONF_DEFAULT_HTTP_AUDIO_FAST_CACHE 0
|
|
||||||
|
|
||||||
#define SRS_CONF_DEFAULT_HTTP_STREAM_PORT "8080"
|
|
||||||
#define SRS_CONF_DEFAULT_HTTP_API_PORT "1985"
|
|
||||||
#define SRS_CONF_DEFAULT_HTTP_API_CROSSDOMAIN true
|
|
||||||
|
|
||||||
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_ENABLED false
|
|
||||||
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_INTERVAL 9.9
|
|
||||||
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_URL "http://"SRS_CONSTS_LOCALHOST":8085/api/v1/servers"
|
|
||||||
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_SUMMARIES false
|
|
||||||
|
|
||||||
#define SRS_CONF_DEFAULT_SECURITY_ENABLED false
|
|
||||||
|
|
||||||
#define SRS_CONF_DEFAULT_STREAM_CASTER_ENABLED false
|
|
||||||
#define SRS_CONF_DEFAULT_STREAM_CASTER_MPEGTS_OVER_UDP "mpegts_over_udp"
|
|
||||||
#define SRS_CONF_DEFAULT_STREAM_CASTER_RTSP "rtsp"
|
|
||||||
#define SRS_CONF_DEFAULT_STREAM_CASTER_FLV "flv"
|
|
||||||
|
|
||||||
#define SRS_CONF_DEFAULT_STATS_NETWORK_DEVICE_INDEX 0
|
|
||||||
|
|
||||||
#define SRS_CONF_DEFAULT_PITHY_PRINT_MS 10000
|
|
||||||
|
|
||||||
#define SRS_CONF_DEFAULT_INGEST_TYPE_FILE "file"
|
|
||||||
#define SRS_CONF_DEFAULT_INGEST_TYPE_STREAM "stream"
|
|
||||||
|
|
||||||
#define SRS_CONF_DEFAULT_TRANSCODE_IFORMAT "flv"
|
|
||||||
#define SRS_CONF_DEFAULT_TRANSCODE_OFORMAT "flv"
|
|
||||||
|
|
||||||
#define SRS_CONF_DEFAULT_EDGE_MODE false
|
|
||||||
#define SRS_CONF_DEFAULT_EDGE_TOKEN_TRAVERSE false
|
|
||||||
#define SRS_CONF_DEFAULT_EDGE_TRANSFORM_VHOST "[vhost]"
|
|
||||||
|
|
||||||
// hds default value
|
|
||||||
#define SRS_CONF_DEFAULT_HDS_PATH "./objs/nginx/html"
|
|
||||||
#define SRS_CONF_DEFAULT_HDS_WINDOW (60)
|
|
||||||
#define SRS_CONF_DEFAULT_HDS_FRAGMENT (10)
|
|
||||||
|
|
||||||
namespace _srs_internal
|
namespace _srs_internal
|
||||||
{
|
{
|
||||||
class SrsConfigBuffer;
|
class SrsConfigBuffer;
|
||||||
|
@ -1218,7 +1131,18 @@ namespace _srs_internal
|
||||||
/**
|
/**
|
||||||
* deep compare directive.
|
* deep compare directive.
|
||||||
*/
|
*/
|
||||||
bool srs_directive_equals(SrsConfDirective* a, SrsConfDirective* b);
|
extern bool srs_directive_equals(SrsConfDirective* a, SrsConfDirective* b);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* helper utilities, used for compare the consts values.
|
||||||
|
*/
|
||||||
|
extern bool srs_config_hls_is_on_error_ignore(std::string strategy);
|
||||||
|
extern bool srs_config_hls_is_on_error_continue(std::string strategy);
|
||||||
|
extern bool srs_config_ingest_is_file(std::string type);
|
||||||
|
extern bool srs_config_ingest_is_stream(std::string type);
|
||||||
|
extern bool srs_config_dvr_is_plan_segment(std::string plan);
|
||||||
|
extern bool srs_config_dvr_is_plan_session(std::string plan);
|
||||||
|
extern bool srs_config_dvr_is_plan_append(std::string plan);
|
||||||
|
|
||||||
// global config
|
// global config
|
||||||
extern SrsConfig* _srs_config;
|
extern SrsConfig* _srs_config;
|
||||||
|
|
|
@ -639,11 +639,11 @@ int SrsDvrPlan::on_reap_segment()
|
||||||
SrsDvrPlan* SrsDvrPlan::create_plan(string vhost)
|
SrsDvrPlan* SrsDvrPlan::create_plan(string vhost)
|
||||||
{
|
{
|
||||||
std::string plan = _srs_config->get_dvr_plan(vhost);
|
std::string plan = _srs_config->get_dvr_plan(vhost);
|
||||||
if (plan == SRS_CONF_DEFAULT_DVR_PLAN_SEGMENT) {
|
if (srs_config_dvr_is_plan_segment(plan)) {
|
||||||
return new SrsDvrSegmentPlan();
|
return new SrsDvrSegmentPlan();
|
||||||
} else if (plan == SRS_CONF_DEFAULT_DVR_PLAN_SESSION) {
|
} else if (srs_config_dvr_is_plan_session(plan)) {
|
||||||
return new SrsDvrSessionPlan();
|
return new SrsDvrSessionPlan();
|
||||||
} else if (plan == SRS_CONF_DEFAULT_DVR_PLAN_APPEND) {
|
} else if (srs_config_dvr_is_plan_append(plan)) {
|
||||||
return new SrsDvrAppendPlan();
|
return new SrsDvrAppendPlan();
|
||||||
} else {
|
} else {
|
||||||
srs_error("invalid dvr plan=%s, vhost=%s", plan.c_str(), vhost.c_str());
|
srs_error("invalid dvr plan=%s, vhost=%s", plan.c_str(), vhost.c_str());
|
||||||
|
|
25
trunk/src/app/srs_app_edge.cpp
Normal file → Executable file
25
trunk/src/app/srs_app_edge.cpp
Normal file → Executable file
|
@ -94,6 +94,13 @@ int SrsEdgeIngester::initialize(SrsSource* source, SrsPlayEdge* edge, SrsRequest
|
||||||
|
|
||||||
int SrsEdgeIngester::start()
|
int SrsEdgeIngester::start()
|
||||||
{
|
{
|
||||||
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
if ((ret = _source->on_publish()) != ERROR_SUCCESS) {
|
||||||
|
srs_error("edge pull stream then publish to edge failed. ret=%d", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
return pthread->start();
|
return pthread->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +121,9 @@ void SrsEdgeIngester::stop()
|
||||||
int SrsEdgeIngester::cycle()
|
int SrsEdgeIngester::cycle()
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
_source->on_source_id_changed(_srs_context->get_id());
|
||||||
|
|
||||||
std::string ep_server, ep_port;
|
std::string ep_server, ep_port;
|
||||||
if ((ret = connect_server(ep_server, ep_port)) != ERROR_SUCCESS) {
|
if ((ret = connect_server(ep_server, ep_port)) != ERROR_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -144,11 +153,6 @@ int SrsEdgeIngester::cycle()
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = _source->on_publish()) != ERROR_SUCCESS) {
|
|
||||||
srs_error("edge pull stream then publish to edge failed. ret=%d", ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ret = _edge->on_ingest_play()) != ERROR_SUCCESS) {
|
if ((ret = _edge->on_ingest_play()) != ERROR_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -381,8 +385,8 @@ int SrsEdgeIngester::connect_server(string& ep_server, string& ep_port)
|
||||||
|
|
||||||
kbps->set_io(io, io);
|
kbps->set_io(io, io);
|
||||||
|
|
||||||
srs_trace("edge pull connected, can_publish=%d, url=%s/%s, server=%s:%d",
|
srs_trace("edge pull connected, url=%s/%s, server=%s:%d",
|
||||||
_source->can_publish(), _req->tcUrl.c_str(), _req->stream.c_str(), server.c_str(), port);
|
_req->tcUrl.c_str(), _req->stream.c_str(), server.c_str(), port);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -803,6 +807,11 @@ int SrsPublishEdge::initialize(SrsSource* source, SrsRequest* req)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SrsPublishEdge::can_publish()
|
||||||
|
{
|
||||||
|
return state != SrsEdgeStatePublish;
|
||||||
|
}
|
||||||
|
|
||||||
int SrsPublishEdge::on_client_publish()
|
int SrsPublishEdge::on_client_publish()
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
1
trunk/src/app/srs_app_edge.hpp
Normal file → Executable file
1
trunk/src/app/srs_app_edge.hpp
Normal file → Executable file
|
@ -207,6 +207,7 @@ public:
|
||||||
virtual void set_queue_size(double queue_size);
|
virtual void set_queue_size(double queue_size);
|
||||||
public:
|
public:
|
||||||
virtual int initialize(SrsSource* source, SrsRequest* req);
|
virtual int initialize(SrsSource* source, SrsRequest* req);
|
||||||
|
virtual bool can_publish();
|
||||||
/**
|
/**
|
||||||
* when client publish stream on edge.
|
* when client publish stream on edge.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -369,7 +369,7 @@ int SrsIngester::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsConfDirective* vhost, S
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input_type == SRS_CONF_DEFAULT_INGEST_TYPE_FILE) {
|
if (srs_config_ingest_is_file(input_type)) {
|
||||||
std::string input_url = _srs_config->get_ingest_input_url(ingest);
|
std::string input_url = _srs_config->get_ingest_input_url(ingest);
|
||||||
if (input_url.empty()) {
|
if (input_url.empty()) {
|
||||||
ret = ERROR_ENCODER_NO_INPUT;
|
ret = ERROR_ENCODER_NO_INPUT;
|
||||||
|
@ -383,7 +383,7 @@ int SrsIngester::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsConfDirective* vhost, S
|
||||||
if ((ret = ffmpeg->initialize(input_url, output, log_file)) != ERROR_SUCCESS) {
|
if ((ret = ffmpeg->initialize(input_url, output, log_file)) != ERROR_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
} else if (input_type == SRS_CONF_DEFAULT_INGEST_TYPE_STREAM) {
|
} else if (srs_config_ingest_is_stream(input_type)) {
|
||||||
std::string input_url = _srs_config->get_ingest_input_url(ingest);
|
std::string input_url = _srs_config->get_ingest_input_url(ingest);
|
||||||
if (input_url.empty()) {
|
if (input_url.empty()) {
|
||||||
ret = ERROR_ENCODER_NO_INPUT;
|
ret = ERROR_ENCODER_NO_INPUT;
|
||||||
|
|
|
@ -206,6 +206,7 @@ int SrsRtmpConn::do_cycle()
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = service_cycle();
|
ret = service_cycle();
|
||||||
|
|
||||||
http_hooks_on_close();
|
http_hooks_on_close();
|
||||||
SrsStatistic* stat = SrsStatistic::instance();
|
SrsStatistic* stat = SrsStatistic::instance();
|
||||||
stat->on_disconnect(_srs_context->get_id());
|
stat->on_disconnect(_srs_context->get_id());
|
||||||
|
@ -432,10 +433,9 @@ int SrsRtmpConn::stream_service_cycle()
|
||||||
}
|
}
|
||||||
|
|
||||||
// check ASAP, to fail it faster if invalid.
|
// check ASAP, to fail it faster if invalid.
|
||||||
if (type != SrsRtmpConnPlay && !vhost_is_edge) {
|
if (type != SrsRtmpConnPlay) {
|
||||||
// check publish available
|
// check publish available
|
||||||
// for edge, never check it, for edge use proxy mode.
|
if (!source->can_publish(vhost_is_edge)) {
|
||||||
if (!source->can_publish()) {
|
|
||||||
ret = ERROR_SYSTEM_STREAM_BUSY;
|
ret = ERROR_SYSTEM_STREAM_BUSY;
|
||||||
srs_warn("stream %s is already publishing. ret=%d",
|
srs_warn("stream %s is already publishing. ret=%d",
|
||||||
req->get_stream_url().c_str(), ret);
|
req->get_stream_url().c_str(), ret);
|
||||||
|
|
0
trunk/src/app/srs_app_rtmp_conn.hpp
Normal file → Executable file
0
trunk/src/app/srs_app_rtmp_conn.hpp
Normal file → Executable file
|
@ -1350,8 +1350,12 @@ int SrsSource::source_id()
|
||||||
return _source_id;
|
return _source_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SrsSource::can_publish()
|
bool SrsSource::can_publish(bool is_edge)
|
||||||
{
|
{
|
||||||
|
if (is_edge) {
|
||||||
|
return publish_edge->can_publish();
|
||||||
|
}
|
||||||
|
|
||||||
return _can_publish;
|
return _can_publish;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1522,7 +1526,7 @@ int SrsSource::on_audio_imp(SrsSharedPtrMessage* msg)
|
||||||
// apply the error strategy for hls.
|
// apply the error strategy for hls.
|
||||||
// @see https://github.com/simple-rtmp-server/srs/issues/264
|
// @see https://github.com/simple-rtmp-server/srs/issues/264
|
||||||
std::string hls_error_strategy = _srs_config->get_hls_on_error(_req->vhost);
|
std::string hls_error_strategy = _srs_config->get_hls_on_error(_req->vhost);
|
||||||
if (hls_error_strategy == SRS_CONF_DEFAULT_HLS_ON_ERROR_IGNORE) {
|
if (srs_config_hls_is_on_error_ignore(hls_error_strategy)) {
|
||||||
srs_warn("hls process audio message failed, ignore and disable hls. ret=%d", ret);
|
srs_warn("hls process audio message failed, ignore and disable hls. ret=%d", ret);
|
||||||
|
|
||||||
// unpublish, ignore ret.
|
// unpublish, ignore ret.
|
||||||
|
@ -1530,7 +1534,7 @@ int SrsSource::on_audio_imp(SrsSharedPtrMessage* msg)
|
||||||
|
|
||||||
// ignore.
|
// ignore.
|
||||||
ret = ERROR_SUCCESS;
|
ret = ERROR_SUCCESS;
|
||||||
} else if (hls_error_strategy == SRS_CONF_DEFAULT_HLS_ON_ERROR_CONTINUE) {
|
} else if (srs_config_hls_is_on_error_continue(hls_error_strategy)) {
|
||||||
// compare the sequence header with audio, continue when it's actually an sequence header.
|
// compare the sequence header with audio, continue when it's actually an sequence header.
|
||||||
if (ret == ERROR_HLS_DECODE_ERROR && cache_sh_audio && cache_sh_audio->size == msg->size) {
|
if (ret == ERROR_HLS_DECODE_ERROR && cache_sh_audio && cache_sh_audio->size == msg->size) {
|
||||||
srs_warn("the audio is actually a sequence header, ignore this packet.");
|
srs_warn("the audio is actually a sequence header, ignore this packet.");
|
||||||
|
@ -1726,7 +1730,7 @@ int SrsSource::on_video_imp(SrsSharedPtrMessage* msg)
|
||||||
// apply the error strategy for hls.
|
// apply the error strategy for hls.
|
||||||
// @see https://github.com/simple-rtmp-server/srs/issues/264
|
// @see https://github.com/simple-rtmp-server/srs/issues/264
|
||||||
std::string hls_error_strategy = _srs_config->get_hls_on_error(_req->vhost);
|
std::string hls_error_strategy = _srs_config->get_hls_on_error(_req->vhost);
|
||||||
if (hls_error_strategy == SRS_CONF_DEFAULT_HLS_ON_ERROR_IGNORE) {
|
if (srs_config_hls_is_on_error_ignore(hls_error_strategy)) {
|
||||||
srs_warn("hls process video message failed, ignore and disable hls. ret=%d", ret);
|
srs_warn("hls process video message failed, ignore and disable hls. ret=%d", ret);
|
||||||
|
|
||||||
// unpublish, ignore ret.
|
// unpublish, ignore ret.
|
||||||
|
@ -1734,7 +1738,7 @@ int SrsSource::on_video_imp(SrsSharedPtrMessage* msg)
|
||||||
|
|
||||||
// ignore.
|
// ignore.
|
||||||
ret = ERROR_SUCCESS;
|
ret = ERROR_SUCCESS;
|
||||||
} else if (hls_error_strategy == SRS_CONF_DEFAULT_HLS_ON_ERROR_CONTINUE) {
|
} else if (srs_config_hls_is_on_error_continue(hls_error_strategy)) {
|
||||||
// compare the sequence header with video, continue when it's actually an sequence header.
|
// compare the sequence header with video, continue when it's actually an sequence header.
|
||||||
if (ret == ERROR_HLS_DECODE_ERROR && cache_sh_video && cache_sh_video->size == msg->size) {
|
if (ret == ERROR_HLS_DECODE_ERROR && cache_sh_video && cache_sh_video->size == msg->size) {
|
||||||
srs_warn("the video is actually a sequence header, ignore this packet.");
|
srs_warn("the video is actually a sequence header, ignore this packet.");
|
||||||
|
|
2
trunk/src/app/srs_app_source.hpp
Normal file → Executable file
2
trunk/src/app/srs_app_source.hpp
Normal file → Executable file
|
@ -537,7 +537,7 @@ public:
|
||||||
virtual int source_id();
|
virtual int source_id();
|
||||||
// logic data methods
|
// logic data methods
|
||||||
public:
|
public:
|
||||||
virtual bool can_publish();
|
virtual bool can_publish(bool is_edge);
|
||||||
virtual int on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata);
|
virtual int on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata);
|
||||||
public:
|
public:
|
||||||
virtual int on_audio(SrsCommonMessage* audio);
|
virtual int on_audio(SrsCommonMessage* audio);
|
||||||
|
|
|
@ -154,14 +154,17 @@ public:
|
||||||
virtual void on_stream_close(SrsRequest* req);
|
virtual void on_stream_close(SrsRequest* req);
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* when got a client to publish/play stream,
|
* when got a client to publish/play stream,
|
||||||
* @param id, the client srs id.
|
* @param id, the client srs id.
|
||||||
* @param req, the client request object.
|
* @param req, the client request object.
|
||||||
*/
|
*/
|
||||||
virtual int on_client(int id, SrsRequest* req);
|
virtual int on_client(int id, SrsRequest* req);
|
||||||
/**
|
/**
|
||||||
* client disconnect
|
* client disconnect
|
||||||
*/
|
* @remark the on_disconnect always call, while the on_client is call when
|
||||||
|
* only got the request object, so the client specified by id maybe not
|
||||||
|
* exists in stat.
|
||||||
|
*/
|
||||||
virtual void on_disconnect(int id);
|
virtual void on_disconnect(int id);
|
||||||
/**
|
/**
|
||||||
* sample the kbps, add delta bytes of conn.
|
* sample the kbps, add delta bytes of conn.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue