Handle acquiring display names based on encoder
This commit is contained in:
@@ -286,8 +286,8 @@ std::unique_ptr<audio_control_t> audio_control();
|
|||||||
*/
|
*/
|
||||||
std::shared_ptr<display_t> display(mem_type_e hwdevice_type, const std::string &display_name, int framerate);
|
std::shared_ptr<display_t> display(mem_type_e hwdevice_type, const std::string &display_name, int framerate);
|
||||||
|
|
||||||
// A list of names of displays accepted as display_name
|
// A list of names of displays accepted as display_name with the mem_type_e
|
||||||
std::vector<std::string> display_names();
|
std::vector<std::string> display_names(mem_type_e hwdevice_type);
|
||||||
|
|
||||||
input_t input();
|
input_t input();
|
||||||
void move_mouse(input_t &input, int deltaX, int deltaY);
|
void move_mouse(input_t &input, int deltaX, int deltaY);
|
||||||
|
|||||||
@@ -140,7 +140,8 @@ std::string get_mac_address(const std::string_view &address) {
|
|||||||
return "00:00:00:00:00:00"s;
|
return "00:00:00:00:00:00"s;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class source_e {
|
namespace source {
|
||||||
|
enum source_e : std::size_t {
|
||||||
#ifdef SUNSHINE_BUILD_CUDA
|
#ifdef SUNSHINE_BUILD_CUDA
|
||||||
NVFBC,
|
NVFBC,
|
||||||
#endif
|
#endif
|
||||||
@@ -153,8 +154,11 @@ enum class source_e {
|
|||||||
#ifdef SUNSHINE_BUILD_X11
|
#ifdef SUNSHINE_BUILD_X11
|
||||||
X11,
|
X11,
|
||||||
#endif
|
#endif
|
||||||
|
MAX_FLAGS
|
||||||
};
|
};
|
||||||
static source_e source;
|
} // namespace source
|
||||||
|
|
||||||
|
static std::bitset<source::MAX_FLAGS> sources;
|
||||||
|
|
||||||
#ifdef SUNSHINE_BUILD_CUDA
|
#ifdef SUNSHINE_BUILD_CUDA
|
||||||
std::vector<std::string> nvfbc_display_names();
|
std::vector<std::string> nvfbc_display_names();
|
||||||
@@ -192,48 +196,48 @@ bool verify_x11() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::vector<std::string> display_names() {
|
std::vector<std::string> display_names(mem_type_e hwdevice_type) {
|
||||||
switch(source) {
|
|
||||||
#ifdef SUNSHINE_BUILD_CUDA
|
#ifdef SUNSHINE_BUILD_CUDA
|
||||||
case source_e::NVFBC:
|
// display using NvFBC only supports mem_type_e::cuda
|
||||||
return nvfbc_display_names();
|
if(sources[source::NVFBC] && hwdevice_type == mem_type_e::cuda) return nvfbc_display_names();
|
||||||
#endif
|
#endif
|
||||||
#ifdef SUNSHINE_BUILD_WAYLAND
|
#ifdef SUNSHINE_BUILD_WAYLAND
|
||||||
case source_e::WAYLAND:
|
if(sources[source::WAYLAND]) return wl_display_names();
|
||||||
return wl_display_names();
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef SUNSHINE_BUILD_DRM
|
#ifdef SUNSHINE_BUILD_DRM
|
||||||
case source_e::KMS:
|
if(sources[source::KMS]) return kms_display_names();
|
||||||
return kms_display_names();
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef SUNSHINE_BUILD_X11
|
#ifdef SUNSHINE_BUILD_X11
|
||||||
case source_e::X11:
|
if(sources[source::X11]) return x11_display_names();
|
||||||
return x11_display_names();
|
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<display_t> display(mem_type_e hwdevice_type, const std::string &display_name, int framerate) {
|
std::shared_ptr<display_t> display(mem_type_e hwdevice_type, const std::string &display_name, int framerate) {
|
||||||
switch(source) {
|
|
||||||
#ifdef SUNSHINE_BUILD_CUDA
|
#ifdef SUNSHINE_BUILD_CUDA
|
||||||
case source_e::NVFBC:
|
if(sources[source::NVFBC] && hwdevice_type == mem_type_e::cuda) {
|
||||||
|
BOOST_LOG(info) << "Screencasting with NvFBC"sv;
|
||||||
return nvfbc_display(hwdevice_type, display_name, framerate);
|
return nvfbc_display(hwdevice_type, display_name, framerate);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef SUNSHINE_BUILD_WAYLAND
|
#ifdef SUNSHINE_BUILD_WAYLAND
|
||||||
case source_e::WAYLAND:
|
if(sources[source::WAYLAND]) {
|
||||||
|
BOOST_LOG(info) << "Screencasting with Wayland's protocol"sv;
|
||||||
return wl_display(hwdevice_type, display_name, framerate);
|
return wl_display(hwdevice_type, display_name, framerate);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef SUNSHINE_BUILD_DRM
|
#ifdef SUNSHINE_BUILD_DRM
|
||||||
case source_e::KMS:
|
if(sources[source::KMS]) {
|
||||||
|
BOOST_LOG(info) << "Screencasting with KMS"sv;
|
||||||
return kms_display(hwdevice_type, display_name, framerate);
|
return kms_display(hwdevice_type, display_name, framerate);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef SUNSHINE_BUILD_X11
|
#ifdef SUNSHINE_BUILD_X11
|
||||||
case source_e::X11:
|
if(sources[source::X11]) {
|
||||||
|
BOOST_LOG(info) << "Screencasting with X11"sv;
|
||||||
return x11_display(hwdevice_type, display_name, framerate);
|
return x11_display(hwdevice_type, display_name, framerate);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -260,16 +264,14 @@ std::unique_ptr<deinit_t> init() {
|
|||||||
#endif
|
#endif
|
||||||
#ifdef SUNSHINE_BUILD_CUDA
|
#ifdef SUNSHINE_BUILD_CUDA
|
||||||
if(verify_nvfbc()) {
|
if(verify_nvfbc()) {
|
||||||
BOOST_LOG(info) << "Using nvFBC for screencasting"sv;
|
BOOST_LOG(info) << "Using NvFBC for screencasting"sv;
|
||||||
source = source_e::NVFBC;
|
sources[source::NVFBC] = true;
|
||||||
goto found_source;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef SUNSHINE_BUILD_WAYLAND
|
#ifdef SUNSHINE_BUILD_WAYLAND
|
||||||
if(verify_wl()) {
|
if(verify_wl()) {
|
||||||
BOOST_LOG(info) << "Using Wayland for screencasting"sv;
|
BOOST_LOG(info) << "Using Wayland for screencasting"sv;
|
||||||
source = source_e::WAYLAND;
|
sources[source::WAYLAND] = true;
|
||||||
goto found_source;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef SUNSHINE_BUILD_DRM
|
#ifdef SUNSHINE_BUILD_DRM
|
||||||
@@ -281,23 +283,20 @@ std::unique_ptr<deinit_t> init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BOOST_LOG(info) << "Using KMS for screencasting"sv;
|
BOOST_LOG(info) << "Using KMS for screencasting"sv;
|
||||||
source = source_e::KMS;
|
sources[source::KMS] = true;
|
||||||
goto found_source;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef SUNSHINE_BUILD_X11
|
#ifdef SUNSHINE_BUILD_X11
|
||||||
if(verify_x11()) {
|
if(verify_x11()) {
|
||||||
BOOST_LOG(info) << "Using X11 for screencasting"sv;
|
BOOST_LOG(info) << "Using X11 for screencasting"sv;
|
||||||
source = source_e::X11;
|
sources[source::X11] = true;
|
||||||
goto found_source;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// Did not find a source
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
// Normally, I would simply use if-else statements to achieve this result,
|
if(sources.none()) {
|
||||||
// but due to the macro's, (*spits on ground*), it would be too messy
|
return nullptr;
|
||||||
found_source:
|
}
|
||||||
|
|
||||||
if(!gladLoaderLoadEGL(EGL_NO_DISPLAY) || !eglGetPlatformDisplay) {
|
if(!gladLoaderLoadEGL(EGL_NO_DISPLAY) || !eglGetPlatformDisplay) {
|
||||||
BOOST_LOG(warning) << "Couldn't load EGL library"sv;
|
BOOST_LOG(warning) << "Couldn't load EGL library"sv;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -452,7 +452,7 @@ std::shared_ptr<display_t> display(mem_type_e hwdevice_type, const std::string &
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> display_names() {
|
std::vector<std::string> display_names(mem_type_e) {
|
||||||
std::vector<std::string> display_names;
|
std::vector<std::string> display_names;
|
||||||
|
|
||||||
HRESULT status;
|
HRESULT status;
|
||||||
|
|||||||
@@ -585,7 +585,7 @@ void captureThread(
|
|||||||
|
|
||||||
// Get all the monitor names now, rather than at boot, to
|
// Get all the monitor names now, rather than at boot, to
|
||||||
// get the most up-to-date list available monitors
|
// get the most up-to-date list available monitors
|
||||||
auto display_names = platf::display_names();
|
auto display_names = platf::display_names(map_dev_type(encoder.dev_type));
|
||||||
int display_p = 0;
|
int display_p = 0;
|
||||||
|
|
||||||
if(display_names.empty()) {
|
if(display_names.empty()) {
|
||||||
@@ -1112,10 +1112,23 @@ std::optional<sync_session_t> make_synced_session(platf::display_t *disp, const
|
|||||||
|
|
||||||
encode_e encode_run_sync(
|
encode_e encode_run_sync(
|
||||||
std::vector<std::unique_ptr<sync_session_ctx_t>> &synced_session_ctxs,
|
std::vector<std::unique_ptr<sync_session_ctx_t>> &synced_session_ctxs,
|
||||||
encode_session_ctx_queue_t &encode_session_ctx_queue,
|
encode_session_ctx_queue_t &encode_session_ctx_queue) {
|
||||||
int &display_p, const std::vector<std::string> &display_names) {
|
|
||||||
|
|
||||||
const auto &encoder = encoders.front();
|
const auto &encoder = encoders.front();
|
||||||
|
auto display_names = platf::display_names(map_dev_type(encoder.dev_type));
|
||||||
|
int display_p = 0;
|
||||||
|
|
||||||
|
if(display_names.empty()) {
|
||||||
|
display_names.emplace_back(config::video.output_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int x = 0; x < display_names.size(); ++x) {
|
||||||
|
if(display_names[x] == config::video.output_name) {
|
||||||
|
display_p = x;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::shared_ptr<platf::display_t> disp;
|
std::shared_ptr<platf::display_t> disp;
|
||||||
|
|
||||||
@@ -1269,22 +1282,7 @@ void captureThreadSync() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
auto display_names = platf::display_names();
|
while(encode_run_sync(synced_session_ctxs, ctx) == encode_e::reinit) {}
|
||||||
int display_p = 0;
|
|
||||||
|
|
||||||
if(display_names.empty()) {
|
|
||||||
display_names.emplace_back(config::video.output_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int x = 0; x < display_names.size(); ++x) {
|
|
||||||
if(display_names[x] == config::video.output_name) {
|
|
||||||
display_p = x;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while(encode_run_sync(synced_session_ctxs, ctx, display_p, display_names) == encode_e::reinit) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void capture_async(
|
void capture_async(
|
||||||
|
|||||||
Reference in New Issue
Block a user