diff --git a/AUTHORS.txt b/AUTHORS.txt index 2f9444f3e..ab86f6532 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -6,3 +6,4 @@ Authors ordered by first contribution. * naijia.liu * alcoholyi * byteman +* chad.wang diff --git a/trunk/src/app/srs_app_edge.cpp b/trunk/src/app/srs_app_edge.cpp index cd028c263..467d8c769 100644 --- a/trunk/src/app/srs_app_edge.cpp +++ b/trunk/src/app/srs_app_edge.cpp @@ -23,3 +23,20 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include +#include + +SrsEdge::SrsEdge() +{ + state = SrsEdgeStateInit; +} + +SrsEdge::~SrsEdge() +{ +} + +int SrsEdge::on_client_play() +{ + int ret = ERROR_SUCCESS; + return ret; +} + diff --git a/trunk/src/app/srs_app_edge.hpp b/trunk/src/app/srs_app_edge.hpp index ef3dce933..7f4e29716 100644 --- a/trunk/src/app/srs_app_edge.hpp +++ b/trunk/src/app/srs_app_edge.hpp @@ -30,4 +30,34 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include -#endif \ No newline at end of file +/** +* the state of edge +*/ +enum SrsEdgeState +{ + SrsEdgeStateInit = 0, + SrsEdgeStatePlay = 100, + SrsEdgeStatePublish, + SrsEdgeStateConnected, + SrsEdgeStateAborting, + SrsEdgeStateReloading, +}; + +/** +* edge control service. +*/ +class SrsEdge +{ +private: + SrsEdgeState state; +public: + SrsEdge(); + virtual ~SrsEdge(); +public: + /** + * when client play stream on edge. + */ + virtual int on_client_play(); +}; + +#endif diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index a081fc4b0..4074d3a50 100644 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -38,6 +38,7 @@ using namespace std; #include #include #include +#include #define CONST_MAX_JITTER_MS 500 #define DEFAULT_FRAME_TIME_MS 40 @@ -455,6 +456,7 @@ SrsSource::SrsSource(SrsRequest* _req) frame_rate = sample_rate = 0; _can_publish = true; + edge = new SrsEdge(); gop_cache = new SrsGopCache(); _srs_config->subscribe(this); @@ -487,6 +489,7 @@ SrsSource::~SrsSource() srs_freep(cache_sh_video); srs_freep(cache_sh_audio); + srs_freep(edge); srs_freep(gop_cache); #ifdef SRS_AUTO_HLS @@ -1177,8 +1180,7 @@ bool SrsSource::is_atc() int SrsSource::on_edge_play_stream() { - int ret = ERROR_SUCCESS; - return ret; + return edge->on_client_play(); } int SrsSource::create_forwarders() diff --git a/trunk/src/app/srs_app_source.hpp b/trunk/src/app/srs_app_source.hpp index a5025c107..8989b3649 100644 --- a/trunk/src/app/srs_app_source.hpp +++ b/trunk/src/app/srs_app_source.hpp @@ -37,6 +37,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include +class SrsEdge; class SrsSource; class SrsCommonMessage; class SrsOnMetaDataPacket; @@ -234,6 +235,8 @@ private: #ifdef SRS_AUTO_TRANSCODE SrsEncoder* encoder; #endif + // edge control service + SrsEdge* edge; // gop cache for client fast startup. SrsGopCache* gop_cache; // to forward stream to other servers