Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
matanui159 committed Jul 10, 2021
1 parent 403d27b commit 7fe53f1
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 21 deletions.
13 changes: 7 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ add_custom_target(clang-format
)

# Install binary
option(RS_SETUID "Enable the SETUID permission" ON)
option(RS_SETUID "Enable the SETUID permission" OFF)
set(permissions
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
Expand All @@ -226,8 +226,9 @@ install(TARGETS ${binary} DESTINATION bin PERMISSIONS ${permissions})
# Install config
install(FILES sys/replay-sorcery.conf DESTINATION etc)

# Install service
set(RS_SYSTEMD_DIR /usr/lib/systemd/user CACHE STRING "Where to install the systemd service")
set(service replay-sorcery.service)
configure_file(sys/${service}.in ${service})
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${service}" DESTINATION "${RS_SYSTEMD_DIR}")
# Install services
set(RS_SYSTEMD_DIR /usr/lib/systemd CACHE STRING "Where to install the systemd services")
configure_file(sys/replay-sorcery.service.in replay-sorcery.service)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/replay-sorcery.service" DESTINATION "${RS_SYSTEMD_DIR}/user")
configure_file(sys/replay-sorcery-kms.service.in replay-sorcery-kms.service)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/replay-sorcery-kms.service" DESTINATION "${RS_SYSTEMD_DIR}/system")
48 changes: 42 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ I wanted something like this for Linux...
I got tired waiting for someone else to do it.

# Documentation
- [Installing](#installing)
- [Arch](#arch)
- [Building from Source](#building-from-source)
- [Required Dependencies](#required-dependencies)
- [Optional Dependencies](#optional-dependencies)
- [Running](#running)
- [Configuration](#configuration)
- [Hardware Acceleration](#hardware-acceleration)
- [Using `replay-sorcery-kms`](#using-replay-sorcery-kms)
- [Using `RS_SETUID`](#using-rs_setuid)
- [nVidia Support](#nvidia-support)
- [Wayland Support](#wayland-support)

## Installing
### Arch
There is an official AUR package that gets updated from the CI (thanks to [Bennett Hardwick](https://github.com/bennetthardwick)): [replay-sorcery](https://aur.archlinux.org/packages/replay-sorcery).
Expand All @@ -24,9 +37,9 @@ $ sudo make -C bin install
### Required dependencies
- CMake
- FFmpeg
- X11

### Optional dependencies
- Xlib (for the keyboard shortcut on X11)
- PulseAudio (for audio recording)
- `libdrm` (for listing `kms` devices)

Expand All @@ -47,11 +60,6 @@ You can also use systemd to look at the output:
$ journalctl --user -fu replay-sorcery
```

The service runs as root using the `SETUID` permission since this is needed if you enable hardware acceleration. If this causes issues, you can disable it with `-DRS_SETUID=OFF` in CMake:
```
$ cmake -B bin -DRS_SETUID=OFF
```

## Configuration
The config file location and options has completely changed since version 0.3.x

Expand All @@ -61,6 +69,34 @@ There are two config files:

See [`sys/replay-sorcery.conf`](sys/replay-sorcery.conf) for the default values along with documentation. This file is installed into the global config file location.

## Hardware Acceleration
### Using `replay-sorcery-kms`
Due to hardware acceleration requiring root permissions, the recommended way of enabling hardware acceleration is by using the KMS service. Start the service by running:
```
$ sudo systemctl enable --now replay-sorcery-kms
```

Then set `videoInput` in the configuration file to either `hwaccel` or `kms_service` and start or restart the user service as documented above.

### Using `RS_SETUID`
**NOTE: from a security perspective this is a BAD IDEA. This will be removed in a future release.**

You can able `setuid` on the user service so it can access KMS without requiring a second service. You can enable it by using the CMake option:
```
$ cmake -B bin -DRS_SETUID=ON
```

### nVidia Support
The Nouveau open source drivers are supported but sadly the proprietary nVidia drivers do not support VA-API which is currently required for hardware acceleration. In the future NVENC might be supported. Software encoding is always supported and tries to use as little CPU as possible.

## Wayland Support
Wayland screen grabbing is not currently supported, however hardware accelerated screen grabbing works fine. See above for steps for enabling that.

Wayland also does not allow listening to keyboard events unless you are the active window. To get around this you can set `controller` in the configuration file to `command` and setup a shortcut in your window manager to run:
```
$ replay-sorcery save
```

# TODO
- Support NVENC API
- Document code better
Expand Down
6 changes: 4 additions & 2 deletions src/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,10 @@ int rsSocketSend(RSSocket *sock, size_t size, const void *buffer, size_t fileCou
}

struct msghdr msg = {0};
struct iovec *iov = &(struct iovec){.iov_base = (void *)buffer, .iov_len = size};
if (size > 0) {
msg.msg_iovlen = 1;
msg.msg_iov = &(struct iovec){.iov_base = (void *)buffer, .iov_len = size};
msg.msg_iov = iov;
}
if (fileCount > 0) {
size_t filesSize = sizeof(int) * fileCount;
Expand Down Expand Up @@ -203,11 +204,12 @@ int rsSocketReceive(RSSocket *sock, size_t size, void *buffer, size_t fileCount,
}

struct msghdr msg = {0};
struct iovec *iov = &(struct iovec){.iov_base = buffer, .iov_len = size};
size_t filesSize = sizeof(int) * fileCount;
struct cmsghdr *cmsg = NULL;
if (size > 0) {
msg.msg_iovlen = 1;
msg.msg_iov = &(struct iovec){.iov_base = buffer, .iov_len = size};
msg.msg_iov = iov;
}
if (fileCount > 0) {
msg.msg_control = sock->buffer;
Expand Down
11 changes: 11 additions & 0 deletions sys/replay-sorcery-kms.service.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=ReplaySorcery KMS service

[Service]
Type=simple
ExecStart=@CMAKE_INSTALL_PREFIX@/bin/replay-sorcery kms-service
TimeoutStopSec=60
Restart=always

[Install]
WantedBy=multi-user.target
11 changes: 4 additions & 7 deletions sys/replay-sorcery.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@ traceLevel = error
# Default value: 30
recordSeconds = 30

# SET THIS VALUE TO hwaccel TO ENABLE HARDWARE ACCELERATION
# IT IS NOT ENABLED BY DEFAULT DUE TO ISSUES WITH CERTAIN COMPUTERS
# HERE BE DRAGONS AND YOUR MILEAGE MAY VARY
# The video input backend to use for video recording
# Possible values: auto, hwaccel, x11, kms
# Possible values: auto, hwaccel, x11, kms, kms_service
# Default value: auto
videoInput = auto

# The name of the input video device
# For kms, see `replay-sorcery kms-devices`
# For kms and kms_service, see `replay-sorcery kms-devices`
# Possible values: auto, or a device string
# Default value: auto
videoDevice = auto
Expand All @@ -40,7 +37,7 @@ videoHeight = auto
videoFramerate = 30

# The video encoder backend to use for video recording
# Possible values: auto, x264, openh264, vaapi
# Possible values: auto, hevc, x264, openh264, x265, vaapi_h264, vaapi_hevc
# Default value: auto
videoEncoder = auto

Expand Down Expand Up @@ -119,7 +116,7 @@ keyMods = ctrl+super
# Where to save the output file
# Possible values: a strftime formatted file path
# Default value: ~/Videos/ReplaySorcery_%F_%H-%M-%S.mp4
outputFile = ~/Videos/ReplaySorcery_%F_%H-%M-%S.mp4
outputFile = ~/Videos/ReplaySorcery/%F_%H-%M-%S.mp4

# A command to run when a video is successfully saved
# Possible values: a printf formatted command
Expand Down

0 comments on commit 7fe53f1

Please sign in to comment.