Hermes 0.7.0
Linux game streaming host
Loading...
Searching...
No Matches
misc.h File Reference

Miscellaneous declarations for Linux. More...

#include <unistd.h>
#include <vector>
#include "src/utility.h"
Include dependency graph for misc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef void(*) dyn::apiproc(void)

Enumerations

enum class  window_system_e { NONE , X11 , WAYLAND }

Functions

 KITTY_USING_MOVE_T (file_t, int, -1, { if(el >=0) { close(el);} })
int platf::open_drm_node (const char *path, int flags)
 Open a DRM device node without becoming its DRM master.
int platf::open_encode_render_node (bool nvenc=false)
 Open the render node of the best GPU to encode a stream on.
std::string platf::encode_gpu_description (bool nvenc=false)
 Describe the GPU a stream encodes on, for logs and diagnostics: its render node, driver and the name it is sold under, or its PCI id.
void platf::note_vaapi_encode_gpu (int fd)
 Record the GPU a VAAPI encoder actually opened, from its DRM fd.
std::string platf::last_vaapi_encode_gpu ()
 The GPU the last VAAPI encoder opened, described as encode_gpu_description() does, or an empty string.
std::vector< std::string > platf::render_node_descriptions ()
 Describe every GPU render node, as encode_gpu_description() does, the capture-only Hermes-KMS node included and marked as such.
int dyn::load (void *handle, const std::vector< std::tuple< apiproc *, const char * > > &funcs, bool strict)
void * dyn::handle (const std::vector< const char * > &libs)
bool platf::request_user_service_stop ()

Variables

window_system_e window_system

Detailed Description

Miscellaneous declarations for Linux.

Definition in file misc.h.

Typedef Documentation

◆ apiproc

typedef void(*) dyn::apiproc(void)

Definition at line 109 of file misc.h.

Enumeration Type Documentation

◆ window_system_e

enum class window_system_e
strong
Enumerator
NONE 

No window system.

X11 

X11.

WAYLAND 

Wayland.

Definition at line 20 of file misc.h.

Function Documentation

◆ encode_gpu_description()

std::string platf::encode_gpu_description ( bool nvenc = false)

Describe the GPU a stream encodes on, for logs and diagnostics: its render node, driver and the name it is sold under, or its PCI id.

Parameters
nvencWhether the stream encodes with NVENC rather than VAAPI.
Returns
For example "/dev/dri/renderD128 (amdgpu, AMD Radeon RX 9070 XT)", or "(amdgpu, AMD 1002:7550)" where the name is unknown, or an empty string when no GPU qualifies.

Definition at line 266 of file encode_gpu.cpp.

◆ handle()

void * dyn::handle ( const std::vector< const char * > & libs)

Definition at line 95 of file misc.cpp.

◆ last_vaapi_encode_gpu()

std::string platf::last_vaapi_encode_gpu ( )

The GPU the last VAAPI encoder opened, described as encode_gpu_description() does, or an empty string.

Definition at line 294 of file encode_gpu.cpp.

◆ load()

int dyn::load ( void * handle,
const std::vector< std::tuple< apiproc *, const char * > > & funcs,
bool strict )

Definition at line 118 of file misc.cpp.

◆ note_vaapi_encode_gpu()

void platf::note_vaapi_encode_gpu ( int fd)

Record the GPU a VAAPI encoder actually opened, from its DRM fd.

KMS capture hands the encoder the render node of the GPU the captured display is on, which need not be the one adapter_name names. A negative fd forgets the last one.

Definition at line 282 of file encode_gpu.cpp.

◆ open_drm_node()

int platf::open_drm_node ( const char * path,
int flags )

Open a DRM device node without becoming its DRM master.

The kernel makes whoever opens a primary node (/dev/dri/cardN) while no one holds master that device's master. Hermes never sets modes, but a master it holds keeps logind from handing the device back to the compositor when its session becomes active again: switch to a text console during a stream and back, and the compositor is locked out of that GPU until the stream ends. So drop master straight away, as logind and KWin do for the fds they open. The fd is close-on-exec, so launched apps cannot inherit it.

Parameters
pathThe device node.
flagsopen(2) flags; O_CLOEXEC is added.
Returns
An owned file descriptor, or -1 with errno set.

Definition at line 138 of file misc.cpp.

◆ open_encode_render_node()

int platf::open_encode_render_node ( bool nvenc = false)

Open the render node of the best GPU to encode a stream on.

adapter_name when it is set. Otherwise every real GPU is ranked by the video it can encode - AV1, then HEVC Main10, HEVC, H.264 - with more video memory breaking a tie, and the best one wins; for NVENC an NVIDIA GPU comes first. The capture-only Hermes-KMS node never qualifies.

Parameters
nvencWhether the stream encodes with NVENC rather than VAAPI.
Returns
An owned file descriptor, or -1.

Definition at line 80 of file encode_gpu.cpp.

◆ render_node_descriptions()

std::vector< std::string > platf::render_node_descriptions ( )

Describe every GPU render node, as encode_gpu_description() does, the capture-only Hermes-KMS node included and marked as such.

Definition at line 313 of file encode_gpu.cpp.

◆ request_user_service_stop()

bool platf::request_user_service_stop ( )

Ask the user manager to stop Hermes when Quit was selected inside its service.

Definition at line 1068 of file misc.cpp.

Variable Documentation

◆ window_system

window_system_e window_system
extern

Definition at line 92 of file misc.cpp.