blob: 79f8accbb45b46fc1869ad2c3be2b186c496685e [file] [log] [blame]
Jeremy Leconted9578362022-11-09 14:45:04 +01001#!/usr/bin/env vpython3
2# Copyright (c) 2022 The WebRTC project authors. All Rights Reserved.
3#
4# Use of this source code is governed by a BSD-style license
5# that can be found in the LICENSE file in the root of the source
6# tree. An additional intellectual property rights grant can be found
7# in the file PATENTS. All contributing project authors may
8# be found in the AUTHORS file in the root of the source tree.
9"""
10This script is a wrapper that loads "pipewire" library.
11"""
12
13import os
14import subprocess
15import sys
16
17_SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
18_SRC_DIR = os.path.dirname(_SCRIPT_DIR)
19
20
21def _GetPipeWireDir():
22 pipewire_dir = os.path.join(_SRC_DIR, 'third_party', 'pipewire',
23 'linux-amd64')
24
25 if not os.path.isdir(pipewire_dir):
26 pipewire_dir = None
27
28 return pipewire_dir
29
30
31def _ConfigurePipeWirePaths(path):
32 library_dir = os.path.join(path, 'lib64')
33 pipewire_binary_dir = os.path.join(path, 'bin')
34 pipewire_config_prefix = os.path.join(path, 'share', 'pipewire')
35 pipewire_module_dir = os.path.join(library_dir, 'pipewire-0.3')
36 spa_plugin_dir = os.path.join(library_dir, 'spa-0.2')
37 media_session_config_dir = os.path.join(pipewire_config_prefix,
38 'media-session.d')
39
40 env_vars = os.environ
41 env_vars['LD_LIBRARY_PATH'] = library_dir
42 env_vars['PIPEWIRE_CONFIG_PREFIX'] = pipewire_config_prefix
43 env_vars['PIPEWIRE_MODULE_DIR'] = pipewire_module_dir
44 env_vars['SPA_PLUGIN_DIR'] = spa_plugin_dir
45 env_vars['MEDIA_SESSION_CONFIG_DIR'] = media_session_config_dir
46 env_vars['PIPEWIRE_RUNTIME_DIR'] = '/tmp'
47 env_vars['PATH'] = env_vars['PATH'] + ':' + pipewire_binary_dir
48
49
50def main():
51 pipewire_dir = _GetPipeWireDir()
52
53 if pipewire_dir is None:
54 print('configure-pipewire: Couldn\'t find directory %s' % pipewire_dir)
55 return 1
56
57 _ConfigurePipeWirePaths(pipewire_dir)
58
59 pipewire_process = subprocess.Popen(["pipewire"], stdout=None)
60 pipewire_media_session_process = subprocess.Popen(["pipewire-media-session"],
61 stdout=None)
62
63 return_value = subprocess.call(sys.argv[1:])
64
65 pipewire_media_session_process.terminate()
66 pipewire_process.terminate()
67
68 return return_value
69
70
71if __name__ == '__main__':
72 sys.exit(main())