diff --git a/trunk/src/app/srs_app_ingest.cpp b/trunk/src/app/srs_app_ingest.cpp index d58d9fd42..569fd2367 100644 --- a/trunk/src/app/srs_app_ingest.cpp +++ b/trunk/src/app/srs_app_ingest.cpp @@ -32,6 +32,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. SrsIngester::SrsIngester() { + // TODO: FIXME: support reload. pthread = new SrsThread(this, SRS_INGESTER_SLEEP_US); } @@ -40,6 +41,16 @@ SrsIngester::~SrsIngester() srs_freep(pthread); } +int SrsIngester::start() +{ + int ret = ERROR_SUCCESS; + return ret; +} + +void SrsIngester::stop() +{ +} + int SrsIngester::cycle() { int ret = ERROR_SUCCESS; diff --git a/trunk/src/app/srs_app_ingest.hpp b/trunk/src/app/srs_app_ingest.hpp index 2e0d4cac3..54cadc1a1 100644 --- a/trunk/src/app/srs_app_ingest.hpp +++ b/trunk/src/app/srs_app_ingest.hpp @@ -31,15 +31,29 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifdef SRS_INGEST +#include + #include +class SrsFFMPEG; + +/** +* ingest file/stream/device, +* encode with FFMPEG(optional), +* push to SRS(or any RTMP server) over RTMP. +*/ class SrsIngester : public ISrsThreadHandler { +private: + std::vector ffmpegs; private: SrsThread* pthread; public: SrsIngester(); virtual ~SrsIngester(); +public: + virtual int start(); + virtual void stop(); // interface ISrsThreadHandler. public: virtual int cycle(); diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp index 64d3a79cd..c5859cc3f 100644 --- a/trunk/src/app/srs_app_server.cpp +++ b/trunk/src/app/srs_app_server.cpp @@ -169,6 +169,9 @@ SrsServer::SrsServer() #ifdef SRS_HTTP_SERVER http_stream_handler = SrsHttpHandler::create_http_stream(); #endif +#ifdef SRS_INGEST + ingester = new SrsIngester(); +#endif } SrsServer::~SrsServer() @@ -193,6 +196,9 @@ SrsServer::~SrsServer() #ifdef SRS_HTTP_SERVER srs_freep(http_stream_handler); #endif +#ifdef SRS_INGEST + srs_freep(ingester); +#endif } int SrsServer::initialize() @@ -371,11 +377,12 @@ int SrsServer::cycle() { int ret = ERROR_SUCCESS; - // ingest streams - if ((ret = ingest_streams()) != ERROR_SUCCESS) { - srs_error("ingest streams failed. ret=%d", ret); +#ifdef SRS_INGEST + if ((ret = ingester->start()) != ERROR_SUCCESS) { + srs_error("start ingest streams failed. ret=%d", ret); return ret; } +#endif // the deamon thread, update the time cache while (true) { @@ -404,6 +411,10 @@ int SrsServer::cycle() srs_trace("reload config success."); } } + +#ifdef SRS_INGEST + ingester->stop(); +#endif return ret; } @@ -448,15 +459,6 @@ void SrsServer::on_signal(int signo) } } -int SrsServer::ingest_streams() -{ - int ret = ERROR_SUCCESS; -#ifdef SRS_INGEST - -#endif - return ret; -} - void SrsServer::close_listeners() { std::vector::iterator it; diff --git a/trunk/src/app/srs_app_server.hpp b/trunk/src/app/srs_app_server.hpp index 3c14f1b6b..ff8e5fd83 100644 --- a/trunk/src/app/srs_app_server.hpp +++ b/trunk/src/app/srs_app_server.hpp @@ -39,6 +39,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. class SrsServer; class SrsConnection; class SrsHttpHandler; +class SrsIngester; // listener type for server to identify the connection, // that is, use different type to process the connection. @@ -83,6 +84,9 @@ private: #ifdef SRS_HTTP_SERVER SrsHttpHandler* http_stream_handler; #endif +#ifdef SRS_INGEST + SrsIngester* ingester; +#endif private: std::vector conns; std::vector listeners; @@ -100,7 +104,6 @@ public: virtual void remove(SrsConnection* conn); virtual void on_signal(int signo); private: - virtual int ingest_streams(); virtual void close_listeners(); virtual int accept_client(SrsListenerType type, st_netfd_t client_stfd); public: