mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
media-session: add media session helpers
Move all the media-session object monitoring into one place and provide an API to get to the session objects. Make API to add module specific info to objects. Add methods to export and create objects in the session. This should make it possible to link proxy to implementation and avoid a server roundtrip in some cases.
This commit is contained in:
parent
3f3dfbc67e
commit
161cf46898
9 changed files with 1140 additions and 1054 deletions
173
src/examples/media-session/media-session.h
Normal file
173
src/examples/media-session/media-session.h
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
/* PipeWire
|
||||
*
|
||||
* Copyright © 2019 Wim Taymans
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SM_MEDIA_SESSION_H
|
||||
#define SM_MEDIA_SESSION_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct sm_media_session;
|
||||
|
||||
struct sm_object {
|
||||
uint32_t id;
|
||||
uint32_t type;
|
||||
|
||||
struct sm_media_session *session;
|
||||
|
||||
#define SM_OBJECT_CHANGE_MASK_PROPERTIES (1<<0)
|
||||
#define SM_OBJECT_CHANGE_MASK_BIND (1<<1)
|
||||
uint32_t mask; /**< monitored info */
|
||||
uint32_t avail; /**< available info */
|
||||
struct pw_properties *props; /**< global properties */
|
||||
|
||||
struct pw_proxy *proxy;
|
||||
struct spa_hook proxy_listener;
|
||||
struct spa_hook object_listener;
|
||||
pw_destroy_t destroy;
|
||||
|
||||
struct spa_list data;
|
||||
};
|
||||
|
||||
/** get user data with \a id and \a size to an object */
|
||||
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);
|
||||
|
||||
struct sm_client {
|
||||
struct sm_object obj;
|
||||
|
||||
#define SM_CLIENT_CHANGE_MASK_INFO (1<<0)
|
||||
#define SM_CLIENT_CHANGE_MASK_PERMISSIONS (1<<1)
|
||||
uint32_t mask; /**< monitored info */
|
||||
uint32_t avail; /**< available info */
|
||||
uint32_t changed; /**< changed since last update */
|
||||
struct pw_client_info *info;
|
||||
};
|
||||
|
||||
struct sm_node {
|
||||
struct sm_object obj;
|
||||
|
||||
#define SM_NODE_CHANGE_MASK_INFO (1<<0)
|
||||
#define SM_NODE_CHANGE_MASK_PORTS (1<<1)
|
||||
uint32_t mask; /**< monitored info */
|
||||
uint32_t avail; /**< available info */
|
||||
uint32_t changed; /**< changed since last update */
|
||||
struct pw_node_info *info;
|
||||
struct spa_list port_list;
|
||||
};
|
||||
|
||||
struct sm_port {
|
||||
struct sm_object obj;
|
||||
|
||||
enum pw_direction direction;
|
||||
struct sm_node *node;
|
||||
struct spa_list link; /**< link in node port_list */
|
||||
|
||||
#define SM_PORT_CHANGE_MASK_INFO (1<<0)
|
||||
uint32_t mask; /**< monitored info */
|
||||
uint32_t avail; /**< available info */
|
||||
uint32_t changed; /**< changed since last update */
|
||||
struct pw_port_info *info;
|
||||
};
|
||||
|
||||
struct sm_endpoint {
|
||||
struct sm_object obj;
|
||||
|
||||
int32_t priority;
|
||||
|
||||
#define SM_ENDPOINT_CHANGE_MASK_INFO (1<<0)
|
||||
#define SM_ENDPOINT_CHANGE_MASK_STREAMS (1<<1)
|
||||
uint32_t mask; /**< monitored info */
|
||||
uint32_t avail; /**< available info */
|
||||
uint32_t changed; /**< changed since last update */
|
||||
struct pw_endpoint_info *info;
|
||||
struct spa_list stream_list;
|
||||
};
|
||||
|
||||
struct sm_endpoint_stream {
|
||||
struct sm_object obj;
|
||||
|
||||
int32_t priority;
|
||||
|
||||
struct sm_endpoint *endpoint;
|
||||
struct spa_list link; /**< link in endpoint stream_list */
|
||||
|
||||
#define SM_STREAM_CHANGE_MASK_INFO (1<<0)
|
||||
uint32_t mask; /**< monitored info */
|
||||
uint32_t avail; /**< available info */
|
||||
uint32_t changed; /**< changed since last update */
|
||||
struct pw_endpoint_stream_info *info;
|
||||
};
|
||||
|
||||
struct sm_endpoint_link {
|
||||
struct sm_object obj;
|
||||
|
||||
struct spa_list link;
|
||||
|
||||
uint32_t mask; /**< monitored info */
|
||||
uint32_t avail; /**< available info */
|
||||
uint32_t changed; /**< changed since last update */
|
||||
struct pw_endpoint_link_info *info;
|
||||
};
|
||||
|
||||
struct sm_media_session_events {
|
||||
#define SM_VERSION_MEDIA_SESSION_EVENTS 0
|
||||
uint32_t version;
|
||||
|
||||
void (*update) (void *data, struct sm_object *object);
|
||||
void (*remove) (void *data, struct sm_object *object);
|
||||
|
||||
void (*rescan) (void *data, int seq);
|
||||
};
|
||||
|
||||
struct sm_media_session {
|
||||
struct pw_main_loop *loop;
|
||||
struct pw_core *core;
|
||||
|
||||
struct pw_session_info info;
|
||||
};
|
||||
|
||||
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_schedule_rescan(struct sm_media_session *sess);
|
||||
|
||||
struct pw_proxy *sm_media_session_export(struct sm_media_session *sess,
|
||||
uint32_t type, struct pw_properties *properties,
|
||||
void *object, size_t user_data_size);
|
||||
|
||||
struct pw_proxy *sm_media_session_create_object(struct sm_media_session *sess,
|
||||
const char *factory_name, uint32_t type, uint32_t version,
|
||||
const struct spa_dict *props, size_t user_data_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue