refine ingest, start/stop ingest in server

pull/133/head
winlin 11 years ago
parent eea2310b07
commit 095364a72b

@ -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;

@ -31,15 +31,29 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifdef SRS_INGEST
#include <vector>
#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
{
private:
std::vector<SrsFFMPEG*> ffmpegs;
private:
SrsThread* pthread;
public:
SrsIngester();
virtual ~SrsIngester();
public:
virtual int start();
virtual void stop();
// interface ISrsThreadHandler.
public:
virtual int cycle();

@ -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<SrsListener*>::iterator it;

@ -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<SrsConnection*> conns;
std::vector<SrsListener*> 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:

Loading…
Cancel
Save