1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Refactor SRT, using reverse dependency, SRT depends on APP.

This commit is contained in:
winlin 2020-01-23 19:40:40 +08:00
parent 87ba204a42
commit 33c6bf1f8f
8 changed files with 194 additions and 59 deletions

View file

@ -199,3 +199,47 @@ void srt_server::on_work()
}
}
}
SrtServerAdapter::SrtServerAdapter()
{
}
SrtServerAdapter::~SrtServerAdapter()
{
}
srs_error_t SrtServerAdapter::initialize()
{
srs_error_t err = srs_success;
if(_srs_config->get_srt_enabled()) {
srs_trace("srt server is enabled...");
unsigned short srt_port = _srs_config->get_srt_listen_port();
srs_trace("srt server listen port:%d", srt_port);
err = srt2rtmp::get_instance()->init();
if (err != srs_success) {
srs_error_wrap(err, "srt start srt2rtmp error");
return err;
}
srt_ptr = std::make_shared<srt_server>(srt_port);
if (!srt_ptr) {
srs_error_wrap(err, "srt listen %d", srt_port);
}
} else {
srs_trace("srt server is disabled...");
}
return err;
}
srs_error_t SrtServerAdapter::run()
{
srs_error_t err = srs_success;
if(_srs_config->get_srt_enabled()) {
srt_ptr->start();
}
return err;
}

View file

@ -1,10 +1,13 @@
#ifndef SRT_SERVER_H
#define SRT_SERVER_H
#include <srt/srt.h>
#include <thread>
#include <memory>
#include <srs_app_hybrid.hpp>
class srt_handle;
class srt_server {
@ -34,4 +37,16 @@ private:
typedef std::shared_ptr<srt_server> SRT_SERVER_PTR;
class SrtServerAdapter : public ISrsHybridServer
{
private:
SRT_SERVER_PTR srt_ptr;
public:
SrtServerAdapter();
virtual ~SrtServerAdapter();
public:
virtual srs_error_t initialize();
virtual srs_error_t run();
};
#endif//SRT_SERVER_H