extensions: implement new session manager extension

This extension, implemented in module-session-manager, implements
a set of objects that are useful for session managers.
This commit is contained in:
George Kiagiadakis 2019-05-23 18:59:05 +03:00 committed by Wim Taymans
parent 44bf0baaa7
commit 1e14206c71
23 changed files with 5507 additions and 1 deletions

View file

@ -0,0 +1,329 @@
/* PipeWire
*
* Copyright © 2019 Collabora Ltd.
* @author George Kiagiadakis <george.kiagiadakis@collabora.com>
*
* 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 PIPEWIRE_EXT_SESSION_MANAGER_IMPL_INTERFACES_H
#define PIPEWIRE_EXT_SESSION_MANAGER_IMPL_INTERFACES_H
#include <spa/utils/defs.h>
#include <spa/utils/hook.h>
#include <errno.h>
#include "introspect.h"
#ifdef __cplusplus
extern "C" {
#endif
#define PW_VERSION_CLIENT_ENDPOINT_PROXY 0
struct pw_client_endpoint_proxy { struct spa_interface iface; };
#define PW_CLIENT_ENDPOINT_PROXY_EVENT_SET_ID 0
#define PW_CLIENT_ENDPOINT_PROXY_EVENT_SET_SESSION_ID 1
#define PW_CLIENT_ENDPOINT_PROXY_EVENT_SET_PARAM 2
#define PW_CLIENT_ENDPOINT_PROXY_EVENT_STREAM_SET_PARAM 3
#define PW_CLIENT_ENDPOINT_PROXY_EVENT_NUM 4
struct pw_client_endpoint_proxy_events {
#define PW_VERSION_CLIENT_ENDPOINT_PROXY_EVENTS 0
uint32_t version; /**< version of this structure */
/**
* Sets the id of the \a endpoint.
*
* On endpoint implementations, this is called by the server to notify
* the implementation of the assigned global id of the endpoint. The
* implementation is obliged to set this id in the
* #struct pw_endpoint_info \a id field. The implementation should also
* not emit the info() event before this method is called.
*
* \param endpoint a #pw_endpoint
* \param id the global id assigned to this endpoint
*
* \return 0 on success
* -EINVAL when the id has already been set
* -ENOTSUP on the server-side endpoint implementation
*/
int (*set_id) (void *endpoint, uint32_t id);
/**
* Sets the session id of the \a endpoint.
*
* On endpoints that are not session masters, this method notifies
* the implementation that it has been associated with a session.
* The implementation is obliged to set this id in the
* #struct pw_endpoint_info \a session_id field.
*
* \param endpoint a #pw_endpoint
* \param id the session id associated with this endpoint
*
* \return 0 on success
* -EINVAL when the session id has already been set
* -ENOTSUP when the endpoint is a session master
*/
int (*set_session_id) (void *endpoint, uint32_t session_id);
/**
* Set the configurable parameter in \a endpoint.
*
* Usually, \a param will be obtained from enum_params and then
* modified but it is also possible to set another spa_pod
* as long as its keys and types match a supported object.
*
* Objects with property keys that are not known are ignored.
*
* This function must be called from the main thread.
*
* \param endpoint a #struct pw_endpoint
* \param id the parameter id to configure
* \param flags additional flags
* \param param the parameter to configure
*
* \return 0 on success
* -EINVAL when \a endpoint is NULL
* -ENOTSUP when there are no parameters implemented on \a endpoint
* -ENOENT the parameter is unknown
*/
int (*set_param) (void *endpoint,
uint32_t id, uint32_t flags,
const struct spa_pod *param);
/**
* Set a parameter on \a stream_id of \a endpoint.
*
* When \a param is NULL, the parameter will be unset.
*
* This function must be called from the main thread.
*
* \param endpoint a #struct pw_endpoint
* \param stream_id the stream to configure
* \param id the parameter id to set
* \param flags optional flags
* \param param a #struct spa_pod with the parameter to set
* \return 0 on success
* 1 on success, the value of \a param might have been
* changed depending on \a flags and the final value can
* be found by doing stream_enum_params.
* -EINVAL when \a endpoint is NULL or invalid arguments are given
* -ESRCH when the type or size of a property is not correct.
* -ENOENT when the param id is not found
*/
int (*stream_set_param) (void *endpoint, uint32_t stream_id,
uint32_t id, uint32_t flags,
const struct spa_pod *param);
};
#define PW_CLIENT_ENDPOINT_PROXY_METHOD_ADD_LISTENER 0
#define PW_CLIENT_ENDPOINT_PROXY_METHOD_UPDATE 1
#define PW_CLIENT_ENDPOINT_PROXY_METHOD_STREAM_UPDATE 2
#define PW_CLIENT_ENDPOINT_PROXY_METHOD_NUM 3
struct pw_client_endpoint_proxy_methods {
#define PW_VERSION_CLIENT_ENDPOINT_PROXY_METHODS 0
uint32_t version; /**< version of this structure */
int (*add_listener) (void *object,
struct spa_hook *listener,
const struct pw_client_endpoint_proxy_events *events,
void *data);
/** Update endpoint information */
int (*update) (void *object,
#define PW_CLIENT_ENDPOINT_UPDATE_PARAMS (1 << 0)
#define PW_CLIENT_ENDPOINT_UPDATE_INFO (1 << 1)
uint32_t change_mask,
uint32_t n_params,
const struct spa_pod **params,
const struct pw_endpoint_info *info);
/** Update stream information */
int (*stream_update) (void *object,
uint32_t stream_id,
#define PW_CLIENT_ENDPOINT_STREAM_UPDATE_PARAMS (1 << 0)
#define PW_CLIENT_ENDPOINT_STREAM_UPDATE_INFO (1 << 1)
#define PW_CLIENT_ENDPOINT_STREAM_UPDATE_DESTROYED (1 << 2)
uint32_t change_mask,
uint32_t n_params,
const struct spa_pod **params,
const struct pw_endpoint_stream_info *info);
};
#define pw_client_endpoint_proxy_method(o,method,version,...) \
({ \
int _res = -ENOTSUP; \
struct pw_client_endpoint_proxy *_p = o; \
spa_interface_call_res(&_p->iface, \
struct pw_client_endpoint_proxy_methods, _res, \
method, version, ##__VA_ARGS__); \
_res; \
})
#define pw_client_endpoint_proxy_add_listener(o,...) pw_client_endpoint_proxy_method(o,add_listener,0,__VA_ARGS__)
#define pw_client_endpoint_proxy_update(o,...) pw_client_endpoint_proxy_method(o,update,0,__VA_ARGS__)
#define pw_client_endpoint_proxy_stream_update(o,...) pw_client_endpoint_proxy_method(o,stream_update,0,__VA_ARGS__)
#define PW_VERSION_CLIENT_SESSION_PROXY 0
struct pw_client_session_proxy { struct spa_interface iface; };
#define PW_CLIENT_SESSION_PROXY_EVENT_SET_ID 0
#define PW_CLIENT_SESSION_PROXY_EVENT_SET_PARAM 1
#define PW_CLIENT_SESSION_PROXY_EVENT_LINK_SET_PARAM 2
#define PW_CLIENT_SESSION_PROXY_EVENT_CREATE_LINK 3
#define PW_CLIENT_SESSION_PROXY_EVENT_DESTROY_LINK 4
#define PW_CLIENT_SESSION_PROXY_EVENT_LINK_REQUEST_STATE 5
#define PW_CLIENT_SESSION_PROXY_EVENT_NUM 6
struct pw_client_session_proxy_events {
#define PW_VERSION_CLIENT_SESSION_PROXY_EVENTS 0
uint32_t version; /**< version of this structure */
/**
* Sets the id of the \a session.
*
* On session implementations, this is called by the server to notify
* the implementation of the assigned global id of the session. The
* implementation is obliged to set this id in the
* #struct pw_session_info \a id field. The implementation should also
* not emit the info() event before this method is called.
*
* \param session a #pw_session
* \param id the global id assigned to this session
*
* \return 0 on success
* -EINVAL when the id has already been set
* -ENOTSUP on the server-side session implementation
*/
int (*set_id) (void *session, uint32_t id);
/**
* Set the configurable parameter in \a session.
*
* Usually, \a param will be obtained from enum_params and then
* modified but it is also possible to set another spa_pod
* as long as its keys and types match a supported object.
*
* Objects with property keys that are not known are ignored.
*
* This function must be called from the main thread.
*
* \param session a #struct pw_session
* \param id the parameter id to configure
* \param flags additional flags
* \param param the parameter to configure
*
* \return 0 on success
* -EINVAL when \a session is NULL
* -ENOTSUP when there are no parameters implemented on \a session
* -ENOENT the parameter is unknown
*/
int (*set_param) (void *session,
uint32_t id, uint32_t flags,
const struct spa_pod *param);
/**
* Set a parameter on \a link_id of \a session.
*
* When \a param is NULL, the parameter will be unset.
*
* This function must be called from the main thread.
*
* \param session a #struct pw_session
* \param link_id the link to configure
* \param id the parameter id to set
* \param flags optional flags
* \param param a #struct spa_pod with the parameter to set
* \return 0 on success
* 1 on success, the value of \a param might have been
* changed depending on \a flags and the final value can
* be found by doing link_enum_params.
* -EINVAL when \a session is NULL or invalid arguments are given
* -ESRCH when the type or size of a property is not correct.
* -ENOENT when the param id is not found
*/
int (*link_set_param) (void *session, uint32_t link_id,
uint32_t id, uint32_t flags,
const struct spa_pod *param);
int (*create_link) (void *session, const struct spa_dict *props);
int (*destroy_link) (void *session, uint32_t link_id);
int (*link_request_state) (void *session, uint32_t link_id, uint32_t state);
};
#define PW_CLIENT_SESSION_PROXY_METHOD_ADD_LISTENER 0
#define PW_CLIENT_SESSION_PROXY_METHOD_UPDATE 1
#define PW_CLIENT_SESSION_PROXY_METHOD_LINK_UPDATE 2
#define PW_CLIENT_SESSION_PROXY_METHOD_NUM 3
struct pw_client_session_proxy_methods {
#define PW_VERSION_CLIENT_SESSION_PROXY_METHODS 0
uint32_t version; /**< version of this structure */
int (*add_listener) (void *object,
struct spa_hook *listener,
const struct pw_client_session_proxy_events *events,
void *data);
/** Update session information */
int (*update) (void *object,
#define PW_CLIENT_SESSION_UPDATE_PARAMS (1 << 0)
#define PW_CLIENT_SESSION_UPDATE_INFO (1 << 1)
uint32_t change_mask,
uint32_t n_params,
const struct spa_pod **params,
const struct pw_session_info *info);
/** Update link information */
int (*link_update) (void *object,
uint32_t link_id,
#define PW_CLIENT_SESSION_LINK_UPDATE_PARAMS (1 << 0)
#define PW_CLIENT_SESSION_LINK_UPDATE_INFO (1 << 1)
#define PW_CLIENT_SESSION_LINK_UPDATE_DESTROYED (1 << 2)
uint32_t change_mask,
uint32_t n_params,
const struct spa_pod **params,
const struct pw_endpoint_link_info *info);
};
#define pw_client_session_proxy_method(o,method,version,...) \
({ \
int _res = -ENOTSUP; \
struct pw_client_session_proxy *_p = o; \
spa_interface_call_res(&_p->iface, \
struct pw_client_session_proxy_methods, _res, \
method, version, ##__VA_ARGS__); \
_res; \
})
#define pw_client_session_proxy_add_listener(o,...) pw_client_session_proxy_method(o,add_listener,0,__VA_ARGS__)
#define pw_client_session_proxy_update(o,...) pw_client_session_proxy_method(o,update,0,__VA_ARGS__)
#define pw_client_session_proxy_link_update(o,...) pw_client_session_proxy_method(o,link_update,0,__VA_ARGS__)
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* PIPEWIRE_EXT_SESSION_MANAGER_IMPL_INTERFACES_H */

View file

@ -0,0 +1,465 @@
/* PipeWire
*
* Copyright © 2019 Collabora Ltd.
* @author George Kiagiadakis <george.kiagiadakis@collabora.com>
*
* 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 PIPEWIRE_EXT_SESSION_MANAGER_INTERFACES_H
#define PIPEWIRE_EXT_SESSION_MANAGER_INTERFACES_H
#include <spa/utils/defs.h>
#include <spa/utils/hook.h>
#include "introspect.h"
#ifdef __cplusplus
extern "C" {
#endif
#define PW_VERSION_SESSION_PROXY 0
struct pw_session_proxy { struct spa_interface iface; };
#define PW_VERSION_ENDPOINT_PROXY 0
struct pw_endpoint_proxy { struct spa_interface iface; };
#define PW_VERSION_ENDPOINT_STREAM_PROXY 0
struct pw_endpoint_stream_proxy { struct spa_interface iface; };
#define PW_VERSION_ENDPOINT_LINK_PROXY 0
struct pw_endpoint_link_proxy { struct spa_interface iface; };
/* Session */
#define PW_SESSION_PROXY_EVENT_INFO 0
#define PW_SESSION_PROXY_EVENT_PARAM 1
#define PW_SESSION_PROXY_EVENT_NUM 2
struct pw_session_proxy_events {
#define PW_VERSION_SESSION_PROXY_EVENTS 0
uint32_t version; /**< version of this structure */
/**
* Notify session info
*
* \param info info about the session
*/
void (*info) (void *object, const struct pw_session_info *info);
/**
* Notify a session param
*
* Event emited as a result of the enum_params method.
*
* \param seq the sequence number of the request
* \param id the param id
* \param index the param index
* \param next the param index of the next param
* \param param the parameter
*/
void (*param) (void *object, int seq,
uint32_t id, uint32_t index, uint32_t next,
const struct spa_pod *param);
};
#define PW_SESSION_PROXY_METHOD_ADD_LISTENER 0
#define PW_SESSION_PROXY_METHOD_SUBSCRIBE_PARAMS 1
#define PW_SESSION_PROXY_METHOD_ENUM_PARAMS 2
#define PW_SESSION_PROXY_METHOD_SET_PARAM 3
#define PW_SESSION_PROXY_METHOD_CREATE_LINK 4
#define PW_SESSION_PROXY_METHOD_NUM 5
struct pw_session_proxy_methods {
#define PW_VERSION_SESSION_PROXY_METHODS 0
uint32_t version; /**< version of this structure */
int (*add_listener) (void *object,
struct spa_hook *listener,
const struct pw_session_proxy_events *events,
void *data);
/**
* Subscribe to parameter changes
*
* Automatically emit param events for the given ids when
* they are changed.
*
* \param ids an array of param ids
* \param n_ids the number of ids in \a ids
*/
int (*subscribe_params) (void *object, uint32_t *ids, uint32_t n_ids);
/**
* Enumerate session parameters
*
* Start enumeration of session parameters. For each param, a
* param event will be emited.
*
* \param seq a sequence number returned in the reply
* \param id the parameter id to enumerate
* \param start the start index or 0 for the first param
* \param num the maximum number of params to retrieve
* \param filter a param filter or NULL
*/
int (*enum_params) (void *object, int seq,
uint32_t id, uint32_t start, uint32_t num,
const struct spa_pod *filter);
/**
* Set a parameter on the session
*
* \param id the parameter id to set
* \param flags extra parameter flags
* \param param the parameter to set
*/
int (*set_param) (void *object, uint32_t id, uint32_t flags,
const struct spa_pod *param);
int (*create_link) (void *object, const struct spa_dict *props);
};
#define pw_session_proxy_method(o,method,version,...) \
({ \
int _res = -ENOTSUP; \
struct pw_session_proxy *_p = o; \
spa_interface_call_res(&_p->iface, \
struct pw_session_proxy_methods, _res, \
method, version, ##__VA_ARGS__); \
_res; \
})
#define pw_session_proxy_add_listener(c,...) pw_session_proxy_method(c,add_listener,0,__VA_ARGS__)
#define pw_session_proxy_subscribe_params(c,...) pw_session_proxy_method(c,subscribe_params,0,__VA_ARGS__)
#define pw_session_proxy_enum_params(c,...) pw_session_proxy_method(c,enum_params,0,__VA_ARGS__)
#define pw_session_proxy_create_link(c,...) pw_session_proxy_method(c,create_link,0,__VA_ARGS__)
/* Endpoint */
#define PW_ENDPOINT_PROXY_EVENT_INFO 0
#define PW_ENDPOINT_PROXY_EVENT_PARAM 1
#define PW_ENDPOINT_PROXY_EVENT_NUM 2
struct pw_endpoint_proxy_events {
#define PW_VERSION_ENDPOINT_PROXY_EVENTS 0
uint32_t version; /**< version of this structure */
/**
* Notify endpoint info
*
* \param info info about the endpoint
*/
void (*info) (void *object, const struct pw_endpoint_info *info);
/**
* Notify a endpoint param
*
* Event emited as a result of the enum_params method.
*
* \param seq the sequence number of the request
* \param id the param id
* \param index the param index
* \param next the param index of the next param
* \param param the parameter
*/
void (*param) (void *object, int seq,
uint32_t id, uint32_t index, uint32_t next,
const struct spa_pod *param);
};
#define PW_ENDPOINT_PROXY_METHOD_ADD_LISTENER 0
#define PW_ENDPOINT_PROXY_METHOD_SUBSCRIBE_PARAMS 1
#define PW_ENDPOINT_PROXY_METHOD_ENUM_PARAMS 2
#define PW_ENDPOINT_PROXY_METHOD_SET_PARAM 3
#define PW_ENDPOINT_PROXY_METHOD_NUM 4
struct pw_endpoint_proxy_methods {
#define PW_VERSION_ENDPOINT_PROXY_METHODS 0
uint32_t version; /**< version of this structure */
int (*add_listener) (void *object,
struct spa_hook *listener,
const struct pw_endpoint_proxy_events *events,
void *data);
/**
* Subscribe to parameter changes
*
* Automatically emit param events for the given ids when
* they are changed.
*
* \param ids an array of param ids
* \param n_ids the number of ids in \a ids
*/
int (*subscribe_params) (void *object, uint32_t *ids, uint32_t n_ids);
/**
* Enumerate endpoint parameters
*
* Start enumeration of endpoint parameters. For each param, a
* param event will be emited.
*
* \param seq a sequence number returned in the reply
* \param id the parameter id to enumerate
* \param start the start index or 0 for the first param
* \param num the maximum number of params to retrieve
* \param filter a param filter or NULL
*/
int (*enum_params) (void *object, int seq,
uint32_t id, uint32_t start, uint32_t num,
const struct spa_pod *filter);
/**
* Set a parameter on the endpoint
*
* \param id the parameter id to set
* \param flags extra parameter flags
* \param param the parameter to set
*/
int (*set_param) (void *object, uint32_t id, uint32_t flags,
const struct spa_pod *param);
};
#define pw_endpoint_proxy_method(o,method,version,...) \
({ \
int _res = -ENOTSUP; \
struct pw_endpoint_proxy *_p = o; \
spa_interface_call_res(&_p->iface, \
struct pw_endpoint_proxy_methods, _res, \
method, version, ##__VA_ARGS__); \
_res; \
})
#define pw_endpoint_proxy_add_listener(c,...) pw_endpoint_proxy_method(c,add_listener,0,__VA_ARGS__)
#define pw_endpoint_proxy_subscribe_params(c,...) pw_endpoint_proxy_method(c,subscribe_params,0,__VA_ARGS__)
#define pw_endpoint_proxy_enum_params(c,...) pw_endpoint_proxy_method(c,enum_params,0,__VA_ARGS__)
/* Endpoint Stream */
#define PW_ENDPOINT_STREAM_PROXY_EVENT_INFO 0
#define PW_ENDPOINT_STREAM_PROXY_EVENT_PARAM 1
#define PW_ENDPOINT_STREAM_PROXY_EVENT_NUM 2
struct pw_endpoint_stream_proxy_events {
#define PW_VERSION_ENDPOINT_STREAM_PROXY_EVENTS 0
uint32_t version; /**< version of this structure */
/**
* Notify endpoint stream info
*
* \param info info about the endpoint stream
*/
void (*info) (void *object, const struct pw_endpoint_stream_info *info);
/**
* Notify a endpoint stream param
*
* Event emited as a result of the enum_params method.
*
* \param seq the sequence number of the request
* \param id the param id
* \param index the param index
* \param next the param index of the next param
* \param param the parameter
*/
void (*param) (void *object, int seq,
uint32_t id, uint32_t index, uint32_t next,
const struct spa_pod *param);
};
#define PW_ENDPOINT_STREAM_PROXY_METHOD_ADD_LISTENER 0
#define PW_ENDPOINT_STREAM_PROXY_METHOD_SUBSCRIBE_PARAMS 1
#define PW_ENDPOINT_STREAM_PROXY_METHOD_ENUM_PARAMS 2
#define PW_ENDPOINT_STREAM_PROXY_METHOD_SET_PARAM 3
#define PW_ENDPOINT_STREAM_PROXY_METHOD_NUM 4
struct pw_endpoint_stream_proxy_methods {
#define PW_VERSION_ENDPOINT_STREAM_PROXY_METHODS 0
uint32_t version; /**< version of this structure */
int (*add_listener) (void *object,
struct spa_hook *listener,
const struct pw_endpoint_stream_proxy_events *events,
void *data);
/**
* Subscribe to parameter changes
*
* Automatically emit param events for the given ids when
* they are changed.
*
* \param ids an array of param ids
* \param n_ids the number of ids in \a ids
*/
int (*subscribe_params) (void *object, uint32_t *ids, uint32_t n_ids);
/**
* Enumerate stream parameters
*
* Start enumeration of stream parameters. For each param, a
* param event will be emited.
*
* \param seq a sequence number returned in the reply
* \param id the parameter id to enumerate
* \param start the start index or 0 for the first param
* \param num the maximum number of params to retrieve
* \param filter a param filter or NULL
*/
int (*enum_params) (void *object, int seq,
uint32_t id, uint32_t start, uint32_t num,
const struct spa_pod *filter);
/**
* Set a parameter on the stream
*
* \param id the parameter id to set
* \param flags extra parameter flags
* \param param the parameter to set
*/
int (*set_param) (void *object, uint32_t id, uint32_t flags,
const struct spa_pod *param);
};
#define pw_endpoint_stream_proxy_method(o,method,version,...) \
({ \
int _res = -ENOTSUP; \
struct pw_endpoint_stream_proxy *_p = o; \
spa_interface_call_res(&_p->iface, \
struct pw_endpoint_stream_proxy_methods, _res, \
method, version, ##__VA_ARGS__); \
_res; \
})
#define pw_endpoint_stream_proxy_add_listener(c,...) pw_endpoint_stream_proxy_method(c,add_listener,0,__VA_ARGS__)
#define pw_endpoint_stream_proxy_subscribe_params(c,...) pw_endpoint_stream_proxy_method(c,subscribe_params,0,__VA_ARGS__)
#define pw_endpoint_stream_proxy_enum_params(c,...) pw_endpoint_stream_proxy_method(c,enum_params,0,__VA_ARGS__)
/* Endpoint Link */
#define PW_ENDPOINT_LINK_PROXY_EVENT_INFO 0
#define PW_ENDPOINT_LINK_PROXY_EVENT_PARAM 1
#define PW_ENDPOINT_LINK_PROXY_EVENT_NUM 2
struct pw_endpoint_link_proxy_events {
#define PW_VERSION_ENDPOINT_LINK_PROXY_EVENTS 0
uint32_t version; /**< version of this structure */
/**
* Notify endpoint link info
*
* \param info info about the endpoint link
*/
void (*info) (void *object, const struct pw_endpoint_link_info *info);
/**
* Notify a endpoint link param
*
* Event emited as a result of the enum_params method.
*
* \param seq the sequence number of the request
* \param id the param id
* \param index the param index
* \param next the param index of the next param
* \param param the parameter
*/
void (*param) (void *object, int seq,
uint32_t id, uint32_t index, uint32_t next,
const struct spa_pod *param);
};
#define PW_ENDPOINT_LINK_PROXY_METHOD_ADD_LISTENER 0
#define PW_ENDPOINT_LINK_PROXY_METHOD_SUBSCRIBE_PARAMS 1
#define PW_ENDPOINT_LINK_PROXY_METHOD_ENUM_PARAMS 2
#define PW_ENDPOINT_LINK_PROXY_METHOD_SET_PARAM 3
#define PW_ENDPOINT_LINK_PROXY_METHOD_REQUEST_STATE 4
#define PW_ENDPOINT_LINK_PROXY_METHOD_DESTROY 5
#define PW_ENDPOINT_LINK_PROXY_METHOD_NUM 6
struct pw_endpoint_link_proxy_methods {
#define PW_VERSION_ENDPOINT_LINK_PROXY_METHODS 0
uint32_t version; /**< version of this structure */
int (*add_listener) (void *object,
struct spa_hook *listener,
const struct pw_endpoint_link_proxy_events *events,
void *data);
/**
* Subscribe to parameter changes
*
* Automatically emit param events for the given ids when
* they are changed.
*
* \param ids an array of param ids
* \param n_ids the number of ids in \a ids
*/
int (*subscribe_params) (void *object, uint32_t *ids, uint32_t n_ids);
/**
* Enumerate link parameters
*
* Start enumeration of link parameters. For each param, a
* param event will be emited.
*
* \param seq a sequence number returned in the reply
* \param id the parameter id to enumerate
* \param start the start index or 0 for the first param
* \param num the maximum number of params to retrieve
* \param filter a param filter or NULL
*/
int (*enum_params) (void *object, int seq,
uint32_t id, uint32_t start, uint32_t num,
const struct spa_pod *filter);
/**
* Set a parameter on the link
*
* \param id the parameter id to set
* \param flags extra parameter flags
* \param param the parameter to set
*/
int (*set_param) (void *object, uint32_t id, uint32_t flags,
const struct spa_pod *param);
int (*request_state) (void *object, enum pw_endpoint_link_state state);
int (*destroy) (void *object);
};
#define pw_endpoint_link_proxy_method(o,method,version,...) \
({ \
int _res = -ENOTSUP; \
struct pw_endpoint_link_proxy *_p = o; \
spa_interface_call_res(&_p->iface, \
struct pw_endpoint_link_proxy_methods, _res, \
method, version, ##__VA_ARGS__); \
_res; \
})
#define pw_endpoint_link_proxy_add_listener(c,...) pw_endpoint_link_proxy_method(c,add_listener,0,__VA_ARGS__)
#define pw_endpoint_link_proxy_subscribe_params(c,...) pw_endpoint_link_proxy_method(c,subscribe_params,0,__VA_ARGS__)
#define pw_endpoint_link_proxy_enum_params(c,...) pw_endpoint_link_proxy_method(c,enum_params,0,__VA_ARGS__)
#define pw_endpoint_link_proxy_request_state(c,...) pw_endpoint_link_proxy_method(c,request_state,0,__VA_ARGS__)
#define pw_endpoint_link_proxy_destroy(c,...) pw_endpoint_link_proxy_method(c,destroy,0,__VA_ARGS__)
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* PIPEWIRE_EXT_SESSION_MANAGER_INTERFACES_H */

View file

@ -0,0 +1,131 @@
/* PipeWire
*
* Copyright © 2019 Collabora Ltd.
* @author George Kiagiadakis <george.kiagiadakis@collabora.com>
*
* 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 PIPEWIRE_EXT_SESSION_MANAGER_INTROSPECT_H
#define PIPEWIRE_EXT_SESSION_MANAGER_INTROSPECT_H
#include <spa/utils/defs.h>
#include <spa/utils/dict.h>
#include <spa/param/param.h>
#ifdef __cplusplus
extern "C" {
#endif
#define PW_KEY_ENDPOINT_ID "endpoint.id"
#define PW_KEY_SESSION_ID "session.id"
enum pw_endpoint_direction {
PW_ENDPOINT_DIRECTION_SINK_INPUT = SPA_DIRECTION_INPUT,
PW_ENDPOINT_DIRECTION_SOURCE_OUTPUT = SPA_DIRECTION_OUTPUT,
PW_ENDPOINT_DIRECTION_SOURCE,
PW_ENDPOINT_DIRECTION_SINK,
};
enum pw_endpoint_link_state {
PW_ENDPOINT_LINK_STATE_ERROR = -1,
PW_ENDPOINT_LINK_STATE_PREPARING,
PW_ENDPOINT_LINK_STATE_INACTIVE,
PW_ENDPOINT_LINK_STATE_ACTIVE,
};
struct pw_session_info {
#define PW_VERSION_SESSION_INFO 0
uint32_t version; /**< version of this structure */
uint32_t id; /**< the session id (global) */
#define PW_SESSION_CHANGE_MASK_PROPS (1 << 0)
#define PW_SESSION_CHANGE_MASK_PARAMS (1 << 1)
#define PW_SESSION_CHANGE_MASK_ALL ((1 << 2)-1)
uint32_t change_mask; /**< bitfield of changed fields since last call */
struct spa_dict *props; /**< extra properties */
struct spa_param_info *params; /**< parameters */
uint32_t n_params; /**< number of items in \a params */
};
struct pw_endpoint_info {
#define PW_VERSION_ENDPOINT_INFO 0
uint32_t version; /**< version of this structure */
uint32_t id; /**< the endpoint id (global) */
char *name; /**< name of the endpoint */
char *media_class; /**< media class of the endpoint */
enum pw_endpoint_direction direction; /**< direction of the endpoint */
#define PW_ENDPOINT_FLAG_PROVIDES_SESSION (1 << 0)
uint32_t flags; /**< additional flags */
#define PW_ENDPOINT_CHANGE_MASK_STREAMS (1 << 0)
#define PW_ENDPOINT_CHANGE_MASK_SESSION (1 << 1)
#define PW_ENDPOINT_CHANGE_MASK_PROPS (1 << 2)
#define PW_ENDPOINT_CHANGE_MASK_PARAMS (1 << 3)
#define PW_ENDPOINT_CHANGE_MASK_ALL ((1 << 4)-1)
uint32_t change_mask; /**< bitfield of changed fields since last call */
uint32_t n_streams; /**< number of streams available */
uint32_t session_id; /**< the id of the controlling session */
struct spa_dict *props; /**< extra properties */
struct spa_param_info *params; /**< parameters */
uint32_t n_params; /**< number of items in \a params */
};
struct pw_endpoint_stream_info {
#define PW_VERSION_ENDPOINT_STREAM_INFO 0
uint32_t version; /**< version of this structure */
uint32_t id; /**< the stream id (local or global) */
uint32_t endpoint_id; /**< the endpoint id (global) */
char *name; /**< name of the stream */
#define PW_ENDPOINT_STREAM_CHANGE_MASK_LINK_PARAMS (1 << 0)
#define PW_ENDPOINT_STREAM_CHANGE_MASK_PROPS (1 << 1)
#define PW_ENDPOINT_STREAM_CHANGE_MASK_PARAMS (1 << 2)
#define PW_ENDPOINT_STREAM_CHANGE_MASK_ALL ((1 << 3)-1)
uint32_t change_mask; /**< bitfield of changed fields since last call */
struct spa_pod *link_params; /**< information for linking this stream */
struct spa_dict *props; /**< extra properties */
struct spa_param_info *params; /**< parameters */
uint32_t n_params; /**< number of items in \a params */
};
struct pw_endpoint_link_info {
#define PW_VERSION_ENDPOINT_LINK_INFO 0
uint32_t version; /**< version of this structure */
uint32_t id; /**< the link id (global) */
uint32_t session_id; /**< the session id (global) */
uint32_t output_endpoint_id; /**< the output endpoint id (global) */
uint32_t output_stream_id; /**< the output stream id (local or global) */
uint32_t input_endpoint_id; /**< the input endpoint id (global) */
uint32_t input_stream_id; /**< the input stream id (local or global) */
#define PW_ENDPOINT_LINK_CHANGE_MASK_STATE (1 << 0)
#define PW_ENDPOINT_LINK_CHANGE_MASK_PROPS (1 << 1)
#define PW_ENDPOINT_LINK_CHANGE_MASK_PARAMS (1 << 2)
#define PW_ENDPOINT_LINK_CHANGE_MASK_ALL ((1 << 3)-1)
uint32_t change_mask; /**< bitfield of changed fields since last call */
enum pw_endpoint_link_state state; /**< the state of the link */
char *error; /**< error string if state == ERROR */
struct spa_dict *props; /**< extra properties */
struct spa_param_info *params; /**< parameters */
uint32_t n_params; /**< number of items in \a params */
};
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* PIPEWIRE_EXT_SESSION_MANAGER_INTROSPECT_H */

View file

@ -0,0 +1,40 @@
/* PipeWire
*
* Copyright © 2019 Collabora Ltd.
* @author George Kiagiadakis <george.kiagiadakis@collabora.com>
*
* 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 PIPEWIRE_EXT_SESSION_MANAGER_KEYS_H
#define PIPEWIRE_EXT_SESSION_MANAGER_KEYS_H
#ifdef __cplusplus
extern "C" {
#endif
#define PW_KEY_ENDPOINT_ID "endpoint.id"
#define PW_KEY_SESSION_ID "session.id"
#ifdef __cplusplus
}
#endif
#endif /* PIPEWIRE_EXT_SESSION_MANAGER_KEYS_H */