mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
refine ingest, start/stop ingest in server
This commit is contained in:
parent
eea2310b07
commit
095364a72b
4 changed files with 43 additions and 13 deletions
|
@ -32,6 +32,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
SrsIngester::SrsIngester()
|
SrsIngester::SrsIngester()
|
||||||
{
|
{
|
||||||
|
// TODO: FIXME: support reload.
|
||||||
pthread = new SrsThread(this, SRS_INGESTER_SLEEP_US);
|
pthread = new SrsThread(this, SRS_INGESTER_SLEEP_US);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +41,16 @@ SrsIngester::~SrsIngester()
|
||||||
srs_freep(pthread);
|
srs_freep(pthread);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SrsIngester::start()
|
||||||
|
{
|
||||||
|
int ret = ERROR_SUCCESS;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SrsIngester::stop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
int SrsIngester::cycle()
|
int SrsIngester::cycle()
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
|
@ -31,15 +31,29 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#ifdef SRS_INGEST
|
#ifdef SRS_INGEST
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <srs_app_thread.hpp>
|
#include <srs_app_thread.hpp>
|
||||||
|
|
||||||
|
class SrsFFMPEG;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ingest file/stream/device,
|
||||||
|
* encode with FFMPEG(optional),
|
||||||
|
* push to SRS(or any RTMP server) over RTMP.
|
||||||
|
*/
|
||||||
class SrsIngester : public ISrsThreadHandler
|
class SrsIngester : public ISrsThreadHandler
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
std::vector<SrsFFMPEG*> ffmpegs;
|
||||||
private:
|
private:
|
||||||
SrsThread* pthread;
|
SrsThread* pthread;
|
||||||
public:
|
public:
|
||||||
SrsIngester();
|
SrsIngester();
|
||||||
virtual ~SrsIngester();
|
virtual ~SrsIngester();
|
||||||
|
public:
|
||||||
|
virtual int start();
|
||||||
|
virtual void stop();
|
||||||
// interface ISrsThreadHandler.
|
// interface ISrsThreadHandler.
|
||||||
public:
|
public:
|
||||||
virtual int cycle();
|
virtual int cycle();
|
||||||
|
|
|
@ -169,6 +169,9 @@ SrsServer::SrsServer()
|
||||||
#ifdef SRS_HTTP_SERVER
|
#ifdef SRS_HTTP_SERVER
|
||||||
http_stream_handler = SrsHttpHandler::create_http_stream();
|
http_stream_handler = SrsHttpHandler::create_http_stream();
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef SRS_INGEST
|
||||||
|
ingester = new SrsIngester();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsServer::~SrsServer()
|
SrsServer::~SrsServer()
|
||||||
|
@ -193,6 +196,9 @@ SrsServer::~SrsServer()
|
||||||
#ifdef SRS_HTTP_SERVER
|
#ifdef SRS_HTTP_SERVER
|
||||||
srs_freep(http_stream_handler);
|
srs_freep(http_stream_handler);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef SRS_INGEST
|
||||||
|
srs_freep(ingester);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsServer::initialize()
|
int SrsServer::initialize()
|
||||||
|
@ -371,11 +377,12 @@ int SrsServer::cycle()
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
// ingest streams
|
#ifdef SRS_INGEST
|
||||||
if ((ret = ingest_streams()) != ERROR_SUCCESS) {
|
if ((ret = ingester->start()) != ERROR_SUCCESS) {
|
||||||
srs_error("ingest streams failed. ret=%d", ret);
|
srs_error("start ingest streams failed. ret=%d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// the deamon thread, update the time cache
|
// the deamon thread, update the time cache
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -404,6 +411,10 @@ int SrsServer::cycle()
|
||||||
srs_trace("reload config success.");
|
srs_trace("reload config success.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SRS_INGEST
|
||||||
|
ingester->stop();
|
||||||
|
#endif
|
||||||
|
|
||||||
return ret;
|
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()
|
void SrsServer::close_listeners()
|
||||||
{
|
{
|
||||||
std::vector<SrsListener*>::iterator it;
|
std::vector<SrsListener*>::iterator it;
|
||||||
|
|
|
@ -39,6 +39,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
class SrsServer;
|
class SrsServer;
|
||||||
class SrsConnection;
|
class SrsConnection;
|
||||||
class SrsHttpHandler;
|
class SrsHttpHandler;
|
||||||
|
class SrsIngester;
|
||||||
|
|
||||||
// listener type for server to identify the connection,
|
// listener type for server to identify the connection,
|
||||||
// that is, use different type to process the connection.
|
// that is, use different type to process the connection.
|
||||||
|
@ -83,6 +84,9 @@ private:
|
||||||
#ifdef SRS_HTTP_SERVER
|
#ifdef SRS_HTTP_SERVER
|
||||||
SrsHttpHandler* http_stream_handler;
|
SrsHttpHandler* http_stream_handler;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef SRS_INGEST
|
||||||
|
SrsIngester* ingester;
|
||||||
|
#endif
|
||||||
private:
|
private:
|
||||||
std::vector<SrsConnection*> conns;
|
std::vector<SrsConnection*> conns;
|
||||||
std::vector<SrsListener*> listeners;
|
std::vector<SrsListener*> listeners;
|
||||||
|
@ -100,7 +104,6 @@ public:
|
||||||
virtual void remove(SrsConnection* conn);
|
virtual void remove(SrsConnection* conn);
|
||||||
virtual void on_signal(int signo);
|
virtual void on_signal(int signo);
|
||||||
private:
|
private:
|
||||||
virtual int ingest_streams();
|
|
||||||
virtual void close_listeners();
|
virtual void close_listeners();
|
||||||
virtual int accept_client(SrsListenerType type, st_netfd_t client_stfd);
|
virtual int accept_client(SrsListenerType type, st_netfd_t client_stfd);
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue