1#ifndef PIPEWIRE_COMMON_HPP_b6f55dc83d84
2#define PIPEWIRE_COMMON_HPP_b6f55dc83d84
9#include <spa/param/audio/format-utils.h>
10#include <spa/debug/types.h>
11#include <pipewire/pipewire.h>
14template<
typename T, auto delete_func>
16template<
typename T, auto delete_func>
39 spa_hook_remove(&
hook);
52 pw_thread_loop_lock(
l);
55 pw_thread_loop_unlock(
l);
76#if !PW_CHECK_VERSION(0, 3, 49)
77 std::lock_guard<std::mutex> l(
mut);
89#if !PW_CHECK_VERSION(0, 3, 49)
90 std::lock_guard<std::mutex> l(
mut);
93 pw_init(
nullptr,
nullptr);
99#if !PW_CHECK_VERSION(0, 3, 49)
137 spa_audio_format format_map[] = {
138 SPA_AUDIO_FORMAT_UNKNOWN,
140 SPA_AUDIO_FORMAT_S16,
141 SPA_AUDIO_FORMAT_S24,
142 SPA_AUDIO_FORMAT_S32,
145 return bps < std::size(format_map) ? format_map[bps] : SPA_AUDIO_FORMAT_UNKNOWN;
150 case SPA_AUDIO_FORMAT_S8:
return 1;
151 case SPA_AUDIO_FORMAT_S16:
return 2;
152 case SPA_AUDIO_FORMAT_S24:
return 3;
153 case SPA_AUDIO_FORMAT_S32:
return 4;
160 case SPA_VIDEO_FORMAT_RGBA:
161 case SPA_VIDEO_FORMAT_RGBx:
162 case SPA_VIDEO_FORMAT_BGRA:
163 case SPA_VIDEO_FORMAT_BGRx:
165 case SPA_VIDEO_FORMAT_RGB:
167 case SPA_VIDEO_FORMAT_BGR:
169 case SPA_VIDEO_FORMAT_UYVY:
171 case SPA_VIDEO_FORMAT_YUY2:
181 return SPA_VIDEO_FORMAT_RGBA;
183 return SPA_VIDEO_FORMAT_RGB;
185 return SPA_VIDEO_FORMAT_BGR;
187 return SPA_VIDEO_FORMAT_UYVY;
189 return SPA_VIDEO_FORMAT_UNKNOWN;
193#if !PW_CHECK_VERSION(0, 3, 64)
194# define STREAM_TARGET_PROPERTY_KEY PW_KEY_NODE_TARGET
196# define STREAM_TARGET_PROPERTY_KEY PW_KEY_TARGET_OBJECT
199#ifndef PW_KEY_NODE_RATE
200# define PW_KEY_NODE_RATE "node.rate"
pipewire_init_guard & operator=(pipewire_init_guard &)=delete
pipewire_init_guard(pipewire_init_guard &)=delete
pipewire_init_guard & operator=(pipewire_init_guard &&o)
pipewire_init_guard(pipewire_init_guard &&o)
pipewire_init_guard()=default
~pipewire_thread_loop_lock_guard()
pipewire_thread_loop_lock_guard(pipewire_thread_loop_lock_guard &)=delete
pipewire_thread_loop_lock_guard & operator=(pipewire_thread_loop_lock_guard &)=delete
pipewire_thread_loop_lock_guard(pw_thread_loop *loop)
void print_devices(std::string_view media_class)
codec_t uv_codec_from_pw_fmt(spa_video_format fmt)
std::unique_ptr< T, raii_deleter_helper< T, delete_func > > raii_uniq_handle
raii_uniq_proxy_handle< pw_registry > pw_registry_uniq
raii_uniq_handle< pw_stream, pw_stream_destroy > pw_stream_uniq
spa_video_format pw_fmt_from_uv_codec(codec_t codec)
raii_uniq_handle< pw_main_loop, pw_main_loop_destroy > pw_main_loop_uniq
spa_audio_format get_pw_format_from_bps(unsigned bps)
std::vector< Pipewire_device > get_pw_device_list()
std::unique_ptr< T, raii_proxy_deleter_helper< T > > raii_uniq_proxy_handle
raii_uniq_handle< pw_context, pw_context_destroy > pw_context_uniq
bool initialize_pw_common(pipewire_state_common &s, int fd=-1)
unsigned get_bps_from_pw_format(spa_audio_format fmt)
raii_uniq_handle< pw_core, pw_core_disconnect > pw_core_uniq
raii_uniq_handle< pw_thread_loop, pw_thread_loop_destroy > pw_thread_loop_uniq
pw_context_uniq pipewire_context
pw_thread_loop_uniq pipewire_loop
pw_core_uniq pipewire_core
pipewire_init_guard init_guard
spa_hook_uniq core_listener
spa_hook_uniq(spa_hook_uniq &)=delete
spa_hook_uniq & operator=(spa_hook_uniq &)=delete
This file contains some common data types.
@ YUYV
YCbCr 422 8-bit - Y0 Cb Y1 Cr.
@ RGB
RGB 8-bit (packed into 24-bit word)
@ UYVY
YCbCr 422 8-bit - Cb Y0 Cr Y1.
@ VIDEO_CODEC_NONE
dummy color spec
@ RGBA
RGBA 8-bit, big-endian.