Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(jibri): support for pulseaudio #675

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ansible/build-java-jibri-oracle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
tags: "provision"

roles:
- { role: "jibri-kernel", tags: "jibri-kernel"}
- { role: "jibri-kernel", tags: "jibri-kernel", when: not jibri_pulseaudio_enabled }
- { role: "common", tags: "common"}
- { role: "boot-postinstall", tags: "boot-postinstall" }
- { role: "sshusers", tags: "ssh" }
Expand All @@ -44,6 +44,7 @@
- { role: "autoscaler-sidecar", tags: "autoscaler-sidecar",
autoscaler_instance_type: "jibri", autoscaler_install_flag: true, autoscaler_configure_flag: false, jitsi_autoscaler_sidecar: true}
- { role: "jibri-java", tags: "jibri", jibri_install_flag: true, jibri_configure_flag: false}
- { role: "pulseaudio", tags: "pulseaudio", when: jibri_pulseaudio_enabled }
- { role: "jitsi-upload-integrations", tags: "jitsi-upload-integrations",
upload_integrations_install_flag: true, upload_integrations_configure_flag: false }
- { role: "jitsi-upload-customizations", tags: "jitsi-upload-customizations",
Expand Down
16 changes: 16 additions & 0 deletions ansible/roles/jibri-java/templates/jibri.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ jibri {
recordings-directory = "{{ jibri_recordings_dir }}"
finalize-script = "{{ jibri_finalize_recording_script }}"
}
ffmpeg {
// resolution = "1920x1080"
// The audio source that will be used to capture audio on Linux
audio-source = "{{ 'pulse' if jibri_pulse_audio_enabled else 'alsa' }}"
// The audio device that will be used to capture audio on Linux
audio-device = "{{ 'default' if jibri_pulse_audio_enabled else 'plug:bsnoop' }}"
// framerate = 30
// queue-size = 4096
// streaming-max-bitrate = 2976
// Available presets: ultrafast, superfast, veryfast, faster, fast, medium,
// slow, slower, veryslow, placebo
// video-encode-preset = "veryfast"
// The range of the CRF scale is 0-51, where 0 is lossless,
// 23 is the default, and 51 is worst quality possible.
// h264-constant-rate-factor = 25
}
webhook {
subscribers = [{% if jibri_sidecar_webhook %}"{{ jibri_sidecar_webhook }}"{% endif %}{% if sip_jibri_sidecar_webhook %}{% if jibri_sidecar_webhook %},{% endif %}"{{ sip_jibri_sidecar_webhook }}"{% endif %}]
}
Expand Down
1 change: 1 addition & 0 deletions ansible/roles/pulseaudio/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
65 changes: 65 additions & 0 deletions ansible/roles/pulseaudio/files/etc-default.pa
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/pulseaudio -nF
#
# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PulseAudio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.

# This startup script is used only if PulseAudio is started per-user
# (i.e. not in system mode)

# Customized for Jibri

.fail

### Automatically restore the volume of streams and devices
load-module module-device-restore
load-module module-stream-restore
load-module module-card-restore

### Automatically augment property information from .desktop files
### stored in /usr/share/application
load-module module-augment-properties

### Should be after module-*-restore but before module-*-detect
load-module module-switch-on-port-available

### Load several protocols
load-module module-native-protocol-unix

### Automatically restore the default sink/source when changed by the user
### during runtime
### NOTE: This should be loaded as early as possible so that subsequent modules
### that look up the default sink/source get the right value
load-module module-default-device-restore

### Make sure we always have a sink around, even if it is a null sink.
load-module module-always-sink

### Honour intended role device property
load-module module-intended-roles

### Automatically suspend sinks/sources that become idle for too long
load-module module-suspend-on-idle

### If autoexit on idle is enabled we want to make sure we only quit
### when no local session needs us anymore.
#.ifexists module-console-kit.so
#load-module module-console-kit
#.endif
#.ifexists module-systemd-login.so
#load-module module-systemd-login
#.endif

### Enable positioned event sounds
load-module module-position-event-sounds
1 change: 1 addition & 0 deletions ansible/roles/pulseaudio/files/jibri-client.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
autospawn = yes
9 changes: 9 additions & 0 deletions ansible/roles/pulseaudio/files/jibri-daemon.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# daemonize = no
high-priority = no
realtime-scheduling = yes
realtime-priority = 5
exit-idle-time = -1
flat-volumes = no
deferred-volume-safety-margin-usec = 1
log-level = info
log-target = file:/var/log/jitsi/jibri/pulse.log
8 changes: 8 additions & 0 deletions ansible/roles/pulseaudio/files/jibri-default.pa
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.include /etc/pulse/default.pa

# Load the virtual sink and set it as default
load-module module-virtual-sink sink_name=jibri-loop
set-default-sink jibri-loop

# set the monitor of the jibri-loop sink to be the default source
set-default-source jibri-loop.monitor
37 changes: 37 additions & 0 deletions ansible/roles/pulseaudio/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
- name: Install pulseaudio
ansible.builtin.apt:
name: ['pulseaudio']
state: present

- name: Install /etc/pulse/default.pa
ansible.builtin.copy:
src: default.pa
dest: /etc/pulse/default.pa
owner: root
group: root
mode: 0644

- name: Install jibri pulse defaults
ansible.builtin.copy:
src: jibri-default.pa
dest: /home/jibri/.config/pulse/default.pa
owner: jibri
group: jibri
mode: 0644

- name: Install jibri pulse client config
ansible.builtin.copy:
src: jibri-client.conf
dest: /home/jibri/.config/pulse/client.conf
owner: jibri
group: jibri
mode: 0644

- name: Install jibri pulse daemon config
ansible.builtin.copy:
src: jibri-daemon.conf
dest: /home/jibri/.config/pulse/daemon.conf
owner: jibri
group: jibri
mode: 0644