mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-09 13:30:06 -05:00
Integrating libcamera
This commit is contained in:
parent
ee1b79c4cd
commit
9024cc4444
24 changed files with 4826 additions and 13 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue