types: more work on types

This commit is contained in:
Wim Taymans 2017-03-24 11:40:58 +01:00
parent acedfe71c0
commit 5825c62d6d
76 changed files with 1713 additions and 1477 deletions

View file

@ -169,9 +169,9 @@ core_event_update_uris (void *object,
int i; int i;
for (i = 0; i < n_uris; i++, first_id++) { for (i = 0; i < n_uris; i++, first_id++) {
uint32_t this_id = spa_id_map_get_id (this->uri.map, uris[i]); SpaType this_id = spa_type_map_get_id (this->type.map, uris[i]);
printf ("update %d %s -> %d\n", first_id, uris[i], this_id); printf ("update %d %s -> %d\n", first_id, uris[i], this_id);
if (!pinos_map_insert_at (&this->uris, first_id, SPA_UINT32_TO_PTR (this_id))) if (!pinos_map_insert_at (&this->types, first_id, SPA_UINT32_TO_PTR (this_id)))
pinos_log_error ("can't add uri for client"); pinos_log_error ("can't add uri for client");
} }
} }
@ -310,7 +310,7 @@ registry_event_global (void *object,
if (!strcmp (type, PINOS_TYPE__Node)) { if (!strcmp (type, PINOS_TYPE__Node)) {
proxy = pinos_proxy_new (this, proxy = pinos_proxy_new (this,
SPA_ID_INVALID, SPA_ID_INVALID,
this->uri.node); this->type.node);
if (proxy == NULL) if (proxy == NULL)
goto no_mem; goto no_mem;
@ -318,7 +318,7 @@ registry_event_global (void *object,
} else if (!strcmp (type, PINOS_TYPE__Module)) { } else if (!strcmp (type, PINOS_TYPE__Module)) {
proxy = pinos_proxy_new (this, proxy = pinos_proxy_new (this,
SPA_ID_INVALID, SPA_ID_INVALID,
this->uri.module); this->type.module);
if (proxy == NULL) if (proxy == NULL)
goto no_mem; goto no_mem;
@ -326,7 +326,7 @@ registry_event_global (void *object,
} else if (!strcmp (type, PINOS_TYPE__Client)) { } else if (!strcmp (type, PINOS_TYPE__Client)) {
proxy = pinos_proxy_new (this, proxy = pinos_proxy_new (this,
SPA_ID_INVALID, SPA_ID_INVALID,
this->uri.client); this->type.client);
if (proxy == NULL) if (proxy == NULL)
goto no_mem; goto no_mem;
@ -334,7 +334,7 @@ registry_event_global (void *object,
} else if (!strcmp (type, PINOS_TYPE__Link)) { } else if (!strcmp (type, PINOS_TYPE__Link)) {
proxy = pinos_proxy_new (this, proxy = pinos_proxy_new (this,
SPA_ID_INVALID, SPA_ID_INVALID,
this->uri.link); this->type.link);
if (proxy == NULL) if (proxy == NULL)
goto no_mem; goto no_mem;
@ -478,7 +478,7 @@ pinos_context_new (PinosLoop *loop,
pinos_fill_context_properties (properties); pinos_fill_context_properties (properties);
this->properties = properties; this->properties = properties;
pinos_uri_init (&this->uri); pinos_type_init (&this->type);
this->loop = loop; this->loop = loop;
@ -487,7 +487,7 @@ pinos_context_new (PinosLoop *loop,
this->state = PINOS_CONTEXT_STATE_UNCONNECTED; this->state = PINOS_CONTEXT_STATE_UNCONNECTED;
pinos_map_init (&this->objects, 64, 32); pinos_map_init (&this->objects, 64, 32);
pinos_map_init (&this->uris, 64, 32); pinos_map_init (&this->types, 64, 32);
spa_list_init (&this->stream_list); spa_list_init (&this->stream_list);
spa_list_init (&this->global_list); spa_list_init (&this->global_list);
@ -630,7 +630,7 @@ pinos_context_connect_fd (PinosContext *context,
context->core_proxy = pinos_proxy_new (context, context->core_proxy = pinos_proxy_new (context,
0, 0,
context->uri.core); context->type.core);
if (context->core_proxy == NULL) if (context->core_proxy == NULL)
goto no_proxy; goto no_proxy;
@ -641,7 +641,7 @@ pinos_context_connect_fd (PinosContext *context,
context->registry_proxy = pinos_proxy_new (context, context->registry_proxy = pinos_proxy_new (context,
SPA_ID_INVALID, SPA_ID_INVALID,
context->uri.registry); context->type.registry);
if (context->registry_proxy == NULL) if (context->registry_proxy == NULL)
goto no_registry; goto no_registry;
@ -710,7 +710,7 @@ pinos_context_get_core_info (PinosContext *context,
proxy = pinos_map_lookup (&context->objects, 0); proxy = pinos_map_lookup (&context->objects, 0);
if (proxy == NULL) { if (proxy == NULL) {
cb (context, SPA_RESULT_INVALID_OBJECT_ID, NULL, user_data); cb (context, SPA_RESULT_INVALID_OBJECT_ID, NULL, user_data);
} else if (proxy->type == context->uri.core && proxy->user_data) { } else if (proxy->type == context->type.core && proxy->user_data) {
PinosCoreInfo *info = proxy->user_data; PinosCoreInfo *info = proxy->user_data;
cb (context, SPA_RESULT_OK, info, user_data); cb (context, SPA_RESULT_OK, info, user_data);
info->change_mask = 0; info->change_mask = 0;
@ -750,7 +750,7 @@ pinos_context_list_module_info (PinosContext *context,
PinosModuleInfoCallback cb, PinosModuleInfoCallback cb,
void *user_data) void *user_data)
{ {
do_list (context, context->uri.module, (ListFunc) cb, user_data); do_list (context, context->type.module, (ListFunc) cb, user_data);
} }
void void
@ -764,7 +764,7 @@ pinos_context_get_module_info_by_id (PinosContext *context,
proxy = pinos_map_lookup (&context->objects, id); proxy = pinos_map_lookup (&context->objects, id);
if (proxy == NULL) { if (proxy == NULL) {
cb (context, SPA_RESULT_INVALID_OBJECT_ID, NULL, user_data); cb (context, SPA_RESULT_INVALID_OBJECT_ID, NULL, user_data);
} else if (proxy->type == context->uri.module && proxy->user_data) { } else if (proxy->type == context->type.module && proxy->user_data) {
PinosModuleInfo *info = proxy->user_data; PinosModuleInfo *info = proxy->user_data;
cb (context, SPA_RESULT_OK, info, user_data); cb (context, SPA_RESULT_OK, info, user_data);
info->change_mask = 0; info->change_mask = 0;
@ -777,7 +777,7 @@ pinos_context_list_client_info (PinosContext *context,
PinosClientInfoCallback cb, PinosClientInfoCallback cb,
void *user_data) void *user_data)
{ {
do_list (context, context->uri.client, (ListFunc) cb, user_data); do_list (context, context->type.client, (ListFunc) cb, user_data);
} }
void void
@ -791,7 +791,7 @@ pinos_context_get_client_info_by_id (PinosContext *context,
proxy = pinos_map_lookup (&context->objects, id); proxy = pinos_map_lookup (&context->objects, id);
if (proxy == NULL) { if (proxy == NULL) {
cb (context, SPA_RESULT_INVALID_OBJECT_ID, NULL, user_data); cb (context, SPA_RESULT_INVALID_OBJECT_ID, NULL, user_data);
} else if (proxy->type == context->uri.client && proxy->user_data) { } else if (proxy->type == context->type.client && proxy->user_data) {
PinosClientInfo *info = proxy->user_data; PinosClientInfo *info = proxy->user_data;
cb (context, SPA_RESULT_OK, info, user_data); cb (context, SPA_RESULT_OK, info, user_data);
info->change_mask = 0; info->change_mask = 0;
@ -804,7 +804,7 @@ pinos_context_list_node_info (PinosContext *context,
PinosNodeInfoCallback cb, PinosNodeInfoCallback cb,
void *user_data) void *user_data)
{ {
do_list (context, context->uri.node, (ListFunc) cb, user_data); do_list (context, context->type.node, (ListFunc) cb, user_data);
} }
void void
@ -818,7 +818,7 @@ pinos_context_get_node_info_by_id (PinosContext *context,
proxy = pinos_map_lookup (&context->objects, id); proxy = pinos_map_lookup (&context->objects, id);
if (proxy == NULL) { if (proxy == NULL) {
cb (context, SPA_RESULT_INVALID_OBJECT_ID, NULL, user_data); cb (context, SPA_RESULT_INVALID_OBJECT_ID, NULL, user_data);
} else if (proxy->type == context->uri.node && proxy->user_data) { } else if (proxy->type == context->type.node && proxy->user_data) {
PinosNodeInfo *info = proxy->user_data; PinosNodeInfo *info = proxy->user_data;
cb (context, SPA_RESULT_OK, info, user_data); cb (context, SPA_RESULT_OK, info, user_data);
info->change_mask = 0; info->change_mask = 0;
@ -831,7 +831,7 @@ pinos_context_list_link_info (PinosContext *context,
PinosLinkInfoCallback cb, PinosLinkInfoCallback cb,
void *user_data) void *user_data)
{ {
do_list (context, context->uri.link, (ListFunc) cb, user_data); do_list (context, context->type.link, (ListFunc) cb, user_data);
} }
void void
@ -845,7 +845,7 @@ pinos_context_get_link_info_by_id (PinosContext *context,
proxy = pinos_map_lookup (&context->objects, id); proxy = pinos_map_lookup (&context->objects, id);
if (proxy == NULL) { if (proxy == NULL) {
cb (context, SPA_RESULT_INVALID_OBJECT_ID, NULL, user_data); cb (context, SPA_RESULT_INVALID_OBJECT_ID, NULL, user_data);
} else if (proxy->type == context->uri.link && proxy->user_data) { } else if (proxy->type == context->type.link && proxy->user_data) {
PinosLinkInfo *info = proxy->user_data; PinosLinkInfo *info = proxy->user_data;
cb (context, SPA_RESULT_OK, info, user_data); cb (context, SPA_RESULT_OK, info, user_data);
info->change_mask = 0; info->change_mask = 0;

View file

@ -31,7 +31,7 @@ typedef struct _PinosContext PinosContext;
#include <pinos/client/properties.h> #include <pinos/client/properties.h>
#include <pinos/client/subscribe.h> #include <pinos/client/subscribe.h>
#include <pinos/client/proxy.h> #include <pinos/client/proxy.h>
#include <pinos/client/uri.h> #include <pinos/client/type.h>
/** /**
* PinosContextState: * PinosContextState:
@ -60,7 +60,7 @@ struct _PinosContext {
char *name; char *name;
PinosProperties *properties; PinosProperties *properties;
PinosURI uri; PinosType type;
PinosLoop *loop; PinosLoop *loop;
@ -68,8 +68,8 @@ struct _PinosContext {
PinosProxy *registry_proxy; PinosProxy *registry_proxy;
PinosMap objects; PinosMap objects;
uint32_t n_uris; uint32_t n_types;
PinosMap uris; PinosMap types;
SpaList global_list; SpaList global_list;
SpaList stream_list; SpaList stream_list;

View file

@ -58,10 +58,10 @@ typedef struct {
const char *name, const char *name,
const SpaDict *props, const SpaDict *props,
uint32_t new_id); uint32_t new_id);
void (*update_uris) (void *object, void (*update_types) (void *object,
uint32_t first_id, uint32_t first_id,
uint32_t n_uris, uint32_t n_types,
const char **uris); const char **types);
} PinosCoreMethods; } PinosCoreMethods;
#define pinos_core_do_client_update(r,...) ((PinosCoreMethods*)r->iface->methods)->client_update(r,__VA_ARGS__) #define pinos_core_do_client_update(r,...) ((PinosCoreMethods*)r->iface->methods)->client_update(r,__VA_ARGS__)
@ -69,7 +69,7 @@ typedef struct {
#define pinos_core_do_get_registry(r,...) ((PinosCoreMethods*)r->iface->methods)->get_registry(r,__VA_ARGS__) #define pinos_core_do_get_registry(r,...) ((PinosCoreMethods*)r->iface->methods)->get_registry(r,__VA_ARGS__)
#define pinos_core_do_create_node(r,...) ((PinosCoreMethods*)r->iface->methods)->create_node(r,__VA_ARGS__) #define pinos_core_do_create_node(r,...) ((PinosCoreMethods*)r->iface->methods)->create_node(r,__VA_ARGS__)
#define pinos_core_do_create_client_node(r,...) ((PinosCoreMethods*)r->iface->methods)->create_client_node(r,__VA_ARGS__) #define pinos_core_do_create_client_node(r,...) ((PinosCoreMethods*)r->iface->methods)->create_client_node(r,__VA_ARGS__)
#define pinos_core_do_update_uris(r,...) ((PinosCoreMethods*)r->iface->methods)->update_uris(r,__VA_ARGS__) #define pinos_core_do_update_types(r,...) ((PinosCoreMethods*)r->iface->methods)->update_types(r,__VA_ARGS__)
typedef struct { typedef struct {
void (*info) (void *object, void (*info) (void *object,
@ -82,17 +82,17 @@ typedef struct {
const char *error, ...); const char *error, ...);
void (*remove_id) (void *object, void (*remove_id) (void *object,
uint32_t id); uint32_t id);
void (*update_uris) (void *object, void (*update_types) (void *object,
uint32_t first_id, uint32_t first_id,
uint32_t n_uris, uint32_t n_types,
const char **uris); const char **types);
} PinosCoreEvents; } PinosCoreEvents;
#define pinos_core_notify_info(r,...) ((PinosCoreEvents*)r->iface->events)->info(r,__VA_ARGS__) #define pinos_core_notify_info(r,...) ((PinosCoreEvents*)r->iface->events)->info(r,__VA_ARGS__)
#define pinos_core_notify_done(r,...) ((PinosCoreEvents*)r->iface->events)->done(r,__VA_ARGS__) #define pinos_core_notify_done(r,...) ((PinosCoreEvents*)r->iface->events)->done(r,__VA_ARGS__)
#define pinos_core_notify_error(r,...) ((PinosCoreEvents*)r->iface->events)->error(r,__VA_ARGS__) #define pinos_core_notify_error(r,...) ((PinosCoreEvents*)r->iface->events)->error(r,__VA_ARGS__)
#define pinos_core_notify_remove_id(r,...) ((PinosCoreEvents*)r->iface->events)->remove_id(r,__VA_ARGS__) #define pinos_core_notify_remove_id(r,...) ((PinosCoreEvents*)r->iface->events)->remove_id(r,__VA_ARGS__)
#define pinos_core_notify_update_uris(r,...) ((PinosCoreEvents*)r->iface->events)->update_uris(r,__VA_ARGS__) #define pinos_core_notify_update_types(r,...) ((PinosCoreEvents*)r->iface->events)->update_types(r,__VA_ARGS__)
typedef struct { typedef struct {
void (*bind) (void *object, void (*bind) (void *object,

View file

@ -22,76 +22,76 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <spa/id-map.h> #include <spa/type-map.h>
#include <spa/lib/mapper.h> #include <spa/lib/mapper.h>
#include <pinos/client/map.h> #include <pinos/client/map.h>
typedef struct { typedef struct {
SpaIDMap map; SpaTypeMap map;
PinosMap uris; PinosMap types;
PinosArray strings; PinosArray strings;
} IDMap; } TypeMap;
static uint32_t static uint32_t
id_map_get_id (SpaIDMap *map, const char *uri) type_map_get_id (SpaTypeMap *map, const char *type)
{ {
IDMap *this = SPA_CONTAINER_OF (map, IDMap, map); TypeMap *this = SPA_CONTAINER_OF (map, TypeMap, map);
uint32_t i = 0, len; uint32_t i = 0, len;
void *p; void *p;
off_t o; off_t o;
if (uri != NULL) { if (type != NULL) {
for (i = 0; i < pinos_map_get_size (&this->uris); i++) { for (i = 0; i < pinos_map_get_size (&this->types); i++) {
o = (off_t) pinos_map_lookup_unchecked (&this->uris, i); o = (off_t) pinos_map_lookup_unchecked (&this->types, i);
if (strcmp (SPA_MEMBER (this->strings.data, o, char), uri) == 0) if (strcmp (SPA_MEMBER (this->strings.data, o, char), type) == 0)
return i; return i;
} }
len = strlen (uri); len = strlen (type);
p = pinos_array_add (&this->strings, SPA_ROUND_UP_N (len+1, 2)); p = pinos_array_add (&this->strings, SPA_ROUND_UP_N (len+1, 2));
memcpy (p, uri, len+1); memcpy (p, type, len+1);
o = (p - this->strings.data); o = (p - this->strings.data);
i = pinos_map_insert_new (&this->uris, (void *)o); i = pinos_map_insert_new (&this->types, (void *)o);
} }
return i; return i;
} }
static const char * static const char *
id_map_get_uri (SpaIDMap *map, uint32_t id) type_map_get_type (SpaTypeMap *map, uint32_t id)
{ {
IDMap *this = SPA_CONTAINER_OF (map, IDMap, map); TypeMap *this = SPA_CONTAINER_OF (map, TypeMap, map);
if (id == SPA_ID_INVALID) if (id == SPA_ID_INVALID)
return NULL; return NULL;
if (SPA_LIKELY (pinos_map_check_id (&this->uris, id))) { if (SPA_LIKELY (pinos_map_check_id (&this->types, id))) {
off_t o = (off_t) pinos_map_lookup_unchecked (&this->uris, id); off_t o = (off_t) pinos_map_lookup_unchecked (&this->types, id);
return SPA_MEMBER (this->strings.data, o, char); return SPA_MEMBER (this->strings.data, o, char);
} }
return NULL; return NULL;
} }
static uint32_t static size_t
id_map_get_size (SpaIDMap *map) type_map_get_size (SpaTypeMap *map)
{ {
IDMap *this = SPA_CONTAINER_OF (map, IDMap, map); TypeMap *this = SPA_CONTAINER_OF (map, TypeMap, map);
return pinos_map_get_size (&this->uris); return pinos_map_get_size (&this->types);
} }
static IDMap default_id_map = { static TypeMap default_type_map = {
{ sizeof (SpaIDMap), { sizeof (SpaTypeMap),
NULL, NULL,
id_map_get_id, type_map_get_id,
id_map_get_uri, type_map_get_type,
id_map_get_size, type_map_get_size,
}, },
PINOS_MAP_INIT(128), PINOS_MAP_INIT(128),
PINOS_ARRAY_INIT (4096) PINOS_ARRAY_INIT (4096)
}; };
SpaIDMap * SpaTypeMap *
pinos_id_map_get_default (void) pinos_type_map_get_default (void)
{ {
spa_id_map_set_default (&default_id_map.map); spa_type_map_set_default (&default_type_map.map);
return &default_id_map.map; return &default_type_map.map;
} }

View file

@ -15,7 +15,7 @@ pinos_headers = [
'subscribe.h', 'subscribe.h',
'thread-mainloop.h', 'thread-mainloop.h',
'transport.h', 'transport.h',
'uri.h', 'type.h',
'utils.h', 'utils.h',
] ]
@ -35,7 +35,7 @@ pinos_sources = [
'rtkit.c', 'rtkit.c',
'thread-mainloop.c', 'thread-mainloop.c',
'transport.c', 'transport.c',
'uri.c', 'type.c',
'utils.c', 'utils.c',
] ]

View file

@ -35,7 +35,7 @@ extern "C" {
#include <pinos/client/subscribe.h> #include <pinos/client/subscribe.h>
#include <pinos/client/utils.h> #include <pinos/client/utils.h>
#include <spa/include/spa/id-map.h> #include <spa/include/spa/type-map.h>
void pinos_init (int *argc, char **argv[]); void pinos_init (int *argc, char **argv[]);
@ -51,7 +51,7 @@ void pinos_fill_stream_properties (PinosProperties *properties);
PinosDirection pinos_direction_reverse (PinosDirection direction); PinosDirection pinos_direction_reverse (PinosDirection direction);
SpaIDMap * pinos_id_map_get_default (void); SpaTypeMap * pinos_type_map_get_default (void);
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -51,22 +51,22 @@ static void
core_update_map (PinosContext *context) core_update_map (PinosContext *context)
{ {
uint32_t diff, base, i; uint32_t diff, base, i;
const char **uris; const char **types;
base = context->n_uris; base = context->n_types;
diff = spa_id_map_get_size (context->uri.map) - base; diff = spa_type_map_get_size (context->type.map) - base;
if (diff == 0) if (diff == 0)
return; return;
uris = alloca (diff * sizeof (char *)); types = alloca (diff * sizeof (char *));
for (i = 0; i < diff; i++, base++) for (i = 0; i < diff; i++, base++)
uris[i] = spa_id_map_get_uri (context->uri.map, base); types[i] = spa_type_map_get_type (context->type.map, base);
pinos_core_do_update_uris (context->core_proxy, pinos_core_do_update_types (context->core_proxy,
context->n_uris, context->n_types,
diff, diff,
uris); types);
context->n_uris += diff; context->n_types += diff;
} }
static void static void
@ -203,10 +203,10 @@ core_marshal_create_client_node (void *object,
} }
static void static void
core_marshal_update_uris (void *object, core_marshal_update_types (void *object,
uint32_t first_id, uint32_t first_id,
uint32_t n_uris, uint32_t n_types,
const char **uris) const char **types)
{ {
PinosProxy *proxy = object; PinosProxy *proxy = object;
PinosConnection *connection = proxy->context->protocol_private; PinosConnection *connection = proxy->context->protocol_private;
@ -217,11 +217,11 @@ core_marshal_update_uris (void *object,
spa_pod_builder_add (&b.b, spa_pod_builder_add (&b.b,
SPA_POD_TYPE_STRUCT, &f, SPA_POD_TYPE_STRUCT, &f,
SPA_POD_TYPE_INT, first_id, SPA_POD_TYPE_INT, first_id,
SPA_POD_TYPE_INT, n_uris, 0); SPA_POD_TYPE_INT, n_types, 0);
for (i = 0; i < n_uris; i++) { for (i = 0; i < n_types; i++) {
spa_pod_builder_add (&b.b, spa_pod_builder_add (&b.b,
SPA_POD_TYPE_STRING, uris[i], 0); SPA_POD_TYPE_STRING, types[i], 0);
} }
spa_pod_builder_add (&b.b, spa_pod_builder_add (&b.b,
-SPA_POD_TYPE_STRUCT, &f, 0); -SPA_POD_TYPE_STRUCT, &f, 0);
@ -327,29 +327,29 @@ core_demarshal_remove_id (void *object,
} }
static bool static bool
core_demarshal_update_uris (void *object, core_demarshal_update_types (void *object,
void *data, void *data,
size_t size) size_t size)
{ {
PinosProxy *proxy = object; PinosProxy *proxy = object;
SpaPODIter it; SpaPODIter it;
uint32_t first_id, n_uris; uint32_t first_id, n_types;
const char **uris; const char **types;
int i; int i;
if (!spa_pod_iter_struct (&it, data, size) || if (!spa_pod_iter_struct (&it, data, size) ||
!spa_pod_iter_get (&it, !spa_pod_iter_get (&it,
SPA_POD_TYPE_INT, &first_id, SPA_POD_TYPE_INT, &first_id,
SPA_POD_TYPE_INT, &n_uris, SPA_POD_TYPE_INT, &n_types,
0)) 0))
return false; return false;
uris = alloca (n_uris * sizeof (char *)); types = alloca (n_types * sizeof (char *));
for (i = 0; i < n_uris; i++) { for (i = 0; i < n_types; i++) {
if (!spa_pod_iter_get (&it, SPA_POD_TYPE_STRING, &uris[i], 0)) if (!spa_pod_iter_get (&it, SPA_POD_TYPE_STRING, &types[i], 0))
return false; return false;
} }
((PinosCoreEvents*)proxy->implementation)->update_uris (proxy, first_id, n_uris, uris); ((PinosCoreEvents*)proxy->implementation)->update_types (proxy, first_id, n_types, types);
return true; return true;
} }
@ -1009,7 +1009,7 @@ static const PinosCoreMethods pinos_protocol_native_client_core_methods = {
&core_marshal_get_registry, &core_marshal_get_registry,
&core_marshal_create_node, &core_marshal_create_node,
&core_marshal_create_client_node, &core_marshal_create_client_node,
&core_marshal_update_uris, &core_marshal_update_types,
}; };
static const PinosDemarshalFunc pinos_protocol_native_client_core_demarshal[] = { static const PinosDemarshalFunc pinos_protocol_native_client_core_demarshal[] = {
@ -1017,7 +1017,7 @@ static const PinosDemarshalFunc pinos_protocol_native_client_core_demarshal[] =
&core_demarshal_done, &core_demarshal_done,
&core_demarshal_error, &core_demarshal_error,
&core_demarshal_remove_id, &core_demarshal_remove_id,
&core_demarshal_update_uris, &core_demarshal_update_types,
}; };
static const PinosInterface pinos_protocol_native_client_core_interface = { static const PinosInterface pinos_protocol_native_client_core_interface = {
@ -1107,25 +1107,25 @@ pinos_protocol_native_client_setup (PinosProxy *proxy)
{ {
const PinosInterface *iface; const PinosInterface *iface;
if (proxy->type == proxy->context->uri.core) { if (proxy->type == proxy->context->type.core) {
iface = &pinos_protocol_native_client_core_interface; iface = &pinos_protocol_native_client_core_interface;
} }
else if (proxy->type == proxy->context->uri.registry) { else if (proxy->type == proxy->context->type.registry) {
iface = &pinos_protocol_native_client_registry_interface; iface = &pinos_protocol_native_client_registry_interface;
} }
else if (proxy->type == proxy->context->uri.module) { else if (proxy->type == proxy->context->type.module) {
iface = &pinos_protocol_native_client_module_interface; iface = &pinos_protocol_native_client_module_interface;
} }
else if (proxy->type == proxy->context->uri.node) { else if (proxy->type == proxy->context->type.node) {
iface = &pinos_protocol_native_client_node_interface; iface = &pinos_protocol_native_client_node_interface;
} }
else if (proxy->type == proxy->context->uri.client_node) { else if (proxy->type == proxy->context->type.client_node) {
iface = &pinos_protocol_native_client_client_node_interface; iface = &pinos_protocol_native_client_client_node_interface;
} }
else if (proxy->type == proxy->context->uri.client) { else if (proxy->type == proxy->context->type.client) {
iface = &pinos_protocol_native_client_client_interface; iface = &pinos_protocol_native_client_client_interface;
} }
else if (proxy->type == proxy->context->uri.link) { else if (proxy->type == proxy->context->type.link) {
iface = &pinos_protocol_native_client_link_interface; iface = &pinos_protocol_native_client_link_interface;
} else } else
return false; return false;

View file

@ -388,7 +388,7 @@ add_request_clock_update (PinosStream *stream, bool flush)
{ {
PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this); PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
SpaEventNodeRequestClockUpdate rcu = SpaEventNodeRequestClockUpdate rcu =
SPA_EVENT_NODE_REQUEST_CLOCK_UPDATE_INIT (stream->context->uri.event_node.RequestClockUpdate, SPA_EVENT_NODE_REQUEST_CLOCK_UPDATE_INIT (stream->context->type.event_node.RequestClockUpdate,
SPA_EVENT_NODE_REQUEST_CLOCK_UPDATE_TIME, 0, 0); SPA_EVENT_NODE_REQUEST_CLOCK_UPDATE_TIME, 0, 0);
pinos_client_node_do_event (impl->node_proxy, (SpaEvent*)&rcu); pinos_client_node_do_event (impl->node_proxy, (SpaEvent*)&rcu);
@ -402,7 +402,7 @@ add_async_complete (PinosStream *stream,
{ {
PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this); PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
SpaEventNodeAsyncComplete ac = SpaEventNodeAsyncComplete ac =
SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (stream->context->uri.event_node.AsyncComplete, SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (stream->context->type.event_node.AsyncComplete,
seq, res); seq, res);
pinos_client_node_do_event (impl->node_proxy, (SpaEvent*)&ac); pinos_client_node_do_event (impl->node_proxy, (SpaEvent*)&ac);
} }
@ -470,7 +470,7 @@ handle_rtnode_event (PinosStream *stream,
PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this); PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
PinosContext *context = impl->this.context; PinosContext *context = impl->this.context;
if (SPA_EVENT_TYPE (event) == context->uri.event_node.HaveOutput) { if (SPA_EVENT_TYPE (event) == context->type.event_node.HaveOutput) {
int i; int i;
//pinos_log_debug ("stream %p: have output", stream); //pinos_log_debug ("stream %p: have output", stream);
@ -486,11 +486,11 @@ handle_rtnode_event (PinosStream *stream,
} }
send_need_input (stream); send_need_input (stream);
} }
else if (SPA_EVENT_TYPE (event) == context->uri.event_node.NeedInput) { else if (SPA_EVENT_TYPE (event) == context->type.event_node.NeedInput) {
//pinos_log_debug ("stream %p: need input", stream); //pinos_log_debug ("stream %p: need input", stream);
pinos_signal_emit (&stream->need_buffer, stream); pinos_signal_emit (&stream->need_buffer, stream);
} }
else if (SPA_EVENT_TYPE (event) == context->uri.event_node.ReuseBuffer) { else if (SPA_EVENT_TYPE (event) == context->type.event_node.ReuseBuffer) {
SpaEventNodeReuseBuffer *p = (SpaEventNodeReuseBuffer *) event; SpaEventNodeReuseBuffer *p = (SpaEventNodeReuseBuffer *) event;
BufferId *bid; BufferId *bid;
@ -580,14 +580,14 @@ handle_node_command (PinosStream *stream,
PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this); PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
PinosContext *context = stream->context; PinosContext *context = stream->context;
if (SPA_COMMAND_TYPE (command) == context->uri.command_node.Pause) { if (SPA_COMMAND_TYPE (command) == context->type.command_node.Pause) {
pinos_log_debug ("stream %p: pause %d", stream, seq); pinos_log_debug ("stream %p: pause %d", stream, seq);
add_state_change (stream, SPA_NODE_STATE_PAUSED, false); add_state_change (stream, SPA_NODE_STATE_PAUSED, false);
add_async_complete (stream, seq, SPA_RESULT_OK, true); add_async_complete (stream, seq, SPA_RESULT_OK, true);
stream_set_state (stream, PINOS_STREAM_STATE_PAUSED, NULL); stream_set_state (stream, PINOS_STREAM_STATE_PAUSED, NULL);
} }
else if (SPA_COMMAND_TYPE (command) == context->uri.command_node.Start) { else if (SPA_COMMAND_TYPE (command) == context->type.command_node.Start) {
pinos_log_debug ("stream %p: start %d", stream, seq); pinos_log_debug ("stream %p: start %d", stream, seq);
add_state_change (stream, SPA_NODE_STATE_STREAMING, false); add_state_change (stream, SPA_NODE_STATE_STREAMING, false);
add_async_complete (stream, seq, SPA_RESULT_OK, true); add_async_complete (stream, seq, SPA_RESULT_OK, true);
@ -597,7 +597,7 @@ handle_node_command (PinosStream *stream,
stream_set_state (stream, PINOS_STREAM_STATE_STREAMING, NULL); stream_set_state (stream, PINOS_STREAM_STATE_STREAMING, NULL);
} }
else if (SPA_COMMAND_TYPE (command) == context->uri.command_node.ClockUpdate) { else if (SPA_COMMAND_TYPE (command) == context->type.command_node.ClockUpdate) {
SpaCommandNodeClockUpdate *cu = (SpaCommandNodeClockUpdate *) command; SpaCommandNodeClockUpdate *cu = (SpaCommandNodeClockUpdate *) command;
if (cu->body.flags.value & SPA_COMMAND_NODE_CLOCK_UPDATE_FLAG_LIVE) { if (cu->body.flags.value & SPA_COMMAND_NODE_CLOCK_UPDATE_FLAG_LIVE) {
pinos_properties_set (stream->properties, pinos_properties_set (stream->properties,
@ -955,7 +955,7 @@ pinos_stream_connect (PinosStream *stream,
impl->node_proxy = pinos_proxy_new (stream->context, impl->node_proxy = pinos_proxy_new (stream->context,
SPA_ID_INVALID, SPA_ID_INVALID,
stream->context->uri.client_node); stream->context->type.client_node);
if (impl->node_proxy == NULL) if (impl->node_proxy == NULL)
return false; return false;
@ -1125,7 +1125,7 @@ pinos_stream_recycle_buffer (PinosStream *stream,
uint32_t id) uint32_t id)
{ {
PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this); PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
SpaEventNodeReuseBuffer rb = SPA_EVENT_NODE_REUSE_BUFFER_INIT (stream->context->uri.event_node.ReuseBuffer, SpaEventNodeReuseBuffer rb = SPA_EVENT_NODE_REUSE_BUFFER_INIT (stream->context->type.event_node.ReuseBuffer,
impl->port_id, id); impl->port_id, id);
uint64_t cmd = 1; uint64_t cmd = 1;

58
pinos/client/type.c Normal file
View file

@ -0,0 +1,58 @@
/* Pinos
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <string.h>
#include "pinos/client/pinos.h"
#include "pinos/client/type.h"
#include "pinos/server/core.h"
#include "pinos/server/node.h"
#include "pinos/server/node-factory.h"
#include "pinos/server/client.h"
#include "pinos/server/client-node.h"
#include "pinos/server/module.h"
#include "spa/include/spa/monitor.h"
void
pinos_type_init (PinosType *type)
{
type->map = pinos_type_map_get_default();
type->core = spa_type_map_get_id (type->map, PINOS_TYPE__Core);
type->registry = spa_type_map_get_id (type->map, PINOS_TYPE__Registry);
type->node = spa_type_map_get_id (type->map, PINOS_TYPE__Node);
type->node_factory = spa_type_map_get_id (type->map, PINOS_TYPE__NodeFactory);
type->link = spa_type_map_get_id (type->map, PINOS_TYPE__Link);
type->client = spa_type_map_get_id (type->map, PINOS_TYPE__Client);
type->client_node = spa_type_map_get_id (type->map, PINOS_TYPE__ClientNode);
type->module = spa_type_map_get_id (type->map, PINOS_TYPE__Module);
type->spa_node = spa_type_map_get_id (type->map, SPA_TYPE__Node);
type->spa_clock = spa_type_map_get_id (type->map, SPA_TYPE__Clock);
type->spa_monitor = spa_type_map_get_id (type->map, SPA_TYPE__Monitor);
spa_type_event_node_map (type->map, &type->event_node);
spa_type_command_node_map (type->map, &type->command_node);
spa_type_monitor_map (type->map, &type->monitor);
spa_type_alloc_param_buffers_map (type->map, &type->alloc_param_buffers);
spa_type_alloc_param_meta_enable_map (type->map, &type->alloc_param_meta_enable);
spa_type_alloc_param_video_padding_map (type->map, &type->alloc_param_video_padding);
}

View file

@ -17,56 +17,55 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#ifndef __PINOS_URI_H__ #ifndef __PINOS_TYPE_H__
#define __PINOS_URI_H__ #define __PINOS_TYPE_H__
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#define PINOS_TYPE__Uri "Pinos:Object:Uri"
#define PINOS_TYPE_URI_BASE PINOS_TYPE__Uri ":"
#include <pinos/client/map.h> #include <pinos/client/map.h>
#include <spa/include/spa/id-map.h> #include <spa/include/spa/type-map.h>
#include <spa/include/spa/node-event.h> #include <spa/include/spa/event-node.h>
#include <spa/include/spa/command-node.h>
#include <spa/include/spa/monitor.h> #include <spa/include/spa/monitor.h>
#include <spa/include/spa/alloc-param.h>
typedef struct _PinosURI PinosURI; typedef struct _PinosType PinosType;
/** /**
* PinosURI: * PinosType:
* *
* Pinos URI support struct. * Pinos Type support struct.
*/ */
struct _PinosURI { struct _PinosType {
SpaIDMap *map; SpaTypeMap *map;
uint32_t core; SpaType core;
uint32_t registry; SpaType registry;
uint32_t node; SpaType node;
uint32_t node_factory; SpaType node_factory;
uint32_t link; SpaType link;
uint32_t client; SpaType client;
uint32_t client_node; SpaType client_node;
uint32_t module; SpaType module;
uint32_t spa_node; SpaType spa_node;
uint32_t spa_clock; SpaType spa_clock;
uint32_t spa_monitor; SpaType spa_monitor;
SpaEventNode event_node; SpaTypeEventNode event_node;
SpaCommandNode command_node; SpaTypeCommandNode command_node;
SpaMonitorTypes monitor_types; SpaTypeMonitor monitor;
SpaAllocParamBuffers alloc_param_buffers; SpaTypeAllocParamBuffers alloc_param_buffers;
SpaAllocParamMetaEnable alloc_param_meta_enable; SpaTypeAllocParamMetaEnable alloc_param_meta_enable;
SpaAllocParamVideoPadding alloc_param_video_padding; SpaTypeAllocParamVideoPadding alloc_param_video_padding;
}; };
void pinos_uri_init (PinosURI *uri); void pinos_type_init (PinosType *type);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* __PINOS_URI_H__ */ #endif /* __PINOS_TYPE_H__ */

View file

@ -1,58 +0,0 @@
/* Pinos
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <string.h>
#include "pinos/client/pinos.h"
#include "pinos/client/uri.h"
#include "pinos/server/core.h"
#include "pinos/server/node.h"
#include "pinos/server/node-factory.h"
#include "pinos/server/client.h"
#include "pinos/server/client-node.h"
#include "pinos/server/module.h"
#include "spa/include/spa/monitor.h"
void
pinos_uri_init (PinosURI *uri)
{
uri->map = pinos_id_map_get_default();
uri->core = spa_id_map_get_id (uri->map, PINOS_TYPE__Core);
uri->registry = spa_id_map_get_id (uri->map, PINOS_TYPE__Registry);
uri->node = spa_id_map_get_id (uri->map, PINOS_TYPE__Node);
uri->node_factory = spa_id_map_get_id (uri->map, PINOS_TYPE__NodeFactory);
uri->link = spa_id_map_get_id (uri->map, PINOS_TYPE__Link);
uri->client = spa_id_map_get_id (uri->map, PINOS_TYPE__Client);
uri->client_node = spa_id_map_get_id (uri->map, PINOS_TYPE__ClientNode);
uri->module = spa_id_map_get_id (uri->map, PINOS_TYPE__Module);
uri->spa_node = spa_id_map_get_id (uri->map, SPA_TYPE__Node);
uri->spa_clock = spa_id_map_get_id (uri->map, SPA_TYPE__Clock);
uri->spa_monitor = spa_id_map_get_id (uri->map, SPA_TYPE__Monitor);
spa_event_node_map (uri->map, &uri->event_node);
spa_command_node_map (uri->map, &uri->command_node);
spa_monitor_types_map (uri->map, &uri->monitor_types);
spa_alloc_param_buffers_map (uri->map, &uri->alloc_param_buffers);
spa_alloc_param_meta_enable_map (uri->map, &uri->alloc_param_meta_enable);
spa_alloc_param_video_padding_map (uri->map, &uri->alloc_param_video_padding);
}

View file

@ -284,7 +284,7 @@ on_context_subscription (PinosListener *listener,
GstDeviceProvider *provider = GST_DEVICE_PROVIDER (self); GstDeviceProvider *provider = GST_DEVICE_PROVIDER (self);
GstPinosDevice *dev; GstPinosDevice *dev;
if (type != context->uri.node) if (type != context->type.node)
return; return;
dev = find_device (provider, id); dev = find_device (provider, id);

View file

@ -37,121 +37,123 @@ typedef struct {
uint32_t *media_subtype; uint32_t *media_subtype;
} MediaType; } MediaType;
static uint32_t format_type; static struct {
static SpaMediaTypes media_types = { 0, }; uint32_t format;
static SpaMediaSubtypes media_subtypes = { 0, }; SpaTypeMediaType media_type;
static SpaMediaSubtypesVideo media_subtypes_video = { 0, }; SpaTypeMediaSubtype media_subtype;
static SpaMediaSubtypesAudio media_subtypes_audio = { 0, }; SpaTypeMediaSubtypeVideo media_subtype_video;
static SpaPropVideo prop_video = { 0, }; SpaTypeMediaSubtypeAudio media_subtype_audio;
static SpaPropAudio prop_audio = { 0, }; SpaTypePropVideo prop_video;
static SpaVideoFormats video_formats = { 0, }; SpaTypePropAudio prop_audio;
static SpaAudioFormats audio_formats = { 0, }; SpaTypeVideoFormat video_format;
SpaTypeAudioFormat audio_format;
} type = { 0, };
static void static void
ensure_types (void) ensure_types (void)
{ {
SpaIDMap *map = spa_id_map_get_default (); SpaTypeMap *map = spa_type_map_get_default ();
format_type = spa_id_map_get_id (map, SPA_TYPE__Format); type.format = spa_type_map_get_id (map, SPA_TYPE__Format);
spa_media_types_fill (&media_types, map); spa_type_media_type_map (map, &type.media_type);
spa_media_subtypes_map (map, &media_subtypes); spa_type_media_subtype_map (map, &type.media_subtype);
spa_media_subtypes_video_map (map, &media_subtypes_video); spa_type_media_subtype_video_map (map, &type.media_subtype_video);
spa_media_subtypes_audio_map (map, &media_subtypes_audio); spa_type_media_subtype_audio_map (map, &type.media_subtype_audio);
spa_prop_video_map (map, &prop_video); spa_type_prop_video_map (map, &type.prop_video);
spa_prop_audio_map (map, &prop_audio); spa_type_prop_audio_map (map, &type.prop_audio);
spa_video_formats_map (map, &video_formats); spa_type_video_format_map (map, &type.video_format);
spa_audio_formats_map (map, &audio_formats); spa_type_audio_format_map (map, &type.audio_format);
} }
static const MediaType media_type_map[] = { static const MediaType media_type_map[] = {
{ "video/x-raw", &media_types.video, &media_subtypes.raw }, { "video/x-raw", &type.media_type.video, &type.media_subtype.raw },
{ "audio/x-raw", &media_types.audio, &media_subtypes.raw }, { "audio/x-raw", &type.media_type.audio, &type.media_subtype.raw },
{ "image/jpeg", &media_types.video, &media_subtypes_video.mjpg }, { "image/jpeg", &type.media_type.video, &type.media_subtype_video.mjpg },
{ "video/x-h264", &media_types.video, &media_subtypes_video.h264 }, { "video/x-h264", &type.media_type.video, &type.media_subtype_video.h264 },
{ NULL, } { NULL, }
}; };
static const uint32_t *video_format_map[] = { static const uint32_t *video_format_map[] = {
&video_formats.UNKNOWN, &type.video_format.UNKNOWN,
&video_formats.ENCODED, &type.video_format.ENCODED,
&video_formats.I420, &type.video_format.I420,
&video_formats.YV12, &type.video_format.YV12,
&video_formats.YUY2, &type.video_format.YUY2,
&video_formats.UYVY, &type.video_format.UYVY,
&video_formats.AYUV, &type.video_format.AYUV,
&video_formats.RGBx, &type.video_format.RGBx,
&video_formats.BGRx, &type.video_format.BGRx,
&video_formats.xRGB, &type.video_format.xRGB,
&video_formats.xBGR, &type.video_format.xBGR,
&video_formats.RGBA, &type.video_format.RGBA,
&video_formats.BGRA, &type.video_format.BGRA,
&video_formats.ARGB, &type.video_format.ARGB,
&video_formats.ABGR, &type.video_format.ABGR,
&video_formats.RGB, &type.video_format.RGB,
&video_formats.BGR, &type.video_format.BGR,
&video_formats.Y41B, &type.video_format.Y41B,
&video_formats.Y42B, &type.video_format.Y42B,
&video_formats.YVYU, &type.video_format.YVYU,
&video_formats.Y444, &type.video_format.Y444,
&video_formats.v210, &type.video_format.v210,
&video_formats.v216, &type.video_format.v216,
&video_formats.NV12, &type.video_format.NV12,
&video_formats.NV21, &type.video_format.NV21,
&video_formats.GRAY8, &type.video_format.GRAY8,
&video_formats.GRAY16_BE, &type.video_format.GRAY16_BE,
&video_formats.GRAY16_LE, &type.video_format.GRAY16_LE,
&video_formats.v308, &type.video_format.v308,
&video_formats.RGB16, &type.video_format.RGB16,
&video_formats.BGR16, &type.video_format.BGR16,
&video_formats.RGB15, &type.video_format.RGB15,
&video_formats.BGR15, &type.video_format.BGR15,
&video_formats.UYVP, &type.video_format.UYVP,
&video_formats.A420, &type.video_format.A420,
&video_formats.RGB8P, &type.video_format.RGB8P,
&video_formats.YUV9, &type.video_format.YUV9,
&video_formats.YVU9, &type.video_format.YVU9,
&video_formats.IYU1, &type.video_format.IYU1,
&video_formats.ARGB64, &type.video_format.ARGB64,
&video_formats.AYUV64, &type.video_format.AYUV64,
&video_formats.r210, &type.video_format.r210,
&video_formats.I420_10BE, &type.video_format.I420_10BE,
&video_formats.I420_10LE, &type.video_format.I420_10LE,
&video_formats.I422_10BE, &type.video_format.I422_10BE,
&video_formats.I422_10LE, &type.video_format.I422_10LE,
&video_formats.Y444_10BE, &type.video_format.Y444_10BE,
&video_formats.Y444_10LE, &type.video_format.Y444_10LE,
&video_formats.GBR, &type.video_format.GBR,
&video_formats.GBR_10BE, &type.video_format.GBR_10BE,
&video_formats.GBR_10LE, &type.video_format.GBR_10LE,
&video_formats.NV16, &type.video_format.NV16,
&video_formats.NV24, &type.video_format.NV24,
&video_formats.NV12_64Z32, &type.video_format.NV12_64Z32,
&video_formats.A420_10BE, &type.video_format.A420_10BE,
&video_formats.A420_10LE, &type.video_format.A420_10LE,
&video_formats.A422_10BE, &type.video_format.A422_10BE,
&video_formats.A422_10LE, &type.video_format.A422_10LE,
&video_formats.A444_10BE, &type.video_format.A444_10BE,
&video_formats.A444_10LE, &type.video_format.A444_10LE,
&video_formats.NV61, &type.video_format.NV61,
&video_formats.P010_10BE, &type.video_format.P010_10BE,
&video_formats.P010_10LE, &type.video_format.P010_10LE,
&video_formats.IYU2, &type.video_format.IYU2,
&video_formats.VYUY, &type.video_format.VYUY,
}; };
#if __BYTE_ORDER == __BIG_ENDIAN #if __BYTE_ORDER == __BIG_ENDIAN
#define _FORMAT_LE(fmt) &audio_formats. fmt ## _OE #define _FORMAT_LE(fmt) &type.audio_format. fmt ## _OE
#define _FORMAT_BE(fmt) &audio_formats. fmt #define _FORMAT_BE(fmt) &type.audio_format. fmt
#elif __BYTE_ORDER == __LITTLE_ENDIAN #elif __BYTE_ORDER == __LITTLE_ENDIAN
#define _FORMAT_LE(fmt) &audio_formats. fmt #define _FORMAT_LE(fmt) &type.audio_format. fmt
#define _FORMAT_BE(fmt) &audio_formats. fmt ## _OE #define _FORMAT_BE(fmt) &type.audio_format. fmt ## _OE
#endif #endif
static const uint32_t *audio_format_map[] = { static const uint32_t *audio_format_map[] = {
&audio_formats.UNKNOWN, &type.audio_format.UNKNOWN,
&audio_formats.ENCODED, &type.audio_format.ENCODED,
&audio_formats.S8, &type.audio_format.S8,
&audio_formats.U8, &type.audio_format.U8,
_FORMAT_LE (S16), _FORMAT_LE (S16),
_FORMAT_BE (S16), _FORMAT_BE (S16),
_FORMAT_LE (U16), _FORMAT_LE (U16),
@ -367,7 +369,7 @@ handle_video_fields (ConvertData *d)
for (i = 0; (v = get_nth_string (value, i)); i++) { for (i = 0; (v = get_nth_string (value, i)); i++) {
if (i == 0) if (i == 0)
spa_pod_builder_push_prop (&d->b, &f, spa_pod_builder_push_prop (&d->b, &f,
prop_video.format, type.prop_video.format,
get_range_type (value) | SPA_POD_PROP_FLAG_READWRITE); get_range_type (value) | SPA_POD_PROP_FLAG_READWRITE);
spa_pod_builder_uri (&d->b, *video_format_map[gst_video_format_from_string (v)]); spa_pod_builder_uri (&d->b, *video_format_map[gst_video_format_from_string (v)]);
@ -383,7 +385,7 @@ handle_video_fields (ConvertData *d)
for (i = 0; get_nth_rectangle (value, value2, i, &v); i++) { for (i = 0; get_nth_rectangle (value, value2, i, &v); i++) {
if (i == 0) if (i == 0)
spa_pod_builder_push_prop (&d->b, &f, spa_pod_builder_push_prop (&d->b, &f,
prop_video.size, type.prop_video.size,
get_range_type2 (value, value2) | SPA_POD_PROP_FLAG_READWRITE); get_range_type2 (value, value2) | SPA_POD_PROP_FLAG_READWRITE);
spa_pod_builder_rectangle (&d->b, v.width, v.height); spa_pod_builder_rectangle (&d->b, v.width, v.height);
@ -399,7 +401,7 @@ handle_video_fields (ConvertData *d)
for (i = 0; get_nth_fraction (value, i, &v); i++) { for (i = 0; get_nth_fraction (value, i, &v); i++) {
if (i == 0) if (i == 0)
spa_pod_builder_push_prop (&d->b, &f, spa_pod_builder_push_prop (&d->b, &f,
prop_video.framerate, type.prop_video.framerate,
get_range_type (value) | SPA_POD_PROP_FLAG_READWRITE); get_range_type (value) | SPA_POD_PROP_FLAG_READWRITE);
spa_pod_builder_fraction (&d->b, v.num, v.denom); spa_pod_builder_fraction (&d->b, v.num, v.denom);
@ -424,7 +426,7 @@ handle_audio_fields (ConvertData *d)
for (i = 0; (v = get_nth_string (value, i)); i++) { for (i = 0; (v = get_nth_string (value, i)); i++) {
if (i == 0) if (i == 0)
spa_pod_builder_push_prop (&d->b, &f, spa_pod_builder_push_prop (&d->b, &f,
prop_audio.format, type.prop_audio.format,
get_range_type (value) | SPA_POD_PROP_FLAG_READWRITE); get_range_type (value) | SPA_POD_PROP_FLAG_READWRITE);
spa_pod_builder_uri (&d->b, *audio_format_map[gst_audio_format_from_string (v)]); spa_pod_builder_uri (&d->b, *audio_format_map[gst_audio_format_from_string (v)]);
@ -449,7 +451,7 @@ handle_audio_fields (ConvertData *d)
if (i == 0) if (i == 0)
spa_pod_builder_push_prop (&d->b, &f, spa_pod_builder_push_prop (&d->b, &f,
prop_audio.layout, type.prop_audio.layout,
get_range_type (value) | SPA_POD_PROP_FLAG_READWRITE); get_range_type (value) | SPA_POD_PROP_FLAG_READWRITE);
spa_pod_builder_int (&d->b, layout); spa_pod_builder_int (&d->b, layout);
@ -464,7 +466,7 @@ handle_audio_fields (ConvertData *d)
for (i = 0; get_nth_int (value, i, &v); i++) { for (i = 0; get_nth_int (value, i, &v); i++) {
if (i == 0) if (i == 0)
spa_pod_builder_push_prop (&d->b, &f, spa_pod_builder_push_prop (&d->b, &f,
prop_audio.rate, type.prop_audio.rate,
get_range_type (value) | SPA_POD_PROP_FLAG_READWRITE); get_range_type (value) | SPA_POD_PROP_FLAG_READWRITE);
spa_pod_builder_int (&d->b, v); spa_pod_builder_int (&d->b, v);
@ -479,7 +481,7 @@ handle_audio_fields (ConvertData *d)
for (i = 0; get_nth_int (value, i, &v); i++) { for (i = 0; get_nth_int (value, i, &v); i++) {
if (i == 0) if (i == 0)
spa_pod_builder_push_prop (&d->b, &f, spa_pod_builder_push_prop (&d->b, &f,
prop_audio.channels, type.prop_audio.channels,
get_range_type (value) | SPA_POD_PROP_FLAG_READWRITE); get_range_type (value) | SPA_POD_PROP_FLAG_READWRITE);
spa_pod_builder_int (&d->b, v); spa_pod_builder_int (&d->b, v);
@ -520,13 +522,13 @@ convert_1 (GstCapsFeatures *cf, GstStructure *cs)
d.b.write = write_pod; d.b.write = write_pod;
spa_pod_builder_push_format (&d.b, &f, format_type, spa_pod_builder_push_format (&d.b, &f, type.format,
*d.type->media_type, *d.type->media_type,
*d.type->media_subtype); *d.type->media_subtype);
if (*d.type->media_type == media_types.video) if (*d.type->media_type == type.media_type.video)
handle_video_fields (&d); handle_video_fields (&d);
else if (*d.type->media_type == media_types.audio) else if (*d.type->media_type == type.media_type.audio)
handle_audio_fields (&d); handle_audio_fields (&d);
spa_pod_builder_pop (&d.b, &f); spa_pod_builder_pop (&d.b, &f);
@ -592,14 +594,14 @@ gst_caps_from_format (const SpaFormat *format)
media_type = format->body.media_type.value; media_type = format->body.media_type.value;
media_subtype = format->body.media_subtype.value; media_subtype = format->body.media_subtype.value;
if (media_type == media_types.video) { if (media_type == type.media_type.video) {
SpaVideoInfo f; SpaVideoInfo f;
if (spa_format_video_parse (format, &f) < 0) if (spa_format_video_parse (format, &f) < 0)
return NULL; return NULL;
if (media_subtype == media_subtypes.raw) { if (media_subtype == type.media_subtype.raw) {
const char * str = spa_id_map_get_uri (spa_id_map_get_default (), f.info.raw.format); const char * str = spa_type_map_get_type (spa_type_map_get_default (), f.info.raw.format);
res = gst_caps_new_simple ("video/x-raw", res = gst_caps_new_simple ("video/x-raw",
"format", G_TYPE_STRING, rindex (str, ':') + 1, "format", G_TYPE_STRING, rindex (str, ':') + 1,
@ -608,14 +610,14 @@ gst_caps_from_format (const SpaFormat *format)
"framerate", GST_TYPE_FRACTION, f.info.raw.framerate.num, f.info.raw.framerate.denom, "framerate", GST_TYPE_FRACTION, f.info.raw.framerate.num, f.info.raw.framerate.denom,
NULL); NULL);
} }
else if (media_subtype == media_subtypes_video.mjpg) { else if (media_subtype == type.media_subtype_video.mjpg) {
res = gst_caps_new_simple ("image/jpeg", res = gst_caps_new_simple ("image/jpeg",
"width", G_TYPE_INT, f.info.mjpg.size.width, "width", G_TYPE_INT, f.info.mjpg.size.width,
"height", G_TYPE_INT, f.info.mjpg.size.height, "height", G_TYPE_INT, f.info.mjpg.size.height,
"framerate", GST_TYPE_FRACTION, f.info.mjpg.framerate.num, f.info.mjpg.framerate.denom, "framerate", GST_TYPE_FRACTION, f.info.mjpg.framerate.num, f.info.mjpg.framerate.denom,
NULL); NULL);
} }
else if (media_subtype == media_subtypes_video.h264) { else if (media_subtype == type.media_subtype_video.h264) {
res = gst_caps_new_simple ("video/x-h264", res = gst_caps_new_simple ("video/x-h264",
"width", G_TYPE_INT, f.info.h264.size.width, "width", G_TYPE_INT, f.info.h264.size.width,
"height", G_TYPE_INT, f.info.h264.size.height, "height", G_TYPE_INT, f.info.h264.size.height,
@ -624,14 +626,14 @@ gst_caps_from_format (const SpaFormat *format)
"alignment", G_TYPE_STRING, "au", "alignment", G_TYPE_STRING, "au",
NULL); NULL);
} }
} else if (media_type == media_types.audio) { } else if (media_type == type.media_type.audio) {
SpaAudioInfo f; SpaAudioInfo f;
if (spa_format_audio_parse (format, &f) < 0) if (spa_format_audio_parse (format, &f) < 0)
return NULL; return NULL;
if (media_subtype == media_subtypes.raw) { if (media_subtype == type.media_subtype.raw) {
const char * str = spa_id_map_get_uri (spa_id_map_get_default (), f.info.raw.format); const char * str = spa_type_map_get_type (spa_type_map_get_default (), f.info.raw.format);
res = gst_caps_new_simple ("audio/x-raw", res = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, rindex (str, ':') + 1, "format", G_TYPE_STRING, rindex (str, ':') + 1,

View file

@ -134,25 +134,25 @@ do_start (GstBufferPool * pool)
gst_buffer_pool_config_get_params (config, &caps, &size, &min_buffers, &max_buffers); gst_buffer_pool_config_get_params (config, &caps, &size, &min_buffers, &max_buffers);
spa_pod_builder_init (&b, buffer, sizeof (buffer)); spa_pod_builder_init (&b, buffer, sizeof (buffer));
spa_pod_builder_object (&b, &f[0], 0, ctx->uri.alloc_param_buffers.Buffers, spa_pod_builder_object (&b, &f[0], 0, ctx->type.alloc_param_buffers.Buffers,
PROP (&f[1], ctx->uri.alloc_param_buffers.size, SPA_POD_TYPE_INT, size), PROP (&f[1], ctx->type.alloc_param_buffers.size, SPA_POD_TYPE_INT, size),
PROP (&f[1], ctx->uri.alloc_param_buffers.stride, SPA_POD_TYPE_INT, 0), PROP (&f[1], ctx->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, 0),
PROP_MM (&f[1], ctx->uri.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, min_buffers, min_buffers, max_buffers), PROP_MM (&f[1], ctx->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, min_buffers, min_buffers, max_buffers),
PROP (&f[1], ctx->uri.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16)); PROP (&f[1], ctx->type.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));
port_params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam); port_params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
spa_pod_builder_object (&b, &f[0], 0, ctx->uri.alloc_param_meta_enable.MetaEnable, spa_pod_builder_object (&b, &f[0], 0, ctx->type.alloc_param_meta_enable.MetaEnable,
PROP (&f[1], ctx->uri.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_HEADER)); PROP (&f[1], ctx->type.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_HEADER));
port_params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam); port_params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
spa_pod_builder_object (&b, &f[0], 0, ctx->uri.alloc_param_meta_enable.MetaEnable, spa_pod_builder_object (&b, &f[0], 0, ctx->type.alloc_param_meta_enable.MetaEnable,
PROP (&f[1], ctx->uri.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_RINGBUFFER), PROP (&f[1], ctx->type.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_RINGBUFFER),
PROP (&f[1], ctx->uri.alloc_param_meta_enable.ringbufferSize, SPA_POD_TYPE_INT, PROP (&f[1], ctx->type.alloc_param_meta_enable.ringbufferSize, SPA_POD_TYPE_INT,
size * SPA_MAX (4, size * SPA_MAX (4,
SPA_MAX (min_buffers, max_buffers))), SPA_MAX (min_buffers, max_buffers))),
PROP (&f[1], ctx->uri.alloc_param_meta_enable.ringbufferStride, SPA_POD_TYPE_INT, 0), PROP (&f[1], ctx->type.alloc_param_meta_enable.ringbufferStride, SPA_POD_TYPE_INT, 0),
PROP (&f[1], ctx->uri.alloc_param_meta_enable.ringbufferBlocks, SPA_POD_TYPE_INT, 1), PROP (&f[1], ctx->type.alloc_param_meta_enable.ringbufferBlocks, SPA_POD_TYPE_INT, 1),
PROP (&f[1], ctx->uri.alloc_param_meta_enable.ringbufferAlign, SPA_POD_TYPE_INT, 16)); PROP (&f[1], ctx->type.alloc_param_meta_enable.ringbufferAlign, SPA_POD_TYPE_INT, 16));
port_params[2] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam); port_params[2] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
pinos_stream_finish_format (p->stream, SPA_RESULT_OK, port_params, 2); pinos_stream_finish_format (p->stream, SPA_RESULT_OK, port_params, 2);

View file

@ -789,8 +789,8 @@ on_format_changed (PinosListener *listener,
SpaPODFrame f[2]; SpaPODFrame f[2];
spa_pod_builder_init (&b, buffer, sizeof (buffer)); spa_pod_builder_init (&b, buffer, sizeof (buffer));
spa_pod_builder_object (&b, &f[0], 0, ctx->uri.alloc_param_meta_enable.MetaEnable, spa_pod_builder_object (&b, &f[0], 0, ctx->type.alloc_param_meta_enable.MetaEnable,
PROP (&f[1], ctx->uri.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_HEADER)); PROP (&f[1], ctx->type.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_HEADER));
params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam); params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
GST_DEBUG_OBJECT (pinossrc, "doing finish format"); GST_DEBUG_OBJECT (pinossrc, "doing finish format");

View file

@ -64,7 +64,7 @@ do_check_send (PinosListener *listener,
PinosClient *client = data->client; PinosClient *client = data->client;
PinosCore *core = client->core; PinosCore *core = client->core;
if (data->resource->type == core->uri.registry) { if (data->resource->type == core->type.registry) {
#if 0 #if 0
switch (data->opcode) { switch (data->opcode) {
case 0: case 0:
@ -107,7 +107,7 @@ do_check_dispatch (PinosListener *listener,
PinosClient *client = data->client; PinosClient *client = data->client;
PinosCore *core = client->core; PinosCore *core = client->core;
if (data->resource->type == core->uri.registry) { if (data->resource->type == core->type.registry) {
#if 0 #if 0
if (data->opcode == 0) { if (data->opcode == 0) {
PinosMessageBind *m = data->message; PinosMessageBind *m = data->message;

View file

@ -307,7 +307,7 @@ on_resource_added (PinosListener *listener,
ClientInfo *cinfo = SPA_CONTAINER_OF (listener, ClientInfo, resource_added); ClientInfo *cinfo = SPA_CONTAINER_OF (listener, ClientInfo, resource_added);
ModuleImpl *impl = cinfo->impl; ModuleImpl *impl = cinfo->impl;
if (resource->type == impl->core->uri.client_node) { if (resource->type == impl->core->type.client_node) {
PinosClientNode *cnode = resource->object; PinosClientNode *cnode = resource->object;
on_node_added (impl, cnode->node, resource, cinfo); on_node_added (impl, cnode->node, resource, cinfo);
} }
@ -321,7 +321,7 @@ on_resource_removed (PinosListener *listener,
ClientInfo *cinfo = SPA_CONTAINER_OF (listener, ClientInfo, resource_removed); ClientInfo *cinfo = SPA_CONTAINER_OF (listener, ClientInfo, resource_removed);
ModuleImpl *impl = cinfo->impl; ModuleImpl *impl = cinfo->impl;
if (resource->type == impl->core->uri.client_node) { if (resource->type == impl->core->type.client_node) {
PinosClientNode *cnode = resource->object; PinosClientNode *cnode = resource->object;
NodeInfo *ninfo; NodeInfo *ninfo;
@ -339,7 +339,7 @@ on_global_added (PinosListener *listener,
{ {
ModuleImpl *impl = SPA_CONTAINER_OF (listener, ModuleImpl, global_added); ModuleImpl *impl = SPA_CONTAINER_OF (listener, ModuleImpl, global_added);
if (global->type == impl->core->uri.client) { if (global->type == impl->core->type.client) {
PinosClient *client = global->object; PinosClient *client = global->object;
ClientInfo *cinfo; ClientInfo *cinfo;
@ -362,7 +362,7 @@ on_global_removed (PinosListener *listener,
{ {
ModuleImpl *impl = SPA_CONTAINER_OF (listener, ModuleImpl, global_removed); ModuleImpl *impl = SPA_CONTAINER_OF (listener, ModuleImpl, global_removed);
if (global->type == impl->core->uri.client) { if (global->type == impl->core->type.client) {
PinosClient *client = global->object; PinosClient *client = global->object;
ClientInfo *cinfo; ClientInfo *cinfo;

View file

@ -330,7 +330,7 @@ handle_create_node (PinosDaemon1 *interface,
pinos_resource_new (client, pinos_resource_new (client,
SPA_ID_INVALID, SPA_ID_INVALID,
impl->core->uri.node, impl->core->type.node,
node, node,
(PinosDestroy) pinos_node_destroy); (PinosDestroy) pinos_node_destroy);
@ -519,7 +519,7 @@ on_global_added (PinosListener *listener,
PinosProtocolDBus *impl = SPA_CONTAINER_OF (listener, PinosProtocolDBus, global_added); PinosProtocolDBus *impl = SPA_CONTAINER_OF (listener, PinosProtocolDBus, global_added);
PinosObjectSkeleton *skel; PinosObjectSkeleton *skel;
if (global->type == impl->core->uri.client) { if (global->type == impl->core->type.client) {
PinosClient1 *iface; PinosClient1 *iface;
PinosClient *client = global->object; PinosClient *client = global->object;
PinosProperties *props = client->properties; PinosProperties *props = client->properties;
@ -541,7 +541,7 @@ on_global_added (PinosListener *listener,
false, false,
(PinosDestroy) client_destroy); (PinosDestroy) client_destroy);
} else if (global->type == impl->core->uri.node) { } else if (global->type == impl->core->type.node) {
PinosNode1 *iface; PinosNode1 *iface;
PinosNode *node = global->object; PinosNode *node = global->object;
PinosProperties *props = node->properties; PinosProperties *props = node->properties;
@ -610,7 +610,7 @@ on_global_added (PinosListener *listener,
name_lost_handler, name_lost_handler,
proto, proto,
NULL); NULL);
} else if (global->type == impl->core->uri.link) { } else if (global->type == impl->core->type.link) {
PinosLink1 *iface; PinosLink1 *iface;
PinosLink *link = global->object; PinosLink *link = global->object;
PinosProtocolDBusObject *obj; PinosProtocolDBusObject *obj;

View file

@ -131,7 +131,7 @@ on_global_added (PinosListener *listener,
{ {
ModuleImpl *impl = SPA_CONTAINER_OF (listener, ModuleImpl, global_added); ModuleImpl *impl = SPA_CONTAINER_OF (listener, ModuleImpl, global_added);
if (global->type == impl->core->uri.node) { if (global->type == impl->core->type.node) {
PinosNode *node = global->object; PinosNode *node = global->object;
NodeInfo *info; NodeInfo *info;
@ -153,7 +153,7 @@ on_global_removed (PinosListener *listener,
{ {
ModuleImpl *impl = SPA_CONTAINER_OF (listener, ModuleImpl, global_removed); ModuleImpl *impl = SPA_CONTAINER_OF (listener, ModuleImpl, global_removed);
if (global->type == impl->core->uri.node) { if (global->type == impl->core->type.node) {
PinosNode *node = global->object; PinosNode *node = global->object;
NodeInfo *info; NodeInfo *info;

View file

@ -35,14 +35,14 @@ setup_video_node (PinosCore *core, SpaNode *spa_node, PinosProperties *pinos_pro
SpaResult res; SpaResult res;
SpaProps *props; SpaProps *props;
SpaPODProp *prop; SpaPODProp *prop;
const char *pattern, *pattern_uri; const char *pattern, *pattern_type;
/* Retrieve pattern property */ /* Retrieve pattern property */
pattern = pinos_properties_get (pinos_props, "pattern"); pattern = pinos_properties_get (pinos_props, "pattern");
if (strcmp (pattern, "smpte-snow") == 0) { if (strcmp (pattern, "smpte-snow") == 0) {
pattern_uri = SPA_TYPE_PROPS__patternType ":smpte-snow"; pattern_type = SPA_TYPE_PROPS__patternType ":smpte-snow";
} else if (strcmp (pattern, "snow") == 0) { } else if (strcmp (pattern, "snow") == 0) {
pattern_uri = SPA_TYPE_PROPS__patternType ":snow"; pattern_type = SPA_TYPE_PROPS__patternType ":snow";
} else { } else {
pinos_log_debug ("Unrecognized pattern"); pinos_log_debug ("Unrecognized pattern");
return SPA_RESULT_ERROR; return SPA_RESULT_ERROR;
@ -53,9 +53,9 @@ setup_video_node (PinosCore *core, SpaNode *spa_node, PinosProperties *pinos_pro
return SPA_RESULT_ERROR; return SPA_RESULT_ERROR;
} }
if ((prop = spa_pod_object_find_prop (props, spa_id_map_get_id (core->uri.map, SPA_TYPE_PROPS__patternType)))) { if ((prop = spa_pod_object_find_prop (props, spa_type_map_get_id (core->type.map, SPA_TYPE_PROPS__patternType)))) {
if (prop->body.value.type == SPA_POD_TYPE_URI) if (prop->body.value.type == SPA_POD_TYPE_URI)
SPA_POD_VALUE (SpaPODURI, &prop->body.value) = spa_id_map_get_id (core->uri.map, pattern_uri); SPA_POD_VALUE (SpaPODURI, &prop->body.value) = spa_type_map_get_id (core->type.map, pattern_type);
} }
if ((res = spa_node_set_props (spa_node, props)) != SPA_RESULT_OK) { if ((res = spa_node_set_props (spa_node, props)) != SPA_RESULT_OK) {

View file

@ -67,11 +67,11 @@ add_item (PinosSpaMonitor *this, SpaMonitorItem *item)
SpaPOD *info = NULL; SpaPOD *info = NULL;
spa_pod_object_query (item, spa_pod_object_query (item,
impl->core->uri.monitor_types.name, SPA_POD_TYPE_STRING, &name, impl->core->type.monitor.name, SPA_POD_TYPE_STRING, &name,
impl->core->uri.monitor_types.id, SPA_POD_TYPE_STRING, &id, impl->core->type.monitor.id, SPA_POD_TYPE_STRING, &id,
impl->core->uri.monitor_types.klass, SPA_POD_TYPE_STRING, &klass, impl->core->type.monitor.klass, SPA_POD_TYPE_STRING, &klass,
impl->core->uri.monitor_types.factory, SPA_POD_TYPE_POINTER, &factory, impl->core->type.monitor.factory, SPA_POD_TYPE_POINTER, &factory,
impl->core->uri.monitor_types.info, SPA_POD_TYPE_STRUCT, &info, impl->core->type.monitor.info, SPA_POD_TYPE_STRUCT, &info,
0); 0);
pinos_log_debug ("monitor %p: add: \"%s\" (%s)", this, name, id); pinos_log_debug ("monitor %p: add: \"%s\" (%s)", this, name, id);
@ -85,11 +85,11 @@ add_item (PinosSpaMonitor *this, SpaMonitorItem *item)
pinos_log_error ("can't make factory instance: %d", res); pinos_log_error ("can't make factory instance: %d", res);
return; return;
} }
if ((res = spa_handle_get_interface (handle, impl->core->uri.spa_node, &node_iface)) < 0) { if ((res = spa_handle_get_interface (handle, impl->core->type.spa_node, &node_iface)) < 0) {
pinos_log_error ("can't get NODE interface: %d", res); pinos_log_error ("can't get NODE interface: %d", res);
return; return;
} }
if ((res = spa_handle_get_interface (handle, impl->core->uri.spa_clock, &clock_iface)) < 0) { if ((res = spa_handle_get_interface (handle, impl->core->type.spa_clock, &clock_iface)) < 0) {
pinos_log_info ("no CLOCK interface: %d", res); pinos_log_info ("no CLOCK interface: %d", res);
} }
@ -151,8 +151,8 @@ remove_item (PinosSpaMonitor *this, SpaMonitorItem *item)
const char *name, *id; const char *name, *id;
spa_pod_object_query (item, spa_pod_object_query (item,
impl->core->uri.monitor_types.name, SPA_POD_TYPE_STRING, &name, impl->core->type.monitor.name, SPA_POD_TYPE_STRING, &name,
impl->core->uri.monitor_types.id, SPA_POD_TYPE_STRING, &id, impl->core->type.monitor.id, SPA_POD_TYPE_STRING, &id,
0); 0);
pinos_log_debug ("monitor %p: remove: \"%s\" (%s)", this, name, id); pinos_log_debug ("monitor %p: remove: \"%s\" (%s)", this, name, id);
@ -169,20 +169,20 @@ on_monitor_event (SpaMonitor *monitor,
PinosSpaMonitor *this = user_data; PinosSpaMonitor *this = user_data;
PinosSpaMonitorImpl *impl = SPA_CONTAINER_OF (this, PinosSpaMonitorImpl, this); PinosSpaMonitorImpl *impl = SPA_CONTAINER_OF (this, PinosSpaMonitorImpl, this);
if (SPA_EVENT_TYPE (event) == impl->core->uri.monitor_types.Added) { if (SPA_EVENT_TYPE (event) == impl->core->type.monitor.Added) {
SpaMonitorItem *item = SPA_POD_CONTENTS (SpaEvent, event); SpaMonitorItem *item = SPA_POD_CONTENTS (SpaEvent, event);
add_item (this, item); add_item (this, item);
} }
else if (SPA_EVENT_TYPE (event) == impl->core->uri.monitor_types.Removed) { else if (SPA_EVENT_TYPE (event) == impl->core->type.monitor.Removed) {
SpaMonitorItem *item = SPA_POD_CONTENTS (SpaEvent, event); SpaMonitorItem *item = SPA_POD_CONTENTS (SpaEvent, event);
remove_item (this, item); remove_item (this, item);
} }
else if (SPA_EVENT_TYPE (event) == impl->core->uri.monitor_types.Changed) { else if (SPA_EVENT_TYPE (event) == impl->core->type.monitor.Changed) {
SpaMonitorItem *item = SPA_POD_CONTENTS (SpaEvent, event); SpaMonitorItem *item = SPA_POD_CONTENTS (SpaEvent, event);
const char *name; const char *name;
spa_pod_object_query (item, spa_pod_object_query (item,
impl->core->uri.monitor_types.name, SPA_POD_TYPE_STRING, &name, impl->core->type.monitor.name, SPA_POD_TYPE_STRING, &name,
0); 0);
pinos_log_debug ("monitor %p: changed: \"%s\"", this, name); pinos_log_debug ("monitor %p: changed: \"%s\"", this, name);
@ -253,7 +253,7 @@ pinos_spa_monitor_load (PinosCore *core,
goto init_failed; goto init_failed;
} }
if ((res = spa_handle_get_interface (handle, if ((res = spa_handle_get_interface (handle,
core->uri.spa_monitor, core->type.spa_monitor,
&iface)) < 0) { &iface)) < 0) {
free (handle); free (handle);
pinos_log_error ("can't get MONITOR interface: %d", res); pinos_log_error ("can't get MONITOR interface: %d", res);

View file

@ -81,7 +81,7 @@ pinos_spa_node_load (PinosCore *core,
goto init_failed; goto init_failed;
} }
if ((res = spa_handle_get_interface (handle, if ((res = spa_handle_get_interface (handle,
core->uri.spa_node, core->type.spa_node,
&iface)) < 0) { &iface)) < 0) {
pinos_log_error ("can't get interface %d", res); pinos_log_error ("can't get interface %d", res);
goto interface_failed; goto interface_failed;
@ -89,7 +89,7 @@ pinos_spa_node_load (PinosCore *core,
spa_node = iface; spa_node = iface;
if ((res = spa_handle_get_interface (handle, if ((res = spa_handle_get_interface (handle,
core->uri.spa_clock, core->type.spa_clock,
&iface)) < 0) { &iface)) < 0) {
iface = NULL; iface = NULL;
} }

View file

@ -88,7 +88,7 @@ struct _SpaProxy
PinosNode *pnode; PinosNode *pnode;
SpaIDMap *map; SpaTypeMap *map;
SpaLog *log; SpaLog *log;
SpaLoop *main_loop; SpaLoop *main_loop;
SpaLoop *data_loop; SpaLoop *data_loop;
@ -130,7 +130,7 @@ static void
send_async_complete (SpaProxy *this, uint32_t seq, SpaResult res) send_async_complete (SpaProxy *this, uint32_t seq, SpaResult res)
{ {
PinosCore *core = this->pnode->core; PinosCore *core = this->pnode->core;
SpaEventNodeAsyncComplete ac = SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (core->uri.event_node.AsyncComplete, SpaEventNodeAsyncComplete ac = SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (core->type.event_node.AsyncComplete,
seq, res); seq, res);
this->event_cb (&this->node, (SpaEvent *)&ac, this->user_data); this->event_cb (&this->node, (SpaEvent *)&ac, this->user_data);
} }
@ -166,7 +166,7 @@ static void
send_need_input (SpaProxy *this) send_need_input (SpaProxy *this)
{ {
PinosNode *pnode = this->pnode; PinosNode *pnode = this->pnode;
SpaEvent event = SPA_EVENT_INIT (pnode->core->uri.event_node.NeedInput); SpaEvent event = SPA_EVENT_INIT (pnode->core->type.event_node.NeedInput);
uint64_t cmd = 1; uint64_t cmd = 1;
pinos_transport_add_event (pnode->transport, &event); pinos_transport_add_event (pnode->transport, &event);
@ -177,7 +177,7 @@ static void
send_have_output (SpaProxy *this) send_have_output (SpaProxy *this)
{ {
PinosNode *pnode = this->pnode; PinosNode *pnode = this->pnode;
SpaEvent event = SPA_EVENT_INIT (pnode->core->uri.event_node.HaveOutput); SpaEvent event = SPA_EVENT_INIT (pnode->core->type.event_node.HaveOutput);
uint64_t cmd = 1; uint64_t cmd = 1;
pinos_transport_add_event (pnode->transport, &event); pinos_transport_add_event (pnode->transport, &event);
@ -202,7 +202,7 @@ spa_proxy_node_send_command (SpaNode *node,
core = this->pnode->core; core = this->pnode->core;
if (SPA_COMMAND_TYPE (command) == core->uri.command_node.ClockUpdate) { if (SPA_COMMAND_TYPE (command) == core->type.command_node.ClockUpdate) {
pinos_client_node_notify_node_command (this->resource, pinos_client_node_notify_node_command (this->resource,
this->seq++, this->seq++,
command); command);
@ -212,7 +212,7 @@ spa_proxy_node_send_command (SpaNode *node,
pinos_client_node_notify_node_command (this->resource, pinos_client_node_notify_node_command (this->resource,
this->seq, this->seq,
command); command);
if (SPA_COMMAND_TYPE (command) == core->uri.command_node.Start) if (SPA_COMMAND_TYPE (command) == core->type.command_node.Start)
send_need_input (this); send_need_input (this);
res = SPA_RESULT_RETURN_ASYNC (this->seq++); res = SPA_RESULT_RETURN_ASYNC (this->seq++);
@ -770,7 +770,7 @@ spa_proxy_node_port_reuse_buffer (SpaNode *node,
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
{ {
SpaEventNodeReuseBuffer rb = SPA_EVENT_NODE_REUSE_BUFFER_INIT (pnode->core->uri.event_node.ReuseBuffer, SpaEventNodeReuseBuffer rb = SPA_EVENT_NODE_REUSE_BUFFER_INIT (pnode->core->type.event_node.ReuseBuffer,
port_id, buffer_id); port_id, buffer_id);
pinos_transport_add_event (pnode->transport, (SpaEvent *)&rb); pinos_transport_add_event (pnode->transport, (SpaEvent *)&rb);
//write (this->data_source.fd, &cmd, 8); //write (this->data_source.fd, &cmd, 8);
@ -999,11 +999,11 @@ proxy_init (SpaProxy *this,
uint32_t i; uint32_t i;
for (i = 0; i < n_support; i++) { for (i = 0; i < n_support; i++) {
if (strcmp (support[i].uri, SPA_TYPE__Log) == 0) if (strcmp (support[i].type, SPA_TYPE__Log) == 0)
this->log = support[i].data; this->log = support[i].data;
else if (strcmp (support[i].uri, SPA_TYPE_LOOP__MainLoop) == 0) else if (strcmp (support[i].type, SPA_TYPE_LOOP__MainLoop) == 0)
this->main_loop = support[i].data; this->main_loop = support[i].data;
else if (strcmp (support[i].uri, SPA_TYPE_LOOP__DataLoop) == 0) else if (strcmp (support[i].type, SPA_TYPE_LOOP__DataLoop) == 0)
this->data_loop = support[i].data; this->data_loop = support[i].data;
} }
if (this->data_loop == NULL) { if (this->data_loop == NULL) {
@ -1164,7 +1164,7 @@ pinos_client_node_new (PinosClient *client,
this->resource = pinos_resource_new (client, this->resource = pinos_resource_new (client,
id, id,
client->core->uri.client_node, client->core->type.client_node,
this, this,
(PinosDestroy) client_node_resource_destroy); (PinosDestroy) client_node_resource_destroy);
if (this->resource == NULL) if (this->resource == NULL)

View file

@ -106,14 +106,14 @@ pinos_client_new (PinosCore *core,
pinos_signal_init (&this->resource_removed); pinos_signal_init (&this->resource_removed);
pinos_map_init (&this->objects, 0, 32); pinos_map_init (&this->objects, 0, 32);
pinos_map_init (&this->uris, 0, 32); pinos_map_init (&this->types, 0, 32);
pinos_signal_init (&this->destroy_signal); pinos_signal_init (&this->destroy_signal);
spa_list_insert (core->client_list.prev, &this->link); spa_list_insert (core->client_list.prev, &this->link);
this->global = pinos_core_add_global (core, this->global = pinos_core_add_global (core,
this, this,
core->uri.client, core->type.client,
0, 0,
this, this,
client_bind_func); client_bind_func);

View file

@ -55,8 +55,8 @@ struct _PinosClient {
PinosResource *core_resource; PinosResource *core_resource;
PinosMap objects; PinosMap objects;
uint32_t n_uris; uint32_t n_types;
PinosMap uris; PinosMap types;
SpaList resource_list; SpaList resource_list;
PINOS_SIGNAL (resource_added, (PinosListener *listener, PINOS_SIGNAL (resource_added, (PinosListener *listener,

View file

@ -111,7 +111,7 @@ core_get_registry (void *object,
registry_resource = pinos_resource_new (client, registry_resource = pinos_resource_new (client,
new_id, new_id,
this->uri.registry, this->type.registry,
this, this,
destroy_registry_resource); destroy_registry_resource);
if (registry_resource == NULL) if (registry_resource == NULL)
@ -124,7 +124,7 @@ core_get_registry (void *object,
spa_list_for_each (global, &this->global_list, link) spa_list_for_each (global, &this->global_list, link)
pinos_registry_notify_global (registry_resource, pinos_registry_notify_global (registry_resource,
global->id, global->id,
spa_id_map_get_uri (this->uri.map, global->type)); spa_type_map_get_type (this->type.map, global->type));
return; return;
@ -203,21 +203,21 @@ no_mem:
} }
static void static void
core_update_uris (void *object, core_update_types (void *object,
uint32_t first_id, uint32_t first_id,
uint32_t n_uris, uint32_t n_types,
const char **uris) const char **types)
{ {
PinosResource *resource = object; PinosResource *resource = object;
PinosCore *this = resource->core; PinosCore *this = resource->core;
PinosClient *client = resource->client; PinosClient *client = resource->client;
int i; int i;
for (i = 0; i < n_uris; i++, first_id++) { for (i = 0; i < n_types; i++, first_id++) {
uint32_t this_id = spa_id_map_get_id (this->uri.map, uris[i]); uint32_t this_id = spa_type_map_get_id (this->type.map, types[i]);
printf ("update %d %s -> %d\n", first_id, uris[i], this_id); printf ("update %d %s -> %d\n", first_id, types[i], this_id);
if (!pinos_map_insert_at (&client->uris, first_id, SPA_UINT32_TO_PTR (this_id))) if (!pinos_map_insert_at (&client->types, first_id, SPA_UINT32_TO_PTR (this_id)))
pinos_log_error ("can't add uri for client"); pinos_log_error ("can't add type for client");
} }
} }
@ -227,7 +227,7 @@ static PinosCoreMethods core_methods = {
&core_get_registry, &core_get_registry,
&core_create_node, &core_create_node,
&core_create_client_node, &core_create_client_node,
&core_update_uris &core_update_types
}; };
static void static void
@ -291,17 +291,17 @@ pinos_core_new (PinosMainLoop *main_loop,
this->main_loop = main_loop; this->main_loop = main_loop;
this->properties = properties; this->properties = properties;
pinos_uri_init (&this->uri); pinos_type_init (&this->type);
pinos_access_init (&this->access); pinos_access_init (&this->access);
pinos_map_init (&this->objects, 128, 32); pinos_map_init (&this->objects, 128, 32);
impl->support[0].uri = SPA_TYPE__IDMap; impl->support[0].type = SPA_TYPE__TypeMap;
impl->support[0].data = this->uri.map; impl->support[0].data = this->type.map;
impl->support[1].uri = SPA_TYPE__Log; impl->support[1].type = SPA_TYPE__Log;
impl->support[1].data = pinos_log_get (); impl->support[1].data = pinos_log_get ();
impl->support[2].uri = SPA_TYPE_LOOP__DataLoop; impl->support[2].type = SPA_TYPE_LOOP__DataLoop;
impl->support[2].data = this->data_loop->loop->loop; impl->support[2].data = this->data_loop->loop->loop;
impl->support[3].uri = SPA_TYPE_LOOP__MainLoop; impl->support[3].type = SPA_TYPE_LOOP__MainLoop;
impl->support[3].data = this->main_loop->loop->loop; impl->support[3].data = this->main_loop->loop->loop;
this->support = impl->support; this->support = impl->support;
this->n_support = 4; this->n_support = 4;
@ -321,7 +321,7 @@ pinos_core_new (PinosMainLoop *main_loop,
this->global = pinos_core_add_global (this, this->global = pinos_core_add_global (this,
NULL, NULL,
this->uri.core, this->type.core,
0, 0,
this, this,
core_bind_func); core_bind_func);
@ -370,7 +370,7 @@ pinos_core_add_global (PinosCore *core,
PinosGlobalImpl *impl; PinosGlobalImpl *impl;
PinosGlobal *this; PinosGlobal *this;
PinosResource *registry; PinosResource *registry;
const char *type_uri; const char *type_name;
impl = calloc (1, sizeof (PinosGlobalImpl)); impl = calloc (1, sizeof (PinosGlobalImpl));
if (impl == NULL) if (impl == NULL)
@ -392,13 +392,13 @@ pinos_core_add_global (PinosCore *core,
spa_list_insert (core->global_list.prev, &this->link); spa_list_insert (core->global_list.prev, &this->link);
pinos_signal_emit (&core->global_added, core, this); pinos_signal_emit (&core->global_added, core, this);
type_uri = spa_id_map_get_uri (core->uri.map, this->type); type_name = spa_type_map_get_type (core->type.map, this->type);
pinos_log_debug ("global %p: new %u %s", this, this->id, type_uri); pinos_log_debug ("global %p: new %u %s", this, this->id, type_name);
spa_list_for_each (registry, &core->registry_resource_list, link) spa_list_for_each (registry, &core->registry_resource_list, link)
pinos_registry_notify_global (registry, pinos_registry_notify_global (registry,
this->id, this->id,
type_uri); type_name);
return this; return this;
} }

View file

@ -29,7 +29,7 @@ typedef struct _PinosGlobal PinosGlobal;
#include <spa/include/spa/log.h> #include <spa/include/spa/log.h>
#include <pinos/client/uri.h> #include <pinos/client/type.h>
#include <pinos/server/access.h> #include <pinos/server/access.h>
#include <pinos/server/main-loop.h> #include <pinos/server/main-loop.h>
@ -68,7 +68,7 @@ struct _PinosCore {
PinosProperties *properties; PinosProperties *properties;
PinosURI uri; PinosType type;
PinosAccess access; PinosAccess access;
PinosMap objects; PinosMap objects;

View file

@ -158,11 +158,11 @@ find_meta_enable (PinosCore *core, const SpaPortInfo *info, SpaMetaType type)
uint32_t i; uint32_t i;
for (i = 0; i < info->n_params; i++) { for (i = 0; i < info->n_params; i++) {
if (spa_pod_is_object_type (&info->params[i]->pod, core->uri.alloc_param_meta_enable.MetaEnable)) { if (spa_pod_is_object_type (&info->params[i]->pod, core->type.alloc_param_meta_enable.MetaEnable)) {
uint32_t qtype; uint32_t qtype;
if (spa_alloc_param_query (info->params[i], if (spa_alloc_param_query (info->params[i],
core->uri.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, &qtype, 0) != 1) core->type.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, &qtype, 0) != 1)
continue; continue;
if (qtype == type) if (qtype == type)
@ -208,11 +208,11 @@ alloc_buffers (PinosLink *this,
for (i = 0; i < n_params; i++) { for (i = 0; i < n_params; i++) {
SpaAllocParam *ap = params[i]; SpaAllocParam *ap = params[i];
if (ap->pod.type == this->core->uri.alloc_param_meta_enable.MetaEnable) { if (ap->pod.type == this->core->type.alloc_param_meta_enable.MetaEnable) {
uint32_t type; uint32_t type;
if (spa_alloc_param_query (ap, if (spa_alloc_param_query (ap,
this->core->uri.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, &type, this->core->type.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, &type,
0) != 1) 0) != 1)
continue; continue;
@ -404,43 +404,43 @@ do_allocation (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
max_buffers = 1; max_buffers = 1;
if (spa_alloc_param_query (in_me, if (spa_alloc_param_query (in_me,
this->core->uri.alloc_param_meta_enable.ringbufferSize, SPA_POD_TYPE_INT, &ms1, this->core->type.alloc_param_meta_enable.ringbufferSize, SPA_POD_TYPE_INT, &ms1,
this->core->uri.alloc_param_meta_enable.ringbufferStride, SPA_POD_TYPE_INT, &s1, 0) == 2 && this->core->type.alloc_param_meta_enable.ringbufferStride, SPA_POD_TYPE_INT, &s1, 0) == 2 &&
spa_alloc_param_query (in_me, spa_alloc_param_query (in_me,
this->core->uri.alloc_param_meta_enable.ringbufferSize, SPA_POD_TYPE_INT, &ms2, this->core->type.alloc_param_meta_enable.ringbufferSize, SPA_POD_TYPE_INT, &ms2,
this->core->uri.alloc_param_meta_enable.ringbufferStride, SPA_POD_TYPE_INT, &s2, 0) == 2) { this->core->type.alloc_param_meta_enable.ringbufferStride, SPA_POD_TYPE_INT, &s2, 0) == 2) {
minsize = SPA_MAX (ms1, ms2); minsize = SPA_MAX (ms1, ms2);
stride = SPA_MAX (s1, s2); stride = SPA_MAX (s1, s2);
} }
} else { } else {
max_buffers = MAX_BUFFERS; max_buffers = MAX_BUFFERS;
minsize = stride = 0; minsize = stride = 0;
in_alloc = find_param (iinfo, this->core->uri.alloc_param_buffers.Buffers); in_alloc = find_param (iinfo, this->core->type.alloc_param_buffers.Buffers);
if (in_alloc) { if (in_alloc) {
uint32_t qmax_buffers = max_buffers, uint32_t qmax_buffers = max_buffers,
qminsize = minsize, qminsize = minsize,
qstride = stride; qstride = stride;
spa_alloc_param_query (in_alloc, spa_alloc_param_query (in_alloc,
this->core->uri.alloc_param_buffers.size, SPA_POD_TYPE_INT, &qminsize, this->core->type.alloc_param_buffers.size, SPA_POD_TYPE_INT, &qminsize,
this->core->uri.alloc_param_buffers.stride, SPA_POD_TYPE_INT, &qstride, this->core->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, &qstride,
this->core->uri.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, &qmax_buffers, this->core->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, &qmax_buffers,
0); 0);
max_buffers = qmax_buffers == 0 ? max_buffers : SPA_MIN (qmax_buffers, max_buffers); max_buffers = qmax_buffers == 0 ? max_buffers : SPA_MIN (qmax_buffers, max_buffers);
minsize = SPA_MAX (minsize, qminsize); minsize = SPA_MAX (minsize, qminsize);
stride = SPA_MAX (stride, qstride); stride = SPA_MAX (stride, qstride);
} }
out_alloc = find_param (oinfo, this->core->uri.alloc_param_buffers.Buffers); out_alloc = find_param (oinfo, this->core->type.alloc_param_buffers.Buffers);
if (out_alloc) { if (out_alloc) {
uint32_t qmax_buffers = max_buffers, uint32_t qmax_buffers = max_buffers,
qminsize = minsize, qminsize = minsize,
qstride = stride; qstride = stride;
spa_alloc_param_query (out_alloc, spa_alloc_param_query (out_alloc,
this->core->uri.alloc_param_buffers.size, SPA_POD_TYPE_INT, &qminsize, this->core->type.alloc_param_buffers.size, SPA_POD_TYPE_INT, &qminsize,
this->core->uri.alloc_param_buffers.stride, SPA_POD_TYPE_INT, &qstride, this->core->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, &qstride,
this->core->uri.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, &qmax_buffers, this->core->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, &qmax_buffers,
0); 0);
max_buffers = qmax_buffers == 0 ? max_buffers : SPA_MIN (qmax_buffers, max_buffers); max_buffers = qmax_buffers == 0 ? max_buffers : SPA_MIN (qmax_buffers, max_buffers);
@ -866,7 +866,7 @@ pinos_link_new (PinosCore *core,
this->global = pinos_core_add_global (core, this->global = pinos_core_add_global (core,
NULL, NULL,
core->uri.link, core->type.link,
0, 0,
this, this,
link_bind_func); link_bind_func);

View file

@ -194,7 +194,7 @@ pinos_module_load (PinosCore *core,
this->global = pinos_core_add_global (core, this->global = pinos_core_add_global (core,
NULL, NULL,
core->uri.module, core->type.module,
0, 0,
impl, impl,
module_bind_func); module_bind_func);

View file

@ -21,8 +21,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include "spa/include/spa/node-command.h"
#include "pinos/client/pinos.h" #include "pinos/client/pinos.h"
#include "pinos/client/interfaces.h" #include "pinos/client/interfaces.h"
@ -169,7 +167,7 @@ pause_node (PinosNode *this)
pinos_log_debug ("node %p: pause node", this); pinos_log_debug ("node %p: pause node", this);
{ {
SpaCommand cmd = SPA_COMMAND_INIT (this->core->uri.command_node.Pause); SpaCommand cmd = SPA_COMMAND_INIT (this->core->type.command_node.Pause);
if ((res = spa_node_send_command (this->node, &cmd)) < 0) if ((res = spa_node_send_command (this->node, &cmd)) < 0)
pinos_log_debug ("got error %d", res); pinos_log_debug ("got error %d", res);
} }
@ -183,7 +181,7 @@ start_node (PinosNode *this)
pinos_log_debug ("node %p: start node", this); pinos_log_debug ("node %p: start node", this);
{ {
SpaCommand cmd = SPA_COMMAND_INIT (this->core->uri.command_node.Start); SpaCommand cmd = SPA_COMMAND_INIT (this->core->type.command_node.Start);
if ((res = spa_node_send_command (this->node, &cmd)) < 0) if ((res = spa_node_send_command (this->node, &cmd)) < 0)
pinos_log_debug ("got error %d", res); pinos_log_debug ("got error %d", res);
} }
@ -226,7 +224,7 @@ send_clock_update (PinosNode *this)
SpaResult res; SpaResult res;
SpaCommandNodeClockUpdate cu = SpaCommandNodeClockUpdate cu =
SPA_COMMAND_NODE_CLOCK_UPDATE_INIT( SPA_COMMAND_NODE_CLOCK_UPDATE_INIT(
this->core->uri.command_node.ClockUpdate, this->core->type.command_node.ClockUpdate,
SPA_COMMAND_NODE_CLOCK_UPDATE_TIME | SPA_COMMAND_NODE_CLOCK_UPDATE_TIME |
SPA_COMMAND_NODE_CLOCK_UPDATE_SCALE | SPA_COMMAND_NODE_CLOCK_UPDATE_SCALE |
SPA_COMMAND_NODE_CLOCK_UPDATE_STATE | SPA_COMMAND_NODE_CLOCK_UPDATE_STATE |
@ -258,7 +256,7 @@ on_node_event (SpaNode *node, SpaEvent *event, void *user_data)
PinosNode *this = user_data; PinosNode *this = user_data;
PinosNodeImpl *impl = SPA_CONTAINER_OF (this, PinosNodeImpl, this); PinosNodeImpl *impl = SPA_CONTAINER_OF (this, PinosNodeImpl, this);
if (SPA_EVENT_TYPE (event) == this->core->uri.event_node.AsyncComplete) { if (SPA_EVENT_TYPE (event) == this->core->type.event_node.AsyncComplete) {
SpaEventNodeAsyncComplete *ac = (SpaEventNodeAsyncComplete *) event; SpaEventNodeAsyncComplete *ac = (SpaEventNodeAsyncComplete *) event;
pinos_log_debug ("node %p: async complete event %d %d", this, ac->body.seq.value, ac->body.res.value); pinos_log_debug ("node %p: async complete event %d %d", this, ac->body.seq.value, ac->body.res.value);
@ -266,7 +264,7 @@ on_node_event (SpaNode *node, SpaEvent *event, void *user_data)
pinos_signal_emit (&this->async_complete, this, ac->body.seq.value, ac->body.res.value); pinos_signal_emit (&this->async_complete, this, ac->body.seq.value, ac->body.res.value);
} }
} }
else if (SPA_EVENT_TYPE (event) == this->core->uri.event_node.NeedInput) { else if (SPA_EVENT_TYPE (event) == this->core->type.event_node.NeedInput) {
SpaResult res; SpaResult res;
int i; int i;
bool processed = false; bool processed = false;
@ -310,7 +308,7 @@ on_node_event (SpaNode *node, SpaEvent *event, void *user_data)
pinos_log_warn ("node %p: got process input %d", this, res); pinos_log_warn ("node %p: got process input %d", this, res);
} }
} }
else if (SPA_EVENT_TYPE (event) == this->core->uri.event_node.HaveOutput) { else if (SPA_EVENT_TYPE (event) == this->core->type.event_node.HaveOutput) {
SpaResult res; SpaResult res;
int i; int i;
bool processed = false; bool processed = false;
@ -353,7 +351,7 @@ on_node_event (SpaNode *node, SpaEvent *event, void *user_data)
pinos_log_warn ("node %p: got process output %d", this, res); pinos_log_warn ("node %p: got process output %d", this, res);
} }
} }
else if (SPA_EVENT_TYPE (event) == this->core->uri.event_node.RequestClockUpdate) { else if (SPA_EVENT_TYPE (event) == this->core->type.event_node.RequestClockUpdate) {
send_clock_update (this); send_clock_update (this);
} }
} }
@ -455,7 +453,7 @@ init_complete (PinosNode *this)
spa_list_insert (this->core->node_list.prev, &this->link); spa_list_insert (this->core->node_list.prev, &this->link);
this->global = pinos_core_add_global (this->core, this->global = pinos_core_add_global (this->core,
NULL, NULL,
this->core->uri.node, this->core->type.node,
0, 0,
this, this,
node_bind_func); node_bind_func);

View file

@ -206,7 +206,7 @@ no_mem:
static SpaResult static SpaResult
pinos_port_pause (PinosPort *port) pinos_port_pause (PinosPort *port)
{ {
SpaCommand cmd = SPA_COMMAND_INIT (port->node->core->uri.command_node.Pause); SpaCommand cmd = SPA_COMMAND_INIT (port->node->core->type.command_node.Pause);
return spa_node_port_send_command (port->node->node, return spa_node_port_send_command (port->node->node,
port->direction, port->direction,
port->port_id, port->port_id,

View file

@ -50,22 +50,22 @@ core_update_map (PinosClient *client)
{ {
uint32_t diff, base, i; uint32_t diff, base, i;
PinosCore *core = client->core; PinosCore *core = client->core;
const char **uris; const char **types;
base = client->n_uris; base = client->n_types;
diff = spa_id_map_get_size (core->uri.map) - base; diff = spa_type_map_get_size (core->type.map) - base;
if (diff == 0) if (diff == 0)
return; return;
uris = alloca (diff * sizeof (char *)); types = alloca (diff * sizeof (char *));
for (i = 0; i < diff; i++, base++) for (i = 0; i < diff; i++, base++)
uris[i] = spa_id_map_get_uri (core->uri.map, base); types[i] = spa_type_map_get_type (core->type.map, base);
pinos_core_notify_update_uris (client->core_resource, pinos_core_notify_update_types (client->core_resource,
client->n_uris, client->n_types,
diff, diff,
uris); types);
client->n_uris += diff; client->n_types += diff;
} }
static void static void
@ -166,10 +166,10 @@ core_marshal_remove_id (void *object,
} }
static void static void
core_marshal_update_uris (void *object, core_marshal_update_types (void *object,
uint32_t first_id, uint32_t first_id,
uint32_t n_uris, uint32_t n_types,
const char **uris) const char **types)
{ {
PinosResource *resource = object; PinosResource *resource = object;
PinosConnection *connection = resource->client->protocol_private; PinosConnection *connection = resource->client->protocol_private;
@ -180,11 +180,11 @@ core_marshal_update_uris (void *object,
spa_pod_builder_add (&b.b, spa_pod_builder_add (&b.b,
SPA_POD_TYPE_STRUCT, &f, SPA_POD_TYPE_STRUCT, &f,
SPA_POD_TYPE_INT, first_id, SPA_POD_TYPE_INT, first_id,
SPA_POD_TYPE_INT, n_uris, 0); SPA_POD_TYPE_INT, n_types, 0);
for (i = 0; i < n_uris; i++) { for (i = 0; i < n_types; i++) {
spa_pod_builder_add (&b.b, spa_pod_builder_add (&b.b,
SPA_POD_TYPE_STRING, uris[i], 0); SPA_POD_TYPE_STRING, types[i], 0);
} }
spa_pod_builder_add (&b.b, spa_pod_builder_add (&b.b,
-SPA_POD_TYPE_STRUCT, &f, 0); -SPA_POD_TYPE_STRUCT, &f, 0);
@ -333,29 +333,29 @@ core_demarshal_create_client_node (void *object,
} }
static bool static bool
core_demarshal_update_uris (void *object, core_demarshal_update_types (void *object,
void *data, void *data,
size_t size) size_t size)
{ {
PinosResource *resource = object; PinosResource *resource = object;
SpaPODIter it; SpaPODIter it;
uint32_t first_id, n_uris; uint32_t first_id, n_types;
const char **uris; const char **types;
int i; int i;
if (!spa_pod_iter_struct (&it, data, size) || if (!spa_pod_iter_struct (&it, data, size) ||
!spa_pod_iter_get (&it, !spa_pod_iter_get (&it,
SPA_POD_TYPE_INT, &first_id, SPA_POD_TYPE_INT, &first_id,
SPA_POD_TYPE_INT, &n_uris, SPA_POD_TYPE_INT, &n_types,
0)) 0))
return false; return false;
uris = alloca (n_uris * sizeof (char *)); types = alloca (n_types * sizeof (char *));
for (i = 0; i < n_uris; i++) { for (i = 0; i < n_types; i++) {
if (!spa_pod_iter_get (&it, SPA_POD_TYPE_STRING, &uris[i], 0)) if (!spa_pod_iter_get (&it, SPA_POD_TYPE_STRING, &types[i], 0))
return false; return false;
} }
((PinosCoreMethods*)resource->implementation)->update_uris (resource, first_id, n_uris, uris); ((PinosCoreMethods*)resource->implementation)->update_types (resource, first_id, n_types, types);
return true; return true;
} }
@ -975,7 +975,7 @@ static const PinosDemarshalFunc pinos_protocol_native_server_core_demarshal[] =
&core_demarshal_get_registry, &core_demarshal_get_registry,
&core_demarshal_create_node, &core_demarshal_create_node,
&core_demarshal_create_client_node, &core_demarshal_create_client_node,
&core_demarshal_update_uris &core_demarshal_update_types
}; };
static const PinosCoreEvents pinos_protocol_native_server_core_events = { static const PinosCoreEvents pinos_protocol_native_server_core_events = {
@ -983,7 +983,7 @@ static const PinosCoreEvents pinos_protocol_native_server_core_events = {
&core_marshal_done, &core_marshal_done,
&core_marshal_error, &core_marshal_error,
&core_marshal_remove_id, &core_marshal_remove_id,
&core_marshal_update_uris &core_marshal_update_types
}; };
const PinosInterface pinos_protocol_native_server_core_interface = { const PinosInterface pinos_protocol_native_server_core_interface = {
@ -1072,25 +1072,25 @@ bool
pinos_protocol_native_server_setup (PinosResource *resource) pinos_protocol_native_server_setup (PinosResource *resource)
{ {
const PinosInterface *iface; const PinosInterface *iface;
if (resource->type == resource->core->uri.core) { if (resource->type == resource->core->type.core) {
iface = &pinos_protocol_native_server_core_interface; iface = &pinos_protocol_native_server_core_interface;
} }
else if (resource->type == resource->core->uri.registry) { else if (resource->type == resource->core->type.registry) {
iface = &pinos_protocol_native_server_registry_interface; iface = &pinos_protocol_native_server_registry_interface;
} }
else if (resource->type == resource->core->uri.module) { else if (resource->type == resource->core->type.module) {
iface = &pinos_protocol_native_server_module_interface; iface = &pinos_protocol_native_server_module_interface;
} }
else if (resource->type == resource->core->uri.node) { else if (resource->type == resource->core->type.node) {
iface = &pinos_protocol_native_server_node_interface; iface = &pinos_protocol_native_server_node_interface;
} }
else if (resource->type == resource->core->uri.client) { else if (resource->type == resource->core->type.client) {
iface = &pinos_protocol_native_server_client_interface; iface = &pinos_protocol_native_server_client_interface;
} }
else if (resource->type == resource->core->uri.client_node) { else if (resource->type == resource->core->type.client_node) {
iface = &pinos_protocol_native_server_client_node_interface; iface = &pinos_protocol_native_server_client_node_interface;
} }
else if (resource->type == resource->core->uri.link) { else if (resource->type == resource->core->type.link) {
iface = &pinos_protocol_native_server_link_interface; iface = &pinos_protocol_native_server_link_interface;
} else } else
return false; return false;

View file

@ -187,26 +187,26 @@ dump_object (PinosContext *context,
uint32_t id, uint32_t id,
DumpData *data) DumpData *data)
{ {
if (type == context->uri.core) { if (type == context->type.core) {
pinos_context_get_core_info (context, pinos_context_get_core_info (context,
dump_core_info, dump_core_info,
data); data);
} else if (type == context->uri.node) { } else if (type == context->type.node) {
pinos_context_get_node_info_by_id (context, pinos_context_get_node_info_by_id (context,
id, id,
dump_node_info, dump_node_info,
data); data);
} else if (type == context->uri.module) { } else if (type == context->type.module) {
pinos_context_get_module_info_by_id (context, pinos_context_get_module_info_by_id (context,
id, id,
dump_module_info, dump_module_info,
data); data);
} else if (type == context->uri.client) { } else if (type == context->type.client) {
pinos_context_get_client_info_by_id (context, pinos_context_get_client_info_by_id (context,
id, id,
dump_client_info, dump_client_info,
data); data);
} else if (type == context->uri.link) { } else if (type == context->type.link) {
pinos_context_get_link_info_by_id (context, pinos_context_get_link_info_by_id (context,
id, id,
dump_link_info, dump_link_info,

View file

@ -0,0 +1,160 @@
/* Simple Plugin API
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __SPA_ALLOC_PARAM_H__
#define __SPA_ALLOC_PARAM_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _SpaAllocParam SpaAllocParam;
#include <spa/defs.h>
#include <spa/type-map.h>
#include <spa/pod-utils.h>
#define SPA_TYPE__AllocParam "Spa:Object:AllocParam"
#define SPA_TYPE_ALLOC_PARAM_BASE SPA_TYPE__AllocParam ":"
typedef struct {
SpaPODObjectBody body;
/* SpaPODProp follow */
} SpaAllocParamBody;
struct _SpaAllocParam {
SpaPOD pod;
SpaAllocParamBody body;
};
static inline uint32_t
spa_alloc_param_query (const SpaAllocParam *param, uint32_t key, ...)
{
uint32_t count;
va_list args;
va_start (args, key);
count = spa_pod_contents_queryv (&param->pod, sizeof (SpaAllocParam), key, args);
va_end (args);
return count;
}
#define SPA_TYPE_ALLOC_PARAM__Buffers SPA_TYPE_ALLOC_PARAM_BASE "Buffers"
#define SPA_TYPE_ALLOC_PARAM_BUFFERS_BASE SPA_TYPE_ALLOC_PARAM__Buffers ":"
#define SPA_TYPE_ALLOC_PARAM_BUFFERS__size SPA_TYPE_ALLOC_PARAM_BUFFERS_BASE "size"
#define SPA_TYPE_ALLOC_PARAM_BUFFERS__stride SPA_TYPE_ALLOC_PARAM_BUFFERS_BASE "stride"
#define SPA_TYPE_ALLOC_PARAM_BUFFERS__buffers SPA_TYPE_ALLOC_PARAM_BUFFERS_BASE "buffers"
#define SPA_TYPE_ALLOC_PARAM_BUFFERS__align SPA_TYPE_ALLOC_PARAM_BUFFERS_BASE "align"
typedef struct {
uint32_t Buffers;
uint32_t size;
uint32_t stride;
uint32_t buffers;
uint32_t align;
} SpaTypeAllocParamBuffers;
static inline void
spa_type_alloc_param_buffers_map (SpaTypeMap *map, SpaTypeAllocParamBuffers *type)
{
if (type->Buffers == 0) {
type->Buffers = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM__Buffers);
type->size = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_BUFFERS__size);
type->stride = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_BUFFERS__stride);
type->buffers = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_BUFFERS__buffers);
type->align = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_BUFFERS__align);
}
}
#define SPA_TYPE_ALLOC_PARAM__MetaEnable SPA_TYPE_ALLOC_PARAM_BASE "MetaEnable"
#define SPA_TYPE_ALLOC_PARAM_META_ENABLE_BASE SPA_TYPE_ALLOC_PARAM__MetaEnable ":"
#define SPA_TYPE_ALLOC_PARAM_META_ENABLE__type SPA_TYPE_ALLOC_PARAM_META_ENABLE_BASE "type"
#define SPA_TYPE_ALLOC_PARAM_META_ENABLE__ringbufferSize SPA_TYPE_ALLOC_PARAM_META_ENABLE_BASE "ringbufferSize"
#define SPA_TYPE_ALLOC_PARAM_META_ENABLE__ringbufferStride SPA_TYPE_ALLOC_PARAM_META_ENABLE_BASE "ringbufferStride"
#define SPA_TYPE_ALLOC_PARAM_META_ENABLE__ringbufferBlocks SPA_TYPE_ALLOC_PARAM_META_ENABLE_BASE "ringbufferBlocks"
#define SPA_TYPE_ALLOC_PARAM_META_ENABLE__ringbufferAlign SPA_TYPE_ALLOC_PARAM_META_ENABLE_BASE "ringbufferAlign"
typedef struct {
uint32_t MetaEnable;
uint32_t type;
uint32_t ringbufferSize;
uint32_t ringbufferStride;
uint32_t ringbufferBlocks;
uint32_t ringbufferAlign;
} SpaTypeAllocParamMetaEnable;
static inline void
spa_type_alloc_param_meta_enable_map (SpaTypeMap *map, SpaTypeAllocParamMetaEnable *type)
{
if (type->MetaEnable == 0) {
type->MetaEnable = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM__MetaEnable);
type->type = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_META_ENABLE__type);
type->ringbufferSize = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_META_ENABLE__ringbufferSize);
type->ringbufferStride = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_META_ENABLE__ringbufferStride);
type->ringbufferBlocks = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_META_ENABLE__ringbufferBlocks);
type->ringbufferAlign = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_META_ENABLE__ringbufferAlign);
}
}
#define SPA_TYPE_ALLOC_PARAM__VideoPadding SPA_TYPE_ALLOC_PARAM_BASE "VideoPadding"
#define SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING_BASE SPA_TYPE_ALLOC_PARAM__VideoPadding ":"
#define SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__top SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING_BASE "top"
#define SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__bottom SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING_BASE "bottom"
#define SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__left SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING_BASE "left"
#define SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__right SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING_BASE "right"
#define SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__strideAlign0 SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING_BASE "strideAlign0"
#define SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__strideAlign1 SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING_BASE "strideAlign1"
#define SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__strideAlign2 SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING_BASE "strideAlign2"
#define SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__strideAlign3 SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING_BASE "strideAlign3"
typedef struct {
uint32_t VideoPadding;
uint32_t top;
uint32_t bottom;
uint32_t left;
uint32_t right;
uint32_t strideAlign[4];
} SpaTypeAllocParamVideoPadding;
static inline void
spa_type_alloc_param_video_padding_map (SpaTypeMap *map, SpaTypeAllocParamVideoPadding *type)
{
if (type->VideoPadding == 0) {
type->VideoPadding = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM__VideoPadding);
type->top = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__top);
type->bottom = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__bottom);
type->left = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__left);
type->right = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__right);
type->strideAlign[0] = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__strideAlign0);
type->strideAlign[1] = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__strideAlign1);
type->strideAlign[2] = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__strideAlign2);
type->strideAlign[3] = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__strideAlign3);
}
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPA_ALLOC_PARAM_H__ */

View file

@ -35,18 +35,18 @@ typedef struct {
uint32_t rate; uint32_t rate;
uint32_t channels; uint32_t channels;
uint32_t channel_mask; uint32_t channel_mask;
} SpaPropAudio; } SpaTypePropAudio;
static inline void static inline void
spa_prop_audio_map (SpaIDMap *map, SpaPropAudio *types) spa_type_prop_audio_map (SpaTypeMap *map, SpaTypePropAudio *type)
{ {
if (types->format == 0) { if (type->format == 0) {
types->format = spa_id_map_get_id (map, SPA_TYPE_PROP_AUDIO__format); type->format = spa_type_map_get_id (map, SPA_TYPE_PROP_AUDIO__format);
types->flags = spa_id_map_get_id (map, SPA_TYPE_PROP_AUDIO__flags); type->flags = spa_type_map_get_id (map, SPA_TYPE_PROP_AUDIO__flags);
types->layout = spa_id_map_get_id (map, SPA_TYPE_PROP_AUDIO__layout); type->layout = spa_type_map_get_id (map, SPA_TYPE_PROP_AUDIO__layout);
types->rate = spa_id_map_get_id (map, SPA_TYPE_PROP_AUDIO__rate); type->rate = spa_type_map_get_id (map, SPA_TYPE_PROP_AUDIO__rate);
types->channels = spa_id_map_get_id (map, SPA_TYPE_PROP_AUDIO__channels); type->channels = spa_type_map_get_id (map, SPA_TYPE_PROP_AUDIO__channels);
types->channel_mask = spa_id_map_get_id (map, SPA_TYPE_PROP_AUDIO__channelMask); type->channel_mask = spa_type_map_get_id (map, SPA_TYPE_PROP_AUDIO__channelMask);
} }
} }

View file

@ -24,15 +24,15 @@
extern "C" { extern "C" {
#endif #endif
#include <spa/id-map.h> #include <spa/type-map.h>
#include <spa/audio/raw.h> #include <spa/audio/raw.h>
#if __BYTE_ORDER == __BIG_ENDIAN #if __BYTE_ORDER == __BIG_ENDIAN
#define _SPA_AUDIO_FORMAT_NE(fmt) SPA_TYPE_AUDIO_FORMAT_BASE fmt "BE" #define _SPA_TYPE_AUDIO_FORMAT_NE(fmt) SPA_TYPE_AUDIO_FORMAT_BASE fmt "BE"
#define _SPA_AUDIO_FORMAT_OE(fmt) SPA_TYPE_AUDIO_FORMAT_BASE fmt "LE" #define _SPA_TYPE_AUDIO_FORMAT_OE(fmt) SPA_TYPE_AUDIO_FORMAT_BASE fmt "LE"
#elif __BYTE_ORDER == __LITTLE_ENDIAN #elif __BYTE_ORDER == __LITTLE_ENDIAN
#define _SPA_AUDIO_FORMAT_NE(fmt) SPA_TYPE_AUDIO_FORMAT_BASE fmt "LE" #define _SPA_TYPE_AUDIO_FORMAT_NE(fmt) SPA_TYPE_AUDIO_FORMAT_BASE fmt "LE"
#define _SPA_AUDIO_FORMAT_OE(fmt) SPA_TYPE_AUDIO_FORMAT_BASE fmt "BE" #define _SPA_TYPE_AUDIO_FORMAT_OE(fmt) SPA_TYPE_AUDIO_FORMAT_BASE fmt "BE"
#endif #endif
typedef struct { typedef struct {
@ -68,47 +68,47 @@ typedef struct {
uint32_t U18_OE; uint32_t U18_OE;
uint32_t F32_OE; uint32_t F32_OE;
uint32_t F64_OE; uint32_t F64_OE;
} SpaAudioFormats; } SpaTypeAudioFormat;
static inline void static inline void
spa_audio_formats_map (SpaIDMap *map, SpaAudioFormats *types) spa_type_audio_format_map (SpaTypeMap *map, SpaTypeAudioFormat *type)
{ {
if (types->ENCODED == 0) { if (type->ENCODED == 0) {
types->UNKNOWN = 0; type->UNKNOWN = 0;
types->ENCODED = spa_id_map_get_id (map, SPA_TYPE_AUDIO_FORMAT__ENCODED); type->ENCODED = spa_type_map_get_id (map, SPA_TYPE_AUDIO_FORMAT__ENCODED);
types->S8 = spa_id_map_get_id (map, SPA_TYPE_AUDIO_FORMAT__S8); type->S8 = spa_type_map_get_id (map, SPA_TYPE_AUDIO_FORMAT__S8);
types->U8 = spa_id_map_get_id (map, SPA_TYPE_AUDIO_FORMAT__U8); type->U8 = spa_type_map_get_id (map, SPA_TYPE_AUDIO_FORMAT__U8);
types->S16 = spa_id_map_get_id (map, _SPA_AUDIO_FORMAT_NE ("S16")); type->S16 = spa_type_map_get_id (map, _SPA_TYPE_AUDIO_FORMAT_NE ("S16"));
types->U16 = spa_id_map_get_id (map, _SPA_AUDIO_FORMAT_NE ("U16")); type->U16 = spa_type_map_get_id (map, _SPA_TYPE_AUDIO_FORMAT_NE ("U16"));
types->S24_32 = spa_id_map_get_id (map, _SPA_AUDIO_FORMAT_NE ("S24_32")); type->S24_32 = spa_type_map_get_id (map, _SPA_TYPE_AUDIO_FORMAT_NE ("S24_32"));
types->U24_32 = spa_id_map_get_id (map, _SPA_AUDIO_FORMAT_NE ("U24_32")); type->U24_32 = spa_type_map_get_id (map, _SPA_TYPE_AUDIO_FORMAT_NE ("U24_32"));
types->S32 = spa_id_map_get_id (map, _SPA_AUDIO_FORMAT_NE ("S32")); type->S32 = spa_type_map_get_id (map, _SPA_TYPE_AUDIO_FORMAT_NE ("S32"));
types->U32 = spa_id_map_get_id (map, _SPA_AUDIO_FORMAT_NE ("U32")); type->U32 = spa_type_map_get_id (map, _SPA_TYPE_AUDIO_FORMAT_NE ("U32"));
types->S24 = spa_id_map_get_id (map, _SPA_AUDIO_FORMAT_NE ("S24")); type->S24 = spa_type_map_get_id (map, _SPA_TYPE_AUDIO_FORMAT_NE ("S24"));
types->U24 = spa_id_map_get_id (map, _SPA_AUDIO_FORMAT_NE ("U24")); type->U24 = spa_type_map_get_id (map, _SPA_TYPE_AUDIO_FORMAT_NE ("U24"));
types->S20 = spa_id_map_get_id (map, _SPA_AUDIO_FORMAT_NE ("S20")); type->S20 = spa_type_map_get_id (map, _SPA_TYPE_AUDIO_FORMAT_NE ("S20"));
types->U20 = spa_id_map_get_id (map, _SPA_AUDIO_FORMAT_NE ("U20")); type->U20 = spa_type_map_get_id (map, _SPA_TYPE_AUDIO_FORMAT_NE ("U20"));
types->S18 = spa_id_map_get_id (map, _SPA_AUDIO_FORMAT_NE ("S18")); type->S18 = spa_type_map_get_id (map, _SPA_TYPE_AUDIO_FORMAT_NE ("S18"));
types->U18 = spa_id_map_get_id (map, _SPA_AUDIO_FORMAT_NE ("U18")); type->U18 = spa_type_map_get_id (map, _SPA_TYPE_AUDIO_FORMAT_NE ("U18"));
types->F32 = spa_id_map_get_id (map, _SPA_AUDIO_FORMAT_NE ("F32")); type->F32 = spa_type_map_get_id (map, _SPA_TYPE_AUDIO_FORMAT_NE ("F32"));
types->F64 = spa_id_map_get_id (map, _SPA_AUDIO_FORMAT_NE ("F64")); type->F64 = spa_type_map_get_id (map, _SPA_TYPE_AUDIO_FORMAT_NE ("F64"));
types->S16_OE = spa_id_map_get_id (map, _SPA_AUDIO_FORMAT_OE ("S16")); type->S16_OE = spa_type_map_get_id (map, _SPA_TYPE_AUDIO_FORMAT_OE ("S16"));
types->U16_OE = spa_id_map_get_id (map, _SPA_AUDIO_FORMAT_OE ("U16")); type->U16_OE = spa_type_map_get_id (map, _SPA_TYPE_AUDIO_FORMAT_OE ("U16"));
types->S24_32_OE = spa_id_map_get_id (map, _SPA_AUDIO_FORMAT_OE ("S24_32")); type->S24_32_OE = spa_type_map_get_id (map, _SPA_TYPE_AUDIO_FORMAT_OE ("S24_32"));
types->U24_32_OE = spa_id_map_get_id (map, _SPA_AUDIO_FORMAT_OE ("U24_32")); type->U24_32_OE = spa_type_map_get_id (map, _SPA_TYPE_AUDIO_FORMAT_OE ("U24_32"));
types->S32_OE = spa_id_map_get_id (map, _SPA_AUDIO_FORMAT_OE ("S32")); type->S32_OE = spa_type_map_get_id (map, _SPA_TYPE_AUDIO_FORMAT_OE ("S32"));
types->U32_OE = spa_id_map_get_id (map, _SPA_AUDIO_FORMAT_OE ("U32")); type->U32_OE = spa_type_map_get_id (map, _SPA_TYPE_AUDIO_FORMAT_OE ("U32"));
types->S24_OE = spa_id_map_get_id (map, _SPA_AUDIO_FORMAT_OE ("S24")); type->S24_OE = spa_type_map_get_id (map, _SPA_TYPE_AUDIO_FORMAT_OE ("S24"));
types->U24_OE = spa_id_map_get_id (map, _SPA_AUDIO_FORMAT_OE ("U24")); type->U24_OE = spa_type_map_get_id (map, _SPA_TYPE_AUDIO_FORMAT_OE ("U24"));
types->S20_OE = spa_id_map_get_id (map, _SPA_AUDIO_FORMAT_OE ("S20")); type->S20_OE = spa_type_map_get_id (map, _SPA_TYPE_AUDIO_FORMAT_OE ("S20"));
types->U20_OE = spa_id_map_get_id (map, _SPA_AUDIO_FORMAT_OE ("U20")); type->U20_OE = spa_type_map_get_id (map, _SPA_TYPE_AUDIO_FORMAT_OE ("U20"));
types->S18_OE = spa_id_map_get_id (map, _SPA_AUDIO_FORMAT_OE ("S18")); type->S18_OE = spa_type_map_get_id (map, _SPA_TYPE_AUDIO_FORMAT_OE ("S18"));
types->U18_OE = spa_id_map_get_id (map, _SPA_AUDIO_FORMAT_OE ("U18")); type->U18_OE = spa_type_map_get_id (map, _SPA_TYPE_AUDIO_FORMAT_OE ("U18"));
types->F32_OE = spa_id_map_get_id (map, _SPA_AUDIO_FORMAT_OE ("F32")); type->F32_OE = spa_type_map_get_id (map, _SPA_TYPE_AUDIO_FORMAT_OE ("F32"));
types->F64_OE = spa_id_map_get_id (map, _SPA_AUDIO_FORMAT_OE ("F64")); type->F64_OE = spa_type_map_get_id (map, _SPA_TYPE_AUDIO_FORMAT_OE ("F64"));
} }
} }

View file

@ -24,7 +24,7 @@
extern "C" { extern "C" {
#endif #endif
#include <spa/id-map.h> #include <spa/type-map.h>
#include <spa/command.h> #include <spa/command.h>
#define SPA_TYPE_COMMAND__Node SPA_TYPE_COMMAND_BASE "Node" #define SPA_TYPE_COMMAND__Node SPA_TYPE_COMMAND_BASE "Node"
@ -44,18 +44,18 @@ typedef struct {
uint32_t Drain; uint32_t Drain;
uint32_t Marker; uint32_t Marker;
uint32_t ClockUpdate; uint32_t ClockUpdate;
} SpaCommandNode; } SpaTypeCommandNode;
static inline void static inline void
spa_command_node_map (SpaIDMap *map, SpaCommandNode *types) spa_type_command_node_map (SpaTypeMap *map, SpaTypeCommandNode *type)
{ {
if (types->Pause == 0) { if (type->Pause == 0) {
types->Pause = spa_id_map_get_id (map, SPA_TYPE_COMMAND_NODE__Pause); type->Pause = spa_type_map_get_id (map, SPA_TYPE_COMMAND_NODE__Pause);
types->Start = spa_id_map_get_id (map, SPA_TYPE_COMMAND_NODE__Start); type->Start = spa_type_map_get_id (map, SPA_TYPE_COMMAND_NODE__Start);
types->Flush = spa_id_map_get_id (map, SPA_TYPE_COMMAND_NODE__Flush); type->Flush = spa_type_map_get_id (map, SPA_TYPE_COMMAND_NODE__Flush);
types->Drain = spa_id_map_get_id (map, SPA_TYPE_COMMAND_NODE__Drain); type->Drain = spa_type_map_get_id (map, SPA_TYPE_COMMAND_NODE__Drain);
types->Marker = spa_id_map_get_id (map, SPA_TYPE_COMMAND_NODE__Marker); type->Marker = spa_type_map_get_id (map, SPA_TYPE_COMMAND_NODE__Marker);
types->ClockUpdate = spa_id_map_get_id (map, SPA_TYPE_COMMAND_NODE__ClockUpdate); type->ClockUpdate = spa_type_map_get_id (map, SPA_TYPE_COMMAND_NODE__ClockUpdate);
} }
} }

View file

@ -26,7 +26,7 @@ extern "C" {
#include <spa/defs.h> #include <spa/defs.h>
#include <spa/event.h> #include <spa/event.h>
#include <spa/id-map.h> #include <spa/type-map.h>
#include <spa/node.h> #include <spa/node.h>
#define SPA_TYPE_EVENT__Node SPA_TYPE_EVENT_BASE "Node" #define SPA_TYPE_EVENT__Node SPA_TYPE_EVENT_BASE "Node"
@ -50,20 +50,20 @@ typedef struct {
uint32_t Buffering; uint32_t Buffering;
uint32_t RequestRefresh; uint32_t RequestRefresh;
uint32_t RequestClockUpdate; uint32_t RequestClockUpdate;
} SpaEventNode; } SpaTypeEventNode;
static inline void static inline void
spa_event_node_map (SpaIDMap *map, SpaEventNode *types) spa_type_event_node_map (SpaTypeMap *map, SpaTypeEventNode *type)
{ {
if (types->AsyncComplete == 0) { if (type->AsyncComplete == 0) {
types->AsyncComplete = spa_id_map_get_id (map, SPA_TYPE_EVENT_NODE__AsyncComplete); type->AsyncComplete = spa_type_map_get_id (map, SPA_TYPE_EVENT_NODE__AsyncComplete);
types->HaveOutput = spa_id_map_get_id (map, SPA_TYPE_EVENT_NODE__HaveOutput); type->HaveOutput = spa_type_map_get_id (map, SPA_TYPE_EVENT_NODE__HaveOutput);
types->NeedInput = spa_id_map_get_id (map, SPA_TYPE_EVENT_NODE__NeedInput); type->NeedInput = spa_type_map_get_id (map, SPA_TYPE_EVENT_NODE__NeedInput);
types->ReuseBuffer = spa_id_map_get_id (map, SPA_TYPE_EVENT_NODE__ReuseBuffer); type->ReuseBuffer = spa_type_map_get_id (map, SPA_TYPE_EVENT_NODE__ReuseBuffer);
types->Error = spa_id_map_get_id (map, SPA_TYPE_EVENT_NODE__Error); type->Error = spa_type_map_get_id (map, SPA_TYPE_EVENT_NODE__Error);
types->Buffering = spa_id_map_get_id (map, SPA_TYPE_EVENT_NODE__Buffering); type->Buffering = spa_type_map_get_id (map, SPA_TYPE_EVENT_NODE__Buffering);
types->RequestRefresh = spa_id_map_get_id (map, SPA_TYPE_EVENT_NODE__RequestRefresh); type->RequestRefresh = spa_type_map_get_id (map, SPA_TYPE_EVENT_NODE__RequestRefresh);
types->RequestClockUpdate = spa_id_map_get_id (map, SPA_TYPE_EVENT_NODE__RequestClockUpdate); type->RequestClockUpdate = spa_type_map_get_id (map, SPA_TYPE_EVENT_NODE__RequestClockUpdate);
} }
} }

View file

@ -28,33 +28,33 @@ extern "C" {
#include <spa/format.h> #include <spa/format.h>
#include <spa/pod-utils.h> #include <spa/pod-utils.h>
#include <spa/id-map.h> #include <spa/type-map.h>
typedef struct { typedef struct {
uint32_t audio; uint32_t audio;
uint32_t video; uint32_t video;
uint32_t image; uint32_t image;
} SpaMediaTypes; } SpaTypeMediaType;
static inline void static inline void
spa_media_types_fill (SpaMediaTypes *types, SpaIDMap *map) spa_type_media_type_map (SpaTypeMap *map, SpaTypeMediaType *type)
{ {
if (types->audio == 0) { if (type->audio == 0) {
types->audio = spa_id_map_get_id (map, SPA_TYPE_MEDIA_TYPE__audio); type->audio = spa_type_map_get_id (map, SPA_TYPE_MEDIA_TYPE__audio);
types->video = spa_id_map_get_id (map, SPA_TYPE_MEDIA_TYPE__video); type->video = spa_type_map_get_id (map, SPA_TYPE_MEDIA_TYPE__video);
types->image = spa_id_map_get_id (map, SPA_TYPE_MEDIA_TYPE__image); type->image = spa_type_map_get_id (map, SPA_TYPE_MEDIA_TYPE__image);
} }
} }
typedef struct { typedef struct {
uint32_t raw; uint32_t raw;
} SpaMediaSubtypes; } SpaTypeMediaSubtype;
static inline void static inline void
spa_media_subtypes_map (SpaIDMap *map, SpaMediaSubtypes *types) spa_type_media_subtype_map (SpaTypeMap *map, SpaTypeMediaSubtype *type)
{ {
if (types->raw == 0) { if (type->raw == 0) {
types->raw = spa_id_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__raw); type->raw = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__raw);
} }
} }
@ -73,26 +73,26 @@ typedef struct {
uint32_t vp9; uint32_t vp9;
uint32_t jpeg; uint32_t jpeg;
uint32_t bayer; uint32_t bayer;
} SpaMediaSubtypesVideo; } SpaTypeMediaSubtypeVideo;
static inline void static inline void
spa_media_subtypes_video_map (SpaIDMap *map, SpaMediaSubtypesVideo *types) spa_type_media_subtype_video_map (SpaTypeMap *map, SpaTypeMediaSubtypeVideo *type)
{ {
if (types->h264 == 0) { if (type->h264 == 0) {
types->h264 = spa_id_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__h264); type->h264 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__h264);
types->mjpg = spa_id_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__mjpg); type->mjpg = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__mjpg);
types->dv = spa_id_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__dv); type->dv = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__dv);
types->mpegts = spa_id_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__mpegts); type->mpegts = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__mpegts);
types->h263 = spa_id_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__h263); type->h263 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__h263);
types->mpeg1 = spa_id_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__mpeg1); type->mpeg1 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__mpeg1);
types->mpeg2 = spa_id_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__mpeg2); type->mpeg2 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__mpeg2);
types->mpeg4 = spa_id_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__mpeg4); type->mpeg4 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__mpeg4);
types->xvid = spa_id_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__xvid); type->xvid = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__xvid);
types->vc1 = spa_id_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__vc1); type->vc1 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__vc1);
types->vp8 = spa_id_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__vp8); type->vp8 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__vp8);
types->vp9 = spa_id_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__vp9); type->vp9 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__vp9);
types->jpeg = spa_id_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__jpeg); type->jpeg = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__jpeg);
types->bayer = spa_id_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__bayer); type->bayer = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__bayer);
} }
} }
@ -109,24 +109,24 @@ typedef struct {
uint32_t g729; uint32_t g729;
uint32_t amr; uint32_t amr;
uint32_t gsm; uint32_t gsm;
} SpaMediaSubtypesAudio; } SpaTypeMediaSubtypeAudio;
static inline void static inline void
spa_media_subtypes_audio_map (SpaIDMap *map, SpaMediaSubtypesAudio *types) spa_type_media_subtype_audio_map (SpaTypeMap *map, SpaTypeMediaSubtypeAudio *type)
{ {
if (types->mp3 == 0) { if (type->mp3 == 0) {
types->mp3 = spa_id_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__mp3); type->mp3 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__mp3);
types->aac = spa_id_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__aac); type->aac = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__aac);
types->vorbis = spa_id_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__vorbis); type->vorbis = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__vorbis);
types->wma = spa_id_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__wma); type->wma = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__wma);
types->ra = spa_id_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__ra); type->ra = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__ra);
types->sbc = spa_id_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__sbc); type->sbc = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__sbc);
types->adpcm = spa_id_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__adpcm); type->adpcm = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__adpcm);
types->g723 = spa_id_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__g723); type->g723 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__g723);
types->g726 = spa_id_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__g726); type->g726 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__g726);
types->g729 = spa_id_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__g729); type->g729 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__g729);
types->amr = spa_id_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__amr); type->amr = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__amr);
types->gsm = spa_id_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__gsm); type->gsm = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__gsm);
} }
} }

View file

@ -4,17 +4,16 @@ spa_headers = [
'buffer.h', 'buffer.h',
'clock.h', 'clock.h',
'command.h', 'command.h',
'command-node.h',
'defs.h', 'defs.h',
'dict.h', 'dict.h',
'event.h', 'event.h',
'event-node.h',
'format.h', 'format.h',
'id-map.h',
'list.h', 'list.h',
'log.h', 'log.h',
'loop.h', 'loop.h',
'monitor.h', 'monitor.h',
'node-command.h',
'node-event.h',
'node.h', 'node.h',
'plugin.h', 'plugin.h',
'pod.h', 'pod.h',
@ -22,7 +21,8 @@ spa_headers = [
'pod-iter.h', 'pod-iter.h',
'pod-utils.h', 'pod-utils.h',
'props.h', 'props.h',
'ringbuffer.h' 'ringbuffer.h',
'type-map.h',
] ]
install_headers(spa_headers, subdir : 'spa') install_headers(spa_headers, subdir : 'spa')

View file

@ -67,24 +67,24 @@ typedef struct {
uint32_t klass; uint32_t klass;
uint32_t info; uint32_t info;
uint32_t factory; uint32_t factory;
} SpaMonitorTypes; } SpaTypeMonitor;
static inline void static inline void
spa_monitor_types_map (SpaIDMap *map, SpaMonitorTypes *types) spa_type_monitor_map (SpaTypeMap *map, SpaTypeMonitor *type)
{ {
if (types->Added == 0) { if (type->Added == 0) {
types->Monitor = spa_id_map_get_id (map, SPA_TYPE__Monitor); type->Monitor = spa_type_map_get_id (map, SPA_TYPE__Monitor);
types->Added = spa_id_map_get_id (map, SPA_TYPE_EVENT_MONITOR__Added); type->Added = spa_type_map_get_id (map, SPA_TYPE_EVENT_MONITOR__Added);
types->Removed = spa_id_map_get_id (map, SPA_TYPE_EVENT_MONITOR__Removed); type->Removed = spa_type_map_get_id (map, SPA_TYPE_EVENT_MONITOR__Removed);
types->Changed = spa_id_map_get_id (map, SPA_TYPE_EVENT_MONITOR__Changed); type->Changed = spa_type_map_get_id (map, SPA_TYPE_EVENT_MONITOR__Changed);
types->MonitorItem = spa_id_map_get_id (map, SPA_TYPE__MonitorItem); type->MonitorItem = spa_type_map_get_id (map, SPA_TYPE__MonitorItem);
types->id = spa_id_map_get_id (map, SPA_TYPE_MONITOR_ITEM__id); type->id = spa_type_map_get_id (map, SPA_TYPE_MONITOR_ITEM__id);
types->flags = spa_id_map_get_id (map, SPA_TYPE_MONITOR_ITEM__flags); type->flags = spa_type_map_get_id (map, SPA_TYPE_MONITOR_ITEM__flags);
types->state = spa_id_map_get_id (map, SPA_TYPE_MONITOR_ITEM__state); type->state = spa_type_map_get_id (map, SPA_TYPE_MONITOR_ITEM__state);
types->name = spa_id_map_get_id (map, SPA_TYPE_MONITOR_ITEM__name); type->name = spa_type_map_get_id (map, SPA_TYPE_MONITOR_ITEM__name);
types->klass = spa_id_map_get_id (map, SPA_TYPE_MONITOR_ITEM__class); type->klass = spa_type_map_get_id (map, SPA_TYPE_MONITOR_ITEM__class);
types->info = spa_id_map_get_id (map, SPA_TYPE_MONITOR_ITEM__info); type->info = spa_type_map_get_id (map, SPA_TYPE_MONITOR_ITEM__info);
types->factory = spa_id_map_get_id (map, SPA_TYPE_MONITOR_ITEM__factory); type->factory = spa_type_map_get_id (map, SPA_TYPE_MONITOR_ITEM__factory);
} }
} }

View file

@ -52,8 +52,8 @@ typedef enum {
#include <spa/plugin.h> #include <spa/plugin.h>
#include <spa/props.h> #include <spa/props.h>
#include <spa/alloc-param.h> #include <spa/alloc-param.h>
#include <spa/node-event.h> #include <spa/event-node.h>
#include <spa/node-command.h> #include <spa/command-node.h>
#include <spa/buffer.h> #include <spa/buffer.h>
#include <spa/format.h> #include <spa/format.h>

View file

@ -68,25 +68,25 @@ struct _SpaHandle {
/** /**
* SpaInterfaceInfo: * SpaInterfaceInfo:
* @uri: the uri of the interface, can be used to get the interface * @type: the type of the interface, can be used to get the interface
* *
* This structure lists the information about available interfaces on * This structure lists the information about available interfaces on
* handles. * handles.
*/ */
typedef struct { typedef struct {
const char *uri; const char *type;
} SpaInterfaceInfo; } SpaInterfaceInfo;
/** /**
* SpaSupport: * SpaSupport:
* @uri: the uri of the support item * @type: the type of the support item
* @data: specific data for the item * @data: specific data for the item
* *
* Extra supporting infrastructure passed to the init() function of * Extra supporting infrastructure passed to the init() function of
* a factory. It can be extra information or interfaces such as logging. * a factory. It can be extra information or interfaces such as logging.
*/ */
typedef struct { typedef struct {
const char *uri; const char *type;
void *data; void *data;
} SpaSupport; } SpaSupport;

View file

@ -26,8 +26,8 @@ extern "C" {
typedef struct _SpaRingbuffer SpaRingbuffer; typedef struct _SpaRingbuffer SpaRingbuffer;
#define SPA_RINGBUFFER_URI "http://spaplug.in/ns/ringbuffer" #define SPA_TYPE__RingBuffer "Spa:Object:RingBuffer"
#define SPA_RINGBUFFER_PREFIX SPA_RINGBUFFER_URI "#" #define SPA_TYPE_RINGBUFFER_BASE SPA_TYPE__RingBuffer ":"
#include <string.h> #include <string.h>

View file

@ -17,52 +17,53 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#ifndef __SPA_ID_MAP_H__ #ifndef __SPA_TYPE_MAP_H__
#define __SPA_ID_MAP_H__ #define __SPA_TYPE_MAP_H__
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
typedef struct _SpaIDMap SpaIDMap; typedef struct _SpaTypeMap SpaTypeMap;
#include <spa/defs.h> #include <spa/defs.h>
#include <spa/plugin.h> #include <spa/plugin.h>
#include <spa/type.h>
#define SPA_TYPE__IDMap "Spa:Interface:IDMap" #define SPA_TYPE__TypeMap "Spa:Interface:TypeMap"
#define SPA_TYPE_ID_MAP_BASE SPA_TYPE__IDMap ":" #define SPA_TYPE_TYPE_MAP_BASE SPA_TYPE__TypeMap ":"
/** /**
* SpaIDMap: * SpaTypeMap:
* *
* Maps between uri and its id * Maps between string types and their type id
*/ */
struct _SpaIDMap { struct _SpaTypeMap {
/* the total size of this structure. This can be used to expand this /* the total size of this structure. This can be used to expand this
* structure in the future */ * structure in the future */
const size_t size; const size_t size;
/** /**
* SpaIDMap::info * SpaTypeMap::info
* *
* Extra information about the map * Extra information about the type map
*/ */
const SpaDict *info; const SpaDict *info;
uint32_t (*get_id) (SpaIDMap *map, SpaType (*get_id) (SpaTypeMap *map,
const char *uri); const char *type);
const char * (*get_uri) (SpaIDMap *map, const char * (*get_type) (SpaTypeMap *map,
uint32_t id); SpaType id);
uint32_t (*get_size) (SpaIDMap *map); size_t (*get_size) (SpaTypeMap *map);
}; };
#define spa_id_map_get_id(n,...) (n)->get_id((n),__VA_ARGS__) #define spa_type_map_get_id(n,...) (n)->get_id((n),__VA_ARGS__)
#define spa_id_map_get_uri(n,...) (n)->get_uri((n),__VA_ARGS__) #define spa_type_map_get_type(n,...) (n)->get_type((n),__VA_ARGS__)
#define spa_id_map_get_size(n) (n)->get_size(n) #define spa_type_map_get_size(n) (n)->get_size(n)
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */
#endif #endif
#endif /* __SPA_ID_MAP_H__ */ #endif /* __SPA_TYPE_MAP_H__ */

36
spa/include/spa/type.h Normal file
View file

@ -0,0 +1,36 @@
/* Simple Plugin API
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __SPA_TYPE_H__
#define __SPA_TYPE_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/defs.h>
typedef uint32_t SpaType;
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPA_TYPE_H__ */

View file

@ -47,30 +47,30 @@ typedef struct {
uint32_t level; uint32_t level;
uint32_t stream_format; uint32_t stream_format;
uint32_t alignment; uint32_t alignment;
} SpaPropVideo; } SpaTypePropVideo;
static inline void static inline void
spa_prop_video_map (SpaIDMap *map, SpaPropVideo *types) spa_type_prop_video_map (SpaTypeMap *map, SpaTypePropVideo *type)
{ {
if (types->format == 0) { if (type->format == 0) {
types->format = spa_id_map_get_id (map, SPA_TYPE_PROP_VIDEO__format); type->format = spa_type_map_get_id (map, SPA_TYPE_PROP_VIDEO__format);
types->size = spa_id_map_get_id (map, SPA_TYPE_PROP_VIDEO__size); type->size = spa_type_map_get_id (map, SPA_TYPE_PROP_VIDEO__size);
types->framerate = spa_id_map_get_id (map, SPA_TYPE_PROP_VIDEO__framerate); type->framerate = spa_type_map_get_id (map, SPA_TYPE_PROP_VIDEO__framerate);
types->max_framerate = spa_id_map_get_id (map, SPA_TYPE_PROP_VIDEO__maxFramerate); type->max_framerate = spa_type_map_get_id (map, SPA_TYPE_PROP_VIDEO__maxFramerate);
types->views = spa_id_map_get_id (map, SPA_TYPE_PROP_VIDEO__views); type->views = spa_type_map_get_id (map, SPA_TYPE_PROP_VIDEO__views);
types->interlace_mode = spa_id_map_get_id (map, SPA_TYPE_PROP_VIDEO__interlaceMode); type->interlace_mode = spa_type_map_get_id (map, SPA_TYPE_PROP_VIDEO__interlaceMode);
types->pixel_aspect_ratio = spa_id_map_get_id (map, SPA_TYPE_PROP_VIDEO__pixelAspectRatio); type->pixel_aspect_ratio = spa_type_map_get_id (map, SPA_TYPE_PROP_VIDEO__pixelAspectRatio);
types->multiview_mode = spa_id_map_get_id (map, SPA_TYPE_PROP_VIDEO__multiviewMode); type->multiview_mode = spa_type_map_get_id (map, SPA_TYPE_PROP_VIDEO__multiviewMode);
types->multiview_flags = spa_id_map_get_id (map, SPA_TYPE_PROP_VIDEO__multiviewFlags); type->multiview_flags = spa_type_map_get_id (map, SPA_TYPE_PROP_VIDEO__multiviewFlags);
types->chroma_site = spa_id_map_get_id (map, SPA_TYPE_PROP_VIDEO__chromaSite); type->chroma_site = spa_type_map_get_id (map, SPA_TYPE_PROP_VIDEO__chromaSite);
types->color_range = spa_id_map_get_id (map, SPA_TYPE_PROP_VIDEO__colorRange); type->color_range = spa_type_map_get_id (map, SPA_TYPE_PROP_VIDEO__colorRange);
types->color_matrix = spa_id_map_get_id (map, SPA_TYPE_PROP_VIDEO__colorMatrix); type->color_matrix = spa_type_map_get_id (map, SPA_TYPE_PROP_VIDEO__colorMatrix);
types->transfer_function = spa_id_map_get_id (map, SPA_TYPE_PROP_VIDEO__transferFunction); type->transfer_function = spa_type_map_get_id (map, SPA_TYPE_PROP_VIDEO__transferFunction);
types->color_primaries = spa_id_map_get_id (map, SPA_TYPE_PROP_VIDEO__colorPrimaries); type->color_primaries = spa_type_map_get_id (map, SPA_TYPE_PROP_VIDEO__colorPrimaries);
types->profile = spa_id_map_get_id (map, SPA_TYPE_PROP_VIDEO__profile); type->profile = spa_type_map_get_id (map, SPA_TYPE_PROP_VIDEO__profile);
types->level = spa_id_map_get_id (map, SPA_TYPE_PROP_VIDEO__level); type->level = spa_type_map_get_id (map, SPA_TYPE_PROP_VIDEO__level);
types->stream_format = spa_id_map_get_id (map, SPA_TYPE_PROP_VIDEO__streamFormat); type->stream_format = spa_type_map_get_id (map, SPA_TYPE_PROP_VIDEO__streamFormat);
types->alignment = spa_id_map_get_id (map, SPA_TYPE_PROP_VIDEO__alignment); type->alignment = spa_type_map_get_id (map, SPA_TYPE_PROP_VIDEO__alignment);
} }
} }

View file

@ -26,7 +26,7 @@ extern "C" {
typedef struct _SpaVideoInfoRaw SpaVideoInfoRaw; typedef struct _SpaVideoInfoRaw SpaVideoInfoRaw;
#include <spa/id-map.h> #include <spa/type-map.h>
#include <spa/video/raw.h> #include <spa/video/raw.h>
typedef struct typedef struct
@ -96,77 +96,77 @@ typedef struct
uint32_t P010_10LE; uint32_t P010_10LE;
uint32_t IYU2; uint32_t IYU2;
uint32_t VYUY; uint32_t VYUY;
} SpaVideoFormats; } SpaTypeVideoFormat;
static inline void static inline void
spa_video_formats_map (SpaIDMap *map, SpaVideoFormats *types) spa_type_video_format_map (SpaTypeMap *map, SpaTypeVideoFormat *type)
{ {
if (types->ENCODED == 0) { if (type->ENCODED == 0) {
types->UNKNOWN = 0; type->UNKNOWN = 0;
types->ENCODED = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__ENCODED); type->ENCODED = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__ENCODED);
types->I420 = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__I420); type->I420 = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__I420);
types->YV12 = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__YV12); type->YV12 = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__YV12);
types->YUY2 = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__YUY2); type->YUY2 = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__YUY2);
types->UYVY = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__UYVY); type->UYVY = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__UYVY);
types->AYUV = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__AYUV); type->AYUV = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__AYUV);
types->RGBx = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__RGBx); type->RGBx = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__RGBx);
types->BGRx = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__BGRx); type->BGRx = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__BGRx);
types->xRGB = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__xRGB); type->xRGB = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__xRGB);
types->xBGR = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__xBGR); type->xBGR = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__xBGR);
types->RGBA = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__RGBA); type->RGBA = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__RGBA);
types->BGRA = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__BGRA); type->BGRA = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__BGRA);
types->ARGB = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__ARGB); type->ARGB = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__ARGB);
types->ABGR = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__ABGR); type->ABGR = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__ABGR);
types->RGB = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__RGB); type->RGB = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__RGB);
types->BGR = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__BGR); type->BGR = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__BGR);
types->Y41B = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__Y41B); type->Y41B = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__Y41B);
types->Y42B = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__Y42B); type->Y42B = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__Y42B);
types->YVYU = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__YVYU); type->YVYU = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__YVYU);
types->Y444 = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__Y444); type->Y444 = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__Y444);
types->v210 = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__v210); type->v210 = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__v210);
types->v216 = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__v216); type->v216 = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__v216);
types->NV12 = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__NV12); type->NV12 = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__NV12);
types->NV21 = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__NV21); type->NV21 = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__NV21);
types->GRAY8 = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__GRAY8); type->GRAY8 = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__GRAY8);
types->GRAY16_BE = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__GRAY16_BE); type->GRAY16_BE = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__GRAY16_BE);
types->GRAY16_LE = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__GRAY16_LE); type->GRAY16_LE = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__GRAY16_LE);
types->v308 = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__v308); type->v308 = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__v308);
types->RGB16 = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__RGB16); type->RGB16 = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__RGB16);
types->BGR16 = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__BGR16); type->BGR16 = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__BGR16);
types->RGB15 = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__RGB15); type->RGB15 = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__RGB15);
types->BGR15 = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__BGR15); type->BGR15 = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__BGR15);
types->UYVP = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__UYVP); type->UYVP = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__UYVP);
types->A420 = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__A420); type->A420 = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__A420);
types->RGB8P = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__RGB8P); type->RGB8P = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__RGB8P);
types->YUV9 = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__YUV9); type->YUV9 = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__YUV9);
types->YVU9 = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__YVU9); type->YVU9 = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__YVU9);
types->IYU1 = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__IYU1); type->IYU1 = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__IYU1);
types->ARGB64 = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__ARGB64); type->ARGB64 = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__ARGB64);
types->AYUV64 = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__AYUV64); type->AYUV64 = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__AYUV64);
types->r210 = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__r210); type->r210 = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__r210);
types->I420_10BE = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__I420_10BE); type->I420_10BE = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__I420_10BE);
types->I420_10LE = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__I420_10LE); type->I420_10LE = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__I420_10LE);
types->I422_10BE = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__I422_10BE); type->I422_10BE = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__I422_10BE);
types->I422_10LE = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__I422_10LE); type->I422_10LE = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__I422_10LE);
types->Y444_10BE = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__Y444_10BE); type->Y444_10BE = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__Y444_10BE);
types->Y444_10LE = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__Y444_10LE); type->Y444_10LE = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__Y444_10LE);
types->GBR = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__GBR); type->GBR = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__GBR);
types->GBR_10BE = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__GBR_10BE); type->GBR_10BE = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__GBR_10BE);
types->GBR_10LE = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__GBR_10LE); type->GBR_10LE = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__GBR_10LE);
types->NV16 = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__NV16); type->NV16 = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__NV16);
types->NV24 = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__NV24); type->NV24 = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__NV24);
types->NV12_64Z32 = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__NV12_64Z32); type->NV12_64Z32 = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__NV12_64Z32);
types->A420_10BE = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__A420_10BE); type->A420_10BE = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__A420_10BE);
types->A420_10LE = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__A420_10LE); type->A420_10LE = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__A420_10LE);
types->A422_10BE = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__A422_10BE); type->A422_10BE = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__A422_10BE);
types->A422_10LE = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__A422_10LE); type->A422_10LE = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__A422_10LE);
types->A444_10BE = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__A444_10BE); type->A444_10BE = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__A444_10BE);
types->A444_10LE = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__A444_10LE); type->A444_10LE = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__A444_10LE);
types->NV61 = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__NV61); type->NV61 = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__NV61);
types->P010_10BE = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__P010_10BE); type->P010_10BE = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__P010_10BE);
types->P010_10LE = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__P010_10LE); type->P010_10LE = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__P010_10LE);
types->IYU2 = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__IYU2); type->IYU2 = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__IYU2);
types->VYUY = spa_id_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__VYUY); type->VYUY = spa_type_map_get_id (map, SPA_TYPE_VIDEO_FORMAT__VYUY);
} }
} }

View file

@ -27,7 +27,6 @@ extern "C" {
typedef struct _SpaVideoInfoRaw SpaVideoInfoRaw; typedef struct _SpaVideoInfoRaw SpaVideoInfoRaw;
#include <spa/props.h> #include <spa/props.h>
#include <spa/id-map.h>
#include <spa/video/chroma.h> #include <spa/video/chroma.h>
#include <spa/video/color.h> #include <spa/video/color.h>
#include <spa/video/multiview.h> #include <spa/video/multiview.h>

View file

@ -30,23 +30,24 @@ SpaResult
spa_format_audio_parse (const SpaFormat *format, spa_format_audio_parse (const SpaFormat *format,
SpaAudioInfo *info) SpaAudioInfo *info)
{ {
static SpaMediaTypes media_types = { 0, }; static SpaTypeMediaType media_type = { 0, };
static SpaMediaSubtypes media_subtypes = { 0, }; static SpaTypeMediaSubtype media_subtype = { 0, };
static SpaMediaSubtypesAudio media_subtypes_audio = { 0, }; static SpaTypeMediaSubtypeAudio media_subtype_audio = { 0, };
static SpaPropAudio prop_audio = { 0, }; static SpaTypePropAudio prop_audio = { 0, };
SpaTypeMap *map = spa_type_map_get_default();
spa_media_types_fill (&media_types, spa_id_map_get_default()); spa_type_media_type_map (map, &media_type);
spa_media_subtypes_map (spa_id_map_get_default(), &media_subtypes); spa_type_media_subtype_map (map, &media_subtype);
spa_media_subtypes_audio_map (spa_id_map_get_default (), &media_subtypes_audio); spa_type_media_subtype_audio_map (map, &media_subtype_audio);
spa_prop_audio_map (spa_id_map_get_default (), &prop_audio); spa_type_prop_audio_map (map, &prop_audio);
if (format->body.media_type.value != media_types.audio) if (format->body.media_type.value != media_type.audio)
return SPA_RESULT_INVALID_MEDIA_TYPE; return SPA_RESULT_INVALID_MEDIA_TYPE;
info->media_type = format->body.media_type.value; info->media_type = format->body.media_type.value;
info->media_subtype = format->body.media_subtype.value; info->media_subtype = format->body.media_subtype.value;
if (info->media_subtype == media_subtypes.raw) { if (info->media_subtype == media_subtype.raw) {
spa_format_query (format, spa_format_query (format,
prop_audio.format, SPA_POD_TYPE_URI, &info->info.raw.format, prop_audio.format, SPA_POD_TYPE_URI, &info->info.raw.format,
prop_audio.flags, SPA_POD_TYPE_INT, &info->info.raw.flags, prop_audio.flags, SPA_POD_TYPE_INT, &info->info.raw.flags,

View file

@ -215,7 +215,7 @@ print_pod_value (uint32_t size, uint32_t type, void *body, int prefix)
break; break;
case SPA_POD_TYPE_URI: case SPA_POD_TYPE_URI:
printf ("%-*sURI %d %s\n", prefix, "", *(int32_t *) body, printf ("%-*sURI %d %s\n", prefix, "", *(int32_t *) body,
spa_id_map_get_uri (spa_id_map_get_default(), *(int32_t*)body)); spa_type_map_get_type (spa_type_map_get_default(), *(int32_t*)body));
break; break;
case SPA_POD_TYPE_INT: case SPA_POD_TYPE_INT:
printf ("%-*sInt %d\n", prefix, "", *(int32_t *) body); printf ("%-*sInt %d\n", prefix, "", *(int32_t *) body);
@ -236,7 +236,7 @@ print_pod_value (uint32_t size, uint32_t type, void *body, int prefix)
{ {
SpaPODPointerBody *b = body; SpaPODPointerBody *b = body;
printf ("%-*sPointer %s %p\n", prefix, "", printf ("%-*sPointer %s %p\n", prefix, "",
spa_id_map_get_uri (spa_id_map_get_default(), b->type), b->value); spa_type_map_get_type (spa_type_map_get_default(), b->type), b->value);
break; break;
} }
case SPA_POD_TYPE_RECTANGLE: case SPA_POD_TYPE_RECTANGLE:
@ -278,7 +278,7 @@ print_pod_value (uint32_t size, uint32_t type, void *body, int prefix)
SpaPOD *p; SpaPOD *p;
printf ("%-*sObject: size %d, id %d, type %s\n", prefix, "", size, b->id, printf ("%-*sObject: size %d, id %d, type %s\n", prefix, "", size, b->id,
spa_id_map_get_uri (spa_id_map_get_default(), b->type)); spa_type_map_get_type (spa_type_map_get_default(), b->type));
SPA_POD_OBJECT_BODY_FOREACH (b, size, p) SPA_POD_OBJECT_BODY_FOREACH (b, size, p)
print_pod_value (p->size, p->type, SPA_POD_BODY (p), prefix + 2); print_pod_value (p->size, p->type, SPA_POD_BODY (p), prefix + 2);
break; break;
@ -290,7 +290,7 @@ print_pod_value (uint32_t size, uint32_t type, void *body, int prefix)
int i; int i;
printf ("%-*sProp: key %s, flags %d\n", prefix, "", printf ("%-*sProp: key %s, flags %d\n", prefix, "",
spa_id_map_get_uri (spa_id_map_get_default(), b->key), b->flags); spa_type_map_get_type (spa_type_map_get_default(), b->key), b->flags);
if (b->flags & SPA_POD_PROP_FLAG_UNSET) if (b->flags & SPA_POD_PROP_FLAG_UNSET)
printf ("%-*sUnset (Default):\n", prefix + 2, ""); printf ("%-*sUnset (Default):\n", prefix + 2, "");
else else
@ -336,7 +336,7 @@ print_format_value (uint32_t size, uint32_t type, void *body)
break; break;
case SPA_POD_TYPE_URI: case SPA_POD_TYPE_URI:
{ {
const char *str = spa_id_map_get_uri (spa_id_map_get_default(), *(int32_t*)body); const char *str = spa_type_map_get_type (spa_type_map_get_default(), *(int32_t*)body);
if (str) { if (str) {
const char *h = rindex (str, ':'); const char *h = rindex (str, ':');
if (h) if (h)
@ -400,8 +400,8 @@ spa_debug_format (const SpaFormat *format)
mtype = format->body.media_type.value; mtype = format->body.media_type.value;
mstype = format->body.media_subtype.value; mstype = format->body.media_subtype.value;
media_type = spa_id_map_get_uri (spa_id_map_get_default (), mtype); media_type = spa_type_map_get_type (spa_type_map_get_default (), mtype);
media_subtype = spa_id_map_get_uri (spa_id_map_get_default (), mstype); media_subtype = spa_type_map_get_type (spa_type_map_get_default (), mstype);
fprintf (stderr, "%-6s %s/%s\n", "", rindex (media_type, ':')+1, rindex (media_subtype, ':')+1); fprintf (stderr, "%-6s %s/%s\n", "", rindex (media_type, ':')+1, rindex (media_subtype, ':')+1);
@ -412,7 +412,7 @@ spa_debug_format (const SpaFormat *format)
(prop->body.flags & SPA_POD_PROP_FLAG_OPTIONAL)) (prop->body.flags & SPA_POD_PROP_FLAG_OPTIONAL))
continue; continue;
key = spa_id_map_get_uri (spa_id_map_get_default (), prop->body.key); key = spa_type_map_get_type (spa_type_map_get_default (), prop->body.key);
fprintf (stderr, " %20s : (%s) ", rindex (key, ':')+1, pod_type_names[prop->body.value.type].name); fprintf (stderr, " %20s : (%s) ", rindex (key, ':')+1, pod_type_names[prop->body.value.type].name);

View file

@ -22,66 +22,74 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <spa/id-map.h> #include <spa/type-map.h>
#include <lib/debug.h> #include <lib/debug.h>
#define MAX_URIS 4096 #define MAX_URIS 4096
typedef struct { typedef struct {
SpaIDMap map; SpaTypeMap map;
char *uris[MAX_URIS]; char *types[MAX_URIS];
unsigned int n_uris; unsigned int n_types;
} IDMap; } TypeMap;
static uint32_t static uint32_t
id_map_get_id (SpaIDMap *map, const char *uri) type_map_get_id (SpaTypeMap *map, const char *type)
{ {
IDMap *this = SPA_CONTAINER_OF (map, IDMap, map); TypeMap *this = SPA_CONTAINER_OF (map, TypeMap, map);
unsigned int i = 0; unsigned int i = 0;
if (uri != NULL) { if (type != NULL) {
for (i = 1; i <= this->n_uris; i++) { for (i = 1; i <= this->n_types; i++) {
if (strcmp (this->uris[i], uri) == 0) if (strcmp (this->types[i], type) == 0)
return i; return i;
} }
this->uris[i] = (char *)uri; this->types[i] = (char *)type;
this->n_uris++; this->n_types++;
} }
return i; return i;
} }
static const char * static const char *
id_map_get_uri (SpaIDMap *map, uint32_t id) type_map_get_type (SpaTypeMap *map, uint32_t id)
{ {
IDMap *this = SPA_CONTAINER_OF (map, IDMap, map); TypeMap *this = SPA_CONTAINER_OF (map, TypeMap, map);
if (id <= this->n_uris) if (id <= this->n_types)
return this->uris[id]; return this->types[id];
return NULL; return NULL;
} }
static IDMap default_id_map = { static size_t
{ sizeof (SpaIDMap), type_map_get_size (SpaTypeMap *map)
{
TypeMap *this = SPA_CONTAINER_OF (map, TypeMap, map);
return this->n_types;
}
static TypeMap default_type_map = {
{ sizeof (SpaTypeMap),
NULL, NULL,
id_map_get_id, type_map_get_id,
id_map_get_uri, type_map_get_type,
type_map_get_size,
}, },
{ NULL, }, { NULL, },
0 0
}; };
static SpaIDMap *default_map = &default_id_map.map; static SpaTypeMap *default_map = &default_type_map.map;
SpaIDMap * SpaTypeMap *
spa_id_map_get_default (void) spa_type_map_get_default (void)
{ {
return default_map; return default_map;
} }
void void
spa_id_map_set_default (SpaIDMap *map) spa_type_map_set_default (SpaTypeMap *map)
{ {
default_map = map; default_map = map;
} }

View file

@ -24,10 +24,10 @@
extern "C" { extern "C" {
#endif #endif
#include <spa/id-map.h> #include <spa/type-map.h>
void spa_id_map_set_default (SpaIDMap *map); void spa_type_map_set_default (SpaTypeMap *map);
SpaIDMap * spa_id_map_get_default (void); SpaTypeMap * spa_type_map_get_default (void);
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */

View file

@ -31,23 +31,24 @@ SpaResult
spa_format_video_parse (const SpaFormat *format, spa_format_video_parse (const SpaFormat *format,
SpaVideoInfo *info) SpaVideoInfo *info)
{ {
static SpaMediaTypes media_types = { 0, }; static SpaTypeMediaType media_type = { 0, };
static SpaMediaSubtypes media_subtypes = { 0, }; static SpaTypeMediaSubtype media_subtype = { 0, };
static SpaMediaSubtypesVideo media_subtypes_video = { 0, }; static SpaTypeMediaSubtypeVideo media_subtype_video = { 0, };
static SpaPropVideo prop_video = { 0, }; static SpaTypePropVideo prop_video = { 0, };
SpaTypeMap *map = spa_type_map_get_default ();
spa_media_types_fill (&media_types, spa_id_map_get_default ()); spa_type_media_type_map (map, &media_type);
spa_media_subtypes_map (spa_id_map_get_default (), &media_subtypes); spa_type_media_subtype_map (map, &media_subtype);
spa_media_subtypes_video_map (spa_id_map_get_default (), &media_subtypes_video); spa_type_media_subtype_video_map (map, &media_subtype_video);
spa_prop_video_map (spa_id_map_get_default (), &prop_video); spa_type_prop_video_map (map, &prop_video);
if (format->body.media_type.value != media_types.video) if (format->body.media_type.value != media_type.video)
return SPA_RESULT_INVALID_MEDIA_TYPE; return SPA_RESULT_INVALID_MEDIA_TYPE;
info->media_type = format->body.media_type.value; info->media_type = format->body.media_type.value;
info->media_subtype = format->body.media_subtype.value; info->media_subtype = format->body.media_subtype.value;
if (info->media_subtype == media_subtypes.raw) if (info->media_subtype == media_subtype.raw)
spa_format_query (format, spa_format_query (format,
prop_video.format, SPA_POD_TYPE_URI, &info->info.raw.format, prop_video.format, SPA_POD_TYPE_URI, &info->info.raw.format,
prop_video.size, SPA_POD_TYPE_RECTANGLE, &info->info.raw.size, prop_video.size, SPA_POD_TYPE_RECTANGLE, &info->info.raw.size,
@ -64,13 +65,13 @@ spa_format_video_parse (const SpaFormat *format,
prop_video.transfer_function, SPA_POD_TYPE_INT, &info->info.raw.transfer_function, prop_video.transfer_function, SPA_POD_TYPE_INT, &info->info.raw.transfer_function,
prop_video.color_primaries, SPA_POD_TYPE_INT, &info->info.raw.color_primaries, prop_video.color_primaries, SPA_POD_TYPE_INT, &info->info.raw.color_primaries,
0); 0);
else if (info->media_subtype == media_subtypes_video.h264) else if (info->media_subtype == media_subtype_video.h264)
spa_format_query (format, spa_format_query (format,
prop_video.size, SPA_POD_TYPE_RECTANGLE, &info->info.h264.size, prop_video.size, SPA_POD_TYPE_RECTANGLE, &info->info.h264.size,
prop_video.framerate, SPA_POD_TYPE_FRACTION, &info->info.h264.framerate, prop_video.framerate, SPA_POD_TYPE_FRACTION, &info->info.h264.framerate,
prop_video.max_framerate, SPA_POD_TYPE_FRACTION, &info->info.h264.max_framerate, prop_video.max_framerate, SPA_POD_TYPE_FRACTION, &info->info.h264.max_framerate,
0); 0);
else if (info->media_subtype == media_subtypes_video.mjpg) else if (info->media_subtype == media_subtype_video.mjpg)
spa_format_query (format, spa_format_query (format,
prop_video.size, SPA_POD_TYPE_RECTANGLE, &info->info.mjpg.size, prop_video.size, SPA_POD_TYPE_RECTANGLE, &info->info.mjpg.size,
prop_video.framerate, SPA_POD_TYPE_FRACTION, &info->info.mjpg.framerate, prop_video.framerate, SPA_POD_TYPE_FRACTION, &info->info.mjpg.framerate,

View file

@ -28,7 +28,7 @@
#include <asoundlib.h> #include <asoundlib.h>
#include <spa/log.h> #include <spa/log.h>
#include <spa/id-map.h> #include <spa/type-map.h>
#include <spa/loop.h> #include <spa/loop.h>
#include <spa/monitor.h> #include <spa/monitor.h>
#include <lib/debug.h> #include <lib/debug.h>
@ -45,15 +45,22 @@ typedef struct {
typedef struct { typedef struct {
uint32_t handle_factory; uint32_t handle_factory;
SpaMonitorTypes monitor_types; SpaTypeMonitor monitor;
} URI; } Type;
static inline void
init_type (Type *type, SpaTypeMap *map)
{
type->handle_factory = spa_type_map_get_id (map, SPA_TYPE__HandleFactory);
spa_type_monitor_map (map, &type->monitor);
}
struct _SpaALSAMonitor { struct _SpaALSAMonitor {
SpaHandle handle; SpaHandle handle;
SpaMonitor monitor; SpaMonitor monitor;
URI uri; Type type;
SpaIDMap *map; SpaTypeMap *map;
SpaLog *log; SpaLog *log;
SpaLoop *main_loop; SpaLoop *main_loop;
@ -170,20 +177,20 @@ fill_item (SpaALSAMonitor *this, ALSAItem *item, struct udev_device *udevice)
spa_pod_builder_init (&b, this->item_buffer, sizeof (this->item_buffer)); spa_pod_builder_init (&b, this->item_buffer, sizeof (this->item_buffer));
spa_pod_builder_push_object (&b, &f[0], 0, this->uri.monitor_types.MonitorItem); spa_pod_builder_push_object (&b, &f[0], 0, this->type.monitor.MonitorItem);
spa_pod_builder_add (&b, spa_pod_builder_add (&b,
SPA_POD_PROP (&f[1], this->uri.monitor_types.id, 0, SPA_POD_TYPE_STRING, 1, udev_device_get_syspath (item->udevice)), SPA_POD_PROP (&f[1], this->type.monitor.id, 0, SPA_POD_TYPE_STRING, 1, udev_device_get_syspath (item->udevice)),
SPA_POD_PROP (&f[1], this->uri.monitor_types.flags, 0, SPA_POD_TYPE_INT, 1, 0), SPA_POD_PROP (&f[1], this->type.monitor.flags, 0, SPA_POD_TYPE_INT, 1, 0),
SPA_POD_PROP (&f[1], this->uri.monitor_types.state, 0, SPA_POD_TYPE_INT, 1, SPA_MONITOR_ITEM_STATE_AVAILABLE), SPA_POD_PROP (&f[1], this->type.monitor.state, 0, SPA_POD_TYPE_INT, 1, SPA_MONITOR_ITEM_STATE_AVAILABLE),
SPA_POD_PROP (&f[1], this->uri.monitor_types.name, 0, SPA_POD_TYPE_STRING, 1, name), SPA_POD_PROP (&f[1], this->type.monitor.name, 0, SPA_POD_TYPE_STRING, 1, name),
SPA_POD_PROP (&f[1], this->uri.monitor_types.klass, 0, SPA_POD_TYPE_STRING, 1, "Audio/Device"), SPA_POD_PROP (&f[1], this->type.monitor.klass, 0, SPA_POD_TYPE_STRING, 1, "Audio/Device"),
SPA_POD_PROP (&f[1], this->uri.monitor_types.factory, 0, SPA_POD_TYPE_POINTER, 1, this->uri.handle_factory, SPA_POD_PROP (&f[1], this->type.monitor.factory, 0, SPA_POD_TYPE_POINTER, 1, this->type.handle_factory,
factory), factory),
0); 0);
spa_pod_builder_add (&b, spa_pod_builder_add (&b,
SPA_POD_TYPE_PROP, &f[1], this->uri.monitor_types.info, 0, SPA_POD_TYPE_PROP, &f[1], this->type.monitor.info, 0,
SPA_POD_TYPE_STRUCT, 1, &f[2], 0); SPA_POD_TYPE_STRUCT, 1, &f[2], 0);
spa_pod_builder_add (&b, spa_pod_builder_add (&b,
@ -271,11 +278,11 @@ alsa_on_fd_events (SpaSource *source)
str = "change"; str = "change";
if (strcmp (str, "add") == 0) { if (strcmp (str, "add") == 0) {
type = this->uri.monitor_types.Added; type = this->type.monitor.Added;
} else if (strcmp (str, "change") == 0) { } else if (strcmp (str, "change") == 0) {
type = this->uri.monitor_types.Changed; type = this->type.monitor.Changed;
} else if (strcmp (str, "remove") == 0) { } else if (strcmp (str, "remove") == 0) {
type = this->uri.monitor_types.Removed; type = this->type.monitor.Removed;
} else } else
return; return;
@ -402,7 +409,7 @@ spa_alsa_monitor_get_interface (SpaHandle *handle,
this = (SpaALSAMonitor *) handle; this = (SpaALSAMonitor *) handle;
if (interface_id == this->uri.monitor_types.Monitor) if (interface_id == this->type.monitor.Monitor)
*interface = &this->monitor; *interface = &this->monitor;
else else
return SPA_RESULT_UNKNOWN_INTERFACE; return SPA_RESULT_UNKNOWN_INTERFACE;
@ -435,11 +442,11 @@ alsa_monitor_init (const SpaHandleFactory *factory,
this = (SpaALSAMonitor *) handle; this = (SpaALSAMonitor *) handle;
for (i = 0; i < n_support; i++) { for (i = 0; i < n_support; i++) {
if (strcmp (support[i].uri, SPA_TYPE__IDMap) == 0) if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
this->map = support[i].data; this->map = support[i].data;
else if (strcmp (support[i].uri, SPA_TYPE__Log) == 0) else if (strcmp (support[i].type, SPA_TYPE__Log) == 0)
this->log = support[i].data; this->log = support[i].data;
else if (strcmp (support[i].uri, SPA_TYPE_LOOP__MainLoop) == 0) else if (strcmp (support[i].type, SPA_TYPE_LOOP__MainLoop) == 0)
this->main_loop = support[i].data; this->main_loop = support[i].data;
} }
if (this->map == NULL) { if (this->map == NULL) {
@ -450,8 +457,8 @@ alsa_monitor_init (const SpaHandleFactory *factory,
spa_log_error (this->log, "a main-loop is needed"); spa_log_error (this->log, "a main-loop is needed");
return SPA_RESULT_ERROR; return SPA_RESULT_ERROR;
} }
this->uri.handle_factory = spa_id_map_get_id (this->map, SPA_TYPE__HandleFactory);
spa_monitor_types_map (this->map, &this->uri.monitor_types); init_type (&this->type, this->map);
this->monitor = alsamonitor; this->monitor = alsamonitor;

View file

@ -82,13 +82,13 @@ spa_alsa_sink_node_get_props (SpaNode *node,
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer)); spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
spa_pod_builder_props (&b, &f[0], this->uri.props, spa_pod_builder_props (&b, &f[0], this->type.props,
PROP (&f[1], this->uri.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device)), PROP (&f[1], this->type.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device)),
PROP (&f[1], this->uri.prop_device_name, -SPA_POD_TYPE_STRING, this->props.device_name, sizeof (this->props.device_name)), PROP (&f[1], this->type.prop_device_name, -SPA_POD_TYPE_STRING, this->props.device_name, sizeof (this->props.device_name)),
PROP (&f[1], this->uri.prop_card_name, -SPA_POD_TYPE_STRING, this->props.card_name, sizeof (this->props.card_name)), PROP (&f[1], this->type.prop_card_name, -SPA_POD_TYPE_STRING, this->props.card_name, sizeof (this->props.card_name)),
PROP_MM (&f[1], this->uri.prop_period_size, SPA_POD_TYPE_INT, this->props.period_size, 1, INT32_MAX), PROP_MM (&f[1], this->type.prop_period_size, SPA_POD_TYPE_INT, this->props.period_size, 1, INT32_MAX),
PROP_MM (&f[1], this->uri.prop_periods, SPA_POD_TYPE_INT, this->props.periods, 1, INT32_MAX), PROP_MM (&f[1], this->type.prop_periods, SPA_POD_TYPE_INT, this->props.periods, 1, INT32_MAX),
PROP (&f[1], this->uri.prop_period_event, SPA_POD_TYPE_BOOL, this->props.period_event)); PROP (&f[1], this->type.prop_period_event, SPA_POD_TYPE_BOOL, this->props.period_event));
*props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps); *props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps);
@ -111,10 +111,10 @@ spa_alsa_sink_node_set_props (SpaNode *node,
return SPA_RESULT_OK; return SPA_RESULT_OK;
} else { } else {
spa_props_query (props, spa_props_query (props,
this->uri.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device), this->type.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device),
this->uri.prop_period_size, SPA_POD_TYPE_INT, &this->props.period_size, this->type.prop_period_size, SPA_POD_TYPE_INT, &this->props.period_size,
this->uri.prop_periods, SPA_POD_TYPE_INT, &this->props.periods, this->type.prop_periods, SPA_POD_TYPE_INT, &this->props.periods,
this->uri.prop_period_event, SPA_POD_TYPE_BOOL, &this->props.period_event, this->type.prop_period_event, SPA_POD_TYPE_BOOL, &this->props.period_event,
0); 0);
} }
return SPA_RESULT_OK; return SPA_RESULT_OK;
@ -147,8 +147,8 @@ do_command (SpaLoop *loop,
SpaResult res; SpaResult res;
SpaCommand *cmd = data; SpaCommand *cmd = data;
if (SPA_COMMAND_TYPE (cmd) == this->uri.command_node.Start || if (SPA_COMMAND_TYPE (cmd) == this->type.command_node.Start ||
SPA_COMMAND_TYPE (cmd) == this->uri.command_node.Pause) { SPA_COMMAND_TYPE (cmd) == this->type.command_node.Pause) {
res = spa_node_port_send_command (&this->node, res = spa_node_port_send_command (&this->node,
SPA_DIRECTION_INPUT, SPA_DIRECTION_INPUT,
0, 0,
@ -158,7 +158,7 @@ do_command (SpaLoop *loop,
res = SPA_RESULT_NOT_IMPLEMENTED; res = SPA_RESULT_NOT_IMPLEMENTED;
if (async) { if (async) {
SpaEventNodeAsyncComplete ac = SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (this->uri.event_node.AsyncComplete, SpaEventNodeAsyncComplete ac = SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (this->type.event_node.AsyncComplete,
seq, res); seq, res);
spa_loop_invoke (this->main_loop, spa_loop_invoke (this->main_loop,
do_send_event, do_send_event,
@ -181,8 +181,8 @@ spa_alsa_sink_node_send_command (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaALSASink, node); this = SPA_CONTAINER_OF (node, SpaALSASink, node);
if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Start || if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start ||
SPA_COMMAND_TYPE (command) == this->uri.command_node.Pause) { SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
if (!this->have_format) if (!this->have_format)
return SPA_RESULT_NO_FORMAT; return SPA_RESULT_NO_FORMAT;
@ -302,17 +302,17 @@ next:
switch (index++) { switch (index++) {
case 0: case 0:
spa_pod_builder_format (&b, &f[0], this->uri.format, spa_pod_builder_format (&b, &f[0], this->type.format,
this->uri.media_types.audio, this->uri.media_subtypes.raw, this->type.media_type.audio, this->type.media_subtype.raw,
PROP_U_EN (&f[1], this->uri.prop_audio.format, SPA_POD_TYPE_URI, 3, this->uri.audio_formats.S16, PROP_U_EN (&f[1], this->type.prop_audio.format, SPA_POD_TYPE_URI, 3, this->type.audio_format.S16,
this->uri.audio_formats.S16, this->type.audio_format.S16,
this->uri.audio_formats.S32), this->type.audio_format.S32),
PROP_U_MM (&f[1], this->uri.prop_audio.rate, SPA_POD_TYPE_INT, 44100, 1, INT32_MAX), PROP_U_MM (&f[1], this->type.prop_audio.rate, SPA_POD_TYPE_INT, 44100, 1, INT32_MAX),
PROP_U_MM (&f[1], this->uri.prop_audio.channels, SPA_POD_TYPE_INT, 2, 1, INT32_MAX)); PROP_U_MM (&f[1], this->type.prop_audio.channels, SPA_POD_TYPE_INT, 2, 1, INT32_MAX));
break; break;
case 1: case 1:
spa_pod_builder_format (&b, &f[0], this->uri.format, spa_pod_builder_format (&b, &f[0], this->type.format,
this->uri.media_types.audio, this->uri.media_subtypes_audio.aac, this->type.media_type.audio, this->type.media_subtype_audio.aac,
SPA_POD_TYPE_NONE); SPA_POD_TYPE_NONE);
break; break;
default: default:
@ -385,23 +385,23 @@ spa_alsa_sink_node_port_set_format (SpaNode *node,
this->info.params = this->params; this->info.params = this->params;
spa_pod_builder_init (&b, this->params_buffer, sizeof (this->params_buffer)); spa_pod_builder_init (&b, this->params_buffer, sizeof (this->params_buffer));
spa_pod_builder_object (&b, &f[0], 0, this->uri.alloc_param_buffers.Buffers, spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_buffers.Buffers,
PROP (&f[1], this->uri.alloc_param_buffers.size, SPA_POD_TYPE_INT, this->period_frames * this->frame_size), PROP (&f[1], this->type.alloc_param_buffers.size, SPA_POD_TYPE_INT, this->period_frames * this->frame_size),
PROP (&f[1], this->uri.alloc_param_buffers.stride, SPA_POD_TYPE_INT, 0), PROP (&f[1], this->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, 0),
PROP_MM (&f[1], this->uri.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, 32, 1, 32), PROP_MM (&f[1], this->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, 32, 1, 32),
PROP (&f[1], this->uri.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16)); PROP (&f[1], this->type.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));
this->params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam); this->params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
spa_pod_builder_object (&b, &f[0], 0, this->uri.alloc_param_meta_enable.MetaEnable, spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_meta_enable.MetaEnable,
PROP (&f[1], this->uri.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_HEADER)); PROP (&f[1], this->type.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_HEADER));
this->params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam); this->params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
spa_pod_builder_object (&b, &f[0], 0, this->uri.alloc_param_meta_enable.MetaEnable, spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_meta_enable.MetaEnable,
PROP (&f[1], this->uri.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_RINGBUFFER), PROP (&f[1], this->type.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_RINGBUFFER),
PROP (&f[1], this->uri.alloc_param_meta_enable.ringbufferSize, SPA_POD_TYPE_INT, this->period_frames * this->frame_size * 32), PROP (&f[1], this->type.alloc_param_meta_enable.ringbufferSize, SPA_POD_TYPE_INT, this->period_frames * this->frame_size * 32),
PROP (&f[1], this->uri.alloc_param_meta_enable.ringbufferStride, SPA_POD_TYPE_INT, 0), PROP (&f[1], this->type.alloc_param_meta_enable.ringbufferStride, SPA_POD_TYPE_INT, 0),
PROP (&f[1], this->uri.alloc_param_meta_enable.ringbufferBlocks, SPA_POD_TYPE_INT, 1), PROP (&f[1], this->type.alloc_param_meta_enable.ringbufferBlocks, SPA_POD_TYPE_INT, 1),
PROP (&f[1], this->uri.alloc_param_meta_enable.ringbufferAlign, SPA_POD_TYPE_INT, 16)); PROP (&f[1], this->type.alloc_param_meta_enable.ringbufferAlign, SPA_POD_TYPE_INT, 16));
this->params[2] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam); this->params[2] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
this->info.extra = NULL; this->info.extra = NULL;
@ -612,12 +612,12 @@ spa_alsa_sink_node_port_send_command (SpaNode *node,
if (port_id != 0) if (port_id != 0)
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Pause) { if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
if (SPA_RESULT_IS_OK (res = spa_alsa_pause (this, false))) { if (SPA_RESULT_IS_OK (res = spa_alsa_pause (this, false))) {
update_state (this, SPA_NODE_STATE_PAUSED); update_state (this, SPA_NODE_STATE_PAUSED);
} }
} }
else if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Start) { else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
if (SPA_RESULT_IS_OK (res = spa_alsa_start (this, false))) { if (SPA_RESULT_IS_OK (res = spa_alsa_start (this, false))) {
update_state (this, SPA_NODE_STATE_STREAMING); update_state (this, SPA_NODE_STATE_STREAMING);
} }
@ -720,7 +720,7 @@ spa_alsa_sink_get_interface (SpaHandle *handle,
this = (SpaALSASink *) handle; this = (SpaALSASink *) handle;
if (interface_id == this->uri.node) if (interface_id == this->type.node)
*interface = &this->node; *interface = &this->node;
else else
return SPA_RESULT_UNKNOWN_INTERFACE; return SPA_RESULT_UNKNOWN_INTERFACE;
@ -753,20 +753,20 @@ alsa_sink_init (const SpaHandleFactory *factory,
this = (SpaALSASink *) handle; this = (SpaALSASink *) handle;
for (i = 0; i < n_support; i++) { for (i = 0; i < n_support; i++) {
if (strcmp (support[i].uri, SPA_TYPE__IDMap) == 0) if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
this->map = support[i].data; this->map = support[i].data;
else if (strcmp (support[i].uri, SPA_TYPE__Log) == 0) else if (strcmp (support[i].type, SPA_TYPE__Log) == 0)
this->log = support[i].data; this->log = support[i].data;
else if (strcmp (support[i].uri, SPA_TYPE_LOOP__DataLoop) == 0) else if (strcmp (support[i].type, SPA_TYPE_LOOP__DataLoop) == 0)
this->data_loop = support[i].data; this->data_loop = support[i].data;
else if (strcmp (support[i].uri, SPA_TYPE_LOOP__MainLoop) == 0) else if (strcmp (support[i].type, SPA_TYPE_LOOP__MainLoop) == 0)
this->main_loop = support[i].data; this->main_loop = support[i].data;
} }
if (this->map == NULL) { if (this->map == NULL) {
spa_log_error (this->log, "an id-map is needed"); spa_log_error (this->log, "an id-map is needed");
return SPA_RESULT_ERROR; return SPA_RESULT_ERROR;
} }
init_uri (&this->uri, this->map); init_type (&this->type, this->map);
this->node = alsasink_node; this->node = alsasink_node;
this->stream = SND_PCM_STREAM_PLAYBACK; this->stream = SND_PCM_STREAM_PLAYBACK;

View file

@ -84,13 +84,13 @@ spa_alsa_source_node_get_props (SpaNode *node,
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer)); spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
spa_pod_builder_props (&b, &f[0], this->uri.props, spa_pod_builder_props (&b, &f[0], this->type.props,
PROP (&f[1], this->uri.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device)), PROP (&f[1], this->type.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device)),
PROP (&f[1], this->uri.prop_device_name, -SPA_POD_TYPE_STRING, this->props.device_name, sizeof (this->props.device_name)), PROP (&f[1], this->type.prop_device_name, -SPA_POD_TYPE_STRING, this->props.device_name, sizeof (this->props.device_name)),
PROP (&f[1], this->uri.prop_card_name, -SPA_POD_TYPE_STRING, this->props.card_name, sizeof (this->props.card_name)), PROP (&f[1], this->type.prop_card_name, -SPA_POD_TYPE_STRING, this->props.card_name, sizeof (this->props.card_name)),
PROP_MM (&f[1], this->uri.prop_period_size, SPA_POD_TYPE_INT, this->props.period_size, 1, INT32_MAX), PROP_MM (&f[1], this->type.prop_period_size, SPA_POD_TYPE_INT, this->props.period_size, 1, INT32_MAX),
PROP_MM (&f[1], this->uri.prop_periods, SPA_POD_TYPE_INT, this->props.periods, 1, INT32_MAX), PROP_MM (&f[1], this->type.prop_periods, SPA_POD_TYPE_INT, this->props.periods, 1, INT32_MAX),
PROP (&f[1], this->uri.prop_period_event, SPA_POD_TYPE_BOOL, this->props.period_event)); PROP (&f[1], this->type.prop_period_event, SPA_POD_TYPE_BOOL, this->props.period_event));
*props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps); *props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps);
@ -113,10 +113,10 @@ spa_alsa_source_node_set_props (SpaNode *node,
return SPA_RESULT_OK; return SPA_RESULT_OK;
} else { } else {
spa_props_query (props, spa_props_query (props,
this->uri.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device), this->type.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device),
this->uri.prop_period_size, SPA_POD_TYPE_INT, &this->props.period_size, this->type.prop_period_size, SPA_POD_TYPE_INT, &this->props.period_size,
this->uri.prop_periods, SPA_POD_TYPE_INT, &this->props.periods, this->type.prop_periods, SPA_POD_TYPE_INT, &this->props.periods,
this->uri.prop_period_event, SPA_POD_TYPE_BOOL, &this->props.period_event, this->type.prop_period_event, SPA_POD_TYPE_BOOL, &this->props.period_event,
0); 0);
} }
@ -154,7 +154,7 @@ do_start (SpaLoop *loop,
} }
if (async) { if (async) {
SpaEventNodeAsyncComplete ac = SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (this->uri.event_node.AsyncComplete, SpaEventNodeAsyncComplete ac = SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (this->type.event_node.AsyncComplete,
seq, res); seq, res);
spa_loop_invoke (this->main_loop, spa_loop_invoke (this->main_loop,
do_send_event, do_send_event,
@ -182,7 +182,7 @@ do_pause (SpaLoop *loop,
} }
if (async) { if (async) {
SpaEventNodeAsyncComplete ac = SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (this->uri.event_node.AsyncComplete, SpaEventNodeAsyncComplete ac = SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (this->type.event_node.AsyncComplete,
seq, res); seq, res);
spa_loop_invoke (this->main_loop, spa_loop_invoke (this->main_loop,
do_send_event, do_send_event,
@ -205,7 +205,7 @@ spa_alsa_source_node_send_command (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaALSASource, node); this = SPA_CONTAINER_OF (node, SpaALSASource, node);
if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Start) { if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
if (!this->have_format) if (!this->have_format)
return SPA_RESULT_NO_FORMAT; return SPA_RESULT_NO_FORMAT;
@ -219,7 +219,7 @@ spa_alsa_source_node_send_command (SpaNode *node,
NULL, NULL,
this); this);
} }
else if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Pause) { else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
if (!this->have_format) if (!this->have_format)
return SPA_RESULT_NO_FORMAT; return SPA_RESULT_NO_FORMAT;
@ -340,17 +340,17 @@ next:
switch (index++) { switch (index++) {
case 0: case 0:
spa_pod_builder_format (&b, &f[0], this->uri.format, spa_pod_builder_format (&b, &f[0], this->type.format,
this->uri.media_types.audio, this->uri.media_subtypes.raw, this->type.media_type.audio, this->type.media_subtype.raw,
PROP_U_EN (&f[1], this->uri.prop_audio.format, SPA_POD_TYPE_URI, 3, this->uri.audio_formats.S16, PROP_U_EN (&f[1], this->type.prop_audio.format, SPA_POD_TYPE_URI, 3, this->type.audio_format.S16,
this->uri.audio_formats.S16, this->type.audio_format.S16,
this->uri.audio_formats.S32), this->type.audio_format.S32),
PROP_U_MM (&f[1], this->uri.prop_audio.rate, SPA_POD_TYPE_INT, 44100, 1, INT32_MAX), PROP_U_MM (&f[1], this->type.prop_audio.rate, SPA_POD_TYPE_INT, 44100, 1, INT32_MAX),
PROP_U_MM (&f[1], this->uri.prop_audio.channels, SPA_POD_TYPE_INT, 2, 1, INT32_MAX)); PROP_U_MM (&f[1], this->type.prop_audio.channels, SPA_POD_TYPE_INT, 2, 1, INT32_MAX));
break; break;
case 1: case 1:
spa_pod_builder_format (&b, &f[0], this->uri.format, spa_pod_builder_format (&b, &f[0], this->type.format,
this->uri.media_types.audio, this->uri.media_subtypes_audio.aac, this->type.media_type.audio, this->type.media_subtype_audio.aac,
SPA_POD_TYPE_NONE); SPA_POD_TYPE_NONE);
default: default:
return SPA_RESULT_ENUM_END; return SPA_RESULT_ENUM_END;
@ -434,15 +434,15 @@ spa_alsa_source_node_port_set_format (SpaNode *node,
this->info.params = this->params; this->info.params = this->params;
spa_pod_builder_init (&b, this->params_buffer, sizeof (this->params_buffer)); spa_pod_builder_init (&b, this->params_buffer, sizeof (this->params_buffer));
spa_pod_builder_object (&b, &f[0], 0, this->uri.alloc_param_buffers.Buffers, spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_buffers.Buffers,
PROP (&f[1], this->uri.alloc_param_buffers.size, SPA_POD_TYPE_INT, this->period_frames * this->frame_size), PROP (&f[1], this->type.alloc_param_buffers.size, SPA_POD_TYPE_INT, this->period_frames * this->frame_size),
PROP (&f[1], this->uri.alloc_param_buffers.stride, SPA_POD_TYPE_INT, 0), PROP (&f[1], this->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, 0),
PROP_MM (&f[1], this->uri.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, 32, 1, 32), PROP_MM (&f[1], this->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, 32, 1, 32),
PROP (&f[1], this->uri.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16)); PROP (&f[1], this->type.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));
this->params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam); this->params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
spa_pod_builder_object (&b, &f[0], 0, this->uri.alloc_param_meta_enable.MetaEnable, spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_meta_enable.MetaEnable,
PROP (&f[1], this->uri.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_HEADER)); PROP (&f[1], this->type.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_HEADER));
this->params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam); this->params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
this->info.extra = NULL; this->info.extra = NULL;
@ -671,11 +671,11 @@ spa_alsa_source_node_port_send_command (SpaNode *node,
if (port_id != 0) if (port_id != 0)
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Pause) { if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
if (SPA_RESULT_IS_OK (res = spa_alsa_pause (this, false))) { if (SPA_RESULT_IS_OK (res = spa_alsa_pause (this, false))) {
update_state (this, SPA_NODE_STATE_PAUSED); update_state (this, SPA_NODE_STATE_PAUSED);
} }
} else if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Start) { } else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
if (SPA_RESULT_IS_OK (res = spa_alsa_start (this, false))) { if (SPA_RESULT_IS_OK (res = spa_alsa_start (this, false))) {
update_state (this, SPA_NODE_STATE_STREAMING); update_state (this, SPA_NODE_STATE_STREAMING);
} }
@ -783,9 +783,9 @@ spa_alsa_source_get_interface (SpaHandle *handle,
this = (SpaALSASource *) handle; this = (SpaALSASource *) handle;
if (interface_id == this->uri.node) if (interface_id == this->type.node)
*interface = &this->node; *interface = &this->node;
else if (interface_id == this->uri.clock) else if (interface_id == this->type.clock)
*interface = &this->clock; *interface = &this->clock;
else else
return SPA_RESULT_UNKNOWN_INTERFACE; return SPA_RESULT_UNKNOWN_INTERFACE;
@ -818,20 +818,20 @@ alsa_source_init (const SpaHandleFactory *factory,
this = (SpaALSASource *) handle; this = (SpaALSASource *) handle;
for (i = 0; i < n_support; i++) { for (i = 0; i < n_support; i++) {
if (strcmp (support[i].uri, SPA_TYPE__IDMap) == 0) if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
this->map = support[i].data; this->map = support[i].data;
else if (strcmp (support[i].uri, SPA_TYPE__Log) == 0) else if (strcmp (support[i].type, SPA_TYPE__Log) == 0)
this->log = support[i].data; this->log = support[i].data;
else if (strcmp (support[i].uri, SPA_TYPE_LOOP__DataLoop) == 0) else if (strcmp (support[i].type, SPA_TYPE_LOOP__DataLoop) == 0)
this->data_loop = support[i].data; this->data_loop = support[i].data;
else if (strcmp (support[i].uri, SPA_TYPE_LOOP__MainLoop) == 0) else if (strcmp (support[i].type, SPA_TYPE_LOOP__MainLoop) == 0)
this->main_loop = support[i].data; this->main_loop = support[i].data;
} }
if (this->map == NULL) { if (this->map == NULL) {
spa_log_error (this->log, "an id-map is needed"); spa_log_error (this->log, "an id-map is needed");
return SPA_RESULT_ERROR; return SPA_RESULT_ERROR;
} }
init_uri (&this->uri, this->map); init_type (&this->type, this->map);
this->node = alsasource_node; this->node = alsasource_node;
this->clock = alsasource_clock; this->clock = alsasource_clock;

View file

@ -62,18 +62,18 @@ typedef struct {
} FormatInfo; } FormatInfo;
#if __BYTE_ORDER == __BIG_ENDIAN #if __BYTE_ORDER == __BIG_ENDIAN
#define _FORMAT_LE(fmt) offsetof(URI, audio_formats. fmt ## _OE) #define _FORMAT_LE(fmt) offsetof(Type, audio_format. fmt ## _OE)
#define _FORMAT_BE(fmt) offsetof(URI, audio_formats. fmt) #define _FORMAT_BE(fmt) offsetof(Type, audio_format. fmt)
#elif __BYTE_ORDER == __LITTLE_ENDIAN #elif __BYTE_ORDER == __LITTLE_ENDIAN
#define _FORMAT_LE(fmt) offsetof(URI, audio_formats. fmt) #define _FORMAT_LE(fmt) offsetof(Type, audio_format. fmt)
#define _FORMAT_BE(fmt) offsetof(URI, audio_formats. fmt ## _OE) #define _FORMAT_BE(fmt) offsetof(Type, audio_format. fmt ## _OE)
#endif #endif
static const FormatInfo format_info[] = static const FormatInfo format_info[] =
{ {
{ offsetof(URI, audio_formats.UNKNOWN), SND_PCM_FORMAT_UNKNOWN }, { offsetof(Type, audio_format.UNKNOWN), SND_PCM_FORMAT_UNKNOWN },
{ offsetof(URI, audio_formats.S8), SND_PCM_FORMAT_S8 }, { offsetof(Type, audio_format.S8), SND_PCM_FORMAT_S8 },
{ offsetof(URI, audio_formats.U8), SND_PCM_FORMAT_U8 }, { offsetof(Type, audio_format.U8), SND_PCM_FORMAT_U8 },
{ _FORMAT_LE (S16), SND_PCM_FORMAT_S16_LE }, { _FORMAT_LE (S16), SND_PCM_FORMAT_S16_LE },
{ _FORMAT_BE (S16), SND_PCM_FORMAT_S16_BE }, { _FORMAT_BE (S16), SND_PCM_FORMAT_S16_BE },
{ _FORMAT_LE (U16), SND_PCM_FORMAT_U16_LE }, { _FORMAT_LE (U16), SND_PCM_FORMAT_U16_LE },
@ -93,12 +93,12 @@ static const FormatInfo format_info[] =
}; };
static snd_pcm_format_t static snd_pcm_format_t
spa_alsa_format_to_alsa (URI *uri, uint32_t format) spa_alsa_format_to_alsa (Type *map, uint32_t format)
{ {
int i; int i;
for (i = 0; i < SPA_N_ELEMENTS (format_info); i++) { for (i = 0; i < SPA_N_ELEMENTS (format_info); i++) {
uint32_t f = *SPA_MEMBER (uri, format_info[i].format_offset, uint32_t); uint32_t f = *SPA_MEMBER (map, format_info[i].format_offset, uint32_t);
if (f == format) if (f == format)
return format_info[i].format; return format_info[i].format;
} }
@ -132,7 +132,7 @@ spa_alsa_set_format (SpaALSAState *state, SpaAudioInfo *fmt, SpaPortFormatFlags
CHECK (snd_pcm_hw_params_set_access(hndl, params, SND_PCM_ACCESS_MMAP_INTERLEAVED), "set_access"); CHECK (snd_pcm_hw_params_set_access(hndl, params, SND_PCM_ACCESS_MMAP_INTERLEAVED), "set_access");
/* set the sample format */ /* set the sample format */
format = spa_alsa_format_to_alsa (&state->uri, info->format); format = spa_alsa_format_to_alsa (&state->type, info->format);
spa_log_info (state->log, "Stream parameters are %iHz, %s, %i channels", info->rate, snd_pcm_format_name(format), info->channels); spa_log_info (state->log, "Stream parameters are %iHz, %s, %i channels", info->rate, snd_pcm_format_name(format), info->channels);
CHECK (snd_pcm_hw_params_set_format (hndl, params, format), "set_format"); CHECK (snd_pcm_hw_params_set_format (hndl, params, format), "set_format");
@ -270,7 +270,7 @@ pull_frames_queue (SpaALSAState *state,
snd_pcm_uframes_t frames) snd_pcm_uframes_t frames)
{ {
if (spa_list_is_empty (&state->ready)) { if (spa_list_is_empty (&state->ready)) {
SpaEvent event = SPA_EVENT_INIT (state->uri.event_node.NeedInput); SpaEvent event = SPA_EVENT_INIT (state->type.event_node.NeedInput);
state->event_cb (&state->node, &event, state->user_data); state->event_cb (&state->node, &event, state->user_data);
} }
if (!spa_list_is_empty (&state->ready)) { if (!spa_list_is_empty (&state->ready)) {
@ -294,7 +294,7 @@ pull_frames_queue (SpaALSAState *state,
state->ready_offset += n_bytes; state->ready_offset += n_bytes;
if (state->ready_offset >= size) { if (state->ready_offset >= size) {
SpaEventNodeReuseBuffer rb = SPA_EVENT_NODE_REUSE_BUFFER_INIT (state->uri.event_node.ReuseBuffer, SpaEventNodeReuseBuffer rb = SPA_EVENT_NODE_REUSE_BUFFER_INIT (state->type.event_node.ReuseBuffer,
0, b->outbuf->id); 0, b->outbuf->id);
spa_list_remove (&b->link); spa_list_remove (&b->link);
@ -349,7 +349,7 @@ pull_frames_ringbuffer (SpaALSAState *state,
b->outstanding = true; b->outstanding = true;
{ {
SpaEventNodeReuseBuffer rb = SPA_EVENT_NODE_REUSE_BUFFER_INIT (state->uri.event_node.ReuseBuffer, SpaEventNodeReuseBuffer rb = SPA_EVENT_NODE_REUSE_BUFFER_INIT (state->type.event_node.ReuseBuffer,
0, b->outbuf->id); 0, b->outbuf->id);
state->event_cb (&state->node, (SpaEvent*)&rb, state->user_data); state->event_cb (&state->node, (SpaEvent*)&rb, state->user_data);
} }
@ -498,7 +498,7 @@ mmap_read (SpaALSAState *state)
output->status = SPA_RESULT_OK; output->status = SPA_RESULT_OK;
} }
{ {
SpaEvent event = SPA_EVENT_INIT (state->uri.event_node.HaveOutput); SpaEvent event = SPA_EVENT_INIT (state->type.event_node.HaveOutput);
state->event_cb (&state->node, &event, state->user_data); state->event_cb (&state->node, &event, state->user_data);
} }
} }

View file

@ -28,7 +28,7 @@ extern "C" {
#include <asoundlib.h> #include <asoundlib.h>
#include <spa/id-map.h> #include <spa/type-map.h>
#include <spa/clock.h> #include <spa/clock.h>
#include <spa/log.h> #include <spa/log.h>
#include <spa/list.h> #include <spa/list.h>
@ -71,40 +71,40 @@ typedef struct {
uint32_t prop_period_size; uint32_t prop_period_size;
uint32_t prop_periods; uint32_t prop_periods;
uint32_t prop_period_event; uint32_t prop_period_event;
SpaMediaTypes media_types; SpaTypeMediaType media_type;
SpaMediaSubtypes media_subtypes; SpaTypeMediaSubtype media_subtype;
SpaMediaSubtypesAudio media_subtypes_audio; SpaTypeMediaSubtypeAudio media_subtype_audio;
SpaPropAudio prop_audio; SpaTypePropAudio prop_audio;
SpaAudioFormats audio_formats; SpaTypeAudioFormat audio_format;
SpaEventNode event_node; SpaTypeEventNode event_node;
SpaCommandNode command_node; SpaTypeCommandNode command_node;
SpaAllocParamBuffers alloc_param_buffers; SpaTypeAllocParamBuffers alloc_param_buffers;
SpaAllocParamMetaEnable alloc_param_meta_enable; SpaTypeAllocParamMetaEnable alloc_param_meta_enable;
} URI; } Type;
static inline void static inline void
init_uri (URI *uri, SpaIDMap *map) init_type (Type *type, SpaTypeMap *map)
{ {
uri->node = spa_id_map_get_id (map, SPA_TYPE__Node); type->node = spa_type_map_get_id (map, SPA_TYPE__Node);
uri->clock = spa_id_map_get_id (map, SPA_TYPE__Clock); type->clock = spa_type_map_get_id (map, SPA_TYPE__Clock);
uri->format = spa_id_map_get_id (map, SPA_TYPE__Format); type->format = spa_type_map_get_id (map, SPA_TYPE__Format);
uri->props = spa_id_map_get_id (map, SPA_TYPE__Props); type->props = spa_type_map_get_id (map, SPA_TYPE__Props);
uri->prop_device = spa_id_map_get_id (map, SPA_TYPE_PROPS__device); type->prop_device = spa_type_map_get_id (map, SPA_TYPE_PROPS__device);
uri->prop_device_name = spa_id_map_get_id (map, SPA_TYPE_PROPS__deviceName); type->prop_device_name = spa_type_map_get_id (map, SPA_TYPE_PROPS__deviceName);
uri->prop_card_name = spa_id_map_get_id (map, SPA_TYPE_PROPS__cardName); type->prop_card_name = spa_type_map_get_id (map, SPA_TYPE_PROPS__cardName);
uri->prop_period_size = spa_id_map_get_id (map, SPA_TYPE_PROPS__periodSize); type->prop_period_size = spa_type_map_get_id (map, SPA_TYPE_PROPS__periodSize);
uri->prop_periods = spa_id_map_get_id (map, SPA_TYPE_PROPS__periods); type->prop_periods = spa_type_map_get_id (map, SPA_TYPE_PROPS__periods);
uri->prop_period_event = spa_id_map_get_id (map, SPA_TYPE_PROPS__periodEvent); type->prop_period_event = spa_type_map_get_id (map, SPA_TYPE_PROPS__periodEvent);
spa_media_types_fill (&uri->media_types, map); spa_type_media_type_map (map, &type->media_type);
spa_media_subtypes_map (map, &uri->media_subtypes); spa_type_media_subtype_map (map, &type->media_subtype);
spa_media_subtypes_audio_map (map, &uri->media_subtypes_audio); spa_type_media_subtype_audio_map (map, &type->media_subtype_audio);
spa_prop_audio_map (map, &uri->prop_audio); spa_type_prop_audio_map (map, &type->prop_audio);
spa_audio_formats_map (map, &uri->audio_formats); spa_type_audio_format_map (map, &type->audio_format);
spa_event_node_map (map, &uri->event_node); spa_type_event_node_map (map, &type->event_node);
spa_command_node_map (map, &uri->command_node); spa_type_command_node_map (map, &type->command_node);
spa_alloc_param_buffers_map (map, &uri->alloc_param_buffers); spa_type_alloc_param_buffers_map (map, &type->alloc_param_buffers);
spa_alloc_param_meta_enable_map (map, &uri->alloc_param_meta_enable); spa_type_alloc_param_meta_enable_map (map, &type->alloc_param_meta_enable);
} }
struct _SpaALSAState { struct _SpaALSAState {
@ -114,8 +114,8 @@ struct _SpaALSAState {
uint32_t seq; uint32_t seq;
URI uri; Type type;
SpaIDMap *map; SpaTypeMap *map;
SpaLog *log; SpaLog *log;
SpaLoop *main_loop; SpaLoop *main_loop;
SpaLoop *data_loop; SpaLoop *data_loop;

View file

@ -21,7 +21,7 @@
#include <stdio.h> #include <stdio.h>
#include <spa/log.h> #include <spa/log.h>
#include <spa/id-map.h> #include <spa/type-map.h>
#include <spa/node.h> #include <spa/node.h>
#include <spa/audio/format-utils.h> #include <spa/audio/format-utils.h>
#include <lib/props.h> #include <lib/props.h>
@ -58,22 +58,22 @@ typedef struct {
typedef struct { typedef struct {
uint32_t node; uint32_t node;
SpaCommandNode command_node; SpaTypeCommandNode command_node;
} URI; } Type;
static inline void static inline void
init_uri (URI *uri, SpaIDMap *map) init_type (Type *type, SpaTypeMap *map)
{ {
uri->node = spa_id_map_get_id (map, SPA_TYPE__Node); type->node = spa_type_map_get_id (map, SPA_TYPE__Node);
spa_command_node_map (map, &uri->command_node); spa_type_command_node_map (map, &type->command_node);
} }
struct _SpaAudioMixer { struct _SpaAudioMixer {
SpaHandle handle; SpaHandle handle;
SpaNode node; SpaNode node;
URI uri; Type type;
SpaIDMap *map; SpaTypeMap *map;
SpaLog *log; SpaLog *log;
SpaEventNodeCallback event_cb; SpaEventNodeCallback event_cb;
@ -125,10 +125,10 @@ spa_audiomixer_node_send_command (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaAudioMixer, node); this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Start) { if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
update_state (this, SPA_NODE_STATE_STREAMING); update_state (this, SPA_NODE_STATE_STREAMING);
} }
else if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Pause) { else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
update_state (this, SPA_NODE_STATE_PAUSED); update_state (this, SPA_NODE_STATE_PAUSED);
} }
else else
@ -659,7 +659,7 @@ spa_audiomixer_get_interface (SpaHandle *handle,
this = (SpaAudioMixer *) handle; this = (SpaAudioMixer *) handle;
if (interface_id == this->uri.node) if (interface_id == this->type.node)
*interface = &this->node; *interface = &this->node;
else else
return SPA_RESULT_UNKNOWN_INTERFACE; return SPA_RESULT_UNKNOWN_INTERFACE;
@ -692,16 +692,16 @@ spa_audiomixer_init (const SpaHandleFactory *factory,
this = (SpaAudioMixer *) handle; this = (SpaAudioMixer *) handle;
for (i = 0; i < n_support; i++) { for (i = 0; i < n_support; i++) {
if (strcmp (support[i].uri, SPA_TYPE__IDMap) == 0) if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
this->map = support[i].data; this->map = support[i].data;
else if (strcmp (support[i].uri, SPA_TYPE__Log) == 0) else if (strcmp (support[i].type, SPA_TYPE__Log) == 0)
this->log = support[i].data; this->log = support[i].data;
} }
if (this->map == NULL) { if (this->map == NULL) {
spa_log_error (this->log, "an id-map is needed"); spa_log_error (this->log, "an id-map is needed");
return SPA_RESULT_ERROR; return SPA_RESULT_ERROR;
} }
init_uri (&this->uri, this->map); init_type (&this->type, this->map);
this->node = audiomixer_node; this->node = audiomixer_node;

View file

@ -23,7 +23,7 @@
#include <stdio.h> #include <stdio.h>
#include <sys/timerfd.h> #include <sys/timerfd.h>
#include <spa/id-map.h> #include <spa/type-map.h>
#include <spa/clock.h> #include <spa/clock.h>
#include <spa/log.h> #include <spa/log.h>
#include <spa/loop.h> #include <spa/loop.h>
@ -48,37 +48,37 @@ typedef struct {
uint32_t prop_volume; uint32_t prop_volume;
uint32_t wave_sine; uint32_t wave_sine;
uint32_t wave_square; uint32_t wave_square;
SpaMediaTypes media_types; SpaTypeMediaType media_type;
SpaMediaSubtypes media_subtypes; SpaTypeMediaSubtype media_subtype;
SpaPropAudio prop_audio; SpaTypePropAudio prop_audio;
SpaAudioFormats audio_formats; SpaTypeAudioFormat audio_format;
SpaEventNode event_node; SpaTypeEventNode event_node;
SpaCommandNode command_node; SpaTypeCommandNode command_node;
SpaAllocParamBuffers alloc_param_buffers; SpaTypeAllocParamBuffers alloc_param_buffers;
SpaAllocParamMetaEnable alloc_param_meta_enable; SpaTypeAllocParamMetaEnable alloc_param_meta_enable;
} URI; } Type;
static inline void static inline void
init_uri (URI *uri, SpaIDMap *map) init_type (Type *type, SpaTypeMap *map)
{ {
uri->node = spa_id_map_get_id (map, SPA_TYPE__Node); type->node = spa_type_map_get_id (map, SPA_TYPE__Node);
uri->clock = spa_id_map_get_id (map, SPA_TYPE__Clock); type->clock = spa_type_map_get_id (map, SPA_TYPE__Clock);
uri->format = spa_id_map_get_id (map, SPA_TYPE__Format); type->format = spa_type_map_get_id (map, SPA_TYPE__Format);
uri->props = spa_id_map_get_id (map, SPA_TYPE__Props); type->props = spa_type_map_get_id (map, SPA_TYPE__Props);
uri->prop_live = spa_id_map_get_id (map, SPA_TYPE_PROPS__live); type->prop_live = spa_type_map_get_id (map, SPA_TYPE_PROPS__live);
uri->prop_wave = spa_id_map_get_id (map, SPA_TYPE_PROPS__waveType); type->prop_wave = spa_type_map_get_id (map, SPA_TYPE_PROPS__waveType);
uri->prop_freq = spa_id_map_get_id (map, SPA_TYPE_PROPS__frequency); type->prop_freq = spa_type_map_get_id (map, SPA_TYPE_PROPS__frequency);
uri->prop_volume = spa_id_map_get_id (map, SPA_TYPE_PROPS__volume); type->prop_volume = spa_type_map_get_id (map, SPA_TYPE_PROPS__volume);
uri->wave_sine = spa_id_map_get_id (map, SPA_TYPE_PROPS__waveType ":sine"); type->wave_sine = spa_type_map_get_id (map, SPA_TYPE_PROPS__waveType ":sine");
uri->wave_square = spa_id_map_get_id (map, SPA_TYPE_PROPS__waveType ":square"); type->wave_square = spa_type_map_get_id (map, SPA_TYPE_PROPS__waveType ":square");
spa_media_types_fill (&uri->media_types, map); spa_type_media_type_map (map, &type->media_type);
spa_media_subtypes_map (map, &uri->media_subtypes); spa_type_media_subtype_map (map, &type->media_subtype);
spa_prop_audio_map (map, &uri->prop_audio); spa_type_prop_audio_map (map, &type->prop_audio);
spa_audio_formats_map (map, &uri->audio_formats); spa_type_audio_format_map (map, &type->audio_format);
spa_event_node_map (map, &uri->event_node); spa_type_event_node_map (map, &type->event_node);
spa_command_node_map (map, &uri->command_node); spa_type_command_node_map (map, &type->command_node);
spa_alloc_param_buffers_map (map, &uri->alloc_param_buffers); spa_type_alloc_param_buffers_map (map, &type->alloc_param_buffers);
spa_alloc_param_meta_enable_map (map, &uri->alloc_param_meta_enable); spa_type_alloc_param_meta_enable_map (map, &type->alloc_param_meta_enable);
} }
typedef struct _SpaAudioTestSrc SpaAudioTestSrc; typedef struct _SpaAudioTestSrc SpaAudioTestSrc;
@ -108,8 +108,8 @@ struct _SpaAudioTestSrc {
SpaNode node; SpaNode node;
SpaClock clock; SpaClock clock;
URI uri; Type type;
SpaIDMap *map; SpaTypeMap *map;
SpaLog *log; SpaLog *log;
SpaLoop *data_loop; SpaLoop *data_loop;
@ -154,7 +154,7 @@ static void
reset_audiotestsrc_props (SpaAudioTestSrc *this, SpaAudioTestSrcProps *props) reset_audiotestsrc_props (SpaAudioTestSrc *this, SpaAudioTestSrcProps *props)
{ {
props->live = DEFAULT_LIVE; props->live = DEFAULT_LIVE;
props->wave = this->uri. DEFAULT_WAVE; props->wave = this->type. DEFAULT_WAVE;
props->freq = DEFAULT_FREQ; props->freq = DEFAULT_FREQ;
props->volume = DEFAULT_VOLUME; props->volume = DEFAULT_VOLUME;
} }
@ -190,14 +190,14 @@ spa_audiotestsrc_node_get_props (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node); this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer)); spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
spa_pod_builder_props (&b, &f[0], this->uri.props, spa_pod_builder_props (&b, &f[0], this->type.props,
PROP (&f[1], this->uri.prop_live, SPA_POD_TYPE_BOOL, this->props.live), PROP (&f[1], this->type.prop_live, SPA_POD_TYPE_BOOL, this->props.live),
PROP_EN (&f[1], this->uri.prop_wave, SPA_POD_TYPE_URI, 3, this->props.wave, PROP_EN (&f[1], this->type.prop_wave, SPA_POD_TYPE_URI, 3, this->props.wave,
this->uri.wave_sine, this->type.wave_sine,
this->uri.wave_square), this->type.wave_square),
PROP_MM (&f[1], this->uri.prop_freq, SPA_POD_TYPE_DOUBLE, this->props.freq, PROP_MM (&f[1], this->type.prop_freq, SPA_POD_TYPE_DOUBLE, this->props.freq,
0.0, 50000000.0), 0.0, 50000000.0),
PROP_MM (&f[1], this->uri.prop_volume, SPA_POD_TYPE_DOUBLE, this->props.volume, PROP_MM (&f[1], this->type.prop_volume, SPA_POD_TYPE_DOUBLE, this->props.volume,
0.0, 10.0)); 0.0, 10.0));
*props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps); *props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps);
@ -220,10 +220,10 @@ spa_audiotestsrc_node_set_props (SpaNode *node,
reset_audiotestsrc_props (this, &this->props); reset_audiotestsrc_props (this, &this->props);
} else { } else {
spa_props_query (props, spa_props_query (props,
this->uri.prop_live, SPA_POD_TYPE_BOOL, &this->props.live, this->type.prop_live, SPA_POD_TYPE_BOOL, &this->props.live,
this->uri.prop_wave, SPA_POD_TYPE_URI, &this->props.wave, this->type.prop_wave, SPA_POD_TYPE_URI, &this->props.wave,
this->uri.prop_freq, SPA_POD_TYPE_DOUBLE, &this->props.freq, this->type.prop_freq, SPA_POD_TYPE_DOUBLE, &this->props.freq,
this->uri.prop_volume, SPA_POD_TYPE_DOUBLE, &this->props.volume, this->type.prop_volume, SPA_POD_TYPE_DOUBLE, &this->props.volume,
0); 0);
} }
@ -240,7 +240,7 @@ send_have_output (SpaAudioTestSrc *this)
{ {
if (this->event_cb) { if (this->event_cb) {
SpaEvent event = SPA_EVENT_INIT (this->uri.event_node.HaveOutput); SpaEvent event = SPA_EVENT_INIT (this->type.event_node.HaveOutput);
this->event_cb (&this->node, &event, this->user_data); this->event_cb (&this->node, &event, this->user_data);
} }
@ -334,7 +334,7 @@ spa_audiotestsrc_node_send_command (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node); this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Start) { if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
struct timespec now; struct timespec now;
if (!this->have_format) if (!this->have_format)
@ -358,7 +358,7 @@ spa_audiotestsrc_node_send_command (SpaNode *node,
set_timer (this, true); set_timer (this, true);
update_state (this, SPA_NODE_STATE_STREAMING); update_state (this, SPA_NODE_STATE_STREAMING);
} }
else if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Pause) { else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
if (!this->have_format) if (!this->have_format)
return SPA_RESULT_NO_FORMAT; return SPA_RESULT_NO_FORMAT;
@ -484,13 +484,13 @@ next:
switch (index++) { switch (index++) {
case 0: case 0:
spa_pod_builder_format (&b, &f[0], this->uri.format, spa_pod_builder_format (&b, &f[0], this->type.format,
this->uri.media_types.audio, this->uri.media_subtypes.raw, this->type.media_type.audio, this->type.media_subtype.raw,
PROP_U_EN (&f[1], this->uri.prop_audio.format, SPA_POD_TYPE_URI, 3, this->uri.audio_formats.S16, PROP_U_EN (&f[1], this->type.prop_audio.format, SPA_POD_TYPE_URI, 3, this->type.audio_format.S16,
this->uri.audio_formats.S16, this->type.audio_format.S16,
this->uri.audio_formats.S32), this->type.audio_format.S32),
PROP_U_MM (&f[1], this->uri.prop_audio.rate, SPA_POD_TYPE_INT, 44100, 1, INT32_MAX), PROP_U_MM (&f[1], this->type.prop_audio.rate, SPA_POD_TYPE_INT, 44100, 1, INT32_MAX),
PROP_U_MM (&f[1], this->uri.prop_audio.channels, SPA_POD_TYPE_INT, 2, 1, INT32_MAX)); PROP_U_MM (&f[1], this->type.prop_audio.channels, SPA_POD_TYPE_INT, 2, 1, INT32_MAX));
break; break;
default: default:
return SPA_RESULT_ENUM_END; return SPA_RESULT_ENUM_END;
@ -560,15 +560,15 @@ spa_audiotestsrc_node_port_set_format (SpaNode *node,
this->info.params = this->params; this->info.params = this->params;
spa_pod_builder_init (&b, this->params_buffer, sizeof (this->params_buffer)); spa_pod_builder_init (&b, this->params_buffer, sizeof (this->params_buffer));
spa_pod_builder_object (&b, &f[0], 0, this->uri.alloc_param_buffers.Buffers, spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_buffers.Buffers,
PROP (&f[1], this->uri.alloc_param_buffers.size, SPA_POD_TYPE_INT, 1024), PROP (&f[1], this->type.alloc_param_buffers.size, SPA_POD_TYPE_INT, 1024),
PROP (&f[1], this->uri.alloc_param_buffers.stride, SPA_POD_TYPE_INT, 1024), PROP (&f[1], this->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, 1024),
PROP_U_MM (&f[1], this->uri.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, 32, 2, 32), PROP_U_MM (&f[1], this->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, 32, 2, 32),
PROP (&f[1], this->uri.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16)); PROP (&f[1], this->type.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));
this->params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam); this->params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
spa_pod_builder_object (&b, &f[0], 0, this->uri.alloc_param_meta_enable.MetaEnable, spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_meta_enable.MetaEnable,
PROP (&f[1], this->uri.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_HEADER)); PROP (&f[1], this->type.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_HEADER));
this->params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam); this->params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
this->info.extra = NULL; this->info.extra = NULL;
@ -602,11 +602,11 @@ spa_audiotestsrc_node_port_get_format (SpaNode *node,
return SPA_RESULT_NO_FORMAT; return SPA_RESULT_NO_FORMAT;
spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer)); spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer));
spa_pod_builder_format (&b, &f[0], this->uri.format, spa_pod_builder_format (&b, &f[0], this->type.format,
this->uri.media_types.audio, this->uri.media_subtypes.raw, this->type.media_type.audio, this->type.media_subtype.raw,
PROP (&f[1], this->uri.prop_audio.format, SPA_POD_TYPE_URI, this->current_format.info.raw.format), PROP (&f[1], this->type.prop_audio.format, SPA_POD_TYPE_URI, this->current_format.info.raw.format),
PROP (&f[1], this->uri.prop_audio.rate, SPA_POD_TYPE_INT, this->current_format.info.raw.rate), PROP (&f[1], this->type.prop_audio.rate, SPA_POD_TYPE_INT, this->current_format.info.raw.rate),
PROP (&f[1], this->uri.prop_audio.channels, SPA_POD_TYPE_INT, this->current_format.info.raw.channels)); PROP (&f[1], this->type.prop_audio.channels, SPA_POD_TYPE_INT, this->current_format.info.raw.channels));
*format = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat); *format = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat);
@ -909,9 +909,9 @@ spa_audiotestsrc_get_interface (SpaHandle *handle,
this = (SpaAudioTestSrc *) handle; this = (SpaAudioTestSrc *) handle;
if (interface_id == this->uri.node) if (interface_id == this->type.node)
*interface = &this->node; *interface = &this->node;
else if (interface_id == this->uri.clock) else if (interface_id == this->type.clock)
*interface = &this->clock; *interface = &this->clock;
else else
return SPA_RESULT_UNKNOWN_INTERFACE; return SPA_RESULT_UNKNOWN_INTERFACE;
@ -953,22 +953,22 @@ audiotestsrc_init (const SpaHandleFactory *factory,
this = (SpaAudioTestSrc *) handle; this = (SpaAudioTestSrc *) handle;
for (i = 0; i < n_support; i++) { for (i = 0; i < n_support; i++) {
if (strcmp (support[i].uri, SPA_TYPE__IDMap) == 0) if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
this->map = support[i].data; this->map = support[i].data;
else if (strcmp (support[i].uri, SPA_TYPE__Log) == 0) else if (strcmp (support[i].type, SPA_TYPE__Log) == 0)
this->log = support[i].data; this->log = support[i].data;
else if (strcmp (support[i].uri, SPA_TYPE_LOOP__DataLoop) == 0) else if (strcmp (support[i].type, SPA_TYPE_LOOP__DataLoop) == 0)
this->data_loop = support[i].data; this->data_loop = support[i].data;
} }
if (this->map == NULL) { if (this->map == NULL) {
spa_log_error (this->log, "an id-map is needed"); spa_log_error (this->log, "a type-map is needed");
return SPA_RESULT_ERROR; return SPA_RESULT_ERROR;
} }
if (this->data_loop == NULL) { if (this->data_loop == NULL) {
spa_log_error (this->log, "a data_loop is needed"); spa_log_error (this->log, "a data_loop is needed");
return SPA_RESULT_ERROR; return SPA_RESULT_ERROR;
} }
init_uri (&this->uri, this->map); init_type (&this->type, this->map);
this->node = audiotestsrc_node; this->node = audiotestsrc_node;
this->clock = audiotestsrc_clock; this->clock = audiotestsrc_clock;

View file

@ -22,7 +22,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <spa/id-map.h> #include <spa/type-map.h>
#include <spa/log.h> #include <spa/log.h>
#include <spa/node.h> #include <spa/node.h>
#include <spa/video/format-utils.h> #include <spa/video/format-utils.h>
@ -52,15 +52,22 @@ typedef struct {
typedef struct { typedef struct {
uint32_t node; uint32_t node;
SpaCommandNode command_node; SpaTypeCommandNode command_node;
} URI; } Type;
static inline void
init_type (Type *type, SpaTypeMap *map)
{
type->node = spa_type_map_get_id (map, SPA_TYPE__Node);
spa_type_command_node_map (map, &type->command_node);
}
struct _SpaFFMpegDec { struct _SpaFFMpegDec {
SpaHandle handle; SpaHandle handle;
SpaNode node; SpaNode node;
URI uri; Type type;
SpaIDMap *map; SpaTypeMap *map;
SpaLog *log; SpaLog *log;
SpaEventNodeCallback event_cb; SpaEventNodeCallback event_cb;
@ -105,10 +112,10 @@ spa_ffmpeg_dec_node_send_command (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node); this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node);
if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Start) { if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
update_state (this, SPA_NODE_STATE_STREAMING); update_state (this, SPA_NODE_STATE_STREAMING);
} }
else if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Pause) { else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
update_state (this, SPA_NODE_STATE_PAUSED); update_state (this, SPA_NODE_STATE_PAUSED);
} }
else else
@ -491,7 +498,7 @@ spa_ffmpeg_dec_get_interface (SpaHandle *handle,
this = (SpaFFMpegDec *) handle; this = (SpaFFMpegDec *) handle;
if (interface_id == this->uri.node) if (interface_id == this->type.node)
*interface = &this->node; *interface = &this->node;
else else
return SPA_RESULT_UNKNOWN_INTERFACE; return SPA_RESULT_UNKNOWN_INTERFACE;
@ -513,19 +520,18 @@ spa_ffmpeg_dec_init (SpaHandle *handle,
this = (SpaFFMpegDec *) handle; this = (SpaFFMpegDec *) handle;
for (i = 0; i < n_support; i++) { for (i = 0; i < n_support; i++) {
if (strcmp (support[i].uri, SPA_TYPE__IDMap) == 0) if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
this->map = support[i].data; this->map = support[i].data;
else if (strcmp (support[i].uri, SPA_TYPE__Log) == 0) else if (strcmp (support[i].type, SPA_TYPE__Log) == 0)
this->log = support[i].data; this->log = support[i].data;
} }
if (this->map == NULL) { if (this->map == NULL) {
spa_log_error (this->log, "an id-map is needed"); spa_log_error (this->log, "a type-map is needed");
return SPA_RESULT_ERROR; return SPA_RESULT_ERROR;
} }
this->uri.node = spa_id_map_get_id (this->map, SPA_TYPE__Node); init_type (&this->type, this->map);
this->node = ffmpeg_dec_node; this->node = ffmpeg_dec_node;
spa_command_node_map (this->map, &this->uri.command_node);
this->in_ports[0].info.flags = SPA_PORT_INFO_FLAG_NONE; this->in_ports[0].info.flags = SPA_PORT_INFO_FLAG_NONE;
this->out_ports[0].info.flags = SPA_PORT_INFO_FLAG_NONE; this->out_ports[0].info.flags = SPA_PORT_INFO_FLAG_NONE;

View file

@ -23,7 +23,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <spa/log.h> #include <spa/log.h>
#include <spa/id-map.h> #include <spa/type-map.h>
#include <spa/node.h> #include <spa/node.h>
#include <spa/video/format-utils.h> #include <spa/video/format-utils.h>
#include <lib/props.h> #include <lib/props.h>
@ -57,17 +57,26 @@ typedef struct {
typedef struct { typedef struct {
uint32_t node; uint32_t node;
SpaMediaTypes media_types; SpaTypeMediaType media_type;
SpaMediaSubtypes media_subtypes; SpaTypeMediaSubtype media_subtype;
SpaCommandNode command_node; SpaTypeCommandNode command_node;
} URI; } Type;
static inline void
init_type (Type *type, SpaTypeMap *map)
{
type->node = spa_type_map_get_id (map, SPA_TYPE__Node);
spa_type_media_type_map (map, &type->media_type);
spa_type_media_subtype_map (map, &type->media_subtype);
spa_type_command_node_map (map, &type->command_node);
}
struct _SpaFFMpegEnc { struct _SpaFFMpegEnc {
SpaHandle handle; SpaHandle handle;
SpaNode node; SpaNode node;
URI uri; Type type;
SpaIDMap *map; SpaTypeMap *map;
SpaLog *log; SpaLog *log;
SpaEventNodeCallback event_cb; SpaEventNodeCallback event_cb;
@ -112,10 +121,10 @@ spa_ffmpeg_enc_node_send_command (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node); this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node);
if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Start) { if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
update_state (this, SPA_NODE_STATE_STREAMING); update_state (this, SPA_NODE_STATE_STREAMING);
} }
else if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Pause) { else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
update_state (this, SPA_NODE_STATE_PAUSED); update_state (this, SPA_NODE_STATE_PAUSED);
} }
else else
@ -258,8 +267,8 @@ spa_ffmpeg_enc_node_port_set_format (SpaNode *node,
return SPA_RESULT_OK; return SPA_RESULT_OK;
} }
if (format->body.media_type.value != this->uri.media_types.video || if (format->body.media_type.value != this->type.media_type.video ||
format->body.media_subtype.value != this->uri.media_subtypes.raw) format->body.media_subtype.value != this->type.media_subtype.raw)
return SPA_RESULT_INVALID_MEDIA_TYPE; return SPA_RESULT_INVALID_MEDIA_TYPE;
if ((res = spa_format_video_parse (format, &query_format) < 0)) if ((res = spa_format_video_parse (format, &query_format) < 0))
@ -504,7 +513,7 @@ spa_ffmpeg_enc_get_interface (SpaHandle *handle,
this = (SpaFFMpegEnc *) handle; this = (SpaFFMpegEnc *) handle;
if (interface_id == this->uri.node) if (interface_id == this->type.node)
*interface = &this->node; *interface = &this->node;
else else
return SPA_RESULT_UNKNOWN_INTERFACE; return SPA_RESULT_UNKNOWN_INTERFACE;
@ -526,19 +535,15 @@ spa_ffmpeg_enc_init (SpaHandle *handle,
this = (SpaFFMpegEnc *) handle; this = (SpaFFMpegEnc *) handle;
for (i = 0; i < n_support; i++) { for (i = 0; i < n_support; i++) {
if (strcmp (support[i].uri, SPA_TYPE__IDMap) == 0) if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
this->map = support[i].data; this->map = support[i].data;
else if (strcmp (support[i].uri, SPA_TYPE__Log) == 0) else if (strcmp (support[i].type, SPA_TYPE__Log) == 0)
this->log = support[i].data; this->log = support[i].data;
} }
if (this->map == NULL) { if (this->map == NULL) {
spa_log_error (this->log, "an id-map is needed"); spa_log_error (this->log, "a type-map is needed");
return SPA_RESULT_ERROR; return SPA_RESULT_ERROR;
} }
this->uri.node = spa_id_map_get_id (this->map, SPA_TYPE__Node);
spa_media_types_fill (&this->uri.media_types, this->map);
spa_media_subtypes_map (this->map, &this->uri.media_subtypes);
spa_command_node_map (this->map, &this->uri.command_node);
this->node = ffmpeg_enc_node; this->node = ffmpeg_enc_node;

View file

@ -26,7 +26,7 @@
#include <libudev.h> #include <libudev.h>
#include <spa/log.h> #include <spa/log.h>
#include <spa/id-map.h> #include <spa/type-map.h>
#include <spa/loop.h> #include <spa/loop.h>
#include <spa/monitor.h> #include <spa/monitor.h>
#include <lib/debug.h> #include <lib/debug.h>
@ -42,15 +42,22 @@ typedef struct {
typedef struct { typedef struct {
uint32_t handle_factory; uint32_t handle_factory;
SpaMonitorTypes monitor_types; SpaTypeMonitor monitor;
} URI; } Type;
static inline void
init_type (Type *type, SpaTypeMap *map)
{
type->handle_factory = spa_type_map_get_id (map, SPA_TYPE__HandleFactory);
spa_type_monitor_map (map, &type->monitor);
}
struct _SpaV4l2Monitor { struct _SpaV4l2Monitor {
SpaHandle handle; SpaHandle handle;
SpaMonitor monitor; SpaMonitor monitor;
URI uri; Type type;
SpaIDMap *map; SpaTypeMap *map;
SpaLog *log; SpaLog *log;
SpaLoop *main_loop; SpaLoop *main_loop;
@ -108,20 +115,20 @@ fill_item (SpaV4l2Monitor *this, V4l2Item *item, struct udev_device *udevice)
spa_pod_builder_init (&b, this->item_buffer, sizeof (this->item_buffer)); spa_pod_builder_init (&b, this->item_buffer, sizeof (this->item_buffer));
spa_pod_builder_push_object (&b, &f[0], 0, this->uri.monitor_types.MonitorItem); spa_pod_builder_push_object (&b, &f[0], 0, this->type.monitor.MonitorItem);
spa_pod_builder_add (&b, spa_pod_builder_add (&b,
SPA_POD_PROP (&f[1], this->uri.monitor_types.id, 0, SPA_POD_TYPE_STRING, 1, udev_device_get_syspath (item->udevice)), SPA_POD_PROP (&f[1], this->type.monitor.id, 0, SPA_POD_TYPE_STRING, 1, udev_device_get_syspath (item->udevice)),
SPA_POD_PROP (&f[1], this->uri.monitor_types.flags, 0, SPA_POD_TYPE_INT, 1, 0), SPA_POD_PROP (&f[1], this->type.monitor.flags, 0, SPA_POD_TYPE_INT, 1, 0),
SPA_POD_PROP (&f[1], this->uri.monitor_types.state, 0, SPA_POD_TYPE_INT, 1, SPA_MONITOR_ITEM_STATE_AVAILABLE), SPA_POD_PROP (&f[1], this->type.monitor.state, 0, SPA_POD_TYPE_INT, 1, SPA_MONITOR_ITEM_STATE_AVAILABLE),
SPA_POD_PROP (&f[1], this->uri.monitor_types.name, 0, SPA_POD_TYPE_STRING, 1, name), SPA_POD_PROP (&f[1], this->type.monitor.name, 0, SPA_POD_TYPE_STRING, 1, name),
SPA_POD_PROP (&f[1], this->uri.monitor_types.klass, 0, SPA_POD_TYPE_STRING, 1, "Video/Source"), SPA_POD_PROP (&f[1], this->type.monitor.klass, 0, SPA_POD_TYPE_STRING, 1, "Video/Source"),
SPA_POD_PROP (&f[1], this->uri.monitor_types.factory, 0, SPA_POD_TYPE_POINTER, 1, this->uri.handle_factory, SPA_POD_PROP (&f[1], this->type.monitor.factory, 0, SPA_POD_TYPE_POINTER, 1, this->type.handle_factory,
&spa_v4l2_source_factory), &spa_v4l2_source_factory),
0); 0);
spa_pod_builder_add (&b, spa_pod_builder_add (&b,
SPA_POD_TYPE_PROP, &f[1], this->uri.monitor_types.info, 0, SPA_POD_TYPE_PROP, &f[1], this->type.monitor.info, 0,
SPA_POD_TYPE_STRUCT, 1, &f[2], 0); SPA_POD_TYPE_STRUCT, 1, &f[2], 0);
@ -204,11 +211,11 @@ v4l2_on_fd_events (SpaSource *source)
action = "change"; action = "change";
if (strcmp (action, "add") == 0) { if (strcmp (action, "add") == 0) {
type = this->uri.monitor_types.Added; type = this->type.monitor.Added;
} else if (strcmp (action, "change") == 0) { } else if (strcmp (action, "change") == 0) {
type = this->uri.monitor_types.Changed; type = this->type.monitor.Changed;
} else if (strcmp (action, "remove") == 0) { } else if (strcmp (action, "remove") == 0) {
type = this->uri.monitor_types.Removed; type = this->type.monitor.Removed;
} else } else
return; return;
@ -333,7 +340,7 @@ spa_v4l2_monitor_get_interface (SpaHandle *handle,
this = (SpaV4l2Monitor *) handle; this = (SpaV4l2Monitor *) handle;
if (interface_id == this->uri.monitor_types.Monitor) if (interface_id == this->type.monitor.Monitor)
*interface = &this->monitor; *interface = &this->monitor;
else else
return SPA_RESULT_UNKNOWN_INTERFACE; return SPA_RESULT_UNKNOWN_INTERFACE;
@ -366,23 +373,22 @@ v4l2_monitor_init (const SpaHandleFactory *factory,
this = (SpaV4l2Monitor *) handle; this = (SpaV4l2Monitor *) handle;
for (i = 0; i < n_support; i++) { for (i = 0; i < n_support; i++) {
if (strcmp (support[i].uri, SPA_TYPE__IDMap) == 0) if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
this->map = support[i].data; this->map = support[i].data;
else if (strcmp (support[i].uri, SPA_TYPE__Log) == 0) else if (strcmp (support[i].type, SPA_TYPE__Log) == 0)
this->log = support[i].data; this->log = support[i].data;
else if (strcmp (support[i].uri, SPA_TYPE_LOOP__MainLoop) == 0) else if (strcmp (support[i].type, SPA_TYPE_LOOP__MainLoop) == 0)
this->main_loop = support[i].data; this->main_loop = support[i].data;
} }
if (this->map == NULL) { if (this->map == NULL) {
spa_log_error (this->log, "an id-map is needed"); spa_log_error (this->log, "a type-map is needed");
return SPA_RESULT_ERROR; return SPA_RESULT_ERROR;
} }
if (this->main_loop == NULL) { if (this->main_loop == NULL) {
spa_log_error (this->log, "a main-loop is needed"); spa_log_error (this->log, "a main-loop is needed");
return SPA_RESULT_ERROR; return SPA_RESULT_ERROR;
} }
this->uri.handle_factory = spa_id_map_get_id (this->map, SPA_TYPE__HandleFactory); init_type (&this->type, this->map);
spa_monitor_types_map (this->map, &this->uri.monitor_types);
this->monitor = v4l2monitor; this->monitor = v4l2monitor;

View file

@ -30,7 +30,7 @@
#include <spa/list.h> #include <spa/list.h>
#include <spa/log.h> #include <spa/log.h>
#include <spa/loop.h> #include <spa/loop.h>
#include <spa/id-map.h> #include <spa/type-map.h>
#include <spa/format-builder.h> #include <spa/format-builder.h>
#include <lib/debug.h> #include <lib/debug.h>
#include <lib/props.h> #include <lib/props.h>
@ -71,36 +71,36 @@ typedef struct {
uint32_t prop_device; uint32_t prop_device;
uint32_t prop_device_name; uint32_t prop_device_name;
uint32_t prop_device_fd; uint32_t prop_device_fd;
SpaMediaTypes media_types; SpaTypeMediaType media_type;
SpaMediaSubtypes media_subtypes; SpaTypeMediaSubtype media_subtype;
SpaMediaSubtypesVideo media_subtypes_video; SpaTypeMediaSubtypeVideo media_subtype_video;
SpaPropVideo prop_video; SpaTypePropVideo prop_video;
SpaVideoFormats video_formats; SpaTypeVideoFormat video_format;
SpaEventNode event_node; SpaTypeEventNode event_node;
SpaCommandNode command_node; SpaTypeCommandNode command_node;
SpaAllocParamBuffers alloc_param_buffers; SpaTypeAllocParamBuffers alloc_param_buffers;
SpaAllocParamMetaEnable alloc_param_meta_enable; SpaTypeAllocParamMetaEnable alloc_param_meta_enable;
} URI; } Type;
static inline void static inline void
init_uri (URI *uri, SpaIDMap *map) init_type (Type *type, SpaTypeMap *map)
{ {
uri->node = spa_id_map_get_id (map, SPA_TYPE__Node); type->node = spa_type_map_get_id (map, SPA_TYPE__Node);
uri->clock = spa_id_map_get_id (map, SPA_TYPE__Clock); type->clock = spa_type_map_get_id (map, SPA_TYPE__Clock);
uri->format = spa_id_map_get_id (map, SPA_TYPE__Format); type->format = spa_type_map_get_id (map, SPA_TYPE__Format);
uri->props = spa_id_map_get_id (map, SPA_TYPE__Props); type->props = spa_type_map_get_id (map, SPA_TYPE__Props);
uri->prop_device = spa_id_map_get_id (map, SPA_TYPE_PROPS__device); type->prop_device = spa_type_map_get_id (map, SPA_TYPE_PROPS__device);
uri->prop_device_name = spa_id_map_get_id (map, SPA_TYPE_PROPS__deviceName); type->prop_device_name = spa_type_map_get_id (map, SPA_TYPE_PROPS__deviceName);
uri->prop_device_fd = spa_id_map_get_id (map, SPA_TYPE_PROPS__deviceFd); type->prop_device_fd = spa_type_map_get_id (map, SPA_TYPE_PROPS__deviceFd);
spa_media_types_fill (&uri->media_types, map); spa_type_media_type_map (map, &type->media_type);
spa_media_subtypes_map (map, &uri->media_subtypes); spa_type_media_subtype_map (map, &type->media_subtype);
spa_media_subtypes_video_map (map, &uri->media_subtypes_video); spa_type_media_subtype_video_map (map, &type->media_subtype_video);
spa_prop_video_map (map, &uri->prop_video); spa_type_prop_video_map (map, &type->prop_video);
spa_video_formats_map (map, &uri->video_formats); spa_type_video_format_map (map, &type->video_format);
spa_event_node_map (map, &uri->event_node); spa_type_event_node_map (map, &type->event_node);
spa_command_node_map (map, &uri->command_node); spa_type_command_node_map (map, &type->command_node);
spa_alloc_param_buffers_map (map, &uri->alloc_param_buffers); spa_type_alloc_param_buffers_map (map, &type->alloc_param_buffers);
spa_alloc_param_meta_enable_map (map, &uri->alloc_param_meta_enable); spa_type_alloc_param_meta_enable_map (map, &type->alloc_param_meta_enable);
} }
typedef struct { typedef struct {
@ -148,9 +148,9 @@ struct _SpaV4l2Source {
SpaNode node; SpaNode node;
SpaClock clock; SpaClock clock;
SpaIDMap *map; SpaTypeMap *map;
SpaLog *log; SpaLog *log;
URI uri; Type type;
uint32_t seq; uint32_t seq;
@ -206,10 +206,10 @@ spa_v4l2_source_node_get_props (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaV4l2Source, node); this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer)); spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
spa_pod_builder_props (&b, &f[0], this->uri.props, spa_pod_builder_props (&b, &f[0], this->type.props,
PROP (&f[1], this->uri.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device)), PROP (&f[1], this->type.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device)),
PROP_R (&f[1], this->uri.prop_device_name, -SPA_POD_TYPE_STRING, this->props.device_name, sizeof (this->props.device_name)), PROP_R (&f[1], this->type.prop_device_name, -SPA_POD_TYPE_STRING, this->props.device_name, sizeof (this->props.device_name)),
PROP_R (&f[1], this->uri.prop_device_fd, SPA_POD_TYPE_INT, this->props.device_fd)); PROP_R (&f[1], this->type.prop_device_fd, SPA_POD_TYPE_INT, this->props.device_fd));
*props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps); *props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps);
return SPA_RESULT_OK; return SPA_RESULT_OK;
@ -231,7 +231,7 @@ spa_v4l2_source_node_set_props (SpaNode *node,
return SPA_RESULT_OK; return SPA_RESULT_OK;
} else { } else {
spa_props_query (props, spa_props_query (props,
this->uri.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device), this->type.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device),
0); 0);
} }
return SPA_RESULT_OK; return SPA_RESULT_OK;
@ -279,7 +279,7 @@ do_pause (SpaLoop *loop,
cmd); cmd);
if (async) { if (async) {
SpaEventNodeAsyncComplete ac = SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (this->uri.event_node.AsyncComplete, SpaEventNodeAsyncComplete ac = SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (this->type.event_node.AsyncComplete,
seq, res); seq, res);
spa_loop_invoke (this->state[0].main_loop, spa_loop_invoke (this->state[0].main_loop,
do_pause_done, do_pause_done,
@ -330,7 +330,7 @@ do_start (SpaLoop *loop,
cmd); cmd);
if (async) { if (async) {
SpaEventNodeAsyncComplete ac = SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (this->uri.event_node.AsyncComplete, SpaEventNodeAsyncComplete ac = SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (this->type.event_node.AsyncComplete,
seq, res); seq, res);
spa_loop_invoke (this->state[0].main_loop, spa_loop_invoke (this->state[0].main_loop,
do_start_done, do_start_done,
@ -354,7 +354,7 @@ spa_v4l2_source_node_send_command (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaV4l2Source, node); this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Start) { if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
SpaV4l2State *state = &this->state[0]; SpaV4l2State *state = &this->state[0];
SpaResult res; SpaResult res;
@ -377,7 +377,7 @@ spa_v4l2_source_node_send_command (SpaNode *node,
command, command,
this); this);
} }
else if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Pause) { else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
SpaV4l2State *state = &this->state[0]; SpaV4l2State *state = &this->state[0];
if (!state->have_format) if (!state->have_format)
@ -396,7 +396,7 @@ spa_v4l2_source_node_send_command (SpaNode *node,
command, command,
this); this);
} }
else if (SPA_COMMAND_TYPE (command) == this->uri.command_node.ClockUpdate) { else if (SPA_COMMAND_TYPE (command) == this->type.command_node.ClockUpdate) {
return SPA_RESULT_OK; return SPA_RESULT_OK;
} }
else else
@ -587,28 +587,28 @@ spa_v4l2_source_node_port_get_format (SpaNode *node,
b.data = state->format_buffer; b.data = state->format_buffer;
b.size = sizeof (state->format_buffer); b.size = sizeof (state->format_buffer);
spa_pod_builder_push_format (&b, &f[0], this->uri.format, spa_pod_builder_push_format (&b, &f[0], this->type.format,
state->current_format.media_type, state->current_format.media_type,
state->current_format.media_subtype); state->current_format.media_subtype);
if (state->current_format.media_subtype == this->uri.media_subtypes.raw) { if (state->current_format.media_subtype == this->type.media_subtype.raw) {
spa_pod_builder_add (&b, spa_pod_builder_add (&b,
PROP (&f[1], this->uri.prop_video.format, SPA_POD_TYPE_URI, state->current_format.info.raw.format), PROP (&f[1], this->type.prop_video.format, SPA_POD_TYPE_URI, state->current_format.info.raw.format),
PROP (&f[1], this->uri.prop_video.size, -SPA_POD_TYPE_RECTANGLE, &state->current_format.info.raw.size), PROP (&f[1], this->type.prop_video.size, -SPA_POD_TYPE_RECTANGLE, &state->current_format.info.raw.size),
PROP (&f[1], this->uri.prop_video.framerate, -SPA_POD_TYPE_FRACTION, &state->current_format.info.raw.framerate), PROP (&f[1], this->type.prop_video.framerate, -SPA_POD_TYPE_FRACTION, &state->current_format.info.raw.framerate),
0); 0);
} }
else if (state->current_format.media_subtype == this->uri.media_subtypes_video.mjpg || else if (state->current_format.media_subtype == this->type.media_subtype_video.mjpg ||
state->current_format.media_subtype == this->uri.media_subtypes_video.jpeg) { state->current_format.media_subtype == this->type.media_subtype_video.jpeg) {
spa_pod_builder_add (&b, spa_pod_builder_add (&b,
PROP (&f[1], this->uri.prop_video.size, -SPA_POD_TYPE_RECTANGLE, &state->current_format.info.mjpg.size), PROP (&f[1], this->type.prop_video.size, -SPA_POD_TYPE_RECTANGLE, &state->current_format.info.mjpg.size),
PROP (&f[1], this->uri.prop_video.framerate, -SPA_POD_TYPE_FRACTION, &state->current_format.info.mjpg.framerate), PROP (&f[1], this->type.prop_video.framerate, -SPA_POD_TYPE_FRACTION, &state->current_format.info.mjpg.framerate),
0); 0);
} }
else if (state->current_format.media_subtype == this->uri.media_subtypes_video.h264) { else if (state->current_format.media_subtype == this->type.media_subtype_video.h264) {
spa_pod_builder_add (&b, spa_pod_builder_add (&b,
PROP (&f[1], this->uri.prop_video.size, -SPA_POD_TYPE_RECTANGLE, &state->current_format.info.h264.size), PROP (&f[1], this->type.prop_video.size, -SPA_POD_TYPE_RECTANGLE, &state->current_format.info.h264.size),
PROP (&f[1], this->uri.prop_video.framerate, -SPA_POD_TYPE_FRACTION, &state->current_format.info.h264.framerate), PROP (&f[1], this->type.prop_video.framerate, -SPA_POD_TYPE_FRACTION, &state->current_format.info.h264.framerate),
0); 0);
} else } else
return SPA_RESULT_NO_FORMAT; return SPA_RESULT_NO_FORMAT;
@ -807,10 +807,10 @@ spa_v4l2_source_node_port_send_command (SpaNode *node,
if (port_id != 0) if (port_id != 0)
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Pause) { if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
res = spa_v4l2_port_set_enabled (this, false); res = spa_v4l2_port_set_enabled (this, false);
} }
else if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Start) { else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
res = spa_v4l2_port_set_enabled (this, true); res = spa_v4l2_port_set_enabled (this, true);
} else } else
res = SPA_RESULT_NOT_IMPLEMENTED; res = SPA_RESULT_NOT_IMPLEMENTED;
@ -918,9 +918,9 @@ spa_v4l2_source_get_interface (SpaHandle *handle,
this = (SpaV4l2Source *) handle; this = (SpaV4l2Source *) handle;
if (interface_id == this->uri.node) if (interface_id == this->type.node)
*interface = &this->node; *interface = &this->node;
else if (interface_id == this->uri.clock) else if (interface_id == this->type.clock)
*interface = &this->clock; *interface = &this->clock;
else else
return SPA_RESULT_UNKNOWN_INTERFACE; return SPA_RESULT_UNKNOWN_INTERFACE;
@ -954,17 +954,17 @@ v4l2_source_init (const SpaHandleFactory *factory,
this = (SpaV4l2Source *) handle; this = (SpaV4l2Source *) handle;
for (i = 0; i < n_support; i++) { for (i = 0; i < n_support; i++) {
if (strcmp (support[i].uri, SPA_TYPE__IDMap) == 0) if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
this->map = support[i].data; this->map = support[i].data;
else if (strcmp (support[i].uri, SPA_TYPE__Log) == 0) else if (strcmp (support[i].type, SPA_TYPE__Log) == 0)
this->log = support[i].data; this->log = support[i].data;
else if (strcmp (support[i].uri, SPA_TYPE_LOOP__MainLoop) == 0) else if (strcmp (support[i].type, SPA_TYPE_LOOP__MainLoop) == 0)
this->state[0].main_loop = support[i].data; this->state[0].main_loop = support[i].data;
else if (strcmp (support[i].uri, SPA_TYPE_LOOP__DataLoop) == 0) else if (strcmp (support[i].type, SPA_TYPE_LOOP__DataLoop) == 0)
this->state[0].data_loop = support[i].data; this->state[0].data_loop = support[i].data;
} }
if (this->map == NULL) { if (this->map == NULL) {
spa_log_error (this->log, "an id-map is needed"); spa_log_error (this->log, "a type-map is needed");
return SPA_RESULT_ERROR; return SPA_RESULT_ERROR;
} }
if (this->state[0].main_loop == NULL) { if (this->state[0].main_loop == NULL) {
@ -975,7 +975,7 @@ v4l2_source_init (const SpaHandleFactory *factory,
spa_log_error (this->log, "a data_loop is needed"); spa_log_error (this->log, "a data_loop is needed");
return SPA_RESULT_ERROR; return SPA_RESULT_ERROR;
} }
init_uri (&this->uri, this->map); init_type (&this->type, this->map);
this->node = v4l2source_node; this->node = v4l2source_node;
this->clock = v4l2source_clock; this->clock = v4l2source_clock;

View file

@ -169,54 +169,54 @@ typedef struct {
off_t media_subtype_offset; off_t media_subtype_offset;
} FormatInfo; } FormatInfo;
#define VIDEO offsetof(URI, media_types.video) #define VIDEO offsetof(Type, media_type.video)
#define IMAGE offsetof(URI, media_types.image) #define IMAGE offsetof(Type, media_type.image)
#define RAW offsetof(URI, media_subtypes.raw) #define RAW offsetof(Type, media_subtype.raw)
#define BAYER offsetof(URI, media_subtypes_video.bayer) #define BAYER offsetof(Type, media_subtype_video.bayer)
#define MJPG offsetof(URI, media_subtypes_video.mjpg) #define MJPG offsetof(Type, media_subtype_video.mjpg)
#define JPEG offsetof(URI, media_subtypes_video.jpeg) #define JPEG offsetof(Type, media_subtype_video.jpeg)
#define DV offsetof(URI, media_subtypes_video.dv) #define DV offsetof(Type, media_subtype_video.dv)
#define MPEGTS offsetof(URI, media_subtypes_video.mpegts) #define MPEGTS offsetof(Type, media_subtype_video.mpegts)
#define H264 offsetof(URI, media_subtypes_video.h264) #define H264 offsetof(Type, media_subtype_video.h264)
#define H263 offsetof(URI, media_subtypes_video.h263) #define H263 offsetof(Type, media_subtype_video.h263)
#define MPEG1 offsetof(URI, media_subtypes_video.mpeg1) #define MPEG1 offsetof(Type, media_subtype_video.mpeg1)
#define MPEG2 offsetof(URI, media_subtypes_video.mpeg2) #define MPEG2 offsetof(Type, media_subtype_video.mpeg2)
#define MPEG4 offsetof(URI, media_subtypes_video.mpeg4) #define MPEG4 offsetof(Type, media_subtype_video.mpeg4)
#define XVID offsetof(URI, media_subtypes_video.xvid) #define XVID offsetof(Type, media_subtype_video.xvid)
#define VC1 offsetof(URI, media_subtypes_video.vc1) #define VC1 offsetof(Type, media_subtype_video.vc1)
#define VP8 offsetof(URI, media_subtypes_video.vp8) #define VP8 offsetof(Type, media_subtype_video.vp8)
#define FORMAT_UNKNOWN offsetof(URI, video_formats.UNKNOWN) #define FORMAT_UNKNOWN offsetof(Type, video_format.UNKNOWN)
#define FORMAT_ENCODED offsetof(URI, video_formats.ENCODED) #define FORMAT_ENCODED offsetof(Type, video_format.ENCODED)
#define FORMAT_RGB15 offsetof(URI, video_formats.RGB15) #define FORMAT_RGB15 offsetof(Type, video_format.RGB15)
#define FORMAT_BGR15 offsetof(URI, video_formats.BGR15) #define FORMAT_BGR15 offsetof(Type, video_format.BGR15)
#define FORMAT_RGB16 offsetof(URI, video_formats.RGB16) #define FORMAT_RGB16 offsetof(Type, video_format.RGB16)
#define FORMAT_BGR offsetof(URI, video_formats.BGR) #define FORMAT_BGR offsetof(Type, video_format.BGR)
#define FORMAT_RGB offsetof(URI, video_formats.RGB) #define FORMAT_RGB offsetof(Type, video_format.RGB)
#define FORMAT_BGRA offsetof(URI, video_formats.BGRA) #define FORMAT_BGRA offsetof(Type, video_format.BGRA)
#define FORMAT_BGRx offsetof(URI, video_formats.BGRx) #define FORMAT_BGRx offsetof(Type, video_format.BGRx)
#define FORMAT_ARGB offsetof(URI, video_formats.ARGB) #define FORMAT_ARGB offsetof(Type, video_format.ARGB)
#define FORMAT_xRGB offsetof(URI, video_formats.xRGB) #define FORMAT_xRGB offsetof(Type, video_format.xRGB)
#define FORMAT_GRAY8 offsetof(URI, video_formats.GRAY8) #define FORMAT_GRAY8 offsetof(Type, video_format.GRAY8)
#define FORMAT_GRAY16_LE offsetof(URI, video_formats.GRAY16_LE) #define FORMAT_GRAY16_LE offsetof(Type, video_format.GRAY16_LE)
#define FORMAT_GRAY16_BE offsetof(URI, video_formats.GRAY16_BE) #define FORMAT_GRAY16_BE offsetof(Type, video_format.GRAY16_BE)
#define FORMAT_YVU9 offsetof(URI, video_formats.YVU9) #define FORMAT_YVU9 offsetof(Type, video_format.YVU9)
#define FORMAT_YV12 offsetof(URI, video_formats.YV12) #define FORMAT_YV12 offsetof(Type, video_format.YV12)
#define FORMAT_YUY2 offsetof(URI, video_formats.YUY2) #define FORMAT_YUY2 offsetof(Type, video_format.YUY2)
#define FORMAT_YVYU offsetof(URI, video_formats.YVYU) #define FORMAT_YVYU offsetof(Type, video_format.YVYU)
#define FORMAT_UYVY offsetof(URI, video_formats.UYVY) #define FORMAT_UYVY offsetof(Type, video_format.UYVY)
#define FORMAT_Y42B offsetof(URI, video_formats.Y42B) #define FORMAT_Y42B offsetof(Type, video_format.Y42B)
#define FORMAT_Y41B offsetof(URI, video_formats.Y41B) #define FORMAT_Y41B offsetof(Type, video_format.Y41B)
#define FORMAT_YUV9 offsetof(URI, video_formats.YUV9) #define FORMAT_YUV9 offsetof(Type, video_format.YUV9)
#define FORMAT_I420 offsetof(URI, video_formats.I420) #define FORMAT_I420 offsetof(Type, video_format.I420)
#define FORMAT_NV12 offsetof(URI, video_formats.NV12) #define FORMAT_NV12 offsetof(Type, video_format.NV12)
#define FORMAT_NV12_64Z32 offsetof(URI, video_formats.NV12_64Z32) #define FORMAT_NV12_64Z32 offsetof(Type, video_format.NV12_64Z32)
#define FORMAT_NV21 offsetof(URI, video_formats.NV21) #define FORMAT_NV21 offsetof(Type, video_format.NV21)
#define FORMAT_NV16 offsetof(URI, video_formats.NV16) #define FORMAT_NV16 offsetof(Type, video_format.NV16)
#define FORMAT_NV61 offsetof(URI, video_formats.NV61) #define FORMAT_NV61 offsetof(Type, video_format.NV61)
#define FORMAT_NV24 offsetof(URI, video_formats.NV24) #define FORMAT_NV24 offsetof(Type, video_format.NV24)
static const FormatInfo format_info[] = static const FormatInfo format_info[] =
{ {
@ -354,7 +354,7 @@ video_format_to_format_info (SpaVideoFormat format)
#endif #endif
static const FormatInfo * static const FormatInfo *
find_format_info_by_media_type (URI *uri, find_format_info_by_media_type (Type *types,
uint32_t type, uint32_t type,
uint32_t subtype, uint32_t subtype,
uint32_t format, uint32_t format,
@ -365,9 +365,9 @@ find_format_info_by_media_type (URI *uri,
for (i = startidx; i < SPA_N_ELEMENTS (format_info); i++) { for (i = startidx; i < SPA_N_ELEMENTS (format_info); i++) {
uint32_t media_type, media_subtype, media_format; uint32_t media_type, media_subtype, media_format;
media_type = *SPA_MEMBER (uri, format_info[i].media_type_offset, uint32_t); media_type = *SPA_MEMBER (types, format_info[i].media_type_offset, uint32_t);
media_subtype = *SPA_MEMBER (uri, format_info[i].media_subtype_offset, uint32_t); media_subtype = *SPA_MEMBER (types, format_info[i].media_subtype_offset, uint32_t);
media_format = *SPA_MEMBER (uri, format_info[i].format_offset, uint32_t); media_format = *SPA_MEMBER (types, format_info[i].format_offset, uint32_t);
if ((media_type == type) && if ((media_type == type) &&
(media_subtype == subtype) && (media_subtype == subtype) &&
@ -378,22 +378,22 @@ find_format_info_by_media_type (URI *uri,
} }
static uint32_t static uint32_t
enum_filter_format (URI *uri, const SpaFormat *filter, uint32_t index) enum_filter_format (Type *type, const SpaFormat *filter, uint32_t index)
{ {
uint32_t video_format = 0; uint32_t video_format = 0;
if ((filter->body.media_type.value == uri->media_types.video || if ((filter->body.media_type.value == type->media_type.video ||
filter->body.media_type.value == uri->media_types.image)) { filter->body.media_type.value == type->media_type.image)) {
if (filter->body.media_subtype.value == uri->media_subtypes.raw) { if (filter->body.media_subtype.value == type->media_subtype.raw) {
SpaPODProp *p; SpaPODProp *p;
uint32_t n_values; uint32_t n_values;
const uint32_t *values; const uint32_t *values;
if (!(p = spa_format_find_prop (filter, uri->prop_video.format))) if (!(p = spa_format_find_prop (filter, type->prop_video.format)))
return uri->video_formats.UNKNOWN; return type->video_format.UNKNOWN;
if (p->body.value.type != SPA_POD_TYPE_URI) if (p->body.value.type != SPA_POD_TYPE_URI)
return uri->video_formats.UNKNOWN; return type->video_format.UNKNOWN;
values = SPA_POD_BODY_CONST (&p->body.value); values = SPA_POD_BODY_CONST (&p->body.value);
n_values = SPA_POD_PROP_N_VALUES (p); n_values = SPA_POD_PROP_N_VALUES (p);
@ -407,7 +407,7 @@ enum_filter_format (URI *uri, const SpaFormat *filter, uint32_t index)
} }
} else { } else {
if (index == 0) if (index == 0)
video_format = uri->video_formats.ENCODED; video_format = type->video_format.ENCODED;
} }
} }
return video_format; return video_format;
@ -538,11 +538,11 @@ next_fmtdesc:
while (state->next_fmtdesc) { while (state->next_fmtdesc) {
if (filter) { if (filter) {
video_format = enum_filter_format (&this->uri, filter, state->fmtdesc.index); video_format = enum_filter_format (&this->type, filter, state->fmtdesc.index);
if (video_format == this->uri.video_formats.UNKNOWN) if (video_format == this->type.video_format.UNKNOWN)
return SPA_RESULT_ENUM_END; return SPA_RESULT_ENUM_END;
info = find_format_info_by_media_type (&this->uri, info = find_format_info_by_media_type (&this->type,
filter->body.media_type.value, filter->body.media_type.value,
filter->body.media_subtype.value, filter->body.media_subtype.value,
video_format, video_format,
@ -572,7 +572,7 @@ next_frmsize:
SpaPODProp *p; SpaPODProp *p;
/* check if we have a fixed frame size */ /* check if we have a fixed frame size */
if (!(p = spa_format_find_prop (filter, this->uri.prop_video.size))) if (!(p = spa_format_find_prop (filter, this->type.prop_video.size)))
goto do_frmsize; goto do_frmsize;
if (p->body.value.type != SPA_POD_TYPE_RECTANGLE) if (p->body.value.type != SPA_POD_TYPE_RECTANGLE)
@ -605,7 +605,7 @@ do_frmsize:
uint32_t i, n_values; uint32_t i, n_values;
/* check if we have a fixed frame size */ /* check if we have a fixed frame size */
if (!(p = spa_format_find_prop (filter, this->uri.prop_video.size))) if (!(p = spa_format_find_prop (filter, this->type.prop_video.size)))
goto have_size; goto have_size;
range = p->body.flags & SPA_POD_PROP_RANGE_MASK; range = p->body.flags & SPA_POD_PROP_RANGE_MASK;
@ -658,26 +658,26 @@ have_size:
} }
} }
media_type = *SPA_MEMBER (&this->uri, info->media_type_offset, uint32_t); media_type = *SPA_MEMBER (&this->type, info->media_type_offset, uint32_t);
media_subtype = *SPA_MEMBER (&this->uri, info->media_subtype_offset, uint32_t); media_subtype = *SPA_MEMBER (&this->type, info->media_subtype_offset, uint32_t);
video_format = *SPA_MEMBER (&this->uri, info->format_offset, uint32_t); video_format = *SPA_MEMBER (&this->type, info->format_offset, uint32_t);
spa_pod_builder_push_format (&b, &f[0], this->uri.format, spa_pod_builder_push_format (&b, &f[0], this->type.format,
media_type, media_type,
media_subtype); media_subtype);
if (media_subtype == this->uri.media_subtypes.raw) { if (media_subtype == this->type.media_subtype.raw) {
spa_pod_builder_add (&b, spa_pod_builder_add (&b,
PROP (&f[1], this->uri.prop_video.format, SPA_POD_TYPE_URI, video_format), PROP (&f[1], this->type.prop_video.format, SPA_POD_TYPE_URI, video_format),
0); 0);
} }
spa_pod_builder_add (&b, spa_pod_builder_add (&b,
PROP (&f[1], this->uri.prop_video.size, SPA_POD_TYPE_RECTANGLE, state->frmsize.discrete.width, PROP (&f[1], this->type.prop_video.size, SPA_POD_TYPE_RECTANGLE, state->frmsize.discrete.width,
state->frmsize.discrete.height), state->frmsize.discrete.height),
0); 0);
spa_pod_builder_push_prop (&b, &f[1], spa_pod_builder_push_prop (&b, &f[1],
this->uri.prop_video.framerate, this->type.prop_video.framerate,
SPA_POD_PROP_RANGE_NONE | SPA_POD_PROP_RANGE_NONE |
SPA_POD_PROP_FLAG_UNSET | SPA_POD_PROP_FLAG_UNSET |
SPA_POD_PROP_FLAG_READWRITE); SPA_POD_PROP_FLAG_READWRITE);
@ -705,7 +705,7 @@ have_size:
uint32_t i, n_values; uint32_t i, n_values;
const SpaFraction step = { 1, 1 }, *values; const SpaFraction step = { 1, 1 }, *values;
if (!(p = spa_format_find_prop (filter, this->uri.prop_video.framerate))) if (!(p = spa_format_find_prop (filter, this->type.prop_video.framerate)))
goto have_framerate; goto have_framerate;
if (p->body.value.type != SPA_POD_TYPE_FRACTION) if (p->body.value.type != SPA_POD_TYPE_FRACTION)
@ -804,27 +804,27 @@ spa_v4l2_set_format (SpaV4l2Source *this, SpaVideoInfo *format, bool try_only)
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (format->media_subtype == this->uri.media_subtypes.raw) { if (format->media_subtype == this->type.media_subtype.raw) {
video_format = format->info.raw.format; video_format = format->info.raw.format;
size = &format->info.raw.size; size = &format->info.raw.size;
framerate = &format->info.raw.framerate; framerate = &format->info.raw.framerate;
} }
else if (format->media_subtype == this->uri.media_subtypes_video.mjpg || else if (format->media_subtype == this->type.media_subtype_video.mjpg ||
format->media_subtype == this->uri.media_subtypes_video.jpeg) { format->media_subtype == this->type.media_subtype_video.jpeg) {
video_format = this->uri.video_formats.ENCODED; video_format = this->type.video_format.ENCODED;
size = &format->info.mjpg.size; size = &format->info.mjpg.size;
framerate = &format->info.mjpg.framerate; framerate = &format->info.mjpg.framerate;
} }
else if (format->media_subtype == this->uri.media_subtypes_video.h264) { else if (format->media_subtype == this->type.media_subtype_video.h264) {
video_format = this->uri.video_formats.ENCODED; video_format = this->type.video_format.ENCODED;
size = &format->info.h264.size; size = &format->info.h264.size;
framerate = &format->info.h264.framerate; framerate = &format->info.h264.framerate;
} }
else { else {
video_format = this->uri.video_formats.ENCODED; video_format = this->type.video_format.ENCODED;
} }
info = find_format_info_by_media_type (&this->uri, info = find_format_info_by_media_type (&this->type,
format->media_type, format->media_type,
format->media_subtype, format->media_subtype,
video_format, video_format,
@ -893,15 +893,15 @@ spa_v4l2_set_format (SpaV4l2Source *this, SpaVideoInfo *format, bool try_only)
state->info.params = state->params; state->info.params = state->params;
spa_pod_builder_init (&b, state->params_buffer, sizeof (state->params_buffer)); spa_pod_builder_init (&b, state->params_buffer, sizeof (state->params_buffer));
spa_pod_builder_object (&b, &f[0], 0, this->uri.alloc_param_buffers.Buffers, spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_buffers.Buffers,
PROP (&f[1], this->uri.alloc_param_buffers.size, SPA_POD_TYPE_INT, fmt.fmt.pix.sizeimage), PROP (&f[1], this->type.alloc_param_buffers.size, SPA_POD_TYPE_INT, fmt.fmt.pix.sizeimage),
PROP (&f[1], this->uri.alloc_param_buffers.stride, SPA_POD_TYPE_INT, fmt.fmt.pix.bytesperline), PROP (&f[1], this->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, fmt.fmt.pix.bytesperline),
PROP_U_MM (&f[1], this->uri.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, MAX_BUFFERS, 2, MAX_BUFFERS), PROP_U_MM (&f[1], this->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, MAX_BUFFERS, 2, MAX_BUFFERS),
PROP (&f[1], this->uri.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16)); PROP (&f[1], this->type.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));
state->params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam); state->params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
spa_pod_builder_object (&b, &f[0], 0, this->uri.alloc_param_meta_enable.MetaEnable, spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_meta_enable.MetaEnable,
PROP (&f[1], this->uri.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_HEADER)); PROP (&f[1], this->type.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_HEADER));
state->params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam); state->params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
state->info.extra = NULL; state->info.extra = NULL;
@ -979,7 +979,7 @@ v4l2_on_fd_events (SpaSource *source)
return; return;
{ {
SpaEvent event = SPA_EVENT_INIT (this->uri.event_node.HaveOutput); SpaEvent event = SPA_EVENT_INIT (this->type.event_node.HaveOutput);
this->event_cb (&this->node, &event, this->user_data); this->event_cb (&this->node, &event, this->user_data);
} }
} }

View file

@ -144,14 +144,14 @@ drawing_data_init (DrawingData *dd,
SpaVideoInfo *format = &this->current_format; SpaVideoInfo *format = &this->current_format;
SpaRectangle *size = &format->info.raw.size; SpaRectangle *size = &format->info.raw.size;
if ((format->media_type != this->uri.media_types.video) || if ((format->media_type != this->type.media_type.video) ||
(format->media_subtype != this->uri.media_subtypes.raw)) (format->media_subtype != this->type.media_subtype.raw))
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
if (format->info.raw.format == this->uri.video_formats.RGB) { if (format->info.raw.format == this->type.video_format.RGB) {
dd->draw_pixel = draw_pixel_rgb; dd->draw_pixel = draw_pixel_rgb;
} }
else if (format->info.raw.format == this->uri.video_formats.UYVY) { else if (format->info.raw.format == this->type.video_format.UYVY) {
dd->draw_pixel = draw_pixel_uyvy; dd->draw_pixel = draw_pixel_uyvy;
} }
else else
@ -282,9 +282,9 @@ draw (SpaVideoTestSrc *this, char *data)
return res; return res;
pattern = this->props.pattern; pattern = this->props.pattern;
if (pattern == this->uri.pattern_smpte_snow) if (pattern == this->type.pattern_smpte_snow)
draw_smpte_snow (&dd); draw_smpte_snow (&dd);
else if (pattern == this->uri.pattern_snow) else if (pattern == this->type.pattern_snow)
draw_snow (&dd); draw_snow (&dd);
else else
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;

View file

@ -24,7 +24,7 @@
#include <stdio.h> #include <stdio.h>
#include <sys/timerfd.h> #include <sys/timerfd.h>
#include <spa/id-map.h> #include <spa/type-map.h>
#include <spa/clock.h> #include <spa/clock.h>
#include <spa/log.h> #include <spa/log.h>
#include <spa/loop.h> #include <spa/loop.h>
@ -46,35 +46,35 @@ typedef struct {
uint32_t prop_pattern; uint32_t prop_pattern;
uint32_t pattern_smpte_snow; uint32_t pattern_smpte_snow;
uint32_t pattern_snow; uint32_t pattern_snow;
SpaMediaTypes media_types; SpaTypeMediaType media_type;
SpaMediaSubtypes media_subtypes; SpaTypeMediaSubtype media_subtype;
SpaPropVideo prop_video; SpaTypePropVideo prop_video;
SpaVideoFormats video_formats; SpaTypeVideoFormat video_format;
SpaEventNode event_node; SpaTypeEventNode event_node;
SpaCommandNode command_node; SpaTypeCommandNode command_node;
SpaAllocParamBuffers alloc_param_buffers; SpaTypeAllocParamBuffers alloc_param_buffers;
SpaAllocParamMetaEnable alloc_param_meta_enable; SpaTypeAllocParamMetaEnable alloc_param_meta_enable;
} URI; } Type;
static inline void static inline void
init_uri (URI *uri, SpaIDMap *map) init_type (Type *type, SpaTypeMap *map)
{ {
uri->node = spa_id_map_get_id (map, SPA_TYPE__Node); type->node = spa_type_map_get_id (map, SPA_TYPE__Node);
uri->clock = spa_id_map_get_id (map, SPA_TYPE__Clock); type->clock = spa_type_map_get_id (map, SPA_TYPE__Clock);
uri->format = spa_id_map_get_id (map, SPA_TYPE__Format); type->format = spa_type_map_get_id (map, SPA_TYPE__Format);
uri->props = spa_id_map_get_id (map, SPA_TYPE__Props); type->props = spa_type_map_get_id (map, SPA_TYPE__Props);
uri->prop_live = spa_id_map_get_id (map, SPA_TYPE_PROPS__live); type->prop_live = spa_type_map_get_id (map, SPA_TYPE_PROPS__live);
uri->prop_pattern = spa_id_map_get_id (map, SPA_TYPE_PROPS__patternType); type->prop_pattern = spa_type_map_get_id (map, SPA_TYPE_PROPS__patternType);
uri->pattern_smpte_snow = spa_id_map_get_id (map, SPA_TYPE_PROPS__patternType ":smpte-snow"); type->pattern_smpte_snow = spa_type_map_get_id (map, SPA_TYPE_PROPS__patternType ":smpte-snow");
uri->pattern_snow = spa_id_map_get_id (map, SPA_TYPE_PROPS__patternType ":snow"); type->pattern_snow = spa_type_map_get_id (map, SPA_TYPE_PROPS__patternType ":snow");
spa_media_types_fill (&uri->media_types, map); spa_type_media_type_map (map, &type->media_type);
spa_media_subtypes_map (map, &uri->media_subtypes); spa_type_media_subtype_map (map, &type->media_subtype);
spa_prop_video_map (map, &uri->prop_video); spa_type_prop_video_map (map, &type->prop_video);
spa_video_formats_map (map, &uri->video_formats); spa_type_video_format_map (map, &type->video_format);
spa_event_node_map (map, &uri->event_node); spa_type_event_node_map (map, &type->event_node);
spa_command_node_map (map, &uri->command_node); spa_type_command_node_map (map, &type->command_node);
spa_alloc_param_buffers_map (map, &uri->alloc_param_buffers); spa_type_alloc_param_buffers_map (map, &type->alloc_param_buffers);
spa_alloc_param_meta_enable_map (map, &uri->alloc_param_meta_enable); spa_type_alloc_param_meta_enable_map (map, &type->alloc_param_meta_enable);
} }
typedef struct _SpaVideoTestSrc SpaVideoTestSrc; typedef struct _SpaVideoTestSrc SpaVideoTestSrc;
@ -102,8 +102,8 @@ struct _SpaVideoTestSrc {
SpaNode node; SpaNode node;
SpaClock clock; SpaClock clock;
URI uri; Type type;
SpaIDMap *map; SpaTypeMap *map;
SpaLog *log; SpaLog *log;
SpaLoop *data_loop; SpaLoop *data_loop;
@ -147,7 +147,7 @@ static void
reset_videotestsrc_props (SpaVideoTestSrc *this, SpaVideoTestSrcProps *props) reset_videotestsrc_props (SpaVideoTestSrc *this, SpaVideoTestSrcProps *props)
{ {
props->live = DEFAULT_LIVE; props->live = DEFAULT_LIVE;
props->pattern = this->uri. DEFAULT_PATTERN; props->pattern = this->type. DEFAULT_PATTERN;
} }
#define PROP(f,key,type,...) \ #define PROP(f,key,type,...) \
@ -182,12 +182,12 @@ spa_videotestsrc_node_get_props (SpaNode *node,
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer)); spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
spa_pod_builder_props (&b, &f[0], this->uri.props, spa_pod_builder_props (&b, &f[0], this->type.props,
PROP (&f[1], this->uri.prop_live, SPA_POD_TYPE_BOOL, this->props.live), PROP (&f[1], this->type.prop_live, SPA_POD_TYPE_BOOL, this->props.live),
PROP_EN (&f[1], this->uri.prop_pattern, SPA_POD_TYPE_URI, 3, PROP_EN (&f[1], this->type.prop_pattern, SPA_POD_TYPE_URI, 3,
this->props.pattern, this->props.pattern,
this->uri.pattern_smpte_snow, this->type.pattern_smpte_snow,
this->uri.pattern_snow)); this->type.pattern_snow));
*props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps); *props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps);
@ -209,8 +209,8 @@ spa_videotestsrc_node_set_props (SpaNode *node,
reset_videotestsrc_props (this, &this->props); reset_videotestsrc_props (this, &this->props);
} else { } else {
spa_props_query (props, spa_props_query (props,
this->uri.prop_live, SPA_POD_TYPE_BOOL, &this->props.live, this->type.prop_live, SPA_POD_TYPE_BOOL, &this->props.live,
this->uri.prop_pattern, SPA_POD_TYPE_URI, &this->props.pattern, this->type.prop_pattern, SPA_POD_TYPE_URI, &this->props.pattern,
0); 0);
} }
@ -227,7 +227,7 @@ send_have_output (SpaVideoTestSrc *this)
{ {
if (this->event_cb) { if (this->event_cb) {
SpaEvent event = SPA_EVENT_INIT (this->uri.event_node.HaveOutput); SpaEvent event = SPA_EVENT_INIT (this->type.event_node.HaveOutput);
this->event_cb (&this->node, &event, this->user_data); this->event_cb (&this->node, &event, this->user_data);
} }
return SPA_RESULT_OK; return SPA_RESULT_OK;
@ -315,7 +315,7 @@ spa_videotestsrc_node_send_command (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node); this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Start) { if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
struct timespec now; struct timespec now;
if (!this->have_format) if (!this->have_format)
@ -339,7 +339,7 @@ spa_videotestsrc_node_send_command (SpaNode *node,
set_timer (this, true); set_timer (this, true);
update_state (this, SPA_NODE_STATE_STREAMING); update_state (this, SPA_NODE_STATE_STREAMING);
} }
else if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Pause) { else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
if (!this->have_format) if (!this->have_format)
return SPA_RESULT_NO_FORMAT; return SPA_RESULT_NO_FORMAT;
@ -465,17 +465,17 @@ next:
switch (index++) { switch (index++) {
case 0: case 0:
spa_pod_builder_format (&b, &f[0], this->uri.format, spa_pod_builder_format (&b, &f[0], this->type.format,
this->uri.media_types.video, this->uri.media_subtypes.raw, this->type.media_type.video, this->type.media_subtype.raw,
PROP_U_EN (&f[1], this->uri.prop_video.format, SPA_POD_TYPE_URI, 3, PROP_U_EN (&f[1], this->type.prop_video.format, SPA_POD_TYPE_URI, 3,
this->uri.video_formats.RGB, this->type.video_format.RGB,
this->uri.video_formats.RGB, this->type.video_format.RGB,
this->uri.video_formats.UYVY), this->type.video_format.UYVY),
PROP_U_MM (&f[1], this->uri.prop_video.size, SPA_POD_TYPE_RECTANGLE, PROP_U_MM (&f[1], this->type.prop_video.size, SPA_POD_TYPE_RECTANGLE,
320, 240, 320, 240,
1, 1, 1, 1,
INT32_MAX, INT32_MAX), INT32_MAX, INT32_MAX),
PROP_U_MM (&f[1], this->uri.prop_video.framerate, SPA_POD_TYPE_FRACTION, PROP_U_MM (&f[1], this->type.prop_video.framerate, SPA_POD_TYPE_FRACTION,
25, 1, 25, 1,
0, 1, 0, 1,
INT32_MAX, 1)); INT32_MAX, 1));
@ -542,10 +542,10 @@ spa_videotestsrc_node_port_set_format (SpaNode *node,
SpaPODBuilder b = { NULL }; SpaPODBuilder b = { NULL };
SpaPODFrame f[2]; SpaPODFrame f[2];
if (raw_info->format == this->uri.video_formats.RGB) { if (raw_info->format == this->type.video_format.RGB) {
this->bpp = 3; this->bpp = 3;
} }
else if (raw_info->format == this->uri.video_formats.UYVY) { else if (raw_info->format == this->type.video_format.UYVY) {
this->bpp = 2; this->bpp = 2;
} }
else else
@ -560,15 +560,15 @@ spa_videotestsrc_node_port_set_format (SpaNode *node,
this->stride = SPA_ROUND_UP_N (this->bpp * raw_info->size.width, 4); this->stride = SPA_ROUND_UP_N (this->bpp * raw_info->size.width, 4);
spa_pod_builder_init (&b, this->params_buffer, sizeof (this->params_buffer)); spa_pod_builder_init (&b, this->params_buffer, sizeof (this->params_buffer));
spa_pod_builder_object (&b, &f[0], 0, this->uri.alloc_param_buffers.Buffers, spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_buffers.Buffers,
PROP (&f[1], this->uri.alloc_param_buffers.size, SPA_POD_TYPE_INT, this->stride * raw_info->size.height), PROP (&f[1], this->type.alloc_param_buffers.size, SPA_POD_TYPE_INT, this->stride * raw_info->size.height),
PROP (&f[1], this->uri.alloc_param_buffers.stride, SPA_POD_TYPE_INT, this->stride), PROP (&f[1], this->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, this->stride),
PROP_U_MM (&f[1], this->uri.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, 32, 2, 32), PROP_U_MM (&f[1], this->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, 32, 2, 32),
PROP (&f[1], this->uri.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16)); PROP (&f[1], this->type.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));
this->params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam); this->params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
spa_pod_builder_object (&b, &f[0], 0, this->uri.alloc_param_meta_enable.MetaEnable, spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_meta_enable.MetaEnable,
PROP (&f[1], this->uri.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_HEADER)); PROP (&f[1], this->type.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_HEADER));
this->params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam); this->params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
this->info.extra = NULL; this->info.extra = NULL;
@ -603,11 +603,11 @@ spa_videotestsrc_node_port_get_format (SpaNode *node,
spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer)); spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer));
spa_pod_builder_format (&b, &f[0], this->uri.format, spa_pod_builder_format (&b, &f[0], this->type.format,
this->uri.media_types.video, this->uri.media_subtypes.raw, this->type.media_type.video, this->type.media_subtype.raw,
PROP (&f[1], this->uri.prop_video.format, SPA_POD_TYPE_URI, this->current_format.info.raw.format), PROP (&f[1], this->type.prop_video.format, SPA_POD_TYPE_URI, this->current_format.info.raw.format),
PROP (&f[1], this->uri.prop_video.size, -SPA_POD_TYPE_RECTANGLE, &this->current_format.info.raw.size), PROP (&f[1], this->type.prop_video.size, -SPA_POD_TYPE_RECTANGLE, &this->current_format.info.raw.size),
PROP (&f[1], this->uri.prop_video.framerate, -SPA_POD_TYPE_FRACTION, &this->current_format.info.raw.framerate)); PROP (&f[1], this->type.prop_video.framerate, -SPA_POD_TYPE_FRACTION, &this->current_format.info.raw.framerate));
*format = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat); *format = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat);
return SPA_RESULT_OK; return SPA_RESULT_OK;
@ -909,9 +909,9 @@ spa_videotestsrc_get_interface (SpaHandle *handle,
this = (SpaVideoTestSrc *) handle; this = (SpaVideoTestSrc *) handle;
if (interface_id == this->uri.node) if (interface_id == this->type.node)
*interface = &this->node; *interface = &this->node;
else if (interface_id == this->uri.clock) else if (interface_id == this->type.clock)
*interface = &this->clock; *interface = &this->clock;
else else
return SPA_RESULT_UNKNOWN_INTERFACE; return SPA_RESULT_UNKNOWN_INTERFACE;
@ -953,11 +953,11 @@ videotestsrc_init (const SpaHandleFactory *factory,
this = (SpaVideoTestSrc *) handle; this = (SpaVideoTestSrc *) handle;
for (i = 0; i < n_support; i++) { for (i = 0; i < n_support; i++) {
if (strcmp (support[i].uri, SPA_TYPE__IDMap) == 0) if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
this->map = support[i].data; this->map = support[i].data;
else if (strcmp (support[i].uri, SPA_TYPE__Log) == 0) else if (strcmp (support[i].type, SPA_TYPE__Log) == 0)
this->log = support[i].data; this->log = support[i].data;
else if (strcmp (support[i].uri, SPA_TYPE_LOOP__DataLoop) == 0) else if (strcmp (support[i].type, SPA_TYPE_LOOP__DataLoop) == 0)
this->data_loop = support[i].data; this->data_loop = support[i].data;
} }
if (this->map == NULL) { if (this->map == NULL) {
@ -968,7 +968,7 @@ videotestsrc_init (const SpaHandleFactory *factory,
spa_log_error (this->log, "a data_loop is needed"); spa_log_error (this->log, "a data_loop is needed");
return SPA_RESULT_ERROR; return SPA_RESULT_ERROR;
} }
init_uri (&this->uri, this->map); init_type (&this->type, this->map);
this->node = videotestsrc_node; this->node = videotestsrc_node;
this->clock = videotestsrc_clock; this->clock = videotestsrc_clock;

View file

@ -21,7 +21,7 @@
#include <stddef.h> #include <stddef.h>
#include <spa/log.h> #include <spa/log.h>
#include <spa/id-map.h> #include <spa/type-map.h>
#include <spa/node.h> #include <spa/node.h>
#include <spa/list.h> #include <spa/list.h>
#include <spa/audio/format-utils.h> #include <spa/audio/format-utils.h>
@ -67,40 +67,40 @@ typedef struct {
uint32_t props; uint32_t props;
uint32_t prop_volume; uint32_t prop_volume;
uint32_t prop_mute; uint32_t prop_mute;
SpaMediaTypes media_types; SpaTypeMediaType media_type;
SpaMediaSubtypes media_subtypes; SpaTypeMediaSubtype media_subtype;
SpaPropAudio prop_audio; SpaTypePropAudio prop_audio;
SpaAudioFormats audio_formats; SpaTypeAudioFormat audio_format;
SpaEventNode event_node; SpaTypeEventNode event_node;
SpaCommandNode command_node; SpaTypeCommandNode command_node;
SpaAllocParamBuffers alloc_param_buffers; SpaTypeAllocParamBuffers alloc_param_buffers;
SpaAllocParamMetaEnable alloc_param_meta_enable; SpaTypeAllocParamMetaEnable alloc_param_meta_enable;
} URI; } Type;
static inline void static inline void
init_uri (URI *uri, SpaIDMap *map) init_type (Type *type, SpaTypeMap *map)
{ {
uri->node = spa_id_map_get_id (map, SPA_TYPE__Node); type->node = spa_type_map_get_id (map, SPA_TYPE__Node);
uri->format = spa_id_map_get_id (map, SPA_TYPE__Format); type->format = spa_type_map_get_id (map, SPA_TYPE__Format);
uri->props = spa_id_map_get_id (map, SPA_TYPE__Props); type->props = spa_type_map_get_id (map, SPA_TYPE__Props);
uri->prop_volume = spa_id_map_get_id (map, SPA_TYPE_PROPS__volume); type->prop_volume = spa_type_map_get_id (map, SPA_TYPE_PROPS__volume);
uri->prop_mute = spa_id_map_get_id (map, SPA_TYPE_PROPS__mute); type->prop_mute = spa_type_map_get_id (map, SPA_TYPE_PROPS__mute);
spa_media_types_fill (&uri->media_types, map); spa_type_media_type_map (map, &type->media_type);
spa_media_subtypes_map (map, &uri->media_subtypes); spa_type_media_subtype_map (map, &type->media_subtype);
spa_prop_audio_map (map, &uri->prop_audio); spa_type_prop_audio_map (map, &type->prop_audio);
spa_audio_formats_map (map, &uri->audio_formats); spa_type_audio_format_map (map, &type->audio_format);
spa_event_node_map (map, &uri->event_node); spa_type_event_node_map (map, &type->event_node);
spa_command_node_map (map, &uri->command_node); spa_type_command_node_map (map, &type->command_node);
spa_alloc_param_buffers_map (map, &uri->alloc_param_buffers); spa_type_alloc_param_buffers_map (map, &type->alloc_param_buffers);
spa_alloc_param_meta_enable_map (map, &uri->alloc_param_meta_enable); spa_type_alloc_param_meta_enable_map (map, &type->alloc_param_meta_enable);
} }
struct _SpaVolume { struct _SpaVolume {
SpaHandle handle; SpaHandle handle;
SpaNode node; SpaNode node;
URI uri; Type type;
SpaIDMap *map; SpaTypeMap *map;
SpaLog *log; SpaLog *log;
uint8_t props_buffer[512]; uint8_t props_buffer[512];
@ -165,9 +165,9 @@ spa_volume_node_get_props (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaVolume, node); this = SPA_CONTAINER_OF (node, SpaVolume, node);
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer)); spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
spa_pod_builder_props (&b, &f[0], this->uri.props, spa_pod_builder_props (&b, &f[0], this->type.props,
PROP_MM (&f[1], this->uri.prop_volume, SPA_POD_TYPE_DOUBLE, this->props.volume, 0.0, 10.0), PROP_MM (&f[1], this->type.prop_volume, SPA_POD_TYPE_DOUBLE, this->props.volume, 0.0, 10.0),
PROP (&f[1], this->uri.prop_mute, SPA_POD_TYPE_BOOL, this->props.mute)); PROP (&f[1], this->type.prop_mute, SPA_POD_TYPE_BOOL, this->props.mute));
*props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps); *props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps);
@ -189,8 +189,8 @@ spa_volume_node_set_props (SpaNode *node,
reset_volume_props (&this->props); reset_volume_props (&this->props);
} else { } else {
spa_props_query (props, spa_props_query (props,
this->uri.prop_volume, SPA_POD_TYPE_DOUBLE, &this->props.volume, this->type.prop_volume, SPA_POD_TYPE_DOUBLE, &this->props.volume,
this->uri.prop_mute, SPA_POD_TYPE_BOOL, &this->props.mute, this->type.prop_mute, SPA_POD_TYPE_BOOL, &this->props.mute,
0); 0);
} }
return SPA_RESULT_OK; return SPA_RESULT_OK;
@ -207,10 +207,10 @@ spa_volume_node_send_command (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaVolume, node); this = SPA_CONTAINER_OF (node, SpaVolume, node);
if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Start) { if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
update_state (this, SPA_NODE_STATE_STREAMING); update_state (this, SPA_NODE_STATE_STREAMING);
} }
else if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Pause) { else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
update_state (this, SPA_NODE_STATE_PAUSED); update_state (this, SPA_NODE_STATE_PAUSED);
} }
else else
@ -322,14 +322,14 @@ next:
switch (index++) { switch (index++) {
case 0: case 0:
spa_pod_builder_format (&b, &f[0], this->uri.format, spa_pod_builder_format (&b, &f[0], this->type.format,
this->uri.media_types.audio, this->uri.media_subtypes.raw, this->type.media_type.audio, this->type.media_subtype.raw,
PROP_U_EN (&f[1], this->uri.prop_audio.format, SPA_POD_TYPE_URI, 3, PROP_U_EN (&f[1], this->type.prop_audio.format, SPA_POD_TYPE_URI, 3,
this->uri.audio_formats.S16, this->type.audio_format.S16,
this->uri.audio_formats.S16, this->type.audio_format.S16,
this->uri.audio_formats.S32), this->type.audio_format.S32),
PROP_U_MM (&f[1], this->uri.prop_audio.rate, SPA_POD_TYPE_INT, 44100, 1, INT32_MAX), PROP_U_MM (&f[1], this->type.prop_audio.rate, SPA_POD_TYPE_INT, 44100, 1, INT32_MAX),
PROP_U_MM (&f[1], this->uri.prop_audio.channels, SPA_POD_TYPE_INT, 2, 1, INT32_MAX)); PROP_U_MM (&f[1], this->type.prop_audio.channels, SPA_POD_TYPE_INT, 2, 1, INT32_MAX));
break; break;
default: default:
@ -399,15 +399,15 @@ spa_volume_node_port_set_format (SpaNode *node,
port->info.params = port->params; port->info.params = port->params;
spa_pod_builder_init (&b, port->params_buffer, sizeof (port->params_buffer)); spa_pod_builder_init (&b, port->params_buffer, sizeof (port->params_buffer));
spa_pod_builder_object (&b, &f[0], 0, this->uri.alloc_param_buffers.Buffers, spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_buffers.Buffers,
PROP (&f[1], this->uri.alloc_param_buffers.size, SPA_POD_TYPE_INT, 16), PROP (&f[1], this->type.alloc_param_buffers.size, SPA_POD_TYPE_INT, 16),
PROP (&f[1], this->uri.alloc_param_buffers.stride, SPA_POD_TYPE_INT, 16), PROP (&f[1], this->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, 16),
PROP_U_MM (&f[1], this->uri.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, MAX_BUFFERS, 2, MAX_BUFFERS), PROP_U_MM (&f[1], this->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, MAX_BUFFERS, 2, MAX_BUFFERS),
PROP (&f[1], this->uri.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16)); PROP (&f[1], this->type.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));
port->params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam); port->params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
spa_pod_builder_object (&b, &f[0], 0, this->uri.alloc_param_meta_enable.MetaEnable, spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_meta_enable.MetaEnable,
PROP (&f[1], this->uri.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_HEADER)); PROP (&f[1], this->type.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_HEADER));
port->params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam); port->params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
port->info.extra = NULL; port->info.extra = NULL;
@ -662,7 +662,7 @@ find_free_buffer (SpaVolume *this, SpaVolumePort *port)
static void static void
release_buffer (SpaVolume *this, SpaBuffer *buffer) release_buffer (SpaVolume *this, SpaBuffer *buffer)
{ {
SpaEventNodeReuseBuffer rb = SPA_EVENT_NODE_REUSE_BUFFER_INIT (this->uri.event_node.ReuseBuffer, SpaEventNodeReuseBuffer rb = SPA_EVENT_NODE_REUSE_BUFFER_INIT (this->type.event_node.ReuseBuffer,
0, buffer->id); 0, buffer->id);
this->event_cb (&this->node, (SpaEvent *)&rb, this->user_data); this->event_cb (&this->node, (SpaEvent *)&rb, this->user_data);
} }
@ -811,7 +811,7 @@ spa_volume_get_interface (SpaHandle *handle,
this = (SpaVolume *) handle; this = (SpaVolume *) handle;
if (interface_id == this->uri.node) if (interface_id == this->type.node)
*interface = &this->node; *interface = &this->node;
else else
return SPA_RESULT_UNKNOWN_INTERFACE; return SPA_RESULT_UNKNOWN_INTERFACE;
@ -844,16 +844,16 @@ volume_init (const SpaHandleFactory *factory,
this = (SpaVolume *) handle; this = (SpaVolume *) handle;
for (i = 0; i < n_support; i++) { for (i = 0; i < n_support; i++) {
if (strcmp (support[i].uri, SPA_TYPE__IDMap) == 0) if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
this->map = support[i].data; this->map = support[i].data;
else if (strcmp (support[i].uri, SPA_TYPE__Log) == 0) else if (strcmp (support[i].type, SPA_TYPE__Log) == 0)
this->log = support[i].data; this->log = support[i].data;
} }
if (this->map == NULL) { if (this->map == NULL) {
spa_log_error (this->log, "an id-map is needed"); spa_log_error (this->log, "a type-map is needed");
return SPA_RESULT_ERROR; return SPA_RESULT_ERROR;
} }
init_uri (&this->uri, this->map); init_type (&this->type, this->map);
this->node = volume_node; this->node = volume_node;
reset_volume_props (&this->props); reset_volume_props (&this->props);

View file

@ -24,7 +24,7 @@
#include <linux/videodev2.h> #include <linux/videodev2.h>
#include <spa/id-map.h> #include <spa/type-map.h>
#include <spa/log.h> #include <spa/log.h>
#include <spa/node.h> #include <spa/node.h>
#include <spa/video/format-utils.h> #include <spa/video/format-utils.h>
@ -75,30 +75,30 @@ typedef struct {
uint32_t prop_device; uint32_t prop_device;
uint32_t prop_device_name; uint32_t prop_device_name;
uint32_t prop_device_fd; uint32_t prop_device_fd;
SpaMediaTypes media_types; SpaTypeMediaType media_type;
SpaMediaSubtypes media_subtypes; SpaTypeMediaSubtype media_subtype;
SpaCommandNode command_node; SpaTypeCommandNode command_node;
} URI; } Type;
static inline void static inline void
init_uri (URI *uri, SpaIDMap *map) init_type (Type *type, SpaTypeMap *map)
{ {
uri->node = spa_id_map_get_id (map, SPA_TYPE__Node); type->node = spa_type_map_get_id (map, SPA_TYPE__Node);
uri->props = spa_id_map_get_id (map, SPA_TYPE__Props); type->props = spa_type_map_get_id (map, SPA_TYPE__Props);
uri->prop_device = spa_id_map_get_id (map, SPA_TYPE_PROPS__device); type->prop_device = spa_type_map_get_id (map, SPA_TYPE_PROPS__device);
uri->prop_device_name = spa_id_map_get_id (map, SPA_TYPE_PROPS__deviceName); type->prop_device_name = spa_type_map_get_id (map, SPA_TYPE_PROPS__deviceName);
uri->prop_device_fd = spa_id_map_get_id (map, SPA_TYPE_PROPS__deviceFd); type->prop_device_fd = spa_type_map_get_id (map, SPA_TYPE_PROPS__deviceFd);
spa_media_types_fill (&uri->media_types, map); spa_type_media_type_map (map, &type->media_type);
spa_media_subtypes_map (map, &uri->media_subtypes); spa_type_media_subtype_map (map, &type->media_subtype);
spa_command_node_map (map, &uri->command_node); spa_type_command_node_map (map, &type->command_node);
} }
struct _SpaXvSink { struct _SpaXvSink {
SpaHandle handle; SpaHandle handle;
SpaNode node; SpaNode node;
URI uri; Type type;
SpaIDMap *map; SpaTypeMap *map;
SpaLog *log; SpaLog *log;
uint8_t props_buffer[512]; uint8_t props_buffer[512];
@ -146,10 +146,10 @@ spa_xv_sink_node_get_props (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaXvSink, node); this = SPA_CONTAINER_OF (node, SpaXvSink, node);
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer)); spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
spa_pod_builder_props (&b, &f[0], this->uri.props, spa_pod_builder_props (&b, &f[0], this->type.props,
PROP (&f[1], this->uri.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device)), PROP (&f[1], this->type.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device)),
PROP_R (&f[1], this->uri.prop_device_name, -SPA_POD_TYPE_STRING, this->props.device_name, sizeof (this->props.device_name)), PROP_R (&f[1], this->type.prop_device_name, -SPA_POD_TYPE_STRING, this->props.device_name, sizeof (this->props.device_name)),
PROP_R (&f[1], this->uri.prop_device_fd, SPA_POD_TYPE_INT, this->props.device_fd)); PROP_R (&f[1], this->type.prop_device_fd, SPA_POD_TYPE_INT, this->props.device_fd));
*props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps); *props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps);
return SPA_RESULT_OK; return SPA_RESULT_OK;
@ -170,7 +170,7 @@ spa_xv_sink_node_set_props (SpaNode *node,
reset_xv_sink_props (&this->props); reset_xv_sink_props (&this->props);
} else { } else {
spa_props_query (props, spa_props_query (props,
this->uri.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device), this->type.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device),
0); 0);
} }
return SPA_RESULT_OK; return SPA_RESULT_OK;
@ -187,12 +187,12 @@ spa_xv_sink_node_send_command (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaXvSink, node); this = SPA_CONTAINER_OF (node, SpaXvSink, node);
if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Start) { if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
spa_xv_start (this); spa_xv_start (this);
update_state (this, SPA_NODE_STATE_STREAMING); update_state (this, SPA_NODE_STATE_STREAMING);
} }
else if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Pause) { else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
spa_xv_stop (this); spa_xv_stop (this);
update_state (this, SPA_NODE_STATE_PAUSED); update_state (this, SPA_NODE_STATE_PAUSED);
@ -329,8 +329,8 @@ spa_xv_sink_node_port_set_format (SpaNode *node,
return SPA_RESULT_OK; return SPA_RESULT_OK;
} }
if (format->body.media_type.value == this->uri.media_types.video) { if (format->body.media_type.value == this->type.media_type.video) {
if (format->body.media_subtype.value == this->uri.media_subtypes.raw) { if (format->body.media_subtype.value == this->type.media_subtype.raw) {
if ((res = spa_format_video_parse (format, &info) < 0)) if ((res = spa_format_video_parse (format, &info) < 0))
return res; return res;
} else } else
@ -531,7 +531,7 @@ spa_xv_sink_get_interface (SpaHandle *handle,
this = (SpaXvSink *) handle; this = (SpaXvSink *) handle;
if (interface_id == this->uri.node) if (interface_id == this->type.node)
*interface = &this->node; *interface = &this->node;
else else
return SPA_RESULT_UNKNOWN_INTERFACE; return SPA_RESULT_UNKNOWN_INTERFACE;
@ -564,16 +564,16 @@ xv_sink_init (const SpaHandleFactory *factory,
this = (SpaXvSink *) handle; this = (SpaXvSink *) handle;
for (i = 0; i < n_support; i++) { for (i = 0; i < n_support; i++) {
if (strcmp (support[i].uri, SPA_TYPE__IDMap) == 0) if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
this->map = support[i].data; this->map = support[i].data;
else if (strcmp (support[i].uri, SPA_TYPE__Log) == 0) else if (strcmp (support[i].type, SPA_TYPE__Log) == 0)
this->log = support[i].data; this->log = support[i].data;
} }
if (this->map == NULL) { if (this->map == NULL) {
spa_log_error (this->log, "an id-map is needed"); spa_log_error (this->log, "a type-map is needed");
return SPA_RESULT_ERROR; return SPA_RESULT_ERROR;
} }
init_uri (&this->uri, this->map); init_type (&this->type, this->map);
this->node = xvsink_node; this->node = xvsink_node;
reset_xv_sink_props (&this->props); reset_xv_sink_props (&this->props);

View file

@ -365,13 +365,13 @@ main (int argc, char *argv[])
data.data_loop.update_item = NULL; data.data_loop.update_item = NULL;
data.data_loop.remove_item = NULL; data.data_loop.remove_item = NULL;
data.support[0].uri = SPA_ID_MAP_URI; data.support[0].uri = SPA_TYPE__IDMap;
data.support[0].data = data.map; data.support[0].data = data.map;
data.support[1].uri = SPA_POLL__DataLoop; data.support[1].uri = SPA_TYPE_LOOP__DataLoop;
data.support[1].data = &data.data_loop; data.support[1].data = &data.data_loop;
data.n_support = 2; data.n_support = 2;
data.uri.node = spa_id_map_get_id (data.map, SPA_NODE_URI); data.uri.node = spa_id_map_get_id (data.map, SPA_TYPE__Node);
if ((res = make_nodes (&data)) < 0) { if ((res = make_nodes (&data)) < 0) {
printf ("can't make nodes: %d\n", res); printf ("can't make nodes: %d\n", res);

View file

@ -23,7 +23,7 @@
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <spa/id-map.h> #include <spa/type-map.h>
#include <spa/log.h> #include <spa/log.h>
#include <spa/node.h> #include <spa/node.h>
#include <spa/loop.h> #include <spa/loop.h>
@ -40,19 +40,19 @@
*/ */
spa_build (SPA_MEDIA_TYPE_VIDEO, SPA_MEDIA_SUBTYPE_RAW, spa_build (SPA_MEDIA_TYPE_VIDEO, SPA_MEDIA_SUBTYPE_RAW,
prop_video.format, SPA_PROP_TYPE_URI, type.prop_video.format, SPA_PROP_TYPE_URI,
video_formats.I420 video_format.I420
SPA_POD_PROP_FLAG_UNSET | SPA_POD_PROP_FLAG_UNSET |
SPA_PROP_RANGE_ENUM, 2, SPA_PROP_RANGE_ENUM, 2,
video_formats.I420, video_format.I420,
video_formats.YUY2, video_format.YUY2,
prop_video.size , SPA_PROP_TYPE_RECTANGLE, type.prop_video.size , SPA_PROP_TYPE_RECTANGLE,
320, 240, 320, 240,
SPA_POD_PROP_FLAG_UNSET | SPA_POD_PROP_FLAG_UNSET |
SPA_PROP_RANGE_MIN_MAX, SPA_PROP_RANGE_MIN_MAX,
1, 1, 1, 1,
INT32_MAX, INT32_MAX, INT32_MAX, INT32_MAX,
prop_video.framerate, SPA_PROP_TYPE_FRACTION, 25, 1, type.prop_video.framerate, SPA_PROP_TYPE_FRACTION, 25, 1,
SPA_POD_PROP_FLAG_UNSET | SPA_POD_PROP_FLAG_UNSET |
SPA_PROP_RANGE_MIN_MAX, SPA_PROP_RANGE_MIN_MAX,
0, 1, 0, 1,
@ -60,11 +60,23 @@ spa_build (SPA_MEDIA_TYPE_VIDEO, SPA_MEDIA_SUBTYPE_RAW,
0); 0);
#endif #endif
static uint32_t format_type; static struct {
static SpaMediaTypes media_types; uint32_t format;
static SpaMediaSubtypes media_subtypes; SpaTypeMediaType media_type;
static SpaPropVideo prop_video; SpaTypeMediaSubtype media_subtype;
static SpaVideoFormats video_formats; SpaTypePropVideo prop_video;
SpaTypeVideoFormat video_format;
} type = { 0, };
static inline void
type_init (SpaTypeMap *map)
{
type.format = spa_type_map_get_id (map, SPA_TYPE__Format);
spa_type_media_type_map (map, &type.media_type);
spa_type_media_subtype_map (map, &type.media_subtype);
spa_type_prop_video_map (map, &type.prop_video);
spa_type_video_format_map (map, &type.video_format);
}
static void static void
do_static_struct (void) do_static_struct (void)
@ -96,20 +108,20 @@ do_static_struct (void)
} props; } props;
} test_format = { } test_format = {
{ { sizeof (test_format.props) + sizeof (SpaFormatBody), SPA_POD_TYPE_OBJECT }, { { sizeof (test_format.props) + sizeof (SpaFormatBody), SPA_POD_TYPE_OBJECT },
{ { 0, format_type }, { { 0, type.format },
{ { sizeof (uint32_t), SPA_POD_TYPE_URI }, media_types.video }, { { sizeof (uint32_t), SPA_POD_TYPE_URI }, type.media_type.video },
{ { sizeof (uint32_t), SPA_POD_TYPE_URI }, media_subtypes.raw } }, { { sizeof (uint32_t), SPA_POD_TYPE_URI }, type.media_subtype.raw } },
}, { }, {
{ { sizeof (test_format.props.format_vals) + sizeof (SpaPODPropBody), { { sizeof (test_format.props.format_vals) + sizeof (SpaPODPropBody),
SPA_POD_TYPE_PROP } , SPA_POD_TYPE_PROP } ,
{ prop_video.format, SPA_POD_PROP_RANGE_ENUM | SPA_POD_PROP_FLAG_UNSET, { type.prop_video.format, SPA_POD_PROP_RANGE_ENUM | SPA_POD_PROP_FLAG_UNSET,
{ sizeof (uint32_t), SPA_POD_TYPE_URI } }, }, { sizeof (uint32_t), SPA_POD_TYPE_URI } }, },
{ video_formats.I420, { type.video_format.I420,
{ video_formats.I420, video_formats.YUY2 } }, 0, { type.video_format.I420, type.video_format.YUY2 } }, 0,
{ { sizeof (test_format.props.size_vals) + sizeof (SpaPODPropBody), { { sizeof (test_format.props.size_vals) + sizeof (SpaPODPropBody),
SPA_POD_TYPE_PROP } , SPA_POD_TYPE_PROP } ,
{ prop_video.size, SPA_POD_PROP_RANGE_MIN_MAX | SPA_POD_PROP_FLAG_UNSET, { type.prop_video.size, SPA_POD_PROP_RANGE_MIN_MAX | SPA_POD_PROP_FLAG_UNSET,
{ sizeof (SpaRectangle), SPA_POD_TYPE_RECTANGLE } }, }, { sizeof (SpaRectangle), SPA_POD_TYPE_RECTANGLE } }, },
{ { 320, 243 }, { { 320, 243 },
{ 1, 1 }, { 1, 1 },
@ -117,7 +129,7 @@ do_static_struct (void)
{ { sizeof (test_format.props.framerate_vals) + sizeof (SpaPODPropBody), { { sizeof (test_format.props.framerate_vals) + sizeof (SpaPODPropBody),
SPA_POD_TYPE_PROP } , SPA_POD_TYPE_PROP } ,
{ prop_video.framerate, SPA_POD_PROP_RANGE_MIN_MAX | SPA_POD_PROP_FLAG_UNSET, { type.prop_video.framerate, SPA_POD_PROP_RANGE_MIN_MAX | SPA_POD_PROP_FLAG_UNSET,
{ sizeof (SpaFraction), SPA_POD_TYPE_FRACTION } }, }, { sizeof (SpaFraction), SPA_POD_TYPE_FRACTION } }, },
{ { 25, 1 }, { { 25, 1 },
{ 0, 1 }, { 0, 1 },
@ -133,8 +145,8 @@ do_static_struct (void)
SpaFraction frac = { 0, 0 }; SpaFraction frac = { 0, 0 };
match = spa_pod_contents_query (&test_format.fmt.pod, sizeof (SpaFormat), match = spa_pod_contents_query (&test_format.fmt.pod, sizeof (SpaFormat),
prop_video.format, SPA_POD_TYPE_INT, &format, type.prop_video.format, SPA_POD_TYPE_INT, &format,
prop_video.framerate, SPA_POD_TYPE_FRACTION, &frac, type.prop_video.framerate, SPA_POD_TYPE_FRACTION, &frac,
0); 0);
printf ("%d %d %d %d\n", match, format, frac.num, frac.denom); printf ("%d %d %d %d\n", match, format, frac.num, frac.denom);
@ -149,30 +161,25 @@ main (int argc, char *argv[])
SpaPODFrame frame[4]; SpaPODFrame frame[4];
uint8_t buffer[1024]; uint8_t buffer[1024];
SpaFormat *fmt; SpaFormat *fmt;
SpaIDMap *map = spa_id_map_get_default();
format_type = spa_id_map_get_id (map, SPA_TYPE__Format); type_init (spa_type_map_get_default());
spa_media_types_fill (&media_types, map);
spa_media_subtypes_map (map, &media_subtypes);
spa_prop_video_map (map, &prop_video);
spa_video_formats_map (map, &video_formats);
spa_pod_builder_init (&b, buffer, sizeof (buffer)); spa_pod_builder_init (&b, buffer, sizeof (buffer));
fmt = SPA_MEMBER (buffer, spa_pod_builder_push_format (&b, &frame[0], format_type, fmt = SPA_MEMBER (buffer, spa_pod_builder_push_format (&b, &frame[0], type.format,
media_types.video, type.media_type.video,
media_subtypes.raw), SpaFormat); type.media_subtype.raw), SpaFormat);
spa_pod_builder_push_prop (&b, &frame[1], spa_pod_builder_push_prop (&b, &frame[1],
prop_video.format, type.prop_video.format,
SPA_POD_PROP_RANGE_ENUM | SPA_POD_PROP_FLAG_UNSET | SPA_POD_PROP_FLAG_READWRITE); SPA_POD_PROP_RANGE_ENUM | SPA_POD_PROP_FLAG_UNSET | SPA_POD_PROP_FLAG_READWRITE);
spa_pod_builder_uri (&b, video_formats.I420); spa_pod_builder_uri (&b, type.video_format.I420);
spa_pod_builder_uri (&b, video_formats.I420); spa_pod_builder_uri (&b, type.video_format.I420);
spa_pod_builder_uri (&b, video_formats.YUY2); spa_pod_builder_uri (&b, type.video_format.YUY2);
spa_pod_builder_pop (&b, &frame[1]); spa_pod_builder_pop (&b, &frame[1]);
SpaRectangle size_min_max[] = { { 1, 1 }, { INT32_MAX, INT32_MAX } }; SpaRectangle size_min_max[] = { { 1, 1 }, { INT32_MAX, INT32_MAX } };
spa_pod_builder_push_prop (&b, &frame[1], spa_pod_builder_push_prop (&b, &frame[1],
prop_video.size, type.prop_video.size,
SPA_POD_PROP_RANGE_MIN_MAX | SPA_POD_PROP_FLAG_UNSET | SPA_POD_PROP_FLAG_READWRITE); SPA_POD_PROP_RANGE_MIN_MAX | SPA_POD_PROP_FLAG_UNSET | SPA_POD_PROP_FLAG_READWRITE);
spa_pod_builder_rectangle (&b, 320, 240); spa_pod_builder_rectangle (&b, 320, 240);
spa_pod_builder_raw (&b, size_min_max, sizeof(size_min_max)); spa_pod_builder_raw (&b, size_min_max, sizeof(size_min_max));
@ -180,7 +187,7 @@ main (int argc, char *argv[])
SpaFraction rate_min_max[] = { { 0, 1 }, { INT32_MAX, 1 } }; SpaFraction rate_min_max[] = { { 0, 1 }, { INT32_MAX, 1 } };
spa_pod_builder_push_prop (&b, &frame[1], spa_pod_builder_push_prop (&b, &frame[1],
prop_video.framerate, type.prop_video.framerate,
SPA_POD_PROP_RANGE_MIN_MAX | SPA_POD_PROP_FLAG_UNSET | SPA_POD_PROP_FLAG_READWRITE); SPA_POD_PROP_RANGE_MIN_MAX | SPA_POD_PROP_FLAG_UNSET | SPA_POD_PROP_FLAG_READWRITE);
spa_pod_builder_fraction (&b, 25, 1); spa_pod_builder_fraction (&b, 25, 1);
spa_pod_builder_raw (&b, rate_min_max, sizeof(rate_min_max)); spa_pod_builder_raw (&b, rate_min_max, sizeof(rate_min_max));
@ -192,18 +199,18 @@ main (int argc, char *argv[])
spa_pod_builder_init (&b, buffer, sizeof (buffer)); spa_pod_builder_init (&b, buffer, sizeof (buffer));
spa_pod_builder_format (&b, &frame[0], format_type, spa_pod_builder_format (&b, &frame[0], type.format,
media_types.video, media_subtypes.raw, type.media_type.video, type.media_subtype.raw,
SPA_POD_TYPE_PROP, &frame[1], SPA_POD_TYPE_PROP, &frame[1],
prop_video.format, SPA_POD_PROP_FLAG_UNSET | type.prop_video.format, SPA_POD_PROP_FLAG_UNSET |
SPA_POD_PROP_RANGE_ENUM, SPA_POD_PROP_RANGE_ENUM,
SPA_POD_TYPE_URI, 3, SPA_POD_TYPE_URI, 3,
video_formats.I420, type.video_format.I420,
video_formats.I420, type.video_format.I420,
video_formats.YUY2, type.video_format.YUY2,
-SPA_POD_TYPE_PROP, &frame[1], -SPA_POD_TYPE_PROP, &frame[1],
SPA_POD_TYPE_PROP, &frame[1], SPA_POD_TYPE_PROP, &frame[1],
prop_video.size, SPA_POD_PROP_FLAG_UNSET | type.prop_video.size, SPA_POD_PROP_FLAG_UNSET |
SPA_POD_PROP_RANGE_MIN_MAX, SPA_POD_PROP_RANGE_MIN_MAX,
SPA_POD_TYPE_RECTANGLE, 3, SPA_POD_TYPE_RECTANGLE, 3,
320, 241, 320, 241,
@ -211,7 +218,7 @@ main (int argc, char *argv[])
INT32_MAX, INT32_MAX, INT32_MAX, INT32_MAX,
-SPA_POD_TYPE_PROP, &frame[1], -SPA_POD_TYPE_PROP, &frame[1],
SPA_POD_TYPE_PROP, &frame[1], SPA_POD_TYPE_PROP, &frame[1],
prop_video.framerate, SPA_POD_PROP_FLAG_UNSET | type.prop_video.framerate, SPA_POD_PROP_FLAG_UNSET |
SPA_POD_PROP_RANGE_MIN_MAX, SPA_POD_PROP_RANGE_MIN_MAX,
SPA_POD_TYPE_FRACTION, 3, SPA_POD_TYPE_FRACTION, 3,
25, 1, 25, 1,
@ -226,19 +233,19 @@ main (int argc, char *argv[])
spa_pod_builder_init (&b, buffer, sizeof (buffer)); spa_pod_builder_init (&b, buffer, sizeof (buffer));
spa_pod_builder_add (&b, spa_pod_builder_add (&b,
SPA_POD_TYPE_OBJECT, &frame[0], 0, format_type, SPA_POD_TYPE_OBJECT, &frame[0], 0, type.format,
SPA_POD_TYPE_URI, media_types.video, SPA_POD_TYPE_URI, type.media_type.video,
SPA_POD_TYPE_URI, media_subtypes.raw, SPA_POD_TYPE_URI, type.media_subtype.raw,
SPA_POD_TYPE_PROP, &frame[1], SPA_POD_TYPE_PROP, &frame[1],
prop_video.format, SPA_POD_PROP_FLAG_UNSET | type.prop_video.format, SPA_POD_PROP_FLAG_UNSET |
SPA_POD_PROP_RANGE_ENUM, SPA_POD_PROP_RANGE_ENUM,
SPA_POD_TYPE_URI, 3, SPA_POD_TYPE_URI, 3,
video_formats.I420, type.video_format.I420,
video_formats.I420, type.video_format.I420,
video_formats.YUY2, type.video_format.YUY2,
-SPA_POD_TYPE_PROP, &frame[1], -SPA_POD_TYPE_PROP, &frame[1],
SPA_POD_TYPE_PROP, &frame[1], SPA_POD_TYPE_PROP, &frame[1],
prop_video.size, SPA_POD_PROP_FLAG_UNSET | type.prop_video.size, SPA_POD_PROP_FLAG_UNSET |
SPA_POD_PROP_RANGE_MIN_MAX, SPA_POD_PROP_RANGE_MIN_MAX,
SPA_POD_TYPE_RECTANGLE, 3, SPA_POD_TYPE_RECTANGLE, 3,
320, 242, 320, 242,
@ -246,7 +253,7 @@ main (int argc, char *argv[])
INT32_MAX, INT32_MAX, INT32_MAX, INT32_MAX,
-SPA_POD_TYPE_PROP, &frame[1], -SPA_POD_TYPE_PROP, &frame[1],
SPA_POD_TYPE_PROP, &frame[1], SPA_POD_TYPE_PROP, &frame[1],
prop_video.framerate, SPA_POD_PROP_FLAG_UNSET | type.prop_video.framerate, SPA_POD_PROP_FLAG_UNSET |
SPA_POD_PROP_RANGE_MIN_MAX, SPA_POD_PROP_RANGE_MIN_MAX,
SPA_POD_TYPE_FRACTION, 3, SPA_POD_TYPE_FRACTION, 3,
25, 1, 25, 1,

View file

@ -28,7 +28,7 @@
#include <spa/pod-builder.h> #include <spa/pod-builder.h>
#include <spa/pod-iter.h> #include <spa/pod-iter.h>
#include <spa/id-map.h> #include <spa/type-map.h>
#include <spa/log.h> #include <spa/log.h>
#include <spa/video/format.h> #include <spa/video/format.h>
#include <lib/debug.h> #include <lib/debug.h>

View file

@ -465,13 +465,13 @@ main (int argc, char *argv[])
data.data_loop.update_item = do_update_item; data.data_loop.update_item = do_update_item;
data.data_loop.remove_item = do_remove_item; data.data_loop.remove_item = do_remove_item;
data.support[0].uri = SPA_ID_MAP_URI; data.support[0].uri = SPA_TYPE__IDMap;
data.support[0].data = data.map; data.support[0].data = data.map;
data.support[1].uri = SPA_POLL__DataLoop; data.support[1].uri = SPA_TYPE_LOOP__DataLoop;
data.support[1].data = &data.data_loop; data.support[1].data = &data.data_loop;
data.n_support = 2; data.n_support = 2;
data.uri.node = spa_id_map_get_id (data.map, SPA_NODE_URI); data.uri.node = spa_id_map_get_id (data.map, SPA_TYPE__Node);
if (SDL_Init (SDL_INIT_VIDEO) < 0) { if (SDL_Init (SDL_INIT_VIDEO) < 0) {
printf ("can't initialize SDL: %s\n", SDL_GetError ()); printf ("can't initialize SDL: %s\n", SDL_GetError ());

View file

@ -23,7 +23,7 @@
#include <unistd.h> #include <unistd.h>
#include <dlfcn.h> #include <dlfcn.h>
#include <spa/id-map.h> #include <spa/type-map.h>
#include <spa/clock.h> #include <spa/clock.h>
#include <spa/log.h> #include <spa/log.h>
#include <spa/node.h> #include <spa/node.h>
@ -34,14 +34,14 @@
typedef struct { typedef struct {
uint32_t node; uint32_t node;
uint32_t clock; uint32_t clock;
} URI; } Type;
typedef struct { typedef struct {
URI uri; Type type;
SpaSupport support[4]; SpaSupport support[4];
uint32_t n_support; uint32_t n_support;
SpaIDMap *map; SpaTypeMap *map;
SpaLog *log; SpaLog *log;
SpaLoop loop; SpaLoop loop;
} AppData; } AppData;
@ -143,16 +143,16 @@ inspect_factory (AppData *data, const SpaHandleFactory *factory)
printf ("can't enumerate interfaces: %d\n", res); printf ("can't enumerate interfaces: %d\n", res);
} }
index++; index++;
printf (" interface: '%s'\n", info->uri); printf (" interface: '%s'\n", info->type);
interface_id = spa_id_map_get_id (data->map, info->uri); interface_id = spa_type_map_get_id (data->map, info->type);
if ((res = spa_handle_get_interface (handle, interface_id, &interface)) < 0) { if ((res = spa_handle_get_interface (handle, interface_id, &interface)) < 0) {
printf ("can't get interface: %d\n", res); printf ("can't get interface: %d\n", res);
continue; continue;
} }
if (interface_id == data->uri.node) if (interface_id == data->type.node)
inspect_node (interface); inspect_node (interface);
else else
printf ("skipping unknown interface\n"); printf ("skipping unknown interface\n");
@ -189,25 +189,25 @@ main (int argc, char *argv[])
return -1; return -1;
} }
data.map = spa_id_map_get_default(); data.map = spa_type_map_get_default();
data.log = NULL; data.log = NULL;
data.loop.size = sizeof (SpaLoop); data.loop.size = sizeof (SpaLoop);
data.loop.add_source = do_add_source; data.loop.add_source = do_add_source;
data.loop.update_source = do_update_source; data.loop.update_source = do_update_source;
data.loop.remove_source = do_remove_source; data.loop.remove_source = do_remove_source;
data.support[0].uri = SPA_TYPE__IDMap; data.support[0].type = SPA_TYPE__TypeMap;
data.support[0].data = data.map; data.support[0].data = data.map;
data.support[1].uri = SPA_TYPE__Log; data.support[1].type = SPA_TYPE__Log;
data.support[1].data = data.log; data.support[1].data = data.log;
data.support[2].uri = SPA_TYPE_LOOP__MainLoop; data.support[2].type = SPA_TYPE_LOOP__MainLoop;
data.support[2].data = &data.loop; data.support[2].data = &data.loop;
data.support[3].uri = SPA_TYPE_LOOP__DataLoop; data.support[3].type = SPA_TYPE_LOOP__DataLoop;
data.support[3].data = &data.loop; data.support[3].data = &data.loop;
data.n_support = 4; data.n_support = 4;
data.uri.node = spa_id_map_get_id (data.map, SPA_TYPE__Node); data.type.node = spa_type_map_get_id (data.map, SPA_TYPE__Node);
data.uri.clock = spa_id_map_get_id (data.map, SPA_TYPE__Clock); data.type.clock = spa_type_map_get_id (data.map, SPA_TYPE__Clock);
if ((handle = dlopen (argv[1], RTLD_NOW)) == NULL) { if ((handle = dlopen (argv[1], RTLD_NOW)) == NULL) {
printf ("can't load %s\n", argv[1]); printf ("can't load %s\n", argv[1]);

View file

@ -26,20 +26,20 @@
#include <poll.h> #include <poll.h>
#include <spa/log.h> #include <spa/log.h>
#include <spa/id-map.h> #include <spa/type-map.h>
#include <spa/monitor.h> #include <spa/monitor.h>
#include <spa/loop.h> #include <spa/loop.h>
#include <lib/debug.h> #include <lib/debug.h>
#include <lib/mapper.h> #include <lib/mapper.h>
typedef struct { typedef struct {
SpaMonitorTypes monitor_types; SpaTypeMonitor monitor;
} URI; } Type;
typedef struct { typedef struct {
URI uri; Type type;
SpaIDMap *map; SpaTypeMap *map;
SpaLog *log; SpaLog *log;
SpaLoop main_loop; SpaLoop main_loop;
@ -68,15 +68,15 @@ on_monitor_event (SpaMonitor *monitor,
{ {
AppData *data = user_data; AppData *data = user_data;
if (SPA_EVENT_TYPE (event) == data->uri.monitor_types.Added) { if (SPA_EVENT_TYPE (event) == data->type.monitor.Added) {
fprintf (stderr, "added:\n"); fprintf (stderr, "added:\n");
inspect_item ((SpaMonitorItem*)event); inspect_item ((SpaMonitorItem*)event);
} }
else if (SPA_EVENT_TYPE (event) == data->uri.monitor_types.Removed) { else if (SPA_EVENT_TYPE (event) == data->type.monitor.Removed) {
fprintf (stderr, "removed:\n"); fprintf (stderr, "removed:\n");
inspect_item ((SpaMonitorItem*)event); inspect_item ((SpaMonitorItem*)event);
} }
else if (SPA_EVENT_TYPE (event) == data->uri.monitor_types.Changed) { else if (SPA_EVENT_TYPE (event) == data->type.monitor.Changed) {
fprintf (stderr, "changed:\n"); fprintf (stderr, "changed:\n");
inspect_item ((SpaMonitorItem*)event); inspect_item ((SpaMonitorItem*)event);
} }
@ -169,22 +169,22 @@ main (int argc, char *argv[])
SpaEnumHandleFactoryFunc enum_func; SpaEnumHandleFactoryFunc enum_func;
uint32_t fidx; uint32_t fidx;
data.map = spa_id_map_get_default (); data.map = spa_type_map_get_default ();
data.log = NULL; data.log = NULL;
data.main_loop.size = sizeof (SpaLoop); data.main_loop.size = sizeof (SpaLoop);
data.main_loop.add_source = do_add_source; data.main_loop.add_source = do_add_source;
data.main_loop.update_source = do_update_source; data.main_loop.update_source = do_update_source;
data.main_loop.remove_source = do_remove_source; data.main_loop.remove_source = do_remove_source;
data.support[0].uri = SPA_TYPE__IDMap; data.support[0].type = SPA_TYPE__TypeMap;
data.support[0].data = data.map; data.support[0].data = data.map;
data.support[1].uri = SPA_TYPE__Log; data.support[1].type = SPA_TYPE__Log;
data.support[1].data = data.log; data.support[1].data = data.log;
data.support[2].uri = SPA_TYPE_LOOP__MainLoop; data.support[2].type = SPA_TYPE_LOOP__MainLoop;
data.support[2].data = &data.main_loop; data.support[2].data = &data.main_loop;
data.n_support = 3; data.n_support = 3;
spa_monitor_types_map (data.map, &data.uri.monitor_types); spa_type_monitor_map (data.map, &data.type.monitor);
if (argc < 2) { if (argc < 2) {
printf ("usage: %s <plugin.so>\n", argv[0]); printf ("usage: %s <plugin.so>\n", argv[0]);
@ -219,7 +219,7 @@ main (int argc, char *argv[])
break; break;
} }
if (!strcmp (info->uri, SPA_TYPE__Monitor)) { if (!strcmp (info->type, SPA_TYPE__Monitor)) {
SpaHandle *handle; SpaHandle *handle;
void *interface; void *interface;
@ -229,7 +229,7 @@ main (int argc, char *argv[])
continue; continue;
} }
if ((res = spa_handle_get_interface (handle, data.uri.monitor_types.Monitor, &interface)) < 0) { if ((res = spa_handle_get_interface (handle, data.type.monitor.Monitor, &interface)) < 0) {
printf ("can't get interface: %d\n", res); printf ("can't get interface: %d\n", res);
continue; continue;
} }