protocol-native: extend v3 protocol with message footers

Extend version 3 protocol with message footers, which are for passing
around global state data that is not addressed to a specific object.

The extension is backward compatible with previous v3 clients, and won't
e.g. result to error spam in logs.

The footer is a single SPA POD, appended after the main message POD.
Because both the protocol message and the message POD record their
length, it's possible to append trailing data. Earlier clients will
ignore any data trailing the message POD.

The footer POD contains a sequence [Id opcode, Struct {...}]*,
so there is room to extend with new opcodes later as necessary.

There are separate marshal/demarshal routines for messages aimed at
resources and proxies.
This commit is contained in:
Pauli Virtanen 2022-02-20 14:03:41 +02:00
parent c4997fc46d
commit 680c33d3eb
7 changed files with 253 additions and 1 deletions

View file

@ -30,3 +30,14 @@ int pw_protocol_native_connect_portal_screencast(struct pw_protocol_client *clie
const struct spa_dict *props,
void (*done_callback) (void *data, int res),
void *data);
static inline void *get_first_pod_from_data(void *data, size_t maxsize, off_t offset)
{
void *pod;
if (offset + sizeof(struct spa_pod) > maxsize)
return NULL;
pod = SPA_PTROFF(data, offset, void);
if (offset + SPA_POD_SIZE(pod) > maxsize)
return NULL;
return pod;
}