mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-16 07:00:00 -05:00
Rework serialization
Move serialization to the protocol, we now just send blocks of bytes over the connection and let the protocol deserialize them.
This commit is contained in:
parent
842d73ca4b
commit
41399b0b25
26 changed files with 1617 additions and 2501 deletions
|
|
@ -70,6 +70,16 @@ typedef struct {
|
|||
int32_t value;
|
||||
} SpaPODInt;
|
||||
|
||||
static inline bool
|
||||
spa_pod_get_int (SpaPOD **pod, int32_t *val)
|
||||
{
|
||||
if (*pod == NULL || (*pod)->type != SPA_POD_TYPE_INT)
|
||||
return false;
|
||||
*val = ((SpaPODInt *)(*pod))->value;
|
||||
*pod = SPA_MEMBER (*pod, SPA_ROUND_UP_N (SPA_POD_SIZE (*pod), 8), SpaPOD);
|
||||
return true;
|
||||
}
|
||||
|
||||
typedef SpaPODInt SpaPODBool;
|
||||
typedef SpaPODInt SpaPODURI;
|
||||
|
||||
|
|
@ -78,6 +88,16 @@ typedef struct {
|
|||
int64_t value;
|
||||
} SpaPODLong;
|
||||
|
||||
static inline bool
|
||||
spa_pod_get_long (SpaPOD **pod, int64_t *val)
|
||||
{
|
||||
if (*pod == NULL || (*pod)->type != SPA_POD_TYPE_LONG)
|
||||
return false;
|
||||
*val = ((SpaPODLong *)*pod)->value;
|
||||
*pod = SPA_MEMBER (*pod, SPA_ROUND_UP_N (SPA_POD_SIZE (*pod), 8), SpaPOD);
|
||||
return true;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
SpaPOD pod;
|
||||
float value;
|
||||
|
|
@ -93,6 +113,21 @@ typedef struct {
|
|||
/* value here */
|
||||
} SpaPODString;
|
||||
|
||||
static inline bool
|
||||
spa_pod_get_string (SpaPOD **pod, const char **val)
|
||||
{
|
||||
if (*pod == NULL || (*pod)->type != SPA_POD_TYPE_STRING)
|
||||
return false;
|
||||
*val = SPA_POD_CONTENTS (SpaPODString, *pod);
|
||||
*pod = SPA_MEMBER (*pod, SPA_ROUND_UP_N (SPA_POD_SIZE (*pod), 8), SpaPOD);
|
||||
return true;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
SpaPOD pod;
|
||||
/* value here */
|
||||
} SpaPODBytes;
|
||||
|
||||
typedef struct {
|
||||
SpaPOD pod;
|
||||
SpaRectangle value;
|
||||
|
|
@ -123,6 +158,16 @@ typedef struct {
|
|||
/* one or more SpaPOD follow */
|
||||
} SpaPODStruct;
|
||||
|
||||
static inline bool
|
||||
spa_pod_get_struct (SpaPOD **pod, SpaPOD **val)
|
||||
{
|
||||
if (*pod == NULL || (*pod)->type != SPA_POD_TYPE_STRUCT)
|
||||
return false;
|
||||
*val = *pod;
|
||||
*pod = SPA_MEMBER (*pod, SPA_ROUND_UP_N (SPA_POD_SIZE (*pod), 8), SpaPOD);
|
||||
return true;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
uint32_t key;
|
||||
#define SPA_POD_PROP_RANGE_NONE 0
|
||||
|
|
@ -161,6 +206,28 @@ typedef struct {
|
|||
SpaPODObjectBody body;
|
||||
} SpaPODObject;
|
||||
|
||||
static inline bool
|
||||
spa_pod_get_object (SpaPOD **pod, const SpaPOD **val)
|
||||
{
|
||||
if (*pod == NULL || (*pod)->type != SPA_POD_TYPE_OBJECT)
|
||||
return false;
|
||||
*val = *pod;
|
||||
*pod = SPA_MEMBER (*pod, SPA_ROUND_UP_N (SPA_POD_SIZE (*pod), 8), SpaPOD);
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
spa_pod_get_bytes (SpaPOD **pod, const void **val, uint32_t *size)
|
||||
{
|
||||
if (*pod == NULL || (*pod)->type != SPA_POD_TYPE_BYTES)
|
||||
return false;
|
||||
*val = SPA_POD_CONTENTS (SpaPODBytes, *pod);
|
||||
*size = SPA_POD_SIZE (*pod);
|
||||
*pod = SPA_MEMBER (*pod, SPA_ROUND_UP_N (SPA_POD_SIZE (*pod), 8), SpaPOD);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#define SPA_POD_ARRAY_BODY_FOREACH(body, size, iter) \
|
||||
for ((iter) = SPA_MEMBER (body, sizeof(SpaPODArrayBody), __typeof__(*iter)); \
|
||||
(iter) < SPA_MEMBER (body, (size), __typeof__(*iter)); \
|
||||
|
|
@ -204,6 +271,7 @@ spa_pod_object_find_prop (const SpaPODObject *obj, uint32_t key)
|
|||
return spa_pod_contents_find_prop (&obj->pod, sizeof (SpaPODObject), key);
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue