Reprobe encoders each time streaming begins

Available encoders can change due to driver updates, GPU hotplugging, primary monitor changes, etc.
This commit is contained in:
Cameron Gutman
2023-04-09 16:34:07 -05:00
parent 44f89de33b
commit 6467e10def
4 changed files with 79 additions and 41 deletions

View File

@@ -29,6 +29,7 @@
#include "rtsp.h"
#include "utility.h"
#include "uuid.h"
#include "video.h"
using namespace std::literals;
namespace nvhttp {
@@ -762,6 +763,19 @@ namespace nvhttp {
return;
}
// Probe encoders again before streaming to ensure our chosen
// encoder matches the active GPU (which could have changed
// due to hotplugging, driver crash, primary monitor change,
// or any number of other factors).
if (rtsp_stream::session_count() == 0) {
if (video::probe_encoders()) {
tree.put("root.<xmlattr>.status_code", 503);
tree.put("root.gamesession", 0);
return;
}
}
if (appid > 0) {
auto err = proc::proc.execute(appid);
if (err) {
@@ -820,6 +834,19 @@ namespace nvhttp {
return;
}
// Probe encoders again before streaming to ensure our chosen
// encoder matches the active GPU (which could have changed
// due to hotplugging, driver crash, primary monitor change,
// or any number of other factors).
if (rtsp_stream::session_count() == 0) {
if (video::probe_encoders()) {
tree.put("root.resume", 0);
tree.put("root.<xmlattr>.status_code", 503);
return;
}
}
rtsp_stream::launch_session_raise(make_launch_session(host_audio, args));
tree.put("root.<xmlattr>.status_code", 200);