mirror of
https://github.com/ossrs/srs.git
synced 2025-02-14 20:31:56 +00:00
SRT: remove rtmp_to_srt
This commit is contained in:
parent
43d98d0b1c
commit
fbc6eebe18
7 changed files with 1 additions and 163 deletions
|
@ -412,7 +412,6 @@ vhost srt.vhost.srs.com {
|
|||
srt {
|
||||
enabled on;
|
||||
srt_to_rtmp on;
|
||||
rtmp_to_srt on;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@ vhost __defaultVhost__ {
|
|||
srt {
|
||||
enabled on;
|
||||
srt_to_rtmp on;
|
||||
rtmp_to_srt on;
|
||||
}
|
||||
|
||||
http_remux {
|
||||
|
|
|
@ -2883,7 +2883,7 @@ srs_error_t SrsConfig::check_normal_config()
|
|||
} else if (n == "srt") {
|
||||
for (int j = 0; j < (int)conf->directives.size(); j++) {
|
||||
string m = conf->at(j)->name;
|
||||
if (m != "enabled" && m != "rtmp_to_srt" && m != "srt_to_rtmp") {
|
||||
if (m != "enabled" && m != "srt_to_rtmp") {
|
||||
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal vhost.srt.%s of %s", m.c_str(), vhost->arg0().c_str());
|
||||
}
|
||||
}
|
||||
|
@ -7019,24 +7019,6 @@ bool SrsConfig::get_srt_to_rtmp(std::string vhost)
|
|||
return SRS_CONF_PERFER_FALSE(conf->arg0());
|
||||
}
|
||||
|
||||
bool SrsConfig::get_srt_from_rtmp(std::string vhost)
|
||||
{
|
||||
static bool DEFAULT = false;
|
||||
|
||||
SrsConfDirective* conf = get_srt(vhost);
|
||||
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("rtmp_to_srt");
|
||||
if (!conf || conf->arg0().empty()) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
return SRS_CONF_PERFER_FALSE(conf->arg0());
|
||||
}
|
||||
|
||||
bool SrsConfig::get_http_stream_enabled()
|
||||
{
|
||||
SrsConfDirective* conf = root->get("http_server");
|
||||
|
|
|
@ -665,7 +665,6 @@ private:
|
|||
public:
|
||||
bool get_srt_enabled(std::string vhost);
|
||||
bool get_srt_to_rtmp(std::string vhost);
|
||||
bool get_srt_from_rtmp(std::string vhost);
|
||||
|
||||
// http_hooks section
|
||||
private:
|
||||
|
|
|
@ -952,31 +952,6 @@ srs_error_t SrsRtmpConn::acquire_publish(SrsLiveSource* source)
|
|||
return srs_error_new(ERROR_SYSTEM_STREAM_BUSY, "rtmp: stream %s is busy", req->get_stream_url().c_str());
|
||||
}
|
||||
|
||||
#ifdef SRS_SRT
|
||||
if (_srs_config->get_rtc_from_rtmp(req->vhost)) {
|
||||
SrsSrtSource *srt = NULL;
|
||||
if (!info->edge) {
|
||||
if ((err = _srs_srt_sources->fetch_or_create(req, &srt)) != srs_success) {
|
||||
return srs_error_wrap(err, "create source");
|
||||
}
|
||||
|
||||
if (!srt->can_publish()) {
|
||||
return srs_error_new(ERROR_SYSTEM_STREAM_BUSY, "srt stream %s busy", req->get_stream_url().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (srt) {
|
||||
SrsSrtFromRtmpBridge *bridger = new SrsSrtFromRtmpBridge(srt);
|
||||
if ((err = bridger->initialize(req)) != srs_success) {
|
||||
srs_freep(bridger);
|
||||
return srs_error_wrap(err, "bridger init");
|
||||
}
|
||||
|
||||
source->set_bridger(bridger);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Check whether RTC stream is busy.
|
||||
#ifdef SRS_RTC
|
||||
SrsRtcSource *rtc = NULL;
|
||||
|
|
|
@ -815,95 +815,3 @@ srs_error_t SrsSrtSource::on_packet(SrsSrtPacket* packet)
|
|||
return err;
|
||||
}
|
||||
|
||||
SrsSrtFromRtmpBridge::SrsSrtFromRtmpBridge(SrsSrtSource* source)
|
||||
: ISrsLiveSourceBridger(SrsBridgeDestTypeSRT)
|
||||
{
|
||||
srt_source_ = source;
|
||||
ts_muxer_ = NULL;
|
||||
offset_ = 0;
|
||||
}
|
||||
|
||||
SrsSrtFromRtmpBridge::~SrsSrtFromRtmpBridge()
|
||||
{
|
||||
srs_freep(ts_muxer_);
|
||||
}
|
||||
|
||||
srs_error_t SrsSrtFromRtmpBridge::initialize(SrsRequest* r)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
// TODO: FIXME: check config.
|
||||
req_ = r;
|
||||
|
||||
ts_muxer_ = new SrsTsTransmuxer();
|
||||
if ((err = ts_muxer_->initialize(this)) != srs_success) {
|
||||
return srs_error_wrap(err, "init ts muxer");
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
srs_error_t SrsSrtFromRtmpBridge::on_publish()
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
// TODO: FIXME: check if enable rtmp_to_srt
|
||||
|
||||
if ((err = srt_source_->on_publish()) != srs_success) {
|
||||
return srs_error_wrap(err, "source publish");
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
void SrsSrtFromRtmpBridge::on_unpublish()
|
||||
{
|
||||
// TODO: FIXME: check if enable rtmp_to_srt
|
||||
srt_source_->on_unpublish();
|
||||
}
|
||||
|
||||
srs_error_t SrsSrtFromRtmpBridge::on_audio(SrsSharedPtrMessage* msg)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
if ((err = ts_muxer_->write_audio(msg->timestamp, msg->payload, msg->size)) != srs_success) {
|
||||
return srs_error_wrap(err, "rtmp to srt, ts mux audio");
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
srs_error_t SrsSrtFromRtmpBridge::on_video(SrsSharedPtrMessage* msg)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
if ((err = ts_muxer_->write_video(msg->timestamp, msg->payload, msg->size)) != srs_success) {
|
||||
return srs_error_wrap(err, "rtmp to srt, ts mux video");
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
srs_error_t SrsSrtFromRtmpBridge::write(void* buf, size_t size, ssize_t* nwrite)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
if (size % SRS_TS_PACKET_SIZE != 0) {
|
||||
return srs_error_new(ERROR_RTMP_TO_SRT, "invalid ts size=%u", size);
|
||||
}
|
||||
|
||||
for (int i = 0; i < size; i += SRS_TS_PACKET_SIZE) {
|
||||
memcpy(ts_buf_ + offset_, (const char*)buf + i, SRS_TS_PACKET_SIZE);
|
||||
offset_ += SRS_TS_PACKET_SIZE;
|
||||
if (offset_ >= 1316) {
|
||||
offset_ = 0;
|
||||
SrsSrtPacket* packet = new SrsSrtPacket();
|
||||
SrsAutoFree(SrsSrtPacket, packet);
|
||||
packet->wrap(ts_buf_, 1316);
|
||||
|
||||
srt_source_->on_packet(packet);
|
||||
}
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -182,29 +182,5 @@ private:
|
|||
std::vector<ISrsSrtSourceBridge*> bridgers_;
|
||||
};
|
||||
|
||||
class SrsSrtFromRtmpBridge : public ISrsLiveSourceBridger, public ISrsStreamWriter
|
||||
{
|
||||
public:
|
||||
SrsSrtFromRtmpBridge(SrsSrtSource* source);
|
||||
virtual ~SrsSrtFromRtmpBridge();
|
||||
public:
|
||||
virtual srs_error_t initialize(SrsRequest* r);
|
||||
// Interface for ISrsLiveSourceBridger
|
||||
public:
|
||||
virtual srs_error_t on_publish();
|
||||
virtual void on_unpublish();
|
||||
virtual srs_error_t on_audio(SrsSharedPtrMessage* msg);
|
||||
virtual srs_error_t on_video(SrsSharedPtrMessage* msg);
|
||||
// Interface for ISrsStreamWriter
|
||||
public:
|
||||
virtual srs_error_t write(void* buf, size_t size, ssize_t* nwrite);
|
||||
private:
|
||||
SrsRequest* req_;
|
||||
SrsSrtSource* srt_source_;
|
||||
SrsTsTransmuxer* ts_muxer_;
|
||||
char ts_buf_[1316];
|
||||
int offset_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue