mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
SmartPtr: Support shared ptr for live source. v6.0.129 (#4089)
Detail change log: 1. [Simple,Refactor] Remove member fields of http entry, etc.e34b3d3aa4
2. [Ignore] Rename source to live_source.846f95ec96
3. [Ignore] Use directly ptr in consumer.d38af021ad
4. [Complex, Important] Use shared ptr for live source.88f922413a
The object relationship:  --- Co-authored-by: Jacob Su <suzp1984@gmail.com>
This commit is contained in:
parent
908c2f2a30
commit
e7069788e9
30 changed files with 256 additions and 235 deletions
|
@ -571,19 +571,19 @@ srs_error_t SrsRtmpConn::stream_service_cycle()
|
|||
rtmp->set_send_timeout(SRS_CONSTS_RTMP_TIMEOUT);
|
||||
|
||||
// find a source to serve.
|
||||
SrsLiveSource* source = NULL;
|
||||
if ((err = _srs_sources->fetch_or_create(req, server, &source)) != srs_success) {
|
||||
SrsSharedPtr<SrsLiveSource> live_source;
|
||||
if ((err = _srs_sources->fetch_or_create(req, server, live_source)) != srs_success) {
|
||||
return srs_error_wrap(err, "rtmp: fetch source");
|
||||
}
|
||||
srs_assert(source != NULL);
|
||||
srs_assert(live_source.get() != NULL);
|
||||
|
||||
bool enabled_cache = _srs_config->get_gop_cache(req->vhost);
|
||||
int gcmf = _srs_config->get_gop_cache_max_frames(req->vhost);
|
||||
srs_trace("source url=%s, ip=%s, cache=%d/%d, is_edge=%d, source_id=%s/%s",
|
||||
req->get_stream_url().c_str(), ip.c_str(), enabled_cache, gcmf, info->edge, source->source_id().c_str(),
|
||||
source->pre_source_id().c_str());
|
||||
source->set_cache(enabled_cache);
|
||||
source->set_gop_cache_max_frames(gcmf);
|
||||
req->get_stream_url().c_str(), ip.c_str(), enabled_cache, gcmf, info->edge, live_source->source_id().c_str(),
|
||||
live_source->pre_source_id().c_str());
|
||||
live_source->set_cache(enabled_cache);
|
||||
live_source->set_gop_cache_max_frames(gcmf);
|
||||
|
||||
switch (info->type) {
|
||||
case SrsRtmpConnPlay: {
|
||||
|
@ -610,7 +610,7 @@ srs_error_t SrsRtmpConn::stream_service_cycle()
|
|||
span_main_->end();
|
||||
#endif
|
||||
|
||||
err = playing(source);
|
||||
err = playing(live_source);
|
||||
http_hooks_on_stop();
|
||||
|
||||
return err;
|
||||
|
@ -627,7 +627,7 @@ srs_error_t SrsRtmpConn::stream_service_cycle()
|
|||
span_main_->end();
|
||||
#endif
|
||||
|
||||
return publishing(source);
|
||||
return publishing(live_source);
|
||||
}
|
||||
case SrsRtmpConnHaivisionPublish: {
|
||||
if ((err = rtmp->start_haivision_publish(info->res->stream_id)) != srs_success) {
|
||||
|
@ -641,7 +641,7 @@ srs_error_t SrsRtmpConn::stream_service_cycle()
|
|||
span_main_->end();
|
||||
#endif
|
||||
|
||||
return publishing(source);
|
||||
return publishing(live_source);
|
||||
}
|
||||
case SrsRtmpConnFlashPublish: {
|
||||
if ((err = rtmp->start_flash_publish(info->res->stream_id)) != srs_success) {
|
||||
|
@ -655,7 +655,7 @@ srs_error_t SrsRtmpConn::stream_service_cycle()
|
|||
span_main_->end();
|
||||
#endif
|
||||
|
||||
return publishing(source);
|
||||
return publishing(live_source);
|
||||
}
|
||||
default: {
|
||||
return srs_error_new(ERROR_SYSTEM_CLIENT_INVALID, "rtmp: unknown client type=%d", info->type);
|
||||
|
@ -699,7 +699,7 @@ srs_error_t SrsRtmpConn::check_vhost(bool try_default_vhost)
|
|||
return err;
|
||||
}
|
||||
|
||||
srs_error_t SrsRtmpConn::playing(SrsLiveSource* source)
|
||||
srs_error_t SrsRtmpConn::playing(SrsSharedPtr<SrsLiveSource> source)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
|
@ -786,7 +786,7 @@ srs_error_t SrsRtmpConn::playing(SrsLiveSource* source)
|
|||
return err;
|
||||
}
|
||||
|
||||
srs_error_t SrsRtmpConn::do_playing(SrsLiveSource* source, SrsLiveConsumer* consumer, SrsQueueRecvThread* rtrd)
|
||||
srs_error_t SrsRtmpConn::do_playing(SrsSharedPtr<SrsLiveSource> source, SrsLiveConsumer* consumer, SrsQueueRecvThread* rtrd)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
|
@ -923,7 +923,7 @@ srs_error_t SrsRtmpConn::do_playing(SrsLiveSource* source, SrsLiveConsumer* cons
|
|||
return err;
|
||||
}
|
||||
|
||||
srs_error_t SrsRtmpConn::publishing(SrsLiveSource* source)
|
||||
srs_error_t SrsRtmpConn::publishing(SrsSharedPtr<SrsLiveSource> source)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
|
@ -969,7 +969,7 @@ srs_error_t SrsRtmpConn::publishing(SrsLiveSource* source)
|
|||
return err;
|
||||
}
|
||||
|
||||
srs_error_t SrsRtmpConn::do_publishing(SrsLiveSource* source, SrsPublishRecvThread* rtrd)
|
||||
srs_error_t SrsRtmpConn::do_publishing(SrsSharedPtr<SrsLiveSource> source, SrsPublishRecvThread* rtrd)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
|
@ -1073,7 +1073,7 @@ srs_error_t SrsRtmpConn::do_publishing(SrsLiveSource* source, SrsPublishRecvThre
|
|||
return err;
|
||||
}
|
||||
|
||||
srs_error_t SrsRtmpConn::acquire_publish(SrsLiveSource* source)
|
||||
srs_error_t SrsRtmpConn::acquire_publish(SrsSharedPtr<SrsLiveSource> source)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
|
@ -1141,7 +1141,7 @@ srs_error_t SrsRtmpConn::acquire_publish(SrsLiveSource* source)
|
|||
return err;
|
||||
}
|
||||
|
||||
void SrsRtmpConn::release_publish(SrsLiveSource* source)
|
||||
void SrsRtmpConn::release_publish(SrsSharedPtr<SrsLiveSource> source)
|
||||
{
|
||||
// when edge, notice edge to change state.
|
||||
// when origin, notice all service to unpublish.
|
||||
|
@ -1152,7 +1152,7 @@ void SrsRtmpConn::release_publish(SrsLiveSource* source)
|
|||
}
|
||||
}
|
||||
|
||||
srs_error_t SrsRtmpConn::handle_publish_message(SrsLiveSource* source, SrsCommonMessage* msg)
|
||||
srs_error_t SrsRtmpConn::handle_publish_message(SrsSharedPtr<SrsLiveSource>& source, SrsCommonMessage* msg)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
|
@ -1193,7 +1193,7 @@ srs_error_t SrsRtmpConn::handle_publish_message(SrsLiveSource* source, SrsCommon
|
|||
return err;
|
||||
}
|
||||
|
||||
srs_error_t SrsRtmpConn::process_publish_message(SrsLiveSource* source, SrsCommonMessage* msg)
|
||||
srs_error_t SrsRtmpConn::process_publish_message(SrsSharedPtr<SrsLiveSource>& source, SrsCommonMessage* msg)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue