mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Merge SRS3
This commit is contained in:
commit
77114c7df0
12 changed files with 136 additions and 13 deletions
|
@ -158,6 +158,7 @@ For previous versions, please read:
|
||||||
|
|
||||||
## V3 changes
|
## V3 changes
|
||||||
|
|
||||||
|
* v3.0, 2020-01-29, Fix [#1206][bug #1206], dispose ingester while server quiting. 3.0.111
|
||||||
* v3.0, 2020-01-28, Fix [#1230][bug #1230], racing condition in source fetch or create. 3.0.110
|
* v3.0, 2020-01-28, Fix [#1230][bug #1230], racing condition in source fetch or create. 3.0.110
|
||||||
* v3.0, 2020-01-27, Fix [#1303][bug #1303], do not dispatch previous meta when not publishing. 3.0.109
|
* v3.0, 2020-01-27, Fix [#1303][bug #1303], do not dispatch previous meta when not publishing. 3.0.109
|
||||||
* v3.0, 2020-01-26, Allow use libst.so for ST is MPL license.
|
* v3.0, 2020-01-26, Allow use libst.so for ST is MPL license.
|
||||||
|
@ -1653,6 +1654,7 @@ Winlin
|
||||||
[bug #607]: https://github.com/ossrs/srs/issues/607
|
[bug #607]: https://github.com/ossrs/srs/issues/607
|
||||||
[bug #1303]: https://github.com/ossrs/srs/issues/1303
|
[bug #1303]: https://github.com/ossrs/srs/issues/1303
|
||||||
[bug #1230]: https://github.com/ossrs/srs/issues/1230
|
[bug #1230]: https://github.com/ossrs/srs/issues/1230
|
||||||
|
[bug #1206]: https://github.com/ossrs/srs/issues/1206
|
||||||
[bug #xxxxxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxxxxx
|
[bug #xxxxxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxxxxx
|
||||||
|
|
||||||
[exo #828]: https://github.com/google/ExoPlayer/pull/828
|
[exo #828]: https://github.com/google/ExoPlayer/pull/828
|
||||||
|
|
|
@ -418,6 +418,11 @@ void SrsFFMPEG::fast_stop()
|
||||||
process->fast_stop();
|
process->fast_stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SrsFFMPEG::fast_kill()
|
||||||
|
{
|
||||||
|
process->fast_kill();
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,7 @@ public:
|
||||||
virtual void stop();
|
virtual void stop();
|
||||||
public:
|
public:
|
||||||
virtual void fast_stop();
|
virtual void fast_stop();
|
||||||
|
virtual void fast_kill();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -97,11 +97,17 @@ void SrsIngesterFFMPEG::fast_stop()
|
||||||
ffmpeg->fast_stop();
|
ffmpeg->fast_stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SrsIngesterFFMPEG::fast_kill()
|
||||||
|
{
|
||||||
|
ffmpeg->fast_kill();
|
||||||
|
}
|
||||||
|
|
||||||
SrsIngester::SrsIngester()
|
SrsIngester::SrsIngester()
|
||||||
{
|
{
|
||||||
_srs_config->subscribe(this);
|
_srs_config->subscribe(this);
|
||||||
|
|
||||||
expired = false;
|
expired = false;
|
||||||
|
disposed = false;
|
||||||
|
|
||||||
trd = new SrsDummyCoroutine();
|
trd = new SrsDummyCoroutine();
|
||||||
pprint = SrsPithyPrint::create_ingester();
|
pprint = SrsPithyPrint::create_ingester();
|
||||||
|
@ -117,11 +123,18 @@ SrsIngester::~SrsIngester()
|
||||||
|
|
||||||
void SrsIngester::dispose()
|
void SrsIngester::dispose()
|
||||||
{
|
{
|
||||||
|
if (disposed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
disposed = true;
|
||||||
|
|
||||||
// first, use fast stop to notice all FFMPEG to quit gracefully.
|
// first, use fast stop to notice all FFMPEG to quit gracefully.
|
||||||
fast_stop();
|
fast_stop();
|
||||||
|
|
||||||
|
srs_usleep(100 * SRS_UTIME_MILLISECONDS);
|
||||||
|
|
||||||
// then, use stop to wait FFMPEG quit one by one and send SIGKILL if needed.
|
// then, use fast kill to ensure FFMPEG quit.
|
||||||
stop();
|
fast_kill();
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsIngester::start()
|
srs_error_t SrsIngester::start()
|
||||||
|
@ -166,6 +179,19 @@ void SrsIngester::fast_stop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SrsIngester::fast_kill()
|
||||||
|
{
|
||||||
|
std::vector<SrsIngesterFFMPEG*>::iterator it;
|
||||||
|
for (it = ingesters.begin(); it != ingesters.end(); ++it) {
|
||||||
|
SrsIngesterFFMPEG* ingester = *it;
|
||||||
|
ingester->fast_kill();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ingesters.empty()) {
|
||||||
|
srs_trace("fast kill all ingesters ok.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// when error, ingester sleep for a while and retry.
|
// when error, ingester sleep for a while and retry.
|
||||||
// ingest never sleep a long time, for we must start the stream ASAP.
|
// ingest never sleep a long time, for we must start the stream ASAP.
|
||||||
#define SRS_AUTO_INGESTER_CIMS (3 * SRS_UTIME_SECONDS)
|
#define SRS_AUTO_INGESTER_CIMS (3 * SRS_UTIME_SECONDS)
|
||||||
|
@ -174,7 +200,7 @@ srs_error_t SrsIngester::cycle()
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
while (true) {
|
while (!disposed) {
|
||||||
if ((err = do_cycle()) != srs_success) {
|
if ((err = do_cycle()) != srs_success) {
|
||||||
srs_warn("Ingester: Ignore error, %s", srs_error_desc(err).c_str());
|
srs_warn("Ingester: Ignore error, %s", srs_error_desc(err).c_str());
|
||||||
srs_freep(err);
|
srs_freep(err);
|
||||||
|
|
|
@ -60,6 +60,7 @@ public:
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
// @see SrsFFMPEG.fast_stop().
|
// @see SrsFFMPEG.fast_stop().
|
||||||
virtual void fast_stop();
|
virtual void fast_stop();
|
||||||
|
virtual void fast_kill();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Ingest file/stream/device,
|
// Ingest file/stream/device,
|
||||||
|
@ -75,6 +76,8 @@ private:
|
||||||
// Whether the ingesters are expired, for example, the listen port changed,
|
// Whether the ingesters are expired, for example, the listen port changed,
|
||||||
// all ingesters must be restart.
|
// all ingesters must be restart.
|
||||||
bool expired;
|
bool expired;
|
||||||
|
// Whether already disposed.
|
||||||
|
bool disposed;
|
||||||
public:
|
public:
|
||||||
SrsIngester();
|
SrsIngester();
|
||||||
virtual ~SrsIngester();
|
virtual ~SrsIngester();
|
||||||
|
@ -84,7 +87,10 @@ public:
|
||||||
virtual srs_error_t start();
|
virtual srs_error_t start();
|
||||||
virtual void stop();
|
virtual void stop();
|
||||||
private:
|
private:
|
||||||
|
// Notify FFMPEG to fast stop.
|
||||||
virtual void fast_stop();
|
virtual void fast_stop();
|
||||||
|
// When SRS quit, directly kill FFMPEG after fast stop.
|
||||||
|
virtual void fast_kill();
|
||||||
// Interface ISrsReusableThreadHandler.
|
// Interface ISrsReusableThreadHandler.
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
|
|
@ -327,3 +327,28 @@ void SrsProcess::fast_stop()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SrsProcess::fast_kill()
|
||||||
|
{
|
||||||
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
if (!is_started) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pid <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (kill(pid, SIGKILL) < 0) {
|
||||||
|
ret = ERROR_SYSTEM_KILL;
|
||||||
|
srs_warn("ignore fast kill process failed, pid=%d. ret=%d", pid, ret);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to wait pid to avoid zombie FFMEPG.
|
||||||
|
int status = 0;
|
||||||
|
waitpid(pid, &status, WNOHANG);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,8 @@ public:
|
||||||
// when use stop without fast_stop, we spend maybe [0, SRS_PROCESS_QUIT_TIMEOUT_MS * N]
|
// when use stop without fast_stop, we spend maybe [0, SRS_PROCESS_QUIT_TIMEOUT_MS * N]
|
||||||
// but use fast_stop then stop, the time is almost [0, SRS_PROCESS_QUIT_TIMEOUT_MS].
|
// but use fast_stop then stop, the time is almost [0, SRS_PROCESS_QUIT_TIMEOUT_MS].
|
||||||
virtual void fast_stop();
|
virtual void fast_stop();
|
||||||
|
// Directly kill process, never use it except server quiting.
|
||||||
|
virtual void fast_kill();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -520,7 +520,8 @@ void SrsServer::dispose()
|
||||||
close_listeners(SrsListenerRtsp);
|
close_listeners(SrsListenerRtsp);
|
||||||
close_listeners(SrsListenerFlv);
|
close_listeners(SrsListenerFlv);
|
||||||
|
|
||||||
// @remark don't dispose ingesters, for too slow.
|
// Fast stop to notify FFMPEG to quit, wait for a while then fast kill.
|
||||||
|
ingester->dispose();
|
||||||
|
|
||||||
// dispose the source for hls and dvr.
|
// dispose the source for hls and dvr.
|
||||||
_srs_sources->dispose();
|
_srs_sources->dispose();
|
||||||
|
@ -851,17 +852,14 @@ void SrsServer::on_signal(int signo)
|
||||||
srs_trace("gmc is on, main cycle will terminate normally.");
|
srs_trace("gmc is on, main cycle will terminate normally.");
|
||||||
signal_gmc_stop = true;
|
signal_gmc_stop = true;
|
||||||
#else
|
#else
|
||||||
srs_trace("user terminate program");
|
#ifdef SRS_AUTO_MEM_WATCH
|
||||||
#ifdef SRS_AUTO_MEM_WATCH
|
|
||||||
srs_memory_report();
|
srs_memory_report();
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
exit(0);
|
|
||||||
#endif
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (signo == SRS_SIGNAL_GRACEFULLY_QUIT && !signal_gracefully_quit) {
|
if ((signo == SIGINT || signo == SRS_SIGNAL_GRACEFULLY_QUIT) && !signal_gracefully_quit) {
|
||||||
srs_trace("user terminate program, gracefully quit.");
|
srs_trace("sig=%d, user terminate program, gracefully quit", signo);
|
||||||
signal_gracefully_quit = true;
|
signal_gracefully_quit = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1687,7 +1687,6 @@ srs_error_t SrsSourceManager::fetch_or_create(SrsRequest* r, ISrsSourceHandler*
|
||||||
if ((err = source->initialize(r, h)) != srs_success) {
|
if ((err = source->initialize(r, h)) != srs_success) {
|
||||||
return srs_error_wrap(err, "init source %s", r->get_stream_url().c_str());
|
return srs_error_wrap(err, "init source %s", r->get_stream_url().c_str());
|
||||||
}
|
}
|
||||||
srs_usleep(10 * SRS_UTIME_SECONDS);
|
|
||||||
|
|
||||||
pool[stream_url] = source;
|
pool[stream_url] = source;
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,8 @@
|
||||||
// The version config.
|
// The version config.
|
||||||
#define VERSION_MAJOR 4
|
#define VERSION_MAJOR 4
|
||||||
#define VERSION_MINOR 0
|
#define VERSION_MINOR 0
|
||||||
#define VERSION_REVISION 2
|
#include <srs_core_version4.hpp>
|
||||||
|
#define VERSION_REVISION SRS_VERSION4_REVISION
|
||||||
|
|
||||||
// The macros generated by configure script.
|
// The macros generated by configure script.
|
||||||
#include <srs_auto_headers.hpp>
|
#include <srs_auto_headers.hpp>
|
||||||
|
|
29
trunk/src/core/srs_core_version3.hpp
Normal file
29
trunk/src/core/srs_core_version3.hpp
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/**
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013-2020 Winlin
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SRS_CORE_VERSION3_HPP
|
||||||
|
#define SRS_CORE_VERSION3_HPP
|
||||||
|
|
||||||
|
#define SRS_VERSION3_REVISION 111
|
||||||
|
|
||||||
|
#endif
|
29
trunk/src/core/srs_core_version4.hpp
Normal file
29
trunk/src/core/srs_core_version4.hpp
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/**
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013-2020 Winlin
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SRS_CORE_VERSION4_HPP
|
||||||
|
#define SRS_CORE_VERSION4_HPP
|
||||||
|
|
||||||
|
#define SRS_VERSION4_REVISION 2
|
||||||
|
|
||||||
|
#endif
|
Loading…
Add table
Add a link
Reference in a new issue