From a63a3812e33811cee808b773520daebc93c40aef Mon Sep 17 00:00:00 2001 From: winlin Date: Fri, 25 Apr 2014 16:35:03 +0800 Subject: [PATCH] add srs app edge --- trunk/configure | 2 +- trunk/src/app/srs_app_edge.cpp | 25 ++++++++++++++++++++++ trunk/src/app/srs_app_edge.hpp | 33 +++++++++++++++++++++++++++++ trunk/src/app/srs_app_rtmp_conn.cpp | 7 ++++++ trunk/src/app/srs_app_source.cpp | 6 ++++++ trunk/src/app/srs_app_source.hpp | 2 ++ trunk/src/srs/srs.upp | 2 ++ 7 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 trunk/src/app/srs_app_edge.cpp create mode 100644 trunk/src/app/srs_app_edge.hpp diff --git a/trunk/configure b/trunk/configure index 29093aca7..4789c1c58 100755 --- a/trunk/configure +++ b/trunk/configure @@ -448,7 +448,7 @@ MODULE_FILES=("srs_app_server" "srs_app_conn" "srs_app_rtmp_conn" "srs_app_socke "srs_app_http" "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_ffmpeg" "srs_app_utility" "srs_app_dvr" "srs_app_edge") APP_INCS="src/app"; MODULE_DIR=${APP_INCS} . auto/modules.sh APP_OBJS="${MODULE_OBJS[@]}" # diff --git a/trunk/src/app/srs_app_edge.cpp b/trunk/src/app/srs_app_edge.cpp new file mode 100644 index 000000000..cd028c263 --- /dev/null +++ b/trunk/src/app/srs_app_edge.cpp @@ -0,0 +1,25 @@ +/* +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 + diff --git a/trunk/src/app/srs_app_edge.hpp b/trunk/src/app/srs_app_edge.hpp new file mode 100644 index 000000000..ef3dce933 --- /dev/null +++ b/trunk/src/app/srs_app_edge.hpp @@ -0,0 +1,33 @@ +/* +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_EDGE_HPP +#define SRS_APP_EDGE_HPP + +/* +#include +*/ + +#include + +#endif \ No newline at end of file diff --git a/trunk/src/app/srs_app_rtmp_conn.cpp b/trunk/src/app/srs_app_rtmp_conn.cpp index 1bcfeae26..a4f77606d 100644 --- a/trunk/src/app/srs_app_rtmp_conn.cpp +++ b/trunk/src/app/srs_app_rtmp_conn.cpp @@ -296,6 +296,13 @@ int SrsRtmpConn::stream_service_cycle() case SrsRtmpConnPlay: { srs_verbose("start to play stream %s.", req->stream.c_str()); + if (vhost_is_edge) { + if ((ret = source->on_edge_play_stream()) != ERROR_SUCCESS) { + srs_error("notice edge play stream failed. ret=%d", ret); + return ret; + } + } + if ((ret = rtmp->start_play(res->stream_id)) != ERROR_SUCCESS) { srs_error("start to play stream failed. ret=%d", ret); return ret; diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index 02b206d6f..a081fc4b0 100644 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -1175,6 +1175,12 @@ bool SrsSource::is_atc() return atc; } +int SrsSource::on_edge_play_stream() +{ + int ret = ERROR_SUCCESS; + return ret; +} + int SrsSource::create_forwarders() { int ret = ERROR_SUCCESS; diff --git a/trunk/src/app/srs_app_source.hpp b/trunk/src/app/srs_app_source.hpp index abd1143e6..a5025c107 100644 --- a/trunk/src/app/srs_app_source.hpp +++ b/trunk/src/app/srs_app_source.hpp @@ -309,6 +309,8 @@ public: public: // for consumer, atc feature. virtual bool is_atc(); + // for edge, when play edge stream, check the state + virtual int on_edge_play_stream(); private: virtual int create_forwarders(); virtual void destroy_forwarders(); diff --git a/trunk/src/srs/srs.upp b/trunk/src/srs/srs.upp index f9e3cacac..c895da723 100755 --- a/trunk/src/srs/srs.upp +++ b/trunk/src/srs/srs.upp @@ -49,6 +49,8 @@ file ..\app\srs_app_config.cpp, ..\app\srs_app_dvr.hpp, ..\app\srs_app_dvr.cpp, + ..\app\srs_app_edge.hpp, + ..\app\srs_app_edge.cpp, ..\app\srs_app_encoder.hpp, ..\app\srs_app_encoder.cpp, ..\app\srs_app_ffmpeg.hpp,