pipewire/src/modules/module-avbtp/mvrp.c

77 lines
2.1 KiB
C
Raw Normal View History

/* AVB support
*
* Copyright © 2022 Wim Taymans
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include <pipewire/pipewire.h>
#include "mvrp.h"
static const uint8_t mac[6] = AVB_MVRP_MAC;
struct mvrp {
struct server *server;
struct spa_hook server_listener;
};
static int mvrp_message(void *data, uint64_t now, const void *message, int len)
{
const struct avbtp_packet_mrp *p = message;
if (ntohs(p->eth.type) != AVB_MVRP_ETH)
return 0;
if (memcmp(p->eth.dest, mac, 6) != 0)
return 0;
pw_log_info("MVRP");
return 0;
}
static void mvrp_destroy(void *data)
{
struct mvrp *mvrp = data;
spa_hook_remove(&mvrp->server_listener);
free(mvrp);
}
static const struct server_events server_events = {
AVBTP_VERSION_SERVER_EVENTS,
.destroy = mvrp_destroy,
.message = mvrp_message
};
int avbtp_mvrp_register(struct server *server)
{
struct mvrp *mvrp;
mvrp = calloc(1, sizeof(*mvrp));
if (mvrp == NULL)
return -errno;
mvrp->server = server;
avdecc_server_add_listener(server, &mvrp->server_listener, &server_events, mvrp);
return 0;
}