mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Squash: Fix bugs
This commit is contained in:
parent
4110fb14cb
commit
93aa0eb5ba
25 changed files with 198 additions and 184 deletions
|
@ -50,7 +50,7 @@ const char* _srs_version = "XCORE-" RTMP_SIG_SRS_SERVER;
|
|||
#define SRS_CONF_PERFER_TRUE(conf_arg) conf_arg != "off"
|
||||
|
||||
// default config file.
|
||||
#define SRS_CONF_DEFAULT_COFNIG_FILE "conf/srs.conf"
|
||||
#define SRS_CONF_DEFAULT_COFNIG_FILE SRS_DEFAULT_CONFIG
|
||||
|
||||
// '\n'
|
||||
#define SRS_LF (char)SRS_CONSTS_LF
|
||||
|
|
|
@ -186,8 +186,15 @@ srs_error_t SrsGoApiRtcPlay::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMe
|
|||
server_enabled, rtc_enabled, ruc.req_->vhost.c_str());
|
||||
}
|
||||
|
||||
// Whether RTC stream is active.
|
||||
bool is_rtc_stream_active = false;
|
||||
if (true) {
|
||||
SrsRtcSource* source = _srs_rtc_sources->fetch(ruc.req_);
|
||||
is_rtc_stream_active = (source && !source->can_publish());
|
||||
}
|
||||
|
||||
// For RTMP to RTC, fail if disabled and RTMP is active, see https://github.com/ossrs/srs/issues/2728
|
||||
if (!_srs_config->get_rtc_from_rtmp(ruc.req_->vhost)) {
|
||||
if (!is_rtc_stream_active && !_srs_config->get_rtc_from_rtmp(ruc.req_->vhost)) {
|
||||
SrsLiveSource* rtmp = _srs_sources->fetch(ruc.req_);
|
||||
if (rtmp && !rtmp->inactive()) {
|
||||
return srs_error_new(ERROR_RTC_DISABLED, "Disabled rtmp_to_rtc of %s, see #2728", ruc.req_->vhost.c_str());
|
||||
|
|
|
@ -1183,20 +1183,20 @@ srs_error_t SrsRtcPublishStream::initialize(SrsRequest* r, SrsRtcSourceDescripti
|
|||
}
|
||||
source->set_publish_stream(this);
|
||||
|
||||
// TODO: FIMXE: Check it in SrsRtcConnection::add_publisher?
|
||||
SrsLiveSource *rtmp = _srs_sources->fetch(r);
|
||||
if (rtmp && !rtmp->can_publish(false)) {
|
||||
return srs_error_new(ERROR_SYSTEM_STREAM_BUSY, "rtmp stream %s busy", r->get_stream_url().c_str());
|
||||
}
|
||||
|
||||
// Bridge to rtmp
|
||||
#if defined(SRS_RTC) && defined(SRS_FFMPEG_FIT)
|
||||
bool rtc_to_rtmp = _srs_config->get_rtc_to_rtmp(req_->vhost);
|
||||
if (rtc_to_rtmp) {
|
||||
SrsLiveSource *rtmp = NULL;
|
||||
if ((err = _srs_sources->fetch_or_create(r, _srs_hybrid->srs()->instance(), &rtmp)) != srs_success) {
|
||||
return srs_error_wrap(err, "create source");
|
||||
}
|
||||
|
||||
// TODO: FIMXE: Check it in SrsRtcConnection::add_publisher?
|
||||
if (!rtmp->can_publish(false)) {
|
||||
return srs_error_new(ERROR_SYSTEM_STREAM_BUSY, "rtmp stream %s busy", r->get_stream_url().c_str());
|
||||
}
|
||||
|
||||
// Disable GOP cache for RTC2RTMP bridger, to keep the streams in sync,
|
||||
// especially for stream merging.
|
||||
rtmp->set_cache(false);
|
||||
|
|
|
@ -256,6 +256,10 @@ srs_error_t SrsRtcSourceManager::fetch_or_create(SrsRequest* r, SrsRtcSource** p
|
|||
|
||||
SrsRtcSource* source = NULL;
|
||||
if ((source = fetch(r)) != NULL) {
|
||||
// we always update the request of resource,
|
||||
// for origin auth is on, the token in request maybe invalid,
|
||||
// and we only need to update the token of request, it's simple.
|
||||
source->update_auth(r);
|
||||
*pps = source;
|
||||
return err;
|
||||
}
|
||||
|
@ -291,11 +295,6 @@ SrsRtcSource* SrsRtcSourceManager::fetch(SrsRequest* r)
|
|||
|
||||
source = pool[stream_url];
|
||||
|
||||
// we always update the request of resource,
|
||||
// for origin auth is on, the token in request maybe invalid,
|
||||
// and we only need to update the token of request, it's simple.
|
||||
source->update_auth(r);
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
|
|
|
@ -112,9 +112,8 @@ public:
|
|||
// @param r the client request.
|
||||
// @param pps the matched source, if success never be NULL.
|
||||
virtual srs_error_t fetch_or_create(SrsRequest* r, SrsRtcSource** pps);
|
||||
private:
|
||||
public:
|
||||
// Get the exists source, NULL when not exists.
|
||||
// update the request and return the exists source.
|
||||
virtual SrsRtcSource* fetch(SrsRequest* r);
|
||||
};
|
||||
|
||||
|
|
|
@ -1713,6 +1713,10 @@ srs_error_t SrsLiveSourceManager::fetch_or_create(SrsRequest* r, ISrsLiveSourceH
|
|||
|
||||
SrsLiveSource* source = NULL;
|
||||
if ((source = fetch(r)) != NULL) {
|
||||
// we always update the request of resource,
|
||||
// for origin auth is on, the token in request maybe invalid,
|
||||
// and we only need to update the token of request, it's simple.
|
||||
source->update_auth(r);
|
||||
*pps = source;
|
||||
return err;
|
||||
}
|
||||
|
@ -1751,11 +1755,6 @@ SrsLiveSource* SrsLiveSourceManager::fetch(SrsRequest* r)
|
|||
|
||||
source = pool[stream_url];
|
||||
|
||||
// we always update the request of resource,
|
||||
// for origin auth is on, the token in request maybe invalid,
|
||||
// and we only need to update the token of request, it's simple.
|
||||
source->update_auth(r);
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
|
|
|
@ -450,7 +450,6 @@ public:
|
|||
virtual srs_error_t fetch_or_create(SrsRequest* r, ISrsLiveSourceHandler* h, SrsLiveSource** pps);
|
||||
public:
|
||||
// Get the exists source, NULL when not exists.
|
||||
// update the request and return the exists source.
|
||||
virtual SrsLiveSource* fetch(SrsRequest* r);
|
||||
public:
|
||||
// dispose and cycle all sources.
|
||||
|
|
|
@ -30,13 +30,16 @@
|
|||
// where the char* pstr = new char[size].
|
||||
// To delete object.
|
||||
#define SrsAutoFree(className, instance) \
|
||||
impl_SrsAutoFree<className> _auto_free_##instance(&instance, false, false)
|
||||
impl_SrsAutoFree<className> _auto_free_##instance(&instance, false, false, NULL)
|
||||
// To delete array.
|
||||
#define SrsAutoFreeA(className, instance) \
|
||||
impl_SrsAutoFree<className> _auto_free_array_##instance(&instance, true, false)
|
||||
impl_SrsAutoFree<className> _auto_free_array_##instance(&instance, true, false, NULL)
|
||||
// Use free instead of delete.
|
||||
#define SrsAutoFreeF(className, instance) \
|
||||
impl_SrsAutoFree<className> _auto_free_##instance(&instance, false, true)
|
||||
impl_SrsAutoFree<className> _auto_free_##instance(&instance, false, true, NULL)
|
||||
// Use hook instead of delete.
|
||||
#define SrsAutoFreeH(className, instance, hook) \
|
||||
impl_SrsAutoFree<className> _auto_free_##instance(&instance, false, false, hook)
|
||||
// The template implementation.
|
||||
template<class T>
|
||||
class impl_SrsAutoFree
|
||||
|
@ -45,11 +48,16 @@ private:
|
|||
T** ptr;
|
||||
bool is_array;
|
||||
bool _use_free;
|
||||
void (*_hook)(T*);
|
||||
public:
|
||||
impl_SrsAutoFree(T** p, bool array, bool use_free) {
|
||||
// If use_free, use free(void*) to release the p.
|
||||
// If specified hook, use hook(p) to release it.
|
||||
// Use delete to release p, or delete[] if p is an array.
|
||||
impl_SrsAutoFree(T** p, bool array, bool use_free, void (*hook)(T*)) {
|
||||
ptr = p;
|
||||
is_array = array;
|
||||
_use_free = use_free;
|
||||
_hook = hook;
|
||||
}
|
||||
|
||||
virtual ~impl_SrsAutoFree() {
|
||||
|
@ -59,6 +67,8 @@ public:
|
|||
|
||||
if (_use_free) {
|
||||
free(*ptr);
|
||||
} else if (_hook) {
|
||||
_hook(*ptr);
|
||||
} else {
|
||||
if (is_array) {
|
||||
delete[] *ptr;
|
||||
|
|
|
@ -9,6 +9,6 @@
|
|||
|
||||
#define VERSION_MAJOR 4
|
||||
#define VERSION_MINOR 0
|
||||
#define VERSION_REVISION 220
|
||||
#define VERSION_REVISION 229
|
||||
|
||||
#endif
|
||||
|
|
|
@ -9,6 +9,6 @@
|
|||
|
||||
#define VERSION_MAJOR 5
|
||||
#define VERSION_MINOR 0
|
||||
#define VERSION_REVISION 20
|
||||
#define VERSION_REVISION 21
|
||||
|
||||
#endif
|
||||
|
|
|
@ -126,8 +126,8 @@ srs_error_t do_main(int argc, char** argv)
|
|||
// config already applied to log.
|
||||
srs_trace2(TAG_MAIN, "%s, %s", RTMP_SIG_SRS_SERVER, RTMP_SIG_SRS_LICENSE);
|
||||
srs_trace("authors: %sand %s", RTMP_SIG_SRS_AUTHORS, SRS_CONSTRIBUTORS);
|
||||
srs_trace("cwd=%s, work_dir=%s, build: %s, configure: %s, uname: %s, osx: %d",
|
||||
_srs_config->cwd().c_str(), cwd.c_str(), SRS_BUILD_DATE, SRS_USER_CONFIGURE, SRS_UNAME, SRS_OSX_BOOL);
|
||||
srs_trace("cwd=%s, work_dir=%s, build: %s, configure: %s, uname: %s, osx: %d, pkg: %s",
|
||||
_srs_config->cwd().c_str(), cwd.c_str(), SRS_BUILD_DATE, SRS_USER_CONFIGURE, SRS_UNAME, SRS_OSX_BOOL, SRS_PACKAGER);
|
||||
srs_trace("configure detail: " SRS_CONFIGURE);
|
||||
#ifdef SRS_EMBEDED_TOOL_CHAIN
|
||||
srs_trace("crossbuild tool chain: " SRS_EMBEDED_TOOL_CHAIN);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue