Skip to content

Commit 846f95e

Browse files
committed
SmartPtr: Rename source to live_source.
1 parent e34b3d3 commit 846f95e

13 files changed

+81
-81
lines changed

trunk/src/app/srs_app_edge.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ void SrsEdgeFlvUpstream::kbps_sample(const char* label, srs_utime_t age)
391391

392392
SrsEdgeIngester::SrsEdgeIngester()
393393
{
394-
source = NULL;
394+
source_ = NULL;
395395
edge = NULL;
396396
req = NULL;
397397
#ifdef SRS_APM
@@ -417,7 +417,7 @@ SrsEdgeIngester::~SrsEdgeIngester()
417417

418418
srs_error_t SrsEdgeIngester::initialize(SrsLiveSource* s, SrsPlayEdge* e, SrsRequest* r)
419419
{
420-
source = s;
420+
source_ = s;
421421
edge = e;
422422
req = r;
423423

@@ -435,7 +435,7 @@ srs_error_t SrsEdgeIngester::start()
435435
{
436436
srs_error_t err = srs_success;
437437

438-
if ((err = source->on_publish()) != srs_success) {
438+
if ((err = source_->on_publish()) != srs_success) {
439439
return srs_error_wrap(err, "notify source");
440440
}
441441

@@ -455,8 +455,8 @@ void SrsEdgeIngester::stop()
455455
upstream->close();
456456

457457
// Notify source to un-publish if exists.
458-
if (source) {
459-
source->on_unpublish();
458+
if (source_) {
459+
source_->on_unpublish();
460460
}
461461
}
462462

@@ -549,7 +549,7 @@ srs_error_t SrsEdgeIngester::do_cycle()
549549
upstream = new SrsEdgeRtmpUpstream(redirect);
550550
}
551551

552-
if ((err = source->on_source_id_changed(_srs_context->get_id())) != srs_success) {
552+
if ((err = source_->on_source_id_changed(_srs_context->get_id())) != srs_success) {
553553
return srs_error_wrap(err, "on source id changed");
554554
}
555555

@@ -635,21 +635,21 @@ srs_error_t SrsEdgeIngester::process_publish_message(SrsCommonMessage* msg, stri
635635

636636
// process audio packet
637637
if (msg->header.is_audio()) {
638-
if ((err = source->on_audio(msg)) != srs_success) {
638+
if ((err = source_->on_audio(msg)) != srs_success) {
639639
return srs_error_wrap(err, "source consume audio");
640640
}
641641
}
642642

643643
// process video packet
644644
if (msg->header.is_video()) {
645-
if ((err = source->on_video(msg)) != srs_success) {
645+
if ((err = source_->on_video(msg)) != srs_success) {
646646
return srs_error_wrap(err, "source consume video");
647647
}
648648
}
649649

650650
// process aggregate packet
651651
if (msg->header.is_aggregate()) {
652-
if ((err = source->on_aggregate(msg)) != srs_success) {
652+
if ((err = source_->on_aggregate(msg)) != srs_success) {
653653
return srs_error_wrap(err, "source consume aggregate");
654654
}
655655
return err;
@@ -665,7 +665,7 @@ srs_error_t SrsEdgeIngester::process_publish_message(SrsCommonMessage* msg, stri
665665

666666
if (dynamic_cast<SrsOnMetaDataPacket*>(pkt)) {
667667
SrsOnMetaDataPacket* metadata = dynamic_cast<SrsOnMetaDataPacket*>(pkt);
668-
if ((err = source->on_meta_data(msg, metadata)) != srs_success) {
668+
if ((err = source_->on_meta_data(msg, metadata)) != srs_success) {
669669
return srs_error_wrap(err, "source consume metadata");
670670
}
671671
return err;
@@ -725,7 +725,7 @@ SrsEdgeForwarder::SrsEdgeForwarder()
725725
edge = NULL;
726726
req = NULL;
727727
send_error_code = ERROR_SUCCESS;
728-
source = NULL;
728+
source_ = NULL;
729729

730730
sdk = NULL;
731731
lb = new SrsLbRoundRobin();
@@ -749,7 +749,7 @@ void SrsEdgeForwarder::set_queue_size(srs_utime_t queue_size)
749749

750750
srs_error_t SrsEdgeForwarder::initialize(SrsLiveSource* s, SrsPublishEdge* e, SrsRequest* r)
751751
{
752-
source = s;
752+
source_ = s;
753753
edge = e;
754754
req = r;
755755

trunk/src/app/srs_app_edge.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class SrsEdgeFlvUpstream : public SrsEdgeUpstream
137137
class SrsEdgeIngester : public ISrsCoroutineHandler
138138
{
139139
private:
140-
SrsLiveSource* source;
140+
SrsLiveSource* source_;
141141
SrsPlayEdge* edge;
142142
SrsRequest* req;
143143
SrsCoroutine* trd;
@@ -172,7 +172,7 @@ class SrsEdgeIngester : public ISrsCoroutineHandler
172172
class SrsEdgeForwarder : public ISrsCoroutineHandler
173173
{
174174
private:
175-
SrsLiveSource* source;
175+
SrsLiveSource* source_;
176176
SrsPublishEdge* edge;
177177
SrsRequest* req;
178178
SrsCoroutine* trd;

trunk/src/app/srs_app_http_stream.cpp

+15-15
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,19 @@ srs_error_t SrsBufferCache::cycle()
106106
return err;
107107
}
108108

109-
SrsLiveSource* source = _srs_sources->fetch(req);
110-
if (!source) {
109+
SrsLiveSource* live_source = _srs_sources->fetch(req);
110+
if (!live_source) {
111111
return srs_error_new(ERROR_NO_SOURCE, "no source for %s", req->get_stream_url().c_str());
112112
}
113113

114114
// the stream cache will create consumer to cache stream,
115115
// which will trigger to fetch stream from origin for edge.
116116
SrsLiveConsumer* consumer = NULL;
117117
SrsAutoFree(SrsLiveConsumer, consumer);
118-
if ((err = source->create_consumer(consumer)) != srs_success) {
118+
if ((err = live_source->create_consumer(consumer)) != srs_success) {
119119
return srs_error_wrap(err, "create consumer");
120120
}
121-
if ((err = source->consumer_dumps(consumer, false, false, true)) != srs_success) {
121+
if ((err = live_source->consumer_dumps(consumer, false, false, true)) != srs_success) {
122122
return srs_error_wrap(err, "dumps consumer");
123123
}
124124

@@ -661,18 +661,18 @@ srs_error_t SrsLiveStream::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess
661661
// Enter chunked mode, because we didn't set the content-length.
662662
w->write_header(SRS_CONSTS_HTTP_OK);
663663

664-
SrsLiveSource* source = _srs_sources->fetch(req);
665-
if (!source) {
664+
SrsLiveSource* live_source = _srs_sources->fetch(req);
665+
if (!live_source) {
666666
return srs_error_new(ERROR_NO_SOURCE, "no source for %s", req->get_stream_url().c_str());
667667
}
668668

669669
// create consumer of souce, ignore gop cache, use the audio gop cache.
670670
SrsLiveConsumer* consumer = NULL;
671671
SrsAutoFree(SrsLiveConsumer, consumer);
672-
if ((err = source->create_consumer(consumer)) != srs_success) {
672+
if ((err = live_source->create_consumer(consumer)) != srs_success) {
673673
return srs_error_wrap(err, "create consumer");
674674
}
675-
if ((err = source->consumer_dumps(consumer, true, true, !enc->has_cache())) != srs_success) {
675+
if ((err = live_source->consumer_dumps(consumer, true, true, !enc->has_cache())) != srs_success) {
676676
return srs_error_wrap(err, "dumps consumer");
677677
}
678678

@@ -694,7 +694,7 @@ srs_error_t SrsLiveStream::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess
694694

695695
// if gop cache enabled for encoder, dump to consumer.
696696
if (enc->has_cache()) {
697-
if ((err = enc->dump_cache(consumer, source->jitter())) != srs_success) {
697+
if ((err = enc->dump_cache(consumer, live_source->jitter())) != srs_success) {
698698
return srs_error_wrap(err, "encoder dump cache");
699699
}
700700
}
@@ -1136,16 +1136,16 @@ srs_error_t SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandle
11361136
}
11371137
}
11381138

1139-
SrsLiveSource* s = NULL;
1140-
if ((err = _srs_sources->fetch_or_create(r, server, &s)) != srs_success) {
1139+
SrsLiveSource* live_source = NULL;
1140+
if ((err = _srs_sources->fetch_or_create(r, server, &live_source)) != srs_success) {
11411141
return srs_error_wrap(err, "source create");
11421142
}
1143-
srs_assert(s != NULL);
1143+
srs_assert(live_source != NULL);
11441144

11451145
bool enabled_cache = _srs_config->get_gop_cache(r->vhost);
11461146
int gcmf = _srs_config->get_gop_cache_max_frames(r->vhost);
1147-
s->set_cache(enabled_cache);
1148-
s->set_gop_cache_max_frames(gcmf);
1147+
live_source->set_cache(enabled_cache);
1148+
live_source->set_gop_cache_max_frames(gcmf);
11491149

11501150
// create http streaming handler.
11511151
if ((err = http_mount(r)) != srs_success) {
@@ -1163,7 +1163,7 @@ srs_error_t SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandle
11631163
// trigger edge to fetch from origin.
11641164
bool vhost_is_edge = _srs_config->get_vhost_is_edge(r->vhost);
11651165
srs_trace("flv: source url=%s, is_edge=%d, source_id=%s/%s",
1166-
r->get_stream_url().c_str(), vhost_is_edge, s->source_id().c_str(), s->pre_source_id().c_str());
1166+
r->get_stream_url().c_str(), vhost_is_edge, live_source->source_id().c_str(), live_source->pre_source_id().c_str());
11671167

11681168
return err;
11691169
}

trunk/src/app/srs_app_recv_thread.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ SrsPublishRecvThread::SrsPublishRecvThread(SrsRtmpServer* rtmp_sdk, SrsRequest*
265265
rtmp = rtmp_sdk;
266266

267267
_conn = conn;
268-
_source = source;
268+
source_ = source;
269269

270270
nn_msgs_for_yield_ = 0;
271271
recv_error = srs_success;
@@ -370,7 +370,7 @@ srs_error_t SrsPublishRecvThread::consume(SrsCommonMessage* msg)
370370
srs_update_system_time(), msg->header.timestamp, msg->size);
371371

372372
// the rtmp connection will handle this message
373-
err = _conn->handle_publish_message(_source, msg);
373+
err = _conn->handle_publish_message(source_, msg);
374374

375375
// must always free it,
376376
// the source will copy it if need to use.

trunk/src/app/srs_app_recv_thread.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class SrsPublishRecvThread : public ISrsMessagePumper, public ISrsReloadHandler
146146
srs_error_t recv_error;
147147
SrsRtmpConn* _conn;
148148
// The params for conn callback.
149-
SrsLiveSource* _source;
149+
SrsLiveSource* source_;
150150
// The error timeout cond
151151
srs_cond_t error;
152152
// The merged context id.

trunk/src/app/srs_app_rtc_api.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ srs_error_t SrsGoApiRtcPlay::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessa
224224

225225
// For RTMP to RTC, fail if disabled and RTMP is active, see https://github.com/ossrs/srs/issues/2728
226226
if (!is_rtc_stream_active && !_srs_config->get_rtc_from_rtmp(ruc->req_->vhost)) {
227-
SrsLiveSource* rtmp = _srs_sources->fetch(ruc->req_);
228-
if (rtmp && !rtmp->inactive()) {
227+
SrsLiveSource* live_source = _srs_sources->fetch(ruc->req_);
228+
if (live_source && !live_source->inactive()) {
229229
return srs_error_new(ERROR_RTC_DISABLED, "Disabled rtmp_to_rtc of %s, see #2728", ruc->req_->vhost.c_str());
230230
}
231231
}

trunk/src/app/srs_app_rtc_conn.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -1202,8 +1202,8 @@ srs_error_t SrsRtcPublishStream::initialize(SrsRequest* r, SrsRtcSourceDescripti
12021202
source_->set_publish_stream(this);
12031203

12041204
// TODO: FIMXE: Check it in SrsRtcConnection::add_publisher?
1205-
SrsLiveSource *rtmp = _srs_sources->fetch(r);
1206-
if (rtmp && !rtmp->can_publish(false)) {
1205+
SrsLiveSource* live_source = _srs_sources->fetch(r);
1206+
if (live_source && !live_source->can_publish(false)) {
12071207
return srs_error_new(ERROR_SYSTEM_STREAM_BUSY, "rtmp stream %s busy", r->get_stream_url().c_str());
12081208
}
12091209

@@ -1227,16 +1227,16 @@ srs_error_t SrsRtcPublishStream::initialize(SrsRequest* r, SrsRtcSourceDescripti
12271227
#if defined(SRS_RTC) && defined(SRS_FFMPEG_FIT)
12281228
bool rtc_to_rtmp = _srs_config->get_rtc_to_rtmp(req_->vhost);
12291229
if (rtc_to_rtmp) {
1230-
if ((err = _srs_sources->fetch_or_create(r, _srs_hybrid->srs()->instance(), &rtmp)) != srs_success) {
1230+
if ((err = _srs_sources->fetch_or_create(r, _srs_hybrid->srs()->instance(), &live_source)) != srs_success) {
12311231
return srs_error_wrap(err, "create source");
12321232
}
12331233

12341234
// Disable GOP cache for RTC2RTMP bridge, to keep the streams in sync,
12351235
// especially for stream merging.
1236-
rtmp->set_cache(false);
1236+
live_source->set_cache(false);
12371237

12381238
SrsCompositeBridge* bridge = new SrsCompositeBridge();
1239-
bridge->append(new SrsFrameToRtmpBridge(rtmp));
1239+
bridge->append(new SrsFrameToRtmpBridge(live_source));
12401240

12411241
if ((err = bridge->initialize(r)) != srs_success) {
12421242
srs_freep(bridge);

trunk/src/app/srs_app_rtmp_conn.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -571,19 +571,19 @@ srs_error_t SrsRtmpConn::stream_service_cycle()
571571
rtmp->set_send_timeout(SRS_CONSTS_RTMP_TIMEOUT);
572572

573573
// find a source to serve.
574-
SrsLiveSource* source = NULL;
575-
if ((err = _srs_sources->fetch_or_create(req, server, &source)) != srs_success) {
574+
SrsLiveSource* live_source = NULL;
575+
if ((err = _srs_sources->fetch_or_create(req, server, &live_source)) != srs_success) {
576576
return srs_error_wrap(err, "rtmp: fetch source");
577577
}
578-
srs_assert(source != NULL);
578+
srs_assert(live_source != NULL);
579579

580580
bool enabled_cache = _srs_config->get_gop_cache(req->vhost);
581581
int gcmf = _srs_config->get_gop_cache_max_frames(req->vhost);
582582
srs_trace("source url=%s, ip=%s, cache=%d/%d, is_edge=%d, source_id=%s/%s",
583-
req->get_stream_url().c_str(), ip.c_str(), enabled_cache, gcmf, info->edge, source->source_id().c_str(),
584-
source->pre_source_id().c_str());
585-
source->set_cache(enabled_cache);
586-
source->set_gop_cache_max_frames(gcmf);
583+
req->get_stream_url().c_str(), ip.c_str(), enabled_cache, gcmf, info->edge, live_source->source_id().c_str(),
584+
live_source->pre_source_id().c_str());
585+
live_source->set_cache(enabled_cache);
586+
live_source->set_gop_cache_max_frames(gcmf);
587587

588588
switch (info->type) {
589589
case SrsRtmpConnPlay: {
@@ -610,7 +610,7 @@ srs_error_t SrsRtmpConn::stream_service_cycle()
610610
span_main_->end();
611611
#endif
612612

613-
err = playing(source);
613+
err = playing(live_source);
614614
http_hooks_on_stop();
615615

616616
return err;
@@ -627,7 +627,7 @@ srs_error_t SrsRtmpConn::stream_service_cycle()
627627
span_main_->end();
628628
#endif
629629

630-
return publishing(source);
630+
return publishing(live_source);
631631
}
632632
case SrsRtmpConnHaivisionPublish: {
633633
if ((err = rtmp->start_haivision_publish(info->res->stream_id)) != srs_success) {
@@ -641,7 +641,7 @@ srs_error_t SrsRtmpConn::stream_service_cycle()
641641
span_main_->end();
642642
#endif
643643

644-
return publishing(source);
644+
return publishing(live_source);
645645
}
646646
case SrsRtmpConnFlashPublish: {
647647
if ((err = rtmp->start_flash_publish(info->res->stream_id)) != srs_success) {
@@ -655,7 +655,7 @@ srs_error_t SrsRtmpConn::stream_service_cycle()
655655
span_main_->end();
656656
#endif
657657

658-
return publishing(source);
658+
return publishing(live_source);
659659
}
660660
default: {
661661
return srs_error_new(ERROR_SYSTEM_CLIENT_INVALID, "rtmp: unknown client type=%d", info->type);

0 commit comments

Comments
 (0)