mirror of
https://github.com/Vateron-Media/XC_VM.git
synced 2026-11-18 03:03:58 +01:00
fix(stream): keep an idle on-demand stream's stream_info
An adaptive master lists a variant only by the resolution and bitrate in its stream_info, and stopping an on-demand stream for having no viewers cleared it: an idle HD/FHD variant was left out of the master, and nothing could then start it, so players only ever got the variants already running. The two idle stops (OndemandCommand, the on-demand stop in cron:streams via StreamProcess::stopStream(..., idle: true)) now keep stream_info; a manual stop, a restart and every other stop still clear it. Refs: #61
This commit is contained in:
@@ -850,13 +850,18 @@ class StreamProcess {
|
||||
*
|
||||
* @param int $rStreamID Stream id.
|
||||
* @param bool $rWithMonitor Also clear monitor_pid (full stop vs. movie stop).
|
||||
* @param bool $rKeepInfo Keep stream_info: an idle on-demand stream's last
|
||||
* probe is what an adaptive master lists it by (issue #61).
|
||||
* @return void
|
||||
*/
|
||||
private static function resetStreamServerRow(int $rStreamID, bool $rWithMonitor = false) {
|
||||
private static function resetStreamServerRow(int $rStreamID, bool $rWithMonitor = false, bool $rKeepInfo = false) {
|
||||
$rFields = ['bitrate' => null, 'current_source' => null, 'to_analyze' => 0, 'pid' => null, 'stream_started' => null, 'stream_info' => null, 'audio_codec' => null, 'video_codec' => null, 'resolution' => null, 'compatible' => 0, 'stream_status' => 0];
|
||||
if ($rWithMonitor) {
|
||||
$rFields['monitor_pid'] = null;
|
||||
}
|
||||
if ($rKeepInfo) {
|
||||
unset($rFields['stream_info']);
|
||||
}
|
||||
StreamStateWriter::update($rStreamID, intval(SERVER_ID), $rFields, self::db());
|
||||
}
|
||||
|
||||
@@ -2152,9 +2157,11 @@ class StreamProcess {
|
||||
*
|
||||
* @param int $rStreamID Stream id.
|
||||
* @param bool $rStop Mark the stream as fully stopped (not just restarting).
|
||||
* @param bool $rIdle An on-demand stream stopped for having no viewers:
|
||||
* its stream_info is kept (see resetStreamServerRow).
|
||||
* @return mixed Stop result.
|
||||
*/
|
||||
public static function stopStream(int $rStreamID, bool $rStop = false) {
|
||||
public static function stopStream(int $rStreamID, bool $rStop = false, bool $rIdle = false) {
|
||||
// A supervised stream is released FIRST: its producer dying is exactly
|
||||
// what the fanout supervisor restarts, so killing it before the release
|
||||
// would have the daemon start a replacement and the stream refuse to stop.
|
||||
@@ -2187,7 +2194,7 @@ class StreamProcess {
|
||||
|
||||
if ($rStop) {
|
||||
shell_exec('rm -f ' . DELAY_PATH . intval($rStreamID) . '_*');
|
||||
self::resetStreamServerRow($rStreamID, true);
|
||||
self::resetStreamServerRow($rStreamID, true, $rIdle);
|
||||
self::updateStream($rStreamID);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user