Integrating libcamera

This commit is contained in:
raghu447 2020-04-20 12:26:50 +05:30 committed by Wim Taymans
parent ee1b79c4cd
commit 9024cc4444
24 changed files with 4826 additions and 13 deletions

View file

@ -0,0 +1,498 @@
/* 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.
*/
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <math.h>
#include <time.h>
#include "config.h"
#include <spa/monitor/device.h>
#include <spa/node/node.h>
#include <spa/utils/hook.h>
#include <spa/utils/names.h>
#include <spa/utils/result.h>
#include <spa/param/props.h>
#include <spa/debug/dict.h>
#include <spa/pod/builder.h>
#include "pipewire/pipewire.h"
#include "media-session.h"
struct device;
struct node {
struct impl *impl;
struct device *device;
struct spa_list link;
uint32_t id;
struct pw_properties *props;
struct pw_proxy *proxy;
struct spa_node *node;
};
struct device {
struct impl *impl;
struct spa_list link;
uint32_t id;
uint32_t device_id;
int priority;
int profile;
struct pw_properties *props;
struct spa_handle *handle;
struct spa_device *device;
struct spa_hook device_listener;
struct sm_device *sdevice;
struct spa_hook listener;
unsigned int appeared:1;
struct spa_list node_list;
};
struct impl {
struct sm_media_session *session;
struct spa_hook session_listener;
struct spa_handle *handle;
struct spa_device *monitor;
struct spa_hook listener;
struct spa_list device_list;
};
static struct node *libcamera_find_node(struct device *dev, uint32_t id)
{
struct node *node;
spa_list_for_each(node, &dev->node_list, link) {
if (node->id == id)
return node;
}
return NULL;
}
static void libcamera_update_node(struct device *dev, struct node *node,
const struct spa_device_object_info *info)
{
pw_log_debug("update node %u", node->id);
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
spa_debug_dict(0, info->props);
pw_properties_update(node->props, info->props);
}
static struct node *libcamera_create_node(struct device *dev, uint32_t id,
const struct spa_device_object_info *info)
{
struct node *node;
struct impl *impl = dev->impl;
int res;
const char *str;
pw_log_debug("new node %u", id);
if (strcmp(info->type, SPA_TYPE_INTERFACE_Node) != 0) {
errno = EINVAL;
return NULL;
}
node = calloc(1, sizeof(*node));
if (node == NULL) {
res = -errno;
goto exit;
}
node->props = pw_properties_new_dict(info->props);
pw_properties_setf(node->props, PW_KEY_DEVICE_ID, "%d", dev->device_id);
str = pw_properties_get(dev->props, SPA_KEY_DEVICE_NAME);
if (str == NULL)
str = pw_properties_get(dev->props, SPA_KEY_DEVICE_NICK);
if (str == NULL)
str = pw_properties_get(dev->props, SPA_KEY_DEVICE_ALIAS);
if (str == NULL)
str = "libcamera-device";
pw_properties_setf(node->props, PW_KEY_NODE_NAME, "%s.%s", info->factory_name, str);
str = pw_properties_get(dev->props, SPA_KEY_DEVICE_DESCRIPTION);
if (str == NULL)
str = "libcamera-device";
pw_properties_set(node->props, PW_KEY_NODE_DESCRIPTION, str);
pw_properties_set(node->props, PW_KEY_FACTORY_NAME, info->factory_name);
node->impl = impl;
node->device = dev;
node->id = id;
node->proxy = sm_media_session_create_object(impl->session,
"spa-node-factory",
PW_TYPE_INTERFACE_Node,
PW_VERSION_NODE,
&node->props->dict,
0);
if (node->proxy == NULL) {
res = -errno;
goto clean_node;
}
spa_list_append(&dev->node_list, &node->link);
return node;
clean_node:
pw_properties_free(node->props);
free(node);
exit:
errno = -res;
return NULL;
}
static void libcamera_remove_node(struct device *dev, struct node *node)
{
pw_log_debug("remove node %u", node->id);
spa_list_remove(&node->link);
pw_proxy_destroy(node->proxy);
pw_properties_free(node->props);
free(node);
}
static void libcamera_device_info(void *data, const struct spa_device_info *info)
{
struct device *dev = data;
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
spa_debug_dict(0, info->props);
pw_properties_update(dev->props, info->props);
}
static void libcamera_device_object_info(void *data, uint32_t id,
const struct spa_device_object_info *info)
{
struct device *dev = data;
struct node *node;
node = libcamera_find_node(dev, id);
if (info == NULL) {
if (node == NULL) {
pw_log_warn("device %p: unknown node %u", dev, id);
return;
}
libcamera_remove_node(dev, node);
} else if (node == NULL) {
libcamera_create_node(dev, id, info);
} else {
libcamera_update_node(dev, node, info);
}
}
static const struct spa_device_events libcamera_device_events = {
SPA_VERSION_DEVICE_EVENTS,
.info = libcamera_device_info,
.object_info = libcamera_device_object_info
};
static struct device *libcamera_find_device(struct impl *impl, uint32_t id)
{
struct device *dev;
pw_log_info("In %s:: Invoking spa_list_for_each for id = %d", __FUNCTION__, id);
spa_list_for_each(dev, &impl->device_list, link) {
if (dev->id == id)
return dev;
}
pw_log_info("In %s:: spa_list_for_each returns NULL for id = %d", __FUNCTION__, id);
return NULL;
}
static void libcamera_update_device(struct impl *impl, struct device *dev,
const struct spa_device_object_info *info)
{
pw_log_debug("update device %u", dev->id);
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
spa_debug_dict(0, info->props);
pw_properties_update(dev->props, info->props);
}
static int libcamera_update_device_props(struct device *dev)
{
struct pw_properties *p = dev->props;
const char *s, *d;
char temp[32];
if ((s = pw_properties_get(p, SPA_KEY_DEVICE_NAME)) == NULL) {
if ((s = pw_properties_get(p, SPA_KEY_DEVICE_BUS_ID)) == NULL) {
if ((s = pw_properties_get(p, SPA_KEY_DEVICE_BUS_PATH)) == NULL) {
snprintf(temp, sizeof(temp), "%d", dev->id);
s = temp;
}
}
}
pw_properties_setf(p, PW_KEY_DEVICE_NAME, "libcamera_device.%s", s);
if (pw_properties_get(p, PW_KEY_DEVICE_DESCRIPTION) == NULL) {
d = pw_properties_get(p, PW_KEY_DEVICE_PRODUCT_NAME);
if (!d)
d = "Unknown device";
pw_properties_set(p, PW_KEY_DEVICE_DESCRIPTION, d);
}
return 0;
}
static void set_profile(struct device *device, int index)
{
char buf[1024];
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buf, sizeof(buf));
pw_log_debug("%p: set profile %d id:%d", device, index, device->device_id);
device->profile = index;
if (device->device_id != 0) {
spa_device_set_param(device->device,
SPA_PARAM_Profile, 0,
spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_ParamProfile, SPA_PARAM_Profile,
SPA_PARAM_PROFILE_index, SPA_POD_Int(index)));
}
}
static void device_destroy(void *data)
{
struct device *device = data;
struct node *node;
pw_log_debug("device %p destroy", device);
spa_list_consume(node, &device->node_list, link)
libcamera_remove_node(device, node);
}
static void device_update(void *data)
{
struct device *device = data;
pw_log_debug("device %p appeared %d %d", device, device->appeared, device->profile);
if (device->appeared)
return;
device->device_id = device->sdevice->obj.id;
device->appeared = true;
spa_device_add_listener(device->device,
&device->device_listener,
&libcamera_device_events, device);
set_profile(device, 1);
sm_object_sync_update(&device->sdevice->obj);
}
static const struct sm_object_events device_events = {
SM_VERSION_OBJECT_EVENTS,
.destroy = device_destroy,
.update = device_update,
};
static struct device *libcamera_create_device(struct impl *impl, uint32_t id,
const struct spa_device_object_info *info)
{
struct pw_context *context = impl->session->context;
struct device *dev;
struct spa_handle *handle;
int res;
void *iface;
pw_log_debug("new device %u", id);
if (strcmp(info->type, SPA_TYPE_INTERFACE_Device) != 0) {
errno = EINVAL;
return NULL;
}
handle = pw_context_load_spa_handle(context,
info->factory_name,
info->props);
if (handle == NULL) {
res = -errno;
pw_log_error("can't make factory instance: %m");
goto exit;
}
if ((res = spa_handle_get_interface(handle, info->type, &iface)) < 0) {
pw_log_error("can't get %s interface: %s", info->type, spa_strerror(res));
goto unload_handle;
}
dev = calloc(1, sizeof(*dev));
if (dev == NULL) {
res = -errno;
goto unload_handle;
}
dev->impl = impl;
dev->id = id;
dev->handle = handle;
dev->device = iface;
dev->props = pw_properties_new_dict(info->props);
libcamera_update_device_props(dev);
dev->sdevice = sm_media_session_export_device(impl->session,
&dev->props->dict, dev->device);
if (dev->sdevice == NULL) {
res = -errno;
goto clean_device;
}
pw_log_debug("got object %p", &dev->sdevice->obj);
sm_object_add_listener(&dev->sdevice->obj,
&dev->listener,
&device_events, dev);
spa_list_init(&dev->node_list);
spa_list_append(&impl->device_list, &dev->link);
return dev;
clean_device:
free(dev);
unload_handle:
pw_unload_spa_handle(handle);
exit:
errno = -res;
return NULL;
}
static void libcamera_remove_device(struct impl *impl, struct device *dev)
{
pw_log_debug("remove device %u", dev->id);
spa_list_remove(&dev->link);
if (dev->appeared)
spa_hook_remove(&dev->device_listener);
if (dev->sdevice)
sm_object_destroy(&dev->sdevice->obj);
spa_hook_remove(&dev->listener);
pw_unload_spa_handle(dev->handle);
pw_properties_free(dev->props);
free(dev);
}
static void libcamera_udev_object_info(void *data, uint32_t id,
const struct spa_device_object_info *info)
{
struct impl *impl = data;
struct device *dev = NULL;
pw_log_info("In %s:: Invoking libcamera_find_device for id = %d", __FUNCTION__, id);
dev = libcamera_find_device(impl, id);
if (info == NULL) {
if (dev == NULL)
return;
libcamera_remove_device(impl, dev);
} else if (dev == NULL) {
if (libcamera_create_device(impl, id, info) == NULL)
return;
} else {
libcamera_update_device(impl, dev, info);
}
}
static const struct spa_device_events libcamera_udev_callbacks =
{
SPA_VERSION_DEVICE_EVENTS,
.object_info = libcamera_udev_object_info,
};
static void session_destroy(void *data)
{
struct impl *impl = data;
spa_hook_remove(&impl->session_listener);
spa_hook_remove(&impl->listener);
pw_unload_spa_handle(impl->handle);
free(impl);
}
static const struct sm_media_session_events session_events = {
SM_VERSION_MEDIA_SESSION_EVENTS,
.destroy = session_destroy,
};
int sm_libcamera_monitor_start(struct sm_media_session *sess)
{
struct pw_context *context = sess->context;
struct impl *impl;
int res;
void *iface;
impl = calloc(1, sizeof(struct impl));
if (impl == NULL)
return -errno;
impl->session = sess;
pw_log_info("%s:: Loading spa handle: %s", __FUNCTION__, SPA_NAME_API_LIBCAMERA_DEVICE);
impl->handle = pw_context_load_spa_handle(context, SPA_NAME_API_LIBCAMERA_ENUM_CLIENT, NULL);
if (impl->handle == NULL) {
res = -errno;
goto out_free;
}
if ((res = spa_handle_get_interface(impl->handle, SPA_TYPE_INTERFACE_Device, &iface)) < 0) {
pw_log_error("can't get MONITOR interface: %d", res);
goto out_unload;
}
impl->monitor = iface;
spa_list_init(&impl->device_list);
spa_device_add_listener(impl->monitor, &impl->listener,
&libcamera_udev_callbacks, impl);
sm_media_session_add_listener(sess, &impl->session_listener, &session_events, impl);
return 0;
out_unload:
pw_unload_spa_handle(impl->handle);
out_free:
free(impl);
return res;
}

View file

@ -66,6 +66,7 @@
int sm_metadata_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_alsa_monitor_start(struct sm_media_session *sess);
int sm_suspend_node_start(struct sm_media_session *sess);
@ -1715,8 +1716,7 @@ static void do_quit(void *data, int signal_number)
pw_main_loop_quit(impl->loop);
}
#define DEFAULT_ENABLED "alsa-pcm,alsa-seq,v4l2,bluez5,metadata,suspend-node,policy-node"
#define DEFAULT_ENABLED "alsa-pcm,alsa-seq,v4l2,libcamera,bluez5,metadata,suspend-node,policy-node"
#define DEFAULT_DISABLED ""
static const struct {
@ -1728,6 +1728,7 @@ static const struct {
{ "alsa-seq", "alsa seq midi support", sm_alsa_midi_start },
{ "alsa-pcm", "alsa pcm udev detection", sm_alsa_monitor_start },
{ "v4l2", "video for linux udev detection", sm_v4l2_monitor_start },
{ "libcamera", "libcamera udev detection", sm_libcamera_monitor_start },
{ "bluez5", "bluetooth support", sm_bluez5_monitor_start },
{ "metadata", "export metadata API", sm_metadata_start },
{ "suspend-node", "suspend inactive nodes", sm_suspend_node_start },
@ -1836,6 +1837,7 @@ int main(int argc, char *argv[])
pw_context_add_spa_lib(impl.this.context, "api.bluez5.*", "bluez5/libspa-bluez5");
pw_context_add_spa_lib(impl.this.context, "api.alsa.*", "alsa/libspa-alsa");
pw_context_add_spa_lib(impl.this.context, "api.v4l2.*", "v4l2/libspa-v4l2");
pw_context_add_spa_lib(impl.this.context, "api.libcamera.*", "libcamera/libspa-libcamera");
pw_context_set_object(impl.this.context, SM_TYPE_MEDIA_SESSION, &impl);
@ -1865,7 +1867,7 @@ int main(int argc, char *argv[])
const char *name = modules[i].name;
if (opt_contains(opt_enabled, name) &&
!opt_contains(opt_disabled, name)) {
pw_log_info("enable: %s", name);
pw_log_info("enable: %s. Starting module.", name);
modules[i].start(&impl.this);
}
}

View file

@ -141,6 +141,7 @@ static int client_endpoint_create_link(void *object, const struct spa_dict *prop
struct pw_properties *p;
int res;
pw_log_info(NAME " %s. ", __FUNCTION__);
pw_log_debug(NAME" %p: endpoint %p", impl, endpoint);
if (props == NULL)
@ -160,11 +161,15 @@ static int client_endpoint_create_link(void *object, const struct spa_dict *prop
res = -EINVAL;
goto exit;
}
pw_log_info(NAME " %s. Got %s from PW_KEY_ENDPOINT_LINK_INPUT_ENDPOINT", __FUNCTION__, str);
obj = sm_media_session_find_object(impl->session, atoi(str));
if (obj == NULL || strcmp(obj->type, PW_TYPE_INTERFACE_Endpoint) != 0) {
pw_log_warn(NAME" %p: could not find endpoint %s (%p)", impl, str, obj);
res = -EINVAL;
goto exit;
} else {
pw_log_info(NAME " %s: comparing obj->type[%s] with %s.", __FUNCTION__, obj->type, PW_TYPE_INTERFACE_Endpoint);
}
pw_properties_setf(p, PW_KEY_LINK_OUTPUT_NODE, "%d", endpoint->node->node->info->id);
@ -198,6 +203,7 @@ static struct stream *endpoint_add_stream(struct endpoint *endpoint)
struct stream *s;
const char *str;
pw_log_info(NAME " %s. ", __FUNCTION__);
s = calloc(1, sizeof(*s));
if (s == NULL)
return NULL;
@ -222,7 +228,7 @@ static struct stream *endpoint_add_stream(struct endpoint *endpoint)
s->info.change_mask = PW_ENDPOINT_STREAM_CHANGE_MASK_PROPS;
s->info.props = &s->props->dict;
pw_log_debug("stream %d", s->info.id);
pw_log_info("%s:: stream %s %d", __FUNCTION__, s->info.name, s->info.id);
pw_client_endpoint_stream_update(endpoint->client_endpoint,
s->info.id,
PW_CLIENT_ENDPOINT_STREAM_UPDATE_INFO,
@ -239,6 +245,7 @@ static void destroy_stream(struct stream *stream)
{
struct endpoint *endpoint = stream->endpoint;
pw_log_info(NAME " %s. ", __FUNCTION__);
pw_client_endpoint_stream_update(endpoint->client_endpoint,
stream->info.id,
PW_CLIENT_ENDPOINT_STREAM_UPDATE_DESTROYED,
@ -260,6 +267,7 @@ static void update_params(void *data)
struct sm_node *node = endpoint->node->node;
struct sm_param *p;
pw_log_info(NAME " %s. ", __FUNCTION__);
pw_log_debug(NAME" %p: endpoint", endpoint);
params = alloca(sizeof(struct spa_pod *) * node->n_params);
@ -307,6 +315,7 @@ static void complete_endpoint(void *data)
struct stream *stream;
struct sm_param *p;
pw_log_info(NAME " %s. ", __FUNCTION__);
pw_log_debug("endpoint %p: complete", endpoint);
spa_list_for_each(p, &endpoint->node->node->param_list, link) {
@ -346,6 +355,7 @@ static void proxy_destroy(void *data)
struct endpoint *endpoint = data;
struct stream *s;
pw_log_info(NAME " %s. ", __FUNCTION__);
pw_log_debug("endpoint %p: destroy", endpoint);
spa_list_consume(s, &endpoint->stream_list, link)
@ -361,6 +371,7 @@ static void proxy_destroy(void *data)
static void proxy_bound(void *data, uint32_t id)
{
struct endpoint *endpoint = data;
pw_log_info(NAME " %s. ", __FUNCTION__);
endpoint->info.id = id;
}
@ -382,6 +393,7 @@ static struct endpoint *create_endpoint(struct node *node)
struct pw_properties *pr = node->node->obj.props;
enum pw_direction direction;
pw_log_info(NAME " %s. ", __FUNCTION__);
if (pr == NULL) {
errno = EINVAL;
return NULL;
@ -415,6 +427,7 @@ static struct endpoint *create_endpoint(struct node *node)
if ((str = pw_properties_get(pr, PW_KEY_DEVICE_ICON_NAME)) != NULL)
pw_properties_set(props, PW_KEY_ENDPOINT_ICON_NAME, str);
pw_log_info(NAME " %s. Invoking sm_media_session_create_object", __FUNCTION__);
proxy = sm_media_session_create_object(impl->session,
"client-endpoint",
PW_TYPE_INTERFACE_ClientEndpoint,
@ -449,7 +462,7 @@ static struct endpoint *create_endpoint(struct node *node)
endpoint->info.n_params = 2;
spa_list_init(&endpoint->stream_list);
pw_log_debug(NAME" %p: new endpoint %p for v4l2 node %p", impl, endpoint, node);
pw_log_info(NAME" %p: new endpoint %p %s for v4l2 node %p", impl, endpoint, endpoint->info.name, node);
pw_proxy_add_listener(proxy,
&endpoint->proxy_listener,
&proxy_events, endpoint);
@ -489,6 +502,7 @@ static int setup_v4l2_endpoint(struct device *device)
struct sm_node *n;
struct sm_device *d = device->device;
pw_log_info(NAME " %s. ", __FUNCTION__);
pw_log_debug(NAME" %p: device %p setup", impl, d);
spa_list_for_each(n, &d->node_list, link) {
@ -500,6 +514,7 @@ static int setup_v4l2_endpoint(struct device *device)
node->device = device;
node->node = n;
node->impl = impl;
pw_log_info(NAME " %s. Invoking create_endpoint", __FUNCTION__);
node->endpoint = create_endpoint(node);
if (node->endpoint == NULL)
return -errno;
@ -509,6 +524,8 @@ static int setup_v4l2_endpoint(struct device *device)
static int activate_device(struct device *device)
{
pw_log_info(NAME " In %s. Activating....", __FUNCTION__);
pw_log_info(NAME " In %s. Invoking setup_libcamera_endpoint", __FUNCTION__);
return setup_v4l2_endpoint(device);
}
@ -517,6 +534,7 @@ static int deactivate_device(struct device *device)
struct impl *impl = device->impl;
struct endpoint *e;
pw_log_info(NAME " %s. ", __FUNCTION__);
pw_log_debug(NAME" %p: device %p deactivate", impl, device->device);
spa_list_consume(e, &device->endpoint_list, link)
destroy_endpoint(impl, e);
@ -529,7 +547,8 @@ static void device_update(void *data)
struct device *device = data;
struct impl *impl = device->impl;
pw_log_debug(NAME" %p: device %p %08x %08x", impl, device,
pw_log_info(NAME " %s. ", __FUNCTION__);
pw_log_info(NAME" %p: device %p %08x %08x", impl, device,
device->device->obj.avail, device->device->obj.changed);
if (!SPA_FLAG_IS_SET(device->device->obj.avail,
@ -554,13 +573,14 @@ handle_device(struct impl *impl, struct sm_object *obj)
const char *media_class, *str;
struct device *device;
pw_log_info(NAME " In %s. ", __FUNCTION__);
if (obj->props == NULL)
return 0;
media_class = pw_properties_get(obj->props, PW_KEY_MEDIA_CLASS);
str = pw_properties_get(obj->props, PW_KEY_DEVICE_API);
pw_log_debug(NAME" %p: device "PW_KEY_MEDIA_CLASS":%s api:%s", impl, media_class, str);
pw_log_info(NAME" %p: device "PW_KEY_MEDIA_CLASS":%s api:%s", impl, media_class, str);
if (strstr(media_class, "Video/") != media_class)
return 0;
@ -572,7 +592,7 @@ handle_device(struct impl *impl, struct sm_object *obj)
device->id = obj->id;
device->device = (struct sm_device*)obj;
spa_list_init(&device->endpoint_list);
pw_log_debug(NAME" %p: found v4l2 device %d media_class %s", impl, obj->id, media_class);
pw_log_info(NAME" %p: found v4l2 device %d media_class %s", impl, obj->id, media_class);
sm_object_add_listener(obj, &device->listener, &device_events, device);
@ -581,6 +601,7 @@ handle_device(struct impl *impl, struct sm_object *obj)
static void destroy_device(struct impl *impl, struct device *device)
{
pw_log_info(NAME " In %s. Deactivating...", __FUNCTION__);
deactivate_device(device);
spa_hook_remove(&device->listener);
sm_object_remove_data((struct sm_object*)device->device, SESSION_KEY);
@ -591,6 +612,7 @@ static void session_create(void *data, struct sm_object *object)
struct impl *impl = data;
int res;
pw_log_info(NAME " In %s. comparing object->type[%s] with %s", __FUNCTION__, object->type, PW_TYPE_INTERFACE_Device);
if (strcmp(object->type, PW_TYPE_INTERFACE_Device) == 0)
res = handle_device(impl, object);
else
@ -606,6 +628,7 @@ static void session_remove(void *data, struct sm_object *object)
{
struct impl *impl = data;
pw_log_info(NAME " In %s. ", __FUNCTION__);
if (strcmp(object->type, PW_TYPE_INTERFACE_Device) == 0) {
struct device *device;
if ((device = sm_object_get_data(object, SESSION_KEY)) != NULL)
@ -631,11 +654,13 @@ int sm_v4l2_endpoint_start(struct sm_media_session *session)
{
struct impl *impl;
pw_log_info(NAME " In %s. ", __FUNCTION__);
impl = calloc(1, sizeof(struct impl));
if (impl == NULL)
return -errno;
impl->session = session;
pw_log_info(NAME " In %s. Invoking sm_media_session_add_listener", __FUNCTION__);
sm_media_session_add_listener(session, &impl->listener, &session_events, impl);
return 0;

View file

@ -65,6 +65,7 @@ if alsa_dep.found()
'media-session/policy-node.c',
'media-session/v4l2-monitor.c',
'media-session/v4l2-endpoint.c',
'media-session/libcamera-monitor.c',
'media-session/suspend-node.c',
c_args : [ '-D_GNU_SOURCE' ],
install: true,
@ -99,6 +100,7 @@ if sdl_dep.found()
install: false,
dependencies : [pipewire_dep, sdl_dep],
)
executable('export-sink',
'export-sink.c',
c_args : [ '-D_GNU_SOURCE' ],