PipeWire: media-session.c File Reference

PipeWire 0.3.37

Data Structures | Macros | Functions
media-session.c File Reference
Include dependency graph for media-session.c:

## Data Structures
struct | data
| user data to add to an object More...
struct | param
struct | sync
struct | impl
struct | endpoint_link
struct | link
struct | object_info
struct | registry_event

## Macros
#define | NAME "media-session"
#define | SESSION_PREFIX "media-session.d"
#define | SESSION_CONF "media-session.conf"
#define | sm_object_emit(o, m, v, ...) spa_hook_list_call(&(o)->hooks, struct sm_object_events, m, v, ##__VA_ARGS__)
#define | sm_object_emit_update(s) sm_object_emit(s, update, 0)
#define | sm_object_emit_destroy(s) sm_object_emit(s, destroy, 0)
#define | sm_object_emit_free(s) sm_object_emit(s, free, 0)
#define | sm_media_session_emit(s, m, v, ...) spa_hook_list_call(&(s)->hooks, struct sm_media_session_events, m, v, ##__VA_ARGS__)
#define | sm_media_session_emit_info(s, i) sm_media_session_emit(s, info, 0, i)
#define | sm_media_session_emit_create(s, obj) sm_media_session_emit(s, create, 0, obj)
#define | sm_media_session_emit_remove(s, obj) sm_media_session_emit(s, remove, 0, obj)
#define | sm_media_session_emit_rescan(s, seq) sm_media_session_emit(s, rescan, 0, seq)
#define | sm_media_session_emit_shutdown(s) sm_media_session_emit(s, shutdown, 0)
#define | sm_media_session_emit_destroy(s) sm_media_session_emit(s, destroy, 0)
#define | sm_media_session_emit_seat_active(s, ...) sm_media_session_emit(s, seat_active, 0, __VA_ARGS__)
#define | sm_media_session_emit_dbus_disconnected(s) sm_media_session_emit(s, dbus_disconnected, 0)

## Functions
int | sm_access_flatpak_start (struct sm_media_session *sess)
int | sm_access_portal_start (struct sm_media_session *sess)
int | sm_default_nodes_start (struct sm_media_session *sess)
int | sm_default_profile_start (struct sm_media_session *sess)
int | sm_default_routes_start (struct sm_media_session *sess)
int | sm_restore_stream_start (struct sm_media_session *sess)
int | sm_streams_follow_default_start (struct sm_media_session *sess)
int | sm_alsa_no_dsp_start (struct sm_media_session *sess)
int | sm_alsa_midi_start (struct sm_media_session *sess)
int | sm_v4l2_monitor_start (struct sm_media_session *sess)
int | sm_libcamera_monitor_start (struct sm_media_session *sess)
int | sm_bluez5_monitor_start (struct sm_media_session *sess)
int | sm_bluez5_autoswitch_start (struct sm_media_session *sess)
int | sm_alsa_monitor_start (struct sm_media_session *sess)
int | sm_suspend_node_start (struct sm_media_session *sess)
int | sm_policy_node_start (struct sm_media_session *sess)
int | sm_session_manager_start (struct sm_media_session *sess)
void * | sm_object_add_data (struct sm_object *obj, const char *id, size_t size)
void * | sm_object_get_data (struct sm_object *obj, const char *id)
int | sm_object_remove_data (struct sm_object *obj, const char *id)
int | sm_object_destroy (struct sm_object *obj)
int | sm_object_sync_update (struct sm_object *obj)
int | sm_object_add_listener (struct sm_object *obj, struct spa_hook *listener, const struct sm_object_events *events, void *data)
int | sm_media_session_add_listener (struct sm_media_session *sess, struct spa_hook *listener, const struct sm_media_session_events *events, void *data)
struct sm_object * | sm_media_session_find_object (struct sm_media_session *sess, uint32_t id)
int | sm_media_session_destroy_object (struct sm_media_session *sess, uint32_t id)
int | sm_media_session_for_each_object (struct sm_media_session *sess, int(*callback)(void *data, struct sm_object *object), void *data)
int | sm_media_session_schedule_rescan (struct sm_media_session *sess)
int | sm_media_session_sync (struct sm_media_session *sess, void(*callback)(void *data), void *data)
int | sm_media_session_roundtrip (struct sm_media_session *sess)
struct pw_proxy * | sm_media_session_export (struct sm_media_session *sess, const char *type, const struct spa_dict *props, void *object, size_t user_data_size)
struct sm_node * | sm_media_session_export_node (struct sm_media_session *sess, const struct spa_dict *props, struct pw_impl_node *object)
struct sm_device * | sm_media_session_export_device (struct sm_media_session *sess, const struct spa_dict *props, struct spa_device *object)
struct pw_proxy * | sm_media_session_create_object (struct sm_media_session *sess, const char *factory_name, const char *type, uint32_t version, const struct spa_dict *props, size_t user_data_size)
struct sm_node * | sm_media_session_create_node (struct sm_media_session *sess, const char *factory_name, const struct spa_dict *props)
int | sm_media_session_create_links (struct sm_media_session *sess, const struct spa_dict *dict)
int | sm_media_session_remove_links (struct sm_media_session *sess, const struct spa_dict *dict)
int | sm_media_session_load_conf (struct sm_media_session *sess, const char *name, struct pw_properties *conf)
int | sm_media_session_load_state (struct sm_media_session *sess, const char *name, struct pw_properties *props)
int | sm_media_session_save_state (struct sm_media_session *sess, const char *name, const struct pw_properties *props)
char * | sm_media_session_sanitize_name (char *name, int size, char sub, const char *fmt,...)
char * | sm_media_session_sanitize_description (char *name, int size, char sub, const char *fmt,...)
int | sm_media_session_seat_active_changed (struct sm_media_session *sess, bool active)
int | main (int argc, char *argv[])

## Macro Definition Documentation

## ◆ NAME

#define NAME "media-session"

## ◆ SESSION_CONF

#define SESSION_CONF "media-session.conf"

## ◆ SESSION_PREFIX

#define SESSION_PREFIX "media-session.d"

## ◆ sm_media_session_emit

#define sm_media_session_emit | ( |  | s,
|  |  | m,
|  |  | v,
|  |  | ...
| ) |  | spa_hook_list_call(&(s)->hooks, struct sm_media_session_events, m, v, ##__VA_ARGS__)

## ◆ sm_media_session_emit_create

#define sm_media_session_emit_create | ( |  | s,
|  |  | obj
| ) |  | sm_media_session_emit(s, create, 0, obj)

## ◆ sm_media_session_emit_dbus_disconnected

#define sm_media_session_emit_dbus_disconnected | ( |  | s | ) | sm_media_session_emit(s, dbus_disconnected, 0)

## ◆ sm_media_session_emit_destroy

#define sm_media_session_emit_destroy | ( |  | s | ) | sm_media_session_emit(s, destroy, 0)

## ◆ sm_media_session_emit_info

#define sm_media_session_emit_info | ( |  | s,
|  |  | i
| ) |  | sm_media_session_emit(s, info, 0, i)

## ◆ sm_media_session_emit_remove

#define sm_media_session_emit_remove | ( |  | s,
|  |  | obj
| ) |  | sm_media_session_emit(s, remove, 0, obj)

## ◆ sm_media_session_emit_rescan

#define sm_media_session_emit_rescan | ( |  | s,
|  |  | seq
| ) |  | sm_media_session_emit(s, rescan, 0, seq)

## ◆ sm_media_session_emit_seat_active

#define sm_media_session_emit_seat_active | ( |  | s,
|  |  | ...
| ) |  | sm_media_session_emit(s, seat_active, 0, __VA_ARGS__)

## ◆ sm_media_session_emit_shutdown

#define sm_media_session_emit_shutdown | ( |  | s | ) | sm_media_session_emit(s, shutdown, 0)

## ◆ sm_object_emit

