mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-22 06:59:59 -05:00
modules-avb: Introducing entity builder. The entity builder is necessary
to attach ressource to the descriptors instead of having them splitted. It is the case for the avb-streams which in a seperated list. Instead they should be encapsulated within the descriptor itself, as one cannot leave without the other.
This commit is contained in:
parent
8ea56477d9
commit
57af462ecf
3 changed files with 101 additions and 0 deletions
|
|
@ -736,6 +736,7 @@ if build_module_avb
|
|||
'module-avb/acmp.c',
|
||||
'module-avb/aecp.c',
|
||||
'module-avb/aecp-aem.c',
|
||||
'module-avb/es-builder.c',
|
||||
'module-avb/avdecc.c',
|
||||
'module-avb/maap.c',
|
||||
'module-avb/mmrp.c',
|
||||
|
|
|
|||
81
src/modules/module-avb/es-builder.c
Normal file
81
src/modules/module-avb/es-builder.c
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/* PipeWire */
|
||||
/* SPDX-FileCopyrightText: Copyright © 2025 Alexandre Malki <alexandre.malki@kebag-logic.com> */
|
||||
/* SPDX-License-Identifier: MIT */
|
||||
|
||||
|
||||
#include "es-builder.h"
|
||||
#include "aecp-aem-descriptors.h"
|
||||
|
||||
/**
|
||||
* \brief The goal of this modules is to create a an entity and
|
||||
* attache the necessary status or resources to it so they
|
||||
* do no have to be seperated and referenced somewhere else.
|
||||
*
|
||||
* In a sense, it encapsulates the descriptor, and the states
|
||||
* information that will be altered either by a aecp/acmp commands
|
||||
* or internal state changes reflected into the counters.
|
||||
*/
|
||||
|
||||
/** The callback type used for the different entity descriptor */
|
||||
typedef void* (*es_builder_cb_t) (struct server *server, uint16_t type,
|
||||
uint16_t index, size_t size, void *ptr);
|
||||
|
||||
/** Structure holding all necessary cb
|
||||
* \todo for the future of compatibility between milan's version
|
||||
* and plain AVB, add the right callback, that would reduce
|
||||
* code complexity and increase reusability.
|
||||
* As well as having multiple entity model defined using different
|
||||
* entity on the same machine
|
||||
*/
|
||||
struct es_builder_st {
|
||||
es_builder_cb_t build_descriptor_cb;
|
||||
};
|
||||
|
||||
/** All callback that needs a status information */
|
||||
static const struct es_builder_st es_builder[AVB_AEM_DESC_LAST_RESERVED_17221] =
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief, should be called when creating an a descriptor, it will attach
|
||||
* the right state variable that are necessary for counters, stream info
|
||||
* and so on...
|
||||
*/
|
||||
void es_builder_add_descriptor(struct server *server, uint16_t type,
|
||||
uint16_t index, size_t size, void *ptr_aem)
|
||||
{
|
||||
void *desc_ptr;
|
||||
struct descriptor *d;
|
||||
|
||||
if (!server) {
|
||||
pw_log_error("Invalid server, it is empty %p\n", server);
|
||||
spa_assert(0);
|
||||
}
|
||||
|
||||
if (type >= AVB_AEM_DESC_LAST_RESERVED_17221) {
|
||||
pw_log_error("Invalid Type %u\n", type);
|
||||
spa_assert(0);
|
||||
}
|
||||
|
||||
/* Look if the descriptor has a callback to attach more status data */
|
||||
if (!es_builder[type].build_descriptor_cb) {
|
||||
if (!server_add_descriptor(server, type, index, size, ptr_aem)) {
|
||||
pw_log_error("Could not allocate descriptor %u at "
|
||||
"index %u the avb aem type\n", type, index);
|
||||
|
||||
spa_assert(0);
|
||||
}
|
||||
} else {
|
||||
desc_ptr = es_builder[type].build_descriptor_cb(server, type,
|
||||
index, size, ptr_aem);
|
||||
if (!desc_ptr) {
|
||||
pw_log_error("Could not allocate specific descriptr "
|
||||
"%u at index %u the avb aem type\n",
|
||||
type, index);
|
||||
|
||||
spa_assert(0);
|
||||
}
|
||||
d = (struct descriptor *) desc_ptr;
|
||||
d->size = size;
|
||||
}
|
||||
}
|
||||
19
src/modules/module-avb/es-builder.h
Normal file
19
src/modules/module-avb/es-builder.h
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/* PipeWire */
|
||||
/* SPDX-FileCopyrightText: Copyright © 2025 Alexandre Malki <alexandre.malki@kebag-logic.com> */
|
||||
/* SPDX-License-Identifier: MIT */
|
||||
|
||||
|
||||
#ifndef __ES_BUILDER_H__
|
||||
#define __ES_BUILDER_H__
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
/**
|
||||
* This is a mandatory feature to add the necessary state information
|
||||
* to create the right entity model
|
||||
**/
|
||||
void es_builder_add_descriptor(struct server *server, uint16_t type,
|
||||
uint16_t index, size_t size, void *ptr_aem);
|
||||
|
||||
|
||||
#endif // __ES_BUILDER_H__
|
||||
Loading…
Add table
Add a link
Reference in a new issue