pipewire/src/modules/module-avb/stream.h
Christian F.K. Schaller 14310e66fe module-avb: extend transport abstraction to stream data path
Add stream_setup_socket and stream_send ops to avb_transport_ops so the
stream data plane can use the same pluggable transport backend as the
control plane. Move the raw AF_PACKET socket setup from stream.c into
avdecc.c as raw_stream_setup_socket(), and add a raw_stream_send()
wrapper around sendmsg().

Add a stream list (spa_list) to struct server so streams can be iterated
after creation, and add stream_activate_virtual() for lightweight
activation without MRP/MAAP network operations.

Implement loopback stream ops: eventfd-based dummy sockets and no-op
send that discards audio data. This enables virtual AVB nodes that work
without network hardware or privileges.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-09 07:43:19 +00:00

83 lines
1.7 KiB
C

/* AVB support */
/* SPDX-FileCopyrightText: Copyright © 2022 Wim Taymans */
/* SPDX-License-Identifier: MIT */
#ifndef AVB_STREAM_H
#define AVB_STREAM_H
#include <sys/socket.h>
#include <sys/types.h>
#include <linux/if_packet.h>
#include <net/if.h>
#include <spa/utils/ringbuffer.h>
#include <spa/param/audio/format.h>
#include <pipewire/pipewire.h>
#define BUFFER_SIZE (1u<<16)
#define BUFFER_MASK (BUFFER_SIZE-1)
struct stream {
struct spa_list link;
struct server *server;
uint16_t direction;
uint64_t id;
uint64_t peer_id;
struct pw_stream *stream;
struct spa_hook stream_listener;
uint8_t addr[6];
struct spa_source *source;
int prio;
int vlan_id;
int mtt;
int t_uncertainty;
uint32_t frames_per_pdu;
int ptime_tolerance;
uint8_t pdu[2048];
size_t hdr_size;
size_t payload_size;
size_t pdu_size;
int64_t pdu_period;
uint8_t pdu_seq;
uint8_t prev_seq;
uint8_t dbc;
struct iovec iov[3];
struct sockaddr_ll sock_addr;
struct msghdr msg;
char control[CMSG_SPACE(sizeof(uint64_t))];
struct cmsghdr *cmsg;
struct spa_ringbuffer ring;
void *buffer_data;
size_t buffer_size;
uint64_t format;
uint32_t stride;
struct spa_audio_info info;
struct avb_msrp_attribute *talker_attr;
struct avb_msrp_attribute *listener_attr;
struct avb_mvrp_attribute *vlan_attr;
};
#include "msrp.h"
#include "mvrp.h"
#include "maap.h"
struct stream *server_create_stream(struct server *server, struct stream *stream,
enum spa_direction direction, uint16_t index);
void stream_destroy(struct stream *stream);
int stream_activate(struct stream *stream, uint16_t index, uint64_t now);
int stream_deactivate(struct stream *stream, uint64_t now);
int stream_activate_virtual(struct stream *stream, uint16_t index);
#endif /* AVB_STREAM_H */