mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 11:51:57 +00:00
SRT: Undo extract of fetch_or_create_source and change mode_ to local.
This commit is contained in:
parent
6009395c10
commit
9a0db5a14f
2 changed files with 15 additions and 28 deletions
|
@ -167,7 +167,6 @@ SrsMpegtsSrtConn::SrsMpegtsSrtConn(SrsSrtServer* srt_server, srs_srt_t srt_fd, s
|
||||||
|
|
||||||
srt_source_ = NULL;
|
srt_source_ = NULL;
|
||||||
req_ = new SrsRequest();
|
req_ = new SrsRequest();
|
||||||
mode_ = SrtModePull;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsMpegtsSrtConn::~SrsMpegtsSrtConn()
|
SrsMpegtsSrtConn::~SrsMpegtsSrtConn()
|
||||||
|
@ -239,29 +238,6 @@ srs_error_t SrsMpegtsSrtConn::do_cycle()
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
if ((err = fetch_or_create_source()) != srs_success) {
|
|
||||||
return srs_error_wrap(err, "fetch or create srt source");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((err = http_hooks_on_connect()) != srs_success) {
|
|
||||||
return srs_error_wrap(err, "on connect");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mode_ == SrtModePush) {
|
|
||||||
err = publishing();
|
|
||||||
} else if (mode_ == SrtModePull) {
|
|
||||||
err = playing();
|
|
||||||
}
|
|
||||||
|
|
||||||
http_hooks_on_close();
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
srs_error_t SrsMpegtsSrtConn::fetch_or_create_source()
|
|
||||||
{
|
|
||||||
srs_error_t err = srs_success;
|
|
||||||
|
|
||||||
string streamid = "";
|
string streamid = "";
|
||||||
if ((err = srs_srt_get_streamid(srt_fd_, streamid)) != srs_success) {
|
if ((err = srs_srt_get_streamid(srt_fd_, streamid)) != srs_success) {
|
||||||
return srs_error_wrap(err, "get srt streamid");
|
return srs_error_wrap(err, "get srt streamid");
|
||||||
|
@ -273,7 +249,8 @@ srs_error_t SrsMpegtsSrtConn::fetch_or_create_source()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detect streamid of srt to request.
|
// Detect streamid of srt to request.
|
||||||
if (! srs_srt_streamid_to_request(streamid, mode_, req_)) {
|
SrtMode mode = SrtModePull;
|
||||||
|
if (! srs_srt_streamid_to_request(streamid, mode, req_)) {
|
||||||
return srs_error_new(ERROR_SRT_CONN, "invalid srt streamid=%s", streamid.c_str());
|
return srs_error_new(ERROR_SRT_CONN, "invalid srt streamid=%s", streamid.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,12 +259,24 @@ srs_error_t SrsMpegtsSrtConn::fetch_or_create_source()
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_trace("@srt, streamid=%s, stream_url=%s, vhost=%s, app=%s, stream=%s, param=%s",
|
srs_trace("@srt, streamid=%s, stream_url=%s, vhost=%s, app=%s, stream=%s, param=%s",
|
||||||
streamid.c_str(), req_->get_stream_url().c_str(), req_->vhost.c_str(), req_->app.c_str(), req_->stream.c_str(), req_->param.c_str());
|
streamid.c_str(), req_->get_stream_url().c_str(), req_->vhost.c_str(), req_->app.c_str(), req_->stream.c_str(), req_->param.c_str());
|
||||||
|
|
||||||
if ((err = _srs_srt_sources->fetch_or_create(req_, &srt_source_)) != srs_success) {
|
if ((err = _srs_srt_sources->fetch_or_create(req_, &srt_source_)) != srs_success) {
|
||||||
return srs_error_wrap(err, "fetch srt source");
|
return srs_error_wrap(err, "fetch srt source");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((err = http_hooks_on_connect()) != srs_success) {
|
||||||
|
return srs_error_wrap(err, "on connect");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode == SrtModePush) {
|
||||||
|
err = publishing();
|
||||||
|
} else if (mode == SrtModePull) {
|
||||||
|
err = playing();
|
||||||
|
}
|
||||||
|
|
||||||
|
http_hooks_on_close();
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,6 @@ public:
|
||||||
protected:
|
protected:
|
||||||
virtual srs_error_t do_cycle();
|
virtual srs_error_t do_cycle();
|
||||||
private:
|
private:
|
||||||
srs_error_t fetch_or_create_source();
|
|
||||||
srs_error_t publishing();
|
srs_error_t publishing();
|
||||||
srs_error_t playing();
|
srs_error_t playing();
|
||||||
srs_error_t acquire_publish();
|
srs_error_t acquire_publish();
|
||||||
|
@ -120,7 +119,6 @@ private:
|
||||||
SrsCoroutine* trd_;
|
SrsCoroutine* trd_;
|
||||||
|
|
||||||
SrsRequest* req_;
|
SrsRequest* req_;
|
||||||
SrtMode mode_;
|
|
||||||
SrsSrtSource* srt_source_;
|
SrsSrtSource* srt_source_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue