mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
Fix #2142, Async release bridger when unpublish. 4.0.60
This commit is contained in:
parent
10ffb2da36
commit
06adb9dc42
6 changed files with 60 additions and 5 deletions
|
@ -155,6 +155,7 @@ For previous versions, please read:
|
||||||
|
|
||||||
## V4 changes
|
## V4 changes
|
||||||
|
|
||||||
|
* v4.0, 2021-01-14, For [#2142][bug #2142], Async release bridger when unpublish. 4.0.60
|
||||||
* v4.0, 2021-01-08, HTML5 video tag resolution adaptive. 4.0.59
|
* v4.0, 2021-01-08, HTML5 video tag resolution adaptive. 4.0.59
|
||||||
* v4.0, 2021-01-08, Fix memory leak and bugs for RTC. 4.0.58
|
* v4.0, 2021-01-08, Fix memory leak and bugs for RTC. 4.0.58
|
||||||
* v4.0, 2021-01-06, Merge #2109, Refine srs_string_split.
|
* v4.0, 2021-01-06, Merge #2109, Refine srs_string_split.
|
||||||
|
@ -1795,6 +1796,7 @@ Winlin
|
||||||
[bug #1987]: https://github.com/ossrs/srs/issues/1987
|
[bug #1987]: https://github.com/ossrs/srs/issues/1987
|
||||||
[bug #1548]: https://github.com/ossrs/srs/issues/1548
|
[bug #1548]: https://github.com/ossrs/srs/issues/1548
|
||||||
[bug #1694]: https://github.com/ossrs/srs/issues/1694
|
[bug #1694]: https://github.com/ossrs/srs/issues/1694
|
||||||
|
[bug #2142]: https://github.com/ossrs/srs/issues/2142
|
||||||
[bug #yyyyyyyyyyyyy]: https://github.com/ossrs/srs/issues/yyyyyyyyyyyyy
|
[bug #yyyyyyyyyyyyy]: https://github.com/ossrs/srs/issues/yyyyyyyyyyyyy
|
||||||
|
|
||||||
[bug #1631]: https://github.com/ossrs/srs/issues/1631
|
[bug #1631]: https://github.com/ossrs/srs/issues/1631
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
#include <srs_protocol_json.hpp>
|
#include <srs_protocol_json.hpp>
|
||||||
#include <srs_app_pithy_print.hpp>
|
#include <srs_app_pithy_print.hpp>
|
||||||
#include <srs_app_log.hpp>
|
#include <srs_app_log.hpp>
|
||||||
|
#include <srs_app_rtc_server.hpp>
|
||||||
|
|
||||||
#ifdef SRS_FFMPEG_FIT
|
#ifdef SRS_FFMPEG_FIT
|
||||||
#include <srs_app_rtc_codec.hpp>
|
#include <srs_app_rtc_codec.hpp>
|
||||||
|
@ -323,8 +324,10 @@ SrsRtcStream::~SrsRtcStream()
|
||||||
consumers.clear();
|
consumers.clear();
|
||||||
|
|
||||||
srs_freep(req);
|
srs_freep(req);
|
||||||
srs_freep(bridger_);
|
|
||||||
srs_freep(stream_desc_);
|
srs_freep(stream_desc_);
|
||||||
|
|
||||||
|
// Async remove the bridger, to notify the sources to clear it.
|
||||||
|
_srs_rtc_manager->remove(bridger_);
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcStream::initialize(SrsRequest* r)
|
srs_error_t SrsRtcStream::initialize(SrsRequest* r)
|
||||||
|
@ -483,7 +486,8 @@ void SrsRtcStream::on_unpublish()
|
||||||
|
|
||||||
// release unpublish stream description.
|
// release unpublish stream description.
|
||||||
set_stream_desc(NULL);
|
set_stream_desc(NULL);
|
||||||
srs_freep(bridger_);
|
// Async remove the bridger, to notify the sources to clear it.
|
||||||
|
_srs_rtc_manager->remove(bridger_);
|
||||||
|
|
||||||
// TODO: FIXME: Handle by statistic.
|
// TODO: FIXME: Handle by statistic.
|
||||||
}
|
}
|
||||||
|
@ -717,6 +721,16 @@ srs_error_t SrsRtcFromRtmpBridger::on_audio(SrsSharedPtrMessage* msg)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SrsContextId& SrsRtcFromRtmpBridger::get_id()
|
||||||
|
{
|
||||||
|
return _srs_context->get_id();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string SrsRtcFromRtmpBridger::desc()
|
||||||
|
{
|
||||||
|
return "Rtmp2Rtc";
|
||||||
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcFromRtmpBridger::transcode(char* adts_audio, int nn_adts_audio)
|
srs_error_t SrsRtcFromRtmpBridger::transcode(char* adts_audio, int nn_adts_audio)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
@ -1175,6 +1189,16 @@ void SrsRtcDummyBridger::on_unpublish()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SrsContextId& SrsRtcDummyBridger::get_id()
|
||||||
|
{
|
||||||
|
return _srs_context->get_id();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string SrsRtcDummyBridger::desc()
|
||||||
|
{
|
||||||
|
return "Rtmp2RtcDummy";
|
||||||
|
}
|
||||||
|
|
||||||
SrsCodecPayload::SrsCodecPayload()
|
SrsCodecPayload::SrsCodecPayload()
|
||||||
{
|
{
|
||||||
pt_of_publisher_ = pt_ = 0;
|
pt_of_publisher_ = pt_ = 0;
|
||||||
|
|
|
@ -247,6 +247,10 @@ public:
|
||||||
virtual srs_error_t on_publish();
|
virtual srs_error_t on_publish();
|
||||||
virtual void on_unpublish();
|
virtual void on_unpublish();
|
||||||
virtual srs_error_t on_audio(SrsSharedPtrMessage* msg);
|
virtual srs_error_t on_audio(SrsSharedPtrMessage* msg);
|
||||||
|
// interface ISrsResource
|
||||||
|
public:
|
||||||
|
virtual const SrsContextId& get_id();
|
||||||
|
virtual std::string desc();
|
||||||
private:
|
private:
|
||||||
srs_error_t transcode(char* adts_audio, int nn_adts_audio);
|
srs_error_t transcode(char* adts_audio, int nn_adts_audio);
|
||||||
srs_error_t package_opus(char* data, int size, SrsRtpPacket2** ppkt);
|
srs_error_t package_opus(char* data, int size, SrsRtpPacket2** ppkt);
|
||||||
|
@ -272,6 +276,10 @@ public:
|
||||||
virtual srs_error_t on_audio(SrsSharedPtrMessage* audio);
|
virtual srs_error_t on_audio(SrsSharedPtrMessage* audio);
|
||||||
virtual srs_error_t on_video(SrsSharedPtrMessage* video);
|
virtual srs_error_t on_video(SrsSharedPtrMessage* video);
|
||||||
virtual void on_unpublish();
|
virtual void on_unpublish();
|
||||||
|
// interface ISrsResource
|
||||||
|
public:
|
||||||
|
virtual const SrsContextId& get_id();
|
||||||
|
virtual std::string desc();
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: FIXME: Rename it.
|
// TODO: FIXME: Rename it.
|
||||||
|
|
|
@ -51,6 +51,7 @@ using namespace std;
|
||||||
#include <srs_app_dash.hpp>
|
#include <srs_app_dash.hpp>
|
||||||
#include <srs_protocol_format.hpp>
|
#include <srs_protocol_format.hpp>
|
||||||
#include <srs_app_rtc_source.hpp>
|
#include <srs_app_rtc_source.hpp>
|
||||||
|
#include <srs_app_rtc_server.hpp>
|
||||||
|
|
||||||
#define CONST_MAX_JITTER_MS 250
|
#define CONST_MAX_JITTER_MS 250
|
||||||
#define CONST_MAX_JITTER_MS_NEG -250
|
#define CONST_MAX_JITTER_MS_NEG -250
|
||||||
|
@ -1881,10 +1882,13 @@ SrsSource::SrsSource()
|
||||||
|
|
||||||
_srs_config->subscribe(this);
|
_srs_config->subscribe(this);
|
||||||
atc = false;
|
atc = false;
|
||||||
|
|
||||||
|
_srs_rtc_manager->subscribe(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsSource::~SrsSource()
|
SrsSource::~SrsSource()
|
||||||
{
|
{
|
||||||
|
_srs_rtc_manager->unsubscribe(this);
|
||||||
_srs_config->unsubscribe(this);
|
_srs_config->unsubscribe(this);
|
||||||
|
|
||||||
// never free the consumers,
|
// never free the consumers,
|
||||||
|
@ -1980,6 +1984,18 @@ void SrsSource::bridge_to(ISrsSourceBridger* v)
|
||||||
bridger = v;
|
bridger = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SrsSource::on_before_dispose(ISrsResource* c)
|
||||||
|
{
|
||||||
|
ISrsSourceBridger* pb = dynamic_cast<ISrsSourceBridger*>(c);
|
||||||
|
if (bridger == pb) {
|
||||||
|
bridge_to(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SrsSource::on_disposing(ISrsResource* c)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
srs_error_t SrsSource::on_reload_vhost_play(string vhost)
|
srs_error_t SrsSource::on_reload_vhost_play(string vhost)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include <srs_app_reload.hpp>
|
#include <srs_app_reload.hpp>
|
||||||
#include <srs_core_performance.hpp>
|
#include <srs_core_performance.hpp>
|
||||||
#include <srs_service_st.hpp>
|
#include <srs_service_st.hpp>
|
||||||
|
#include <srs_app_conn.hpp>
|
||||||
|
|
||||||
class SrsFormat;
|
class SrsFormat;
|
||||||
class SrsRtmpFormat;
|
class SrsRtmpFormat;
|
||||||
|
@ -484,7 +485,7 @@ public:
|
||||||
extern SrsSourceManager* _srs_sources;
|
extern SrsSourceManager* _srs_sources;
|
||||||
|
|
||||||
// For two sources to bridge with each other.
|
// For two sources to bridge with each other.
|
||||||
class ISrsSourceBridger
|
class ISrsSourceBridger : public ISrsResource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ISrsSourceBridger();
|
ISrsSourceBridger();
|
||||||
|
@ -497,7 +498,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// live streaming source.
|
// live streaming source.
|
||||||
class SrsSource : public ISrsReloadHandler
|
class SrsSource : virtual public ISrsReloadHandler, virtual public ISrsDisposingHandler
|
||||||
{
|
{
|
||||||
friend class SrsOriginHub;
|
friend class SrsOriginHub;
|
||||||
private:
|
private:
|
||||||
|
@ -559,6 +560,10 @@ public:
|
||||||
virtual srs_error_t initialize(SrsRequest* r, ISrsSourceHandler* h);
|
virtual srs_error_t initialize(SrsRequest* r, ISrsSourceHandler* h);
|
||||||
// Bridge to other source, forward packets to it.
|
// Bridge to other source, forward packets to it.
|
||||||
void bridge_to(ISrsSourceBridger* v);
|
void bridge_to(ISrsSourceBridger* v);
|
||||||
|
// interface ISrsDisposingHandler
|
||||||
|
public:
|
||||||
|
virtual void on_before_dispose(ISrsResource* c);
|
||||||
|
virtual void on_disposing(ISrsResource* c);
|
||||||
// Interface ISrsReloadHandler
|
// Interface ISrsReloadHandler
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t on_reload_vhost_play(std::string vhost);
|
virtual srs_error_t on_reload_vhost_play(std::string vhost);
|
||||||
|
|
|
@ -24,6 +24,6 @@
|
||||||
#ifndef SRS_CORE_VERSION4_HPP
|
#ifndef SRS_CORE_VERSION4_HPP
|
||||||
#define SRS_CORE_VERSION4_HPP
|
#define SRS_CORE_VERSION4_HPP
|
||||||
|
|
||||||
#define SRS_VERSION4_REVISION 59
|
#define SRS_VERSION4_REVISION 60
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue