mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
fix the rewind bug, support republish by restart the ffmpeg encoder.
This commit is contained in:
parent
b9440df745
commit
6207a2f19e
2 changed files with 21 additions and 3 deletions
|
@ -27,6 +27,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
@ -415,8 +417,6 @@ int SrsFFMPEG::cycle()
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: to support rewind.
|
|
||||||
|
|
||||||
if (p == 0) {
|
if (p == 0) {
|
||||||
srs_info("transcode process pid=%d is running.", pid);
|
srs_info("transcode process pid=%d is running.", pid);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -439,7 +439,23 @@ void SrsFFMPEG::stop()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: kill the ffmpeg process when stop.
|
// kill the ffmpeg,
|
||||||
|
// when rewind, upstream will stop publish(unpublish),
|
||||||
|
// unpublish event will stop all ffmpeg encoders,
|
||||||
|
// then publish will start all ffmpeg encoders.
|
||||||
|
if (pid > 0) {
|
||||||
|
if (kill(pid, SIGKILL) < 0) {
|
||||||
|
srs_warn("kill the encoder failed, ignored. pid=%d", pid);
|
||||||
|
}
|
||||||
|
|
||||||
|
int status = 0;
|
||||||
|
if (waitpid(pid, &status, WNOHANG) < 0) {
|
||||||
|
srs_warn("wait the encoder quit failed, ignored. pid=%d", pid);
|
||||||
|
}
|
||||||
|
|
||||||
|
srs_trace("stop the encoder success. pid=%d", pid);
|
||||||
|
pid = -1;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::string>::iterator it;
|
std::vector<std::string>::iterator it;
|
||||||
it = std::find(_transcoded_url.begin(), _transcoded_url.end(), output);
|
it = std::find(_transcoded_url.begin(), _transcoded_url.end(), output);
|
||||||
|
|
|
@ -287,6 +287,8 @@ void SrsServer::on_signal(int signo)
|
||||||
if (signo == SIGNAL_RELOAD) {
|
if (signo == SIGNAL_RELOAD) {
|
||||||
signal_reload = true;
|
signal_reload = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: handle the SIGINT, SIGTERM.
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsServer::close_listeners()
|
void SrsServer::close_listeners()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue