winlin

add srs app edge

@@ -448,7 +448,7 @@ MODULE_FILES=("srs_app_server" "srs_app_conn" "srs_app_rtmp_conn" "srs_app_socke @@ -448,7 +448,7 @@ MODULE_FILES=("srs_app_server" "srs_app_conn" "srs_app_rtmp_conn" "srs_app_socke
448 "srs_app_http" "srs_app_thread" "srs_app_bandwidth" "srs_app_st" "srs_app_log" 448 "srs_app_http" "srs_app_thread" "srs_app_bandwidth" "srs_app_st" "srs_app_log"
449 "srs_app_config" "srs_app_pithy_print" "srs_app_reload" "srs_app_http_api" 449 "srs_app_config" "srs_app_pithy_print" "srs_app_reload" "srs_app_http_api"
450 "srs_app_http_conn" "srs_app_http_hooks" "srs_app_json" "srs_app_ingest" 450 "srs_app_http_conn" "srs_app_http_hooks" "srs_app_json" "srs_app_ingest"
451 - "srs_app_ffmpeg" "srs_app_utility" "srs_app_dvr") 451 + "srs_app_ffmpeg" "srs_app_utility" "srs_app_dvr" "srs_app_edge")
452 APP_INCS="src/app"; MODULE_DIR=${APP_INCS} . auto/modules.sh 452 APP_INCS="src/app"; MODULE_DIR=${APP_INCS} . auto/modules.sh
453 APP_OBJS="${MODULE_OBJS[@]}" 453 APP_OBJS="${MODULE_OBJS[@]}"
454 # 454 #
  1 +/*
  2 +The MIT License (MIT)
  3 +
  4 +Copyright (c) 2013-2014 winlin
  5 +
  6 +Permission is hereby granted, free of charge, to any person obtaining a copy of
  7 +this software and associated documentation files (the "Software"), to deal in
  8 +the Software without restriction, including without limitation the rights to
  9 +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  10 +the Software, and to permit persons to whom the Software is furnished to do so,
  11 +subject to the following conditions:
  12 +
  13 +The above copyright notice and this permission notice shall be included in all
  14 +copies or substantial portions of the Software.
  15 +
  16 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  18 +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  19 +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  20 +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21 +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22 +*/
  23 +
  24 +#include <srs_app_edge.hpp>
  25 +
  1 +/*
  2 +The MIT License (MIT)
  3 +
  4 +Copyright (c) 2013-2014 winlin
  5 +
  6 +Permission is hereby granted, free of charge, to any person obtaining a copy of
  7 +this software and associated documentation files (the "Software"), to deal in
  8 +the Software without restriction, including without limitation the rights to
  9 +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  10 +the Software, and to permit persons to whom the Software is furnished to do so,
  11 +subject to the following conditions:
  12 +
  13 +The above copyright notice and this permission notice shall be included in all
  14 +copies or substantial portions of the Software.
  15 +
  16 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  18 +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  19 +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  20 +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21 +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22 +*/
  23 +
  24 +#ifndef SRS_APP_EDGE_HPP
  25 +#define SRS_APP_EDGE_HPP
  26 +
  27 +/*
  28 +#include <srs_app_edge.hpp>
  29 +*/
  30 +
  31 +#include <srs_core.hpp>
  32 +
  33 +#endif
@@ -296,6 +296,13 @@ int SrsRtmpConn::stream_service_cycle() @@ -296,6 +296,13 @@ int SrsRtmpConn::stream_service_cycle()
296 case SrsRtmpConnPlay: { 296 case SrsRtmpConnPlay: {
297 srs_verbose("start to play stream %s.", req->stream.c_str()); 297 srs_verbose("start to play stream %s.", req->stream.c_str());
298 298
  299 + if (vhost_is_edge) {
  300 + if ((ret = source->on_edge_play_stream()) != ERROR_SUCCESS) {
  301 + srs_error("notice edge play stream failed. ret=%d", ret);
  302 + return ret;
  303 + }
  304 + }
  305 +
299 if ((ret = rtmp->start_play(res->stream_id)) != ERROR_SUCCESS) { 306 if ((ret = rtmp->start_play(res->stream_id)) != ERROR_SUCCESS) {
300 srs_error("start to play stream failed. ret=%d", ret); 307 srs_error("start to play stream failed. ret=%d", ret);
301 return ret; 308 return ret;
@@ -1175,6 +1175,12 @@ bool SrsSource::is_atc() @@ -1175,6 +1175,12 @@ bool SrsSource::is_atc()
1175 return atc; 1175 return atc;
1176 } 1176 }
1177 1177
  1178 +int SrsSource::on_edge_play_stream()
  1179 +{
  1180 + int ret = ERROR_SUCCESS;
  1181 + return ret;
  1182 +}
  1183 +
1178 int SrsSource::create_forwarders() 1184 int SrsSource::create_forwarders()
1179 { 1185 {
1180 int ret = ERROR_SUCCESS; 1186 int ret = ERROR_SUCCESS;
@@ -309,6 +309,8 @@ public: @@ -309,6 +309,8 @@ public:
309 public: 309 public:
310 // for consumer, atc feature. 310 // for consumer, atc feature.
311 virtual bool is_atc(); 311 virtual bool is_atc();
  312 + // for edge, when play edge stream, check the state
  313 + virtual int on_edge_play_stream();
312 private: 314 private:
313 virtual int create_forwarders(); 315 virtual int create_forwarders();
314 virtual void destroy_forwarders(); 316 virtual void destroy_forwarders();
@@ -49,6 +49,8 @@ file @@ -49,6 +49,8 @@ file
49 ..\app\srs_app_config.cpp, 49 ..\app\srs_app_config.cpp,
50 ..\app\srs_app_dvr.hpp, 50 ..\app\srs_app_dvr.hpp,
51 ..\app\srs_app_dvr.cpp, 51 ..\app\srs_app_dvr.cpp,
  52 + ..\app\srs_app_edge.hpp,
  53 + ..\app\srs_app_edge.cpp,
52 ..\app\srs_app_encoder.hpp, 54 ..\app\srs_app_encoder.hpp,
53 ..\app\srs_app_encoder.cpp, 55 ..\app\srs_app_encoder.cpp,
54 ..\app\srs_app_ffmpeg.hpp, 56 ..\app\srs_app_ffmpeg.hpp,