mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
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:
parent
c4997fc46d
commit
680c33d3eb
7 changed files with 253 additions and 1 deletions
|
|
@ -45,6 +45,7 @@ PW_LOG_TOPIC_EXTERN(mod_topic_connection);
|
|||
#include <spa/debug/pod.h>
|
||||
|
||||
#include "connection.h"
|
||||
#include "defs.h"
|
||||
|
||||
#define MAX_BUFFER_SIZE (1024 * 32)
|
||||
#define MAX_FDS 1024u
|
||||
|
|
@ -598,6 +599,38 @@ pw_protocol_native_connection_get_next(struct pw_protocol_native_connection *con
|
|||
return 1;
|
||||
}
|
||||
|
||||
/** Get footer data from the tail of the current packet.
|
||||
*
|
||||
* \param conn the connection
|
||||
* \param msg current message
|
||||
* \return footer POD, or NULL if no valid footer present
|
||||
*
|
||||
* \memberof pw_protocol_native_connection
|
||||
*/
|
||||
struct spa_pod *pw_protocol_native_connection_get_footer(struct pw_protocol_native_connection *conn,
|
||||
const struct pw_protocol_native_message *msg)
|
||||
{
|
||||
struct impl *impl = SPA_CONTAINER_OF(conn, struct impl, this);
|
||||
struct spa_pod *pod;
|
||||
|
||||
if (impl->version != 3)
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
* Protocol version 3 footer: a single SPA POD
|
||||
*/
|
||||
|
||||
/* Footer immediately follows the message POD, if it is present */
|
||||
if ((pod = get_first_pod_from_data(msg->data, msg->size, 0)) == NULL)
|
||||
return NULL;
|
||||
pod = get_first_pod_from_data(msg->data, msg->size, SPA_POD_SIZE(pod));
|
||||
if (pod == NULL)
|
||||
return NULL;
|
||||
pw_log_trace("connection %p: recv message footer, size:%zu",
|
||||
conn, (size_t)SPA_POD_SIZE(pod));
|
||||
return pod;
|
||||
}
|
||||
|
||||
static inline void *begin_write(struct pw_protocol_native_connection *conn, uint32_t size)
|
||||
{
|
||||
struct impl *impl = SPA_CONTAINER_OF(conn, struct impl, this);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue