mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Refine code, move SRS adapter.
This commit is contained in:
parent
d8e27c3845
commit
57919e4351
4 changed files with 87 additions and 85 deletions
|
@ -134,75 +134,6 @@ ISrsHybridServer::~ISrsHybridServer()
|
|||
{
|
||||
}
|
||||
|
||||
SrsServerAdapter::SrsServerAdapter()
|
||||
{
|
||||
srs = new SrsServer();
|
||||
}
|
||||
|
||||
SrsServerAdapter::~SrsServerAdapter()
|
||||
{
|
||||
srs_freep(srs);
|
||||
}
|
||||
|
||||
srs_error_t SrsServerAdapter::initialize()
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
return err;
|
||||
}
|
||||
|
||||
srs_error_t SrsServerAdapter::run()
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
// Initialize the whole system, set hooks to handle server level events.
|
||||
if ((err = srs->initialize(NULL)) != srs_success) {
|
||||
return srs_error_wrap(err, "server initialize");
|
||||
}
|
||||
|
||||
if ((err = srs->initialize_st()) != srs_success) {
|
||||
return srs_error_wrap(err, "initialize st");
|
||||
}
|
||||
|
||||
if ((err = srs->acquire_pid_file()) != srs_success) {
|
||||
return srs_error_wrap(err, "acquire pid file");
|
||||
}
|
||||
|
||||
if ((err = srs->initialize_signal()) != srs_success) {
|
||||
return srs_error_wrap(err, "initialize signal");
|
||||
}
|
||||
|
||||
if ((err = srs->listen()) != srs_success) {
|
||||
return srs_error_wrap(err, "listen");
|
||||
}
|
||||
|
||||
if ((err = srs->register_signal()) != srs_success) {
|
||||
return srs_error_wrap(err, "register signal");
|
||||
}
|
||||
|
||||
if ((err = srs->http_handle()) != srs_success) {
|
||||
return srs_error_wrap(err, "http handle");
|
||||
}
|
||||
|
||||
if ((err = srs->ingest()) != srs_success) {
|
||||
return srs_error_wrap(err, "ingest");
|
||||
}
|
||||
|
||||
if ((err = srs->start()) != srs_success) {
|
||||
return srs_error_wrap(err, "start");
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
void SrsServerAdapter::stop()
|
||||
{
|
||||
}
|
||||
|
||||
SrsServer* SrsServerAdapter::instance()
|
||||
{
|
||||
return srs;
|
||||
}
|
||||
|
||||
SrsHybridServer::SrsHybridServer()
|
||||
{
|
||||
timer_ = NULL;
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <srs_app_hourglass.hpp>
|
||||
|
||||
class SrsServer;
|
||||
class SrsServerAdapter;
|
||||
|
||||
// The hibrid server interfaces, we could register many servers.
|
||||
class ISrsHybridServer
|
||||
|
@ -47,22 +48,6 @@ public:
|
|||
virtual void stop() = 0;
|
||||
};
|
||||
|
||||
// The SRS server adapter, the master server.
|
||||
class SrsServerAdapter : public ISrsHybridServer
|
||||
{
|
||||
private:
|
||||
SrsServer* srs;
|
||||
public:
|
||||
SrsServerAdapter();
|
||||
virtual ~SrsServerAdapter();
|
||||
public:
|
||||
virtual srs_error_t initialize();
|
||||
virtual srs_error_t run();
|
||||
virtual void stop();
|
||||
public:
|
||||
virtual SrsServer* instance();
|
||||
};
|
||||
|
||||
// The hybrid server manager.
|
||||
class SrsHybridServer : public ISrsHourGlass
|
||||
{
|
||||
|
|
|
@ -1807,3 +1807,72 @@ void SrsServer::on_unpublish(SrsSource* s, SrsRequest* r)
|
|||
coworkers->on_unpublish(s, r);
|
||||
}
|
||||
|
||||
SrsServerAdapter::SrsServerAdapter()
|
||||
{
|
||||
srs = new SrsServer();
|
||||
}
|
||||
|
||||
SrsServerAdapter::~SrsServerAdapter()
|
||||
{
|
||||
srs_freep(srs);
|
||||
}
|
||||
|
||||
srs_error_t SrsServerAdapter::initialize()
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
return err;
|
||||
}
|
||||
|
||||
srs_error_t SrsServerAdapter::run()
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
// Initialize the whole system, set hooks to handle server level events.
|
||||
if ((err = srs->initialize(NULL)) != srs_success) {
|
||||
return srs_error_wrap(err, "server initialize");
|
||||
}
|
||||
|
||||
if ((err = srs->initialize_st()) != srs_success) {
|
||||
return srs_error_wrap(err, "initialize st");
|
||||
}
|
||||
|
||||
if ((err = srs->acquire_pid_file()) != srs_success) {
|
||||
return srs_error_wrap(err, "acquire pid file");
|
||||
}
|
||||
|
||||
if ((err = srs->initialize_signal()) != srs_success) {
|
||||
return srs_error_wrap(err, "initialize signal");
|
||||
}
|
||||
|
||||
if ((err = srs->listen()) != srs_success) {
|
||||
return srs_error_wrap(err, "listen");
|
||||
}
|
||||
|
||||
if ((err = srs->register_signal()) != srs_success) {
|
||||
return srs_error_wrap(err, "register signal");
|
||||
}
|
||||
|
||||
if ((err = srs->http_handle()) != srs_success) {
|
||||
return srs_error_wrap(err, "http handle");
|
||||
}
|
||||
|
||||
if ((err = srs->ingest()) != srs_success) {
|
||||
return srs_error_wrap(err, "ingest");
|
||||
}
|
||||
|
||||
if ((err = srs->start()) != srs_success) {
|
||||
return srs_error_wrap(err, "start");
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
void SrsServerAdapter::stop()
|
||||
{
|
||||
}
|
||||
|
||||
SrsServer* SrsServerAdapter::instance()
|
||||
{
|
||||
return srs;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include <srs_app_gb28181.hpp>
|
||||
#include <srs_app_gb28181_sip.hpp>
|
||||
#include <srs_app_hourglass.hpp>
|
||||
#include <srs_app_hybrid.hpp>
|
||||
|
||||
class SrsServer;
|
||||
class SrsHttpServeMux;
|
||||
|
@ -399,5 +400,21 @@ public:
|
|||
virtual void on_unpublish(SrsSource* s, SrsRequest* r);
|
||||
};
|
||||
|
||||
// The SRS server adapter, the master server.
|
||||
class SrsServerAdapter : public ISrsHybridServer
|
||||
{
|
||||
private:
|
||||
SrsServer* srs;
|
||||
public:
|
||||
SrsServerAdapter();
|
||||
virtual ~SrsServerAdapter();
|
||||
public:
|
||||
virtual srs_error_t initialize();
|
||||
virtual srs_error_t run();
|
||||
virtual void stop();
|
||||
public:
|
||||
virtual SrsServer* instance();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue