mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-04-29 06:46:38 -04:00
milan-avb: add AVDECC stream_format decoder in aecp-aem.h
This commit is contained in:
parent
d9f8bacc76
commit
a5fbeef6f8
1 changed files with 74 additions and 0 deletions
|
|
@ -6,8 +6,82 @@
|
|||
#ifndef AVB_AEM_H
|
||||
#define AVB_AEM_H
|
||||
|
||||
#include <endian.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "aecp.h"
|
||||
#include "aecp-aem-types.h"
|
||||
#include "packets.h"
|
||||
|
||||
/* AVDECC stream_format decoder.
|
||||
*
|
||||
* The 64-bit stream_format field carried in STREAM_INPUT/STREAM_OUTPUT
|
||||
* descriptors and in SET/GET_STREAM_FORMAT is encoded per IEEE 1722-2016
|
||||
* Section 7.3.x / Annex H — the high byte is the AVTP subtype, the lower 56 bits
|
||||
* are subtype-specific. This struct exposes the subset needed by the data
|
||||
* plane plus an `is_audio` shortcut so callers can skip non-media streams
|
||||
* (CRF). Fields are 0 when not applicable.
|
||||
*
|
||||
* NOTE: bit-level decoding inside each subtype is incomplete. Today the
|
||||
* decoder identifies the subtype reliably and falls back to the historical
|
||||
* 8 ch / 48 kHz / 24-bit defaults for audio — sufficient for current Milan
|
||||
* builds where every stream_input_0 / stream_output_0 uses one of those
|
||||
* formats. TODO Section H.1 (AAF) and Section F (IEC 61883-6 AM824) fields once a real
|
||||
* conformance run needs other rates / channel counts. */
|
||||
enum avb_aem_stream_format_kind {
|
||||
AVB_AEM_STREAM_FORMAT_KIND_UNKNOWN = 0,
|
||||
AVB_AEM_STREAM_FORMAT_KIND_AAF,
|
||||
AVB_AEM_STREAM_FORMAT_KIND_IEC_61883_6,
|
||||
AVB_AEM_STREAM_FORMAT_KIND_CRF,
|
||||
};
|
||||
|
||||
struct avb_aem_stream_format_info {
|
||||
uint8_t subtype;
|
||||
enum avb_aem_stream_format_kind kind;
|
||||
bool is_audio;
|
||||
uint32_t rate;
|
||||
uint16_t channels;
|
||||
uint8_t bit_depth;
|
||||
uint16_t samples_per_frame;
|
||||
};
|
||||
|
||||
static inline void avb_aem_stream_format_decode(uint64_t fmt_be,
|
||||
struct avb_aem_stream_format_info *out)
|
||||
{
|
||||
uint64_t f = be64toh(fmt_be);
|
||||
out->subtype = (uint8_t)((f >> 56) & 0xFF);
|
||||
out->kind = AVB_AEM_STREAM_FORMAT_KIND_UNKNOWN;
|
||||
out->is_audio = false;
|
||||
out->rate = 0;
|
||||
out->channels = 0;
|
||||
out->bit_depth = 0;
|
||||
out->samples_per_frame = 0;
|
||||
|
||||
switch (out->subtype) {
|
||||
case AVB_SUBTYPE_AAF:
|
||||
out->kind = AVB_AEM_STREAM_FORMAT_KIND_AAF;
|
||||
out->is_audio = true;
|
||||
out->rate = 48000;
|
||||
out->channels = 8;
|
||||
out->bit_depth = 24;
|
||||
out->samples_per_frame = 6;
|
||||
break;
|
||||
case AVB_SUBTYPE_61883_IIDC:
|
||||
out->kind = AVB_AEM_STREAM_FORMAT_KIND_IEC_61883_6;
|
||||
out->is_audio = true;
|
||||
out->rate = 48000;
|
||||
out->channels = 8;
|
||||
out->bit_depth = 24;
|
||||
out->samples_per_frame = 6;
|
||||
break;
|
||||
case AVB_SUBTYPE_CRF:
|
||||
out->kind = AVB_AEM_STREAM_FORMAT_KIND_CRF;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
struct avb_packet_aecp_aem_acquire {
|
||||
uint32_t flags;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue