introspect-funcs.h
Go to the documentation of this file.
/* PipeWire
*
* Copyright © 2020 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_FUNCS_H
#define PIPEWIRE_EXT_SESSION_MANAGER_INTROSPECT_FUNCS_H
#include "introspect.h"
#include <spa/pod/builder.h>
#include <pipewire/pipewire.h>
#ifdef __cplusplus
extern "C" {
#endif
static inline struct pw_session_info *
pw_session_info_update (struct pw_session_info *info,
const struct pw_session_info *update)
{
struct extended_info {
struct pw_properties *props_storage;
struct pw_session_info info;
} *ext;
if (update == NULL)
return info;
if (info == NULL) {
ext = (struct extended_info *) calloc(1, sizeof(*ext));
if (ext == NULL)
return NULL;
info = &ext->info;
info->id = update->id;
} else {
ext = SPA_CONTAINER_OF(info, struct extended_info, info);
}
info->change_mask = update->change_mask;
if (update->change_mask & PW_SESSION_CHANGE_MASK_PROPS) {
if (!ext->props_storage) {
ext->props_storage = pw_properties_new(NULL, NULL);
info->props = &ext->props_storage->dict;
}
pw_properties_clear(ext->props_storage);
pw_properties_update(ext->props_storage, update->props);
}
if (update->change_mask & PW_SESSION_CHANGE_MASK_PARAMS) {
info->n_params = update->n_params;
free((void *) info->params);
if (update->params) {
size_t size = info->n_params * sizeof(struct spa_param_info);
info->params = (struct spa_param_info *) malloc(size);
memcpy(info->params, update->params, size);
}
else
info->params = NULL;
}
return info;
}
static inline void
pw_session_info_free (struct pw_session_info *info)
{
struct extended_info {
struct pw_properties *props_storage;
struct pw_session_info info;
} *ext = SPA_CONTAINER_OF(info, struct extended_info, info);
pw_properties_free(ext->props_storage);
free((void *) info->params);
free(ext);
}
static inline struct pw_endpoint_info *
pw_endpoint_info_update (struct pw_endpoint_info *info,
const struct pw_endpoint_info *update)
{
struct extended_info {
struct pw_properties *props_storage;
struct pw_endpoint_info info;
} *ext;
if (update == NULL)
return info;
if (info == NULL) {
ext = (struct extended_info *) calloc(1, sizeof(*ext));
if (ext == NULL)
return NULL;
info = &ext->info;
info->id = update->id;
info->name = strdup(update->name);
info->media_class = strdup(update->media_class);
info->direction = update->direction;
info->flags = update->flags;
} else {
ext = SPA_CONTAINER_OF(info, struct extended_info, info);
}
info->change_mask = update->change_mask;
if (update->change_mask & PW_ENDPOINT_CHANGE_MASK_STREAMS)
info->n_streams = update->n_streams;
if (update->change_mask & PW_ENDPOINT_CHANGE_MASK_SESSION)
info->session_id = update->session_id;
if (update->change_mask & PW_ENDPOINT_CHANGE_MASK_PROPS) {
if (!ext->props_storage) {
ext->props_storage = pw_properties_new(NULL, NULL);
info->props = &ext->props_storage->dict;
}
pw_properties_clear(ext->props_storage);
pw_properties_update(ext->props_storage, update->props);
}
if (update->change_mask & PW_ENDPOINT_CHANGE_MASK_PARAMS) {
info->n_params = update->n_params;
free((void *) info->params);
if (update->params) {
size_t size = info->n_params * sizeof(struct spa_param_info);
info->params = (struct spa_param_info *) malloc(size);
memcpy(info->params, update->params, size);
}
else
info->params = NULL;
}
return info;
}
static inline void
pw_endpoint_info_free (struct pw_endpoint_info *info)
{
struct extended_info {
struct pw_properties *props_storage;
struct pw_endpoint_info info;
} *ext = SPA_CONTAINER_OF(info, struct extended_info, info);
pw_properties_free(ext->props_storage);
free(info->name);
free(info->media_class);
free((void *) info->params);
free(ext);
}
static inline struct pw_endpoint_stream_info *
pw_endpoint_stream_info_update (struct pw_endpoint_stream_info *info,
const struct pw_endpoint_stream_info *update)
{
struct extended_info {
struct pw_properties *props_storage;
struct pw_endpoint_stream_info info;
} *ext;
if (update == NULL)
return info;
if (info == NULL) {
ext = (struct extended_info *) calloc(1, sizeof(*ext));
if (ext == NULL)
return NULL;
info = &ext->info;
info->id = update->id;
info->endpoint_id = update->endpoint_id;
info->name = strdup(update->name);
} else {
ext = SPA_CONTAINER_OF(info, struct extended_info, info);
}
info->change_mask = update->change_mask;
if (update->change_mask & PW_ENDPOINT_STREAM_CHANGE_MASK_LINK_PARAMS) {
free(info->link_params);
info->link_params = update->link_params ?
spa_pod_copy(update->link_params) : NULL;
}
if (update->change_mask & PW_ENDPOINT_STREAM_CHANGE_MASK_PROPS) {
if (!ext->props_storage) {
ext->props_storage = pw_properties_new(NULL, NULL);
info->props = &ext->props_storage->dict;
}
pw_properties_clear(ext->props_storage);
pw_properties_update(ext->props_storage, update->props);
}
if (update->change_mask & PW_ENDPOINT_STREAM_CHANGE_MASK_PARAMS) {
info->n_params = update->n_params;
free((void *) info->params);
if (update->params) {
size_t size = info->n_params * sizeof(struct spa_param_info);
info->params = (struct spa_param_info *) malloc(size);
memcpy(info->params, update->params, size);
}
else
info->params = NULL;
}
return info;
}
static inline void
pw_endpoint_stream_info_free (struct pw_endpoint_stream_info *info)
{
struct extended_info {
struct pw_properties *props_storage;
struct pw_endpoint_stream_info info;
} *ext = SPA_CONTAINER_OF(info, struct extended_info, info);
pw_properties_free(ext->props_storage);
free(info->name);
free(info->link_params);
free((void *) info->params);
free(ext);
}
static inline struct pw_endpoint_link_info *
pw_endpoint_link_info_update (struct pw_endpoint_link_info *info,
const struct pw_endpoint_link_info *update)
{
struct extended_info {
struct pw_properties *props_storage;
struct pw_endpoint_link_info info;
} *ext;
if (update == NULL)
return info;
if (info == NULL) {
ext = (struct extended_info *) calloc(1, sizeof(*ext));
if (ext == NULL)
return NULL;
info = &ext->info;
info->id = update->id;
info->session_id = update->session_id;
info->output_endpoint_id = update->output_endpoint_id;
info->output_stream_id = update->output_stream_id;
info->input_endpoint_id = update->input_endpoint_id;
info->input_stream_id = update->input_stream_id;
} else {
ext = SPA_CONTAINER_OF(info, struct extended_info, info);
}
info->change_mask = update->change_mask;
if (update->change_mask & PW_ENDPOINT_LINK_CHANGE_MASK_STATE) {
info->state = update->state;
free(info->error);
info->error = update->error ? strdup(update->error) : NULL;
}
if (update->change_mask & PW_ENDPOINT_LINK_CHANGE_MASK_PROPS) {
if (!ext->props_storage) {
ext->props_storage = pw_properties_new(NULL, NULL);
info->props = &ext->props_storage->dict;
}
pw_properties_clear(ext->props_storage);
pw_properties_update(ext->props_storage, update->props);
}
if (update->change_mask & PW_ENDPOINT_LINK_CHANGE_MASK_PARAMS) {
info->n_params = update->n_params;
free((void *) info->params);
if (update->params) {
size_t size = info->n_params * sizeof(struct spa_param_info);
info->params = (struct spa_param_info *) malloc(size);
memcpy(info->params, update->params, size);
}
else
info->params = NULL;
}
return info;
}
static inline void
pw_endpoint_link_info_free (struct pw_endpoint_link_info *info)
{
struct extended_info {
struct pw_properties *props_storage;
struct pw_endpoint_link_info info;
} *ext = SPA_CONTAINER_OF(info, struct extended_info, info);
pw_properties_free(ext->props_storage);
free(info->error);
free((void *) info->params);
free(ext);
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* PIPEWIRE_EXT_SESSION_MANAGER_INTROSPECT_FUNCS_H */
builder.h
spa/pod/builder.h
pw_properties_free
void pw_properties_free(struct pw_properties *properties)
Free a properties object.
Definition: properties.c:368
pw_properties_update
int pw_properties_update(struct pw_properties *props, const struct spa_dict *dict)
Update properties.
Definition: properties.c:302
pw_properties_new
struct pw_properties * pw_properties_new(const char *key,...) 1
Make a new properties object.
Definition: properties.c:102
pw_properties_clear
void pw_properties_clear(struct pw_properties *properties)
Clear a properties object.
Definition: properties.c:281
PW_ENDPOINT_STREAM_CHANGE_MASK_PARAMS
#define PW_ENDPOINT_STREAM_CHANGE_MASK_PARAMS
Definition: introspect.h:111
pw_endpoint_info_free
static void pw_endpoint_info_free(struct pw_endpoint_info *info)
Definition: introspect-funcs.h:164
PW_SESSION_CHANGE_MASK_PROPS
#define PW_SESSION_CHANGE_MASK_PROPS
Definition: introspect.h:59
PW_ENDPOINT_CHANGE_MASK_SESSION
#define PW_ENDPOINT_CHANGE_MASK_SESSION
Definition: introspect.h:84
PW_ENDPOINT_STREAM_CHANGE_MASK_PROPS
#define PW_ENDPOINT_STREAM_CHANGE_MASK_PROPS
Definition: introspect.h:109
PW_ENDPOINT_CHANGE_MASK_STREAMS
#define PW_ENDPOINT_CHANGE_MASK_STREAMS
Definition: introspect.h:82
pw_session_info_free
static void pw_session_info_free(struct pw_session_info *info)
Definition: introspect-funcs.h:94
pw_endpoint_link_info_update
static struct pw_endpoint_link_info * pw_endpoint_link_info_update(struct pw_endpoint_link_info *info, const struct pw_endpoint_link_info *update)
Definition: introspect-funcs.h:249
PW_ENDPOINT_CHANGE_MASK_PROPS
#define PW_ENDPOINT_CHANGE_MASK_PROPS
Definition: introspect.h:86
PW_ENDPOINT_LINK_CHANGE_MASK_PARAMS
#define PW_ENDPOINT_LINK_CHANGE_MASK_PARAMS
Definition: introspect.h:136
PW_ENDPOINT_CHANGE_MASK_PARAMS
#define PW_ENDPOINT_CHANGE_MASK_PARAMS
Definition: introspect.h:88
pw_session_info_update
static struct pw_session_info * pw_session_info_update(struct pw_session_info *info, const struct pw_session_info *update)
Definition: introspect-funcs.h:47
pw_endpoint_stream_info_update
static struct pw_endpoint_stream_info * pw_endpoint_stream_info_update(struct pw_endpoint_stream_info *info, const struct pw_endpoint_stream_info *update)
Definition: introspect-funcs.h:179
PW_ENDPOINT_LINK_CHANGE_MASK_PROPS
#define PW_ENDPOINT_LINK_CHANGE_MASK_PROPS
Definition: introspect.h:134
PW_SESSION_CHANGE_MASK_PARAMS
#define PW_SESSION_CHANGE_MASK_PARAMS
Definition: introspect.h:61
pw_endpoint_stream_info_free
static void pw_endpoint_stream_info_free(struct pw_endpoint_stream_info *info)
Definition: introspect-funcs.h:233
pw_endpoint_link_info_free
static void pw_endpoint_link_info_free(struct pw_endpoint_link_info *info)
Definition: introspect-funcs.h:306
PW_ENDPOINT_STREAM_CHANGE_MASK_LINK_PARAMS
#define PW_ENDPOINT_STREAM_CHANGE_MASK_LINK_PARAMS
Definition: introspect.h:107
pw_endpoint_info_update
static struct pw_endpoint_info * pw_endpoint_info_update(struct pw_endpoint_info *info, const struct pw_endpoint_info *update)
Definition: introspect-funcs.h:107
PW_ENDPOINT_LINK_CHANGE_MASK_STATE
#define PW_ENDPOINT_LINK_CHANGE_MASK_STATE
Definition: introspect.h:132
spa_pod_copy
static struct spa_pod * spa_pod_copy(const struct spa_pod *pod)
Copy a pod structure.
Definition: builder.h:703
SPA_CONTAINER_OF
#define SPA_CONTAINER_OF(p, t, m)
Definition: defs.h:197
introspect.h
pipewire/extensions/session-manager/introspect.h
pipewire.h
pipewire/pipewire.h
pw_endpoint_info
Definition: introspect.h:70
pw_endpoint_info::params
struct spa_param_info * params
parameters
Definition: introspect.h:95
pw_endpoint_info::id
uint32_t id
the endpoint id (global)
Definition: introspect.h:74
pw_endpoint_info::change_mask
uint64_t change_mask
bitfield of changed fields since last call
Definition: introspect.h:91
pw_endpoint_info::direction
enum pw_direction direction
direction of the endpoint
Definition: introspect.h:77
pw_endpoint_info::n_params
uint32_t n_params
number of items in params
Definition: introspect.h:96
pw_endpoint_info::flags
uint32_t flags
additional flags
Definition: introspect.h:80
pw_endpoint_info::media_class
char * media_class
media class of the endpoint
Definition: introspect.h:76
pw_endpoint_info::session_id
uint32_t session_id
the id of the controlling session
Definition: introspect.h:93
pw_endpoint_info::n_streams
uint32_t n_streams
number of streams available
Definition: introspect.h:92
pw_endpoint_link_info
Definition: introspect.h:121
pw_endpoint_link_info::id
uint32_t id
the link id (global)
Definition: introspect.h:125
pw_endpoint_link_info::change_mask
uint64_t change_mask
bitfield of changed fields since last call
Definition: introspect.h:139
pw_endpoint_link_info::output_endpoint_id
uint32_t output_endpoint_id
the output endpoint id (global)
Definition: introspect.h:127
pw_endpoint_link_info::input_endpoint_id
uint32_t input_endpoint_id
the input endpoint id (global)
Definition: introspect.h:129
pw_endpoint_link_info::error
char * error
error string if state == ERROR
Definition: introspect.h:141
pw_endpoint_link_info::params
struct spa_param_info * params
parameters
Definition: introspect.h:143
pw_endpoint_link_info::state
enum pw_endpoint_link_state state
the state of the link
Definition: introspect.h:140
pw_endpoint_link_info::n_params
uint32_t n_params
number of items in params
Definition: introspect.h:144
pw_endpoint_link_info::output_stream_id
uint32_t output_stream_id
the output stream id (local or global)
Definition: introspect.h:128
pw_endpoint_link_info::input_stream_id
uint32_t input_stream_id
the input stream id (local or global)
Definition: introspect.h:130
pw_endpoint_link_info::session_id
uint32_t session_id
the session id (global)
Definition: introspect.h:126
pw_endpoint_stream_info
Definition: introspect.h:99
pw_endpoint_stream_info::n_params
uint32_t n_params
number of items in params
Definition: introspect.h:118
pw_endpoint_stream_info::params
struct spa_param_info * params
parameters
Definition: introspect.h:117
pw_endpoint_stream_info::endpoint_id
uint32_t endpoint_id
the endpoint id (global)
Definition: introspect.h:104
pw_endpoint_stream_info::link_params
struct spa_pod * link_params
information for linking this stream
Definition: introspect.h:115
pw_endpoint_stream_info::id
uint32_t id
the stream id (local or global)
Definition: introspect.h:103
pw_endpoint_stream_info::change_mask
uint64_t change_mask
bitfield of changed fields since last call
Definition: introspect.h:114
pw_properties
Definition: properties.h:53
pw_session_info
Definition: introspect.h:53
pw_session_info::params
struct spa_param_info * params
parameters
Definition: introspect.h:66
pw_session_info::change_mask
uint64_t change_mask
bitfield of changed fields since last call
Definition: introspect.h:64
pw_session_info::id
uint32_t id
the session id (global)
Definition: introspect.h:57
pw_session_info::n_params
uint32_t n_params
number of items in params
Definition: introspect.h:67
spa_param_info
information about a parameter
Definition: param.h:70