Skip to content

Commit 99a6d72

Browse files
committed
SRT: Undo extract of fetch_or_create_source and change mode_ to local.
1 parent 248ce93 commit 99a6d72

File tree

2 files changed

+15
-28
lines changed

2 files changed

+15
-28
lines changed

trunk/src/app/srs_app_srt_conn.cpp

+15-26
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ SrsMpegtsSrtConn::SrsMpegtsSrtConn(SrsSrtServer* srt_server, srs_srt_t srt_fd, s
167167

168168
srt_source_ = NULL;
169169
req_ = new SrsRequest();
170-
mode_ = SrtModePull;
171170
}
172171

173172
SrsMpegtsSrtConn::~SrsMpegtsSrtConn()
@@ -239,29 +238,6 @@ srs_error_t SrsMpegtsSrtConn::do_cycle()
239238
{
240239
srs_error_t err = srs_success;
241240

242-
if ((err = fetch_or_create_source()) != srs_success) {
243-
return srs_error_wrap(err, "fetch or create srt source");
244-
}
245-
246-
if ((err = http_hooks_on_connect()) != srs_success) {
247-
return srs_error_wrap(err, "on connect");
248-
}
249-
250-
if (mode_ == SrtModePush) {
251-
err = publishing();
252-
} else if (mode_ == SrtModePull) {
253-
err = playing();
254-
}
255-
256-
http_hooks_on_close();
257-
258-
return err;
259-
}
260-
261-
srs_error_t SrsMpegtsSrtConn::fetch_or_create_source()
262-
{
263-
srs_error_t err = srs_success;
264-
265241
string streamid = "";
266242
if ((err = srs_srt_get_streamid(srt_fd_, streamid)) != srs_success) {
267243
return srs_error_wrap(err, "get srt streamid");
@@ -273,7 +249,8 @@ srs_error_t SrsMpegtsSrtConn::fetch_or_create_source()
273249
}
274250

275251
// Detect streamid of srt to request.
276-
if (! srs_srt_streamid_to_request(streamid, mode_, req_)) {
252+
SrtMode mode = SrtModePull;
253+
if (! srs_srt_streamid_to_request(streamid, mode, req_)) {
277254
return srs_error_new(ERROR_SRT_CONN, "invalid srt streamid=%s", streamid.c_str());
278255
}
279256

@@ -282,12 +259,24 @@ srs_error_t SrsMpegtsSrtConn::fetch_or_create_source()
282259
}
283260

284261
srs_trace("@srt, streamid=%s, stream_url=%s, vhost=%s, app=%s, stream=%s, param=%s",
285-
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());
262+
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());
286263

287264
if ((err = _srs_srt_sources->fetch_or_create(req_, &srt_source_)) != srs_success) {
288265
return srs_error_wrap(err, "fetch srt source");
289266
}
290267

268+
if ((err = http_hooks_on_connect()) != srs_success) {
269+
return srs_error_wrap(err, "on connect");
270+
}
271+
272+
if (mode == SrtModePush) {
273+
err = publishing();
274+
} else if (mode == SrtModePull) {
275+
err = playing();
276+
}
277+
278+
http_hooks_on_close();
279+
291280
return err;
292281
}
293282

trunk/src/app/srs_app_srt_conn.hpp

-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ class SrsMpegtsSrtConn : public ISrsStartableConneciton, public ISrsCoroutineHan
9393
protected:
9494
virtual srs_error_t do_cycle();
9595
private:
96-
srs_error_t fetch_or_create_source();
9796
srs_error_t publishing();
9897
srs_error_t playing();
9998
srs_error_t acquire_publish();
@@ -120,7 +119,6 @@ class SrsMpegtsSrtConn : public ISrsStartableConneciton, public ISrsCoroutineHan
120119
SrsCoroutine* trd_;
121120

122121
SrsRequest* req_;
123-
SrtMode mode_;
124122
SrsSrtSource* srt_source_;
125123
};
126124

0 commit comments

Comments
 (0)