#define sm_object_emit | ( |  | o,
|  |  | m,
|  |  | v,
|  |  | ...
| ) |  | spa_hook_list_call(&(o)->hooks, struct sm_object_events, m, v, ##__VA_ARGS__)

## ◆ sm_object_emit_destroy

#define sm_object_emit_destroy | ( |  | s | ) | sm_object_emit(s, destroy, 0)

## ◆ sm_object_emit_free

#define sm_object_emit_free | ( |  | s | ) | sm_object_emit(s, free, 0)

## ◆ sm_object_emit_update

#define sm_object_emit_update | ( |  | s | ) | sm_object_emit(s, update, 0)

## Function Documentation

## ◆ main()

int main | ( | int | argc,
|  | char * | argv[]
| ) |  |

References impl::conf, impl::modules, pw_conf_load_conf(), pw_get_library_version(), pw_init(), PW_KEY_CONFIG_NAME, PW_KEY_CONFIG_PREFIX, pw_properties_get(), pw_properties_new(), pw_properties_update_string(), impl::seat_active, SESSION_CONF, SESSION_PREFIX, and impl::this.

## ◆ sm_access_flatpak_start()

int sm_access_flatpak_start | ( | struct sm_media_session * | sess | ) |

References impl::client_list, impl::listener, impl::session, sm_media_session_add_listener(), and spa_list_init().

## ◆ sm_access_portal_start()

int sm_access_portal_start | ( | struct sm_media_session * | sess | ) |

References impl::client_list, impl::session, and spa_list_init().

## ◆ sm_alsa_midi_start()

int sm_alsa_midi_start | ( | struct sm_media_session * | sess | ) |

References DEFAULT_NAME, impl::listener, name, impl::props, pw_properties_get(), pw_properties_new(), impl::session, sm_media_session_add_listener(), SPA_KEY_FACTORY_NAME, SPA_KEY_NODE_NAME, and SPA_NAME_API_ALSA_SEQ_BRIDGE.

## ◆ sm_alsa_monitor_start()

int sm_alsa_monitor_start | ( | struct sm_media_session * | sess | ) |

References impl::conf, impl::props, pw_log_info, pw_properties_get(), pw_properties_new(), pw_properties_update_string(), impl::session, SESSION_CONF, sm_media_session_load_conf(), and spa_strerror.

## ◆ sm_alsa_no_dsp_start()

int sm_alsa_no_dsp_start | ( | struct sm_media_session * | sess | ) |

References KEY_NAME, and pw_properties_set().

## ◆ sm_bluez5_autoswitch_start()

int sm_bluez5_autoswitch_start | ( | struct sm_media_session * | sess | ) |

References impl::context, impl::listener, impl::properties, pw_log_info, pw_properties_new(), impl::session, SESSION_KEY, sm_media_session_add_listener(), sm_media_session_load_state(), and spa_strerror.

## ◆ sm_bluez5_monitor_start()

int sm_bluez5_monitor_start | ( | struct sm_media_session * | sess | ) |

References impl::conf, impl::device_list, impl::props, pw_log_info, pw_properties_get(), pw_properties_new(), pw_properties_set(), pw_properties_update_string(), impl::seat_active, impl::session, SESSION_CONF, impl::session_listener, sm_media_session_add_listener(), sm_media_session_load_conf(), spa_list_init(), and spa_strerror.

## ◆ sm_default_nodes_start()

int sm_default_nodes_start | ( | struct sm_media_session * | sess | ) |

References impl::context, impl::listener, impl::properties, pw_log_info, pw_properties_new(), impl::session, SESSION_KEY, sm_media_session_add_listener(), sm_media_session_load_state(), and spa_strerror.

## ◆ sm_default_profile_start()

int sm_default_profile_start | ( | struct sm_media_session * | sess | ) |

References impl::context, impl::properties, pw_properties_get(), pw_properties_new(), impl::restore_bluetooth, and impl::session.

## ◆ sm_default_routes_start()

int sm_default_routes_start | ( | struct sm_media_session * | sess | ) |

References impl::context, impl::listener, pw_log_info, pw_properties_new(), impl::session, SESSION_KEY, sm_media_session_add_listener(), sm_media_session_load_state(), spa_strerror, and impl::to_restore.

## ◆ sm_libcamera_monitor_start()

int sm_libcamera_monitor_start | ( | struct sm_media_session * | sess | ) |

References impl::context, impl::device_list, impl::handle, impl::listener, impl::monitor, pw_context_load_spa_handle(), pw_log_error, impl::session, spa_device_add_listener, spa_handle_get_interface, spa_list_init(), SPA_NAME_API_LIBCAMERA_ENUM_CLIENT, and SPA_TYPE_INTERFACE_Device.

## ◆ sm_media_session_add_listener()

int sm_media_session_add_listener | ( | struct sm_media_session * | sess,
|  | struct spa_hook * | listener,
|  | const struct sm_media_session_events * | events,
|  | void * | data
| ) |  |

References impl::hooks, impl::object_list, sm_media_session_emit_create, SPA_CONTAINER_OF, spa_hook_list_isolate(), spa_hook_list_join(), SPA_ID_INVALID, and spa_list_for_each.

Referenced by sm_access_flatpak_start(), sm_alsa_endpoint_start(), sm_alsa_midi_start(), sm_bluez5_autoswitch_start(), sm_bluez5_endpoint_start(), sm_bluez5_monitor_start(), sm_default_nodes_start(), sm_default_routes_start(), sm_media_session_export_metadata(), sm_policy_ep_start(), sm_session_manager_start(), sm_stream_endpoint_start(), sm_suspend_node_start(), and sm_v4l2_endpoint_start().

## ◆ sm_media_session_create_links()

int sm_media_session_create_links | ( | struct sm_media_session * | sess,
|  | const struct spa_dict * | dict
| ) |  |

References PW_KEY_LINK_OUTPUT_NODE, sm_media_session_roundtrip(), SPA_CONTAINER_OF, and spa_dict_lookup().

## ◆ sm_media_session_create_node()

struct sm_node * sm_media_session_create_node | ( | struct sm_media_session * | sess,
|  | const char * | factory_name,
|  | const struct spa_dict * | props
| ) |  |

References NAME, pw_log_debug, and SPA_CONTAINER_OF.

## ◆ sm_media_session_create_object()

struct pw_proxy * sm_media_session_create_object | ( | struct sm_media_session * | sess,
|  | const char * | factory_name,
|  | const char * | type,
|  | uint32_t | version,
|  | const struct spa_dict * | props,
|  | size_t | user_data_size
| ) |  |

References SPA_CONTAINER_OF.

## ◆ sm_media_session_destroy_object()

int sm_media_session_destroy_object | ( | struct sm_media_session * | sess,
|  | uint32_t | id
| ) |  |

References pw_registry_destroy, impl::registry, and SPA_CONTAINER_OF.

## ◆ sm_media_session_export()

struct pw_proxy * sm_media_session_export | ( | struct sm_media_session * | sess,
|  | const char * | type,
|  | const struct spa_dict * | props,
|  | void * | object,
|  | size_t | user_data_size
| ) |  |

References impl::monitor_core, NAME, props, pw_core_export(), pw_log_debug, and SPA_CONTAINER_OF.

Referenced by sm_media_session_export_metadata().

## ◆ sm_media_session_export_device()

struct sm_device * sm_media_session_export_device | ( | struct sm_media_session * | sess,
|  | const struct spa_dict * | props,
|  | struct spa_device * | object
| ) |  |

References impl::monitor_core, NAME, props, pw_core_export(), pw_log_debug, SPA_CONTAINER_OF, and SPA_TYPE_INTERFACE_Device.

## ◆ sm_media_session_export_node()

struct sm_node * sm_media_session_export_node | ( | struct sm_media_session * | sess,
|  | const struct spa_dict * | props,
|  | struct pw_impl_node * | object
| ) |  |

References impl::monitor_core, NAME, props, pw_core_export(), pw_log_debug, PW_TYPE_INTERFACE_Node, and SPA_CONTAINER_OF.

## ◆ sm_media_session_find_object()

struct sm_object * sm_media_session_find_object | ( | struct sm_media_session * | sess,
|  | uint32_t | id
| ) |  |

References SPA_CONTAINER_OF.

## ◆ sm_media_session_for_each_object()

int sm_media_session_for_each_object | ( | struct sm_media_session * | sess,
|  | int(*)(void *data, struct sm_object *object) | callback,
|  | void * | data
| ) |  |

References impl::object_list, SPA_CONTAINER_OF, SPA_ID_INVALID, and spa_list_for_each.

## ◆ sm_media_session_load_conf()

int sm_media_session_load_conf | ( | struct sm_media_session * | sess,
|  | const char * | name,
|  | struct pw_properties * | conf
| ) |  |

References name, pw_conf_load_conf(), and SESSION_PREFIX.

Referenced by sm_alsa_monitor_start(), sm_bluez5_monitor_start(), and sm_v4l2_monitor_start().

## ◆ sm_media_session_load_state()

int sm_media_session_load_state | ( | struct sm_media_session * | sess,
|  | const char * | name,
|  | struct pw_properties * | props
| ) |  |

References name, props, pw_conf_load_state(), and SESSION_PREFIX.

Referenced by sm_bluez5_autoswitch_start(), sm_default_nodes_start(), and sm_default_routes_start().

## ◆ sm_media_session_remove_links()

int sm_media_session_remove_links | ( | struct sm_media_session * | sess,
|  | const struct spa_dict * | dict
| ) |  |

References PW_KEY_LINK_OUTPUT_NODE, SPA_CONTAINER_OF, and spa_dict_lookup().

## ◆ sm_media_session_roundtrip()

int sm_media_session_roundtrip | ( | struct sm_media_session * | sess | ) |

References pw_loop::loop, impl::policy_core, sm_media_session_sync(), SPA_CONTAINER_OF, and impl::this.

Referenced by sm_media_session_create_links().

## ◆ sm_media_session_sanitize_description()

char * sm_media_session_sanitize_description | ( | char * | name,
|  | int | size,
|  | char | sub,
|  | const char * | fmt,
|  |  | ...
| ) |  |

References name.

## ◆ sm_media_session_sanitize_name()

char * sm_media_session_sanitize_name | ( | char * | name,
|  | int | size,
|  | char | sub,
|  | const char * | fmt,
|  |  | ...
| ) |  |

References name.

## ◆ sm_media_session_save_state()

int sm_media_session_save_state | ( | struct sm_media_session * | sess,
|  | const char * | name,
|  | const struct pw_properties * | props
| ) |  |

References name, props, pw_conf_save_state(), and SESSION_PREFIX.

## ◆ sm_media_session_schedule_rescan()

int sm_media_session_schedule_rescan | ( | struct sm_media_session * | sess | ) |

References impl::last_seq, impl::policy_core, pw_core_sync, impl::rescan_pending, impl::rescan_seq, impl::scanning, and SPA_CONTAINER_OF.

## ◆ sm_media_session_seat_active_changed()

int sm_media_session_seat_active_changed | ( | struct sm_media_session * | sess,
|  | bool | active
| ) |  |

References impl::seat_active, sm_media_session_emit_seat_active, and SPA_CONTAINER_OF.

## ◆ sm_media_session_sync()

int sm_media_session_sync | ( | struct sm_media_session * | sess,
|  | void(*)(void *data) | callback,
|  | void * | data
| ) |  |

References sync::callback, sync::data, impl::last_seq, sync::link, impl::policy_core, pw_core_sync, sync::seq, SPA_CONTAINER_OF, spa_list_append, and impl::sync_list.

Referenced by sm_media_session_roundtrip().

## ◆ sm_object_add_data()

void * sm_object_add_data | ( | struct sm_object * | obj,
|  | const char * | id,
|  | size_t | size
| ) |  |

## ◆ sm_object_add_listener()

int sm_object_add_listener | ( | struct sm_object * | obj,
|  | struct spa_hook * | listener,
|  | const struct sm_object_events * | events,
|  | void * | data
| ) |  |

References spa_hook_list_append().

## ◆ sm_object_destroy()

int sm_object_destroy | ( | struct sm_object * | obj | ) |

## ◆ sm_object_get_data()

void * sm_object_get_data | ( | struct sm_object * | obj,
|  | const char * | id
| ) |  |

## ◆ sm_object_remove_data()

int sm_object_remove_data | ( | struct sm_object * | obj,
|  | const char * | id
| ) |  |

## ◆ sm_object_sync_update()

int sm_object_sync_update | ( | struct sm_object * | obj | ) |

References pw_log_debug, and pw_proxy_sync().

## ◆ sm_policy_node_start()

int sm_policy_node_start | ( | struct sm_media_session * | sess | ) |

References impl::context, DEFAULT_AUDIO_SINK, DEFAULT_AUDIO_SINK_KEY, DEFAULT_AUDIO_SOURCE, DEFAULT_AUDIO_SOURCE_KEY, DEFAULT_CONFIG_AUDIO_SINK_KEY, DEFAULT_CONFIG_AUDIO_SOURCE_KEY, DEFAULT_CONFIG_VIDEO_SOURCE_KEY, DEFAULT_VIDEO_SOURCE, DEFAULT_VIDEO_SOURCE_KEY, impl::defaults, NAME, pw_properties_get(), impl::sample_rate, impl::session, and impl::streams_follow_default.

## ◆ sm_restore_stream_start()

int sm_restore_stream_start | ( | struct sm_media_session * | sess | ) |

References impl::context, impl::metadata, impl::metadata_listener, impl::props, pw_properties_new(), impl::session, and sm_media_session_export_metadata().

## ◆ sm_session_manager_start()

int sm_session_manager_start | ( | struct sm_media_session * | sess | ) |

References impl::context, impl::listener, impl::session, and sm_media_session_add_listener().

## ◆ sm_streams_follow_default_start()

int sm_streams_follow_default_start | ( | struct sm_media_session * | sess | ) |

References KEY_NAME, and pw_properties_set().

## ◆ sm_suspend_node_start()

int sm_suspend_node_start | ( | struct sm_media_session * | sess | ) |

References impl::context, impl::listener, impl::node_list, impl::session, sm_media_session_add_listener(), and spa_list_init().

## ◆ sm_v4l2_monitor_start()

int sm_v4l2_monitor_start | ( | struct sm_media_session * | sess | ) |

References impl::conf, impl::context, impl::device_list, impl::handle, impl::listener, impl::monitor, pw_context_load_spa_handle(), pw_log_error, pw_log_info, pw_properties_new(), impl::session, SESSION_CONF, sm_media_session_load_conf(), spa_device_add_listener, spa_handle_get_interface, spa_list_init(), SPA_NAME_API_V4L2_ENUM_UDEV, spa_strerror, and SPA_TYPE_INTERFACE_Device.

## Variable Documentation

## ◆ desc

const char* desc

## ◆ name

const char* name

Referenced by pw_conf_load_conf(), pw_conf_load_state(), pw_context_create_core(), pw_context_create_device(), pw_context_create_factory(), pw_context_create_metadata(), pw_context_create_node(), pw_context_find_factory(), pw_context_find_protocol(), pw_protocol_new(), sm_alsa_midi_start(), sm_media_session_export_metadata(), sm_media_session_load_conf(), sm_media_session_load_state(), sm_media_session_sanitize_description(), sm_media_session_sanitize_name(), sm_media_session_save_state(), spa_debug_format(), spa_debug_type_find_type(), and spa_debug_type_short_name().

## ◆ props

const char* props

Referenced by pipewire__module_init(), pw_core_export(), pw_filter_add_port(), pw_filter_new_simple(), pw_loop_new(), pw_mempool_new(), pw_properties_add(), pw_properties_add_keys(), pw_properties_update(), pw_properties_update_keys(), pw_properties_update_string(), pw_stream_connect(), pw_stream_new_simple(), sm_media_session_export(), sm_media_session_export_device(), sm_media_session_export_node(), sm_media_session_load_state(), sm_media_session_save_state(), spa_thread_utils_create(), and spa_thread_utils_get_rt_range().

## ◆ start

int(* start) (struct sm_media_session *sess) | ( | struct sm_media_session * | sess | ) |

Referenced by spa_pod_find_prop(), and spa_pod_object_find_prop().