| 1 |
/* |
| 2 |
* Copyright (c) 2017, Intel Corporation |
| 3 |
* |
| 4 |
* Redistribution and use in source and binary forms, with or without |
| 5 |
* modification, are permitted provided that the following conditions are met: |
| 6 |
* |
| 7 |
* * Redistributions of source code must retain the above copyright notice, |
| 8 |
* this list of conditions and the following disclaimer. |
| 9 |
* * Redistributions in binary form must reproduce the above copyright |
| 10 |
* notice, this list of conditions and the following disclaimer in the |
| 11 |
* documentation and/or other materials provided with the distribution. |
| 12 |
* * Neither the name of Intel Corporation nor the names of its contributors |
| 13 |
* may be used to endorse or promote products derived from this software |
| 14 |
* without specific prior written permission. |
| 15 |
* |
| 16 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 17 |
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 18 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 19 |
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE |
| 20 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 21 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 22 |
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 23 |
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 24 |
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 25 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 |
*/ |
| 27 |
|
| 28 |
#pragma once |
| 29 |
|
| 30 |
#include <errno.h> |
| 31 |
#include <stdint.h> |
| 32 |
|
| 33 |
#ifdef __cplusplus |
| 34 |
extern "C" { |
| 35 |
#endif |
| 36 |
|
| 37 |
/* AVTP subtypes values. For further information refer to section 4.4.3.2 from |
| 38 |
* IEEE 1722-2016 spec. |
| 39 |
*/ |
| 40 |
#define AVTP_SUBTYPE_61883_IIDC 0x00 |
| 41 |
#define AVTP_SUBTYPE_MMA_STREAM 0x01 |
| 42 |
#define AVTP_SUBTYPE_AAF 0x02 |
| 43 |
#define AVTP_SUBTYPE_CVF 0x03 |
| 44 |
#define AVTP_SUBTYPE_CRF 0x04 |
| 45 |
#define AVTP_SUBTYPE_TSCF 0x05 |
| 46 |
#define AVTP_SUBTYPE_SVF 0x06 |
| 47 |
#define AVTP_SUBTYPE_RVF 0x07 |
| 48 |
#define AVTP_SUBTYPE_AEF_CONTINUOUS 0x6E |
| 49 |
#define AVTP_SUBTYPE_VSF_STREAM 0x6F |
| 50 |
#define AVTP_SUBTYPE_EF_STREAM 0x7F |
| 51 |
#define AVTP_SUBTYPE_NTSCF 0x82 |
| 52 |
#define AVTP_SUBTYPE_ESCF 0xEC |
| 53 |
#define AVTP_SUBTYPE_EECF 0xED |
| 54 |
#define AVTP_SUBTYPE_AEF_DISCRETE 0xEE |
| 55 |
#define AVTP_SUBTYPE_ADP 0xFA |
| 56 |
#define AVTP_SUBTYPE_AECP 0xFB |
| 57 |
#define AVTP_SUBTYPE_ACMP 0xFC |
| 58 |
#define AVTP_SUBTYPE_MAAP 0xFE |
| 59 |
#define AVTP_SUBTYPE_EF_CONTROL 0xFF |
| 60 |
|
| 61 |
/* XXX: Fields from PDU structs should not be read or written directly since |
| 62 |
* they are encoded in Network order which may be different from the Host |
| 63 |
* order (see section 3.4.1 from IEEE 1722-2016 spec for further information). |
| 64 |
* |
| 65 |
* Any read or write operation with PDU structs should be done via getter and |
| 66 |
* setter APIs which handle byte order conversion. |
| 67 |
*/ |
| 68 |
struct avtp_common_pdu { |
| 69 |
uint32_t subtype_data; |
| 70 |
uint8_t pdu_specific[0]; |
| 71 |
} __attribute__ ((__packed__)); |
| 72 |
|
| 73 |
struct avtp_stream_pdu { |
| 74 |
uint32_t subtype_data; |
| 75 |
uint64_t stream_id; |
| 76 |
uint32_t avtp_time; |
| 77 |
uint32_t format_specific; |
| 78 |
uint32_t packet_info; |
| 79 |
uint8_t avtp_payload[0]; |
| 80 |
} __attribute__ ((__packed__)); |
| 81 |
|
| 82 |
enum avtp_field { |
| 83 |
AVTP_FIELD_SUBTYPE, |
| 84 |
AVTP_FIELD_VERSION, |
| 85 |
AVTP_FIELD_MAX, |
| 86 |
}; |
| 87 |
|
| 88 |
/* Get value from Common AVTPDU field. |
| 89 |
* @pdu: Pointer to PDU struct. |
| 90 |
* @field: PDU field to be retrieved. |
| 91 |
* @val: Pointer to variable which the retrieved value should be saved. |
| 92 |
* |
| 93 |
* Returns: |
| 94 |
* 0: Success. |
| 95 |
* -EINVAL: If any argument is invalid. |
| 96 |
*/ |
| 97 |
int avtp_pdu_get(const struct avtp_common_pdu *pdu, enum avtp_field field, |
| 98 |
uint32_t *val); |
| 99 |
|
| 100 |
/* Set value from Common AVTPDU field. |
| 101 |
* @pdu: Pointer to PDU struct. |
| 102 |
* @field: PDU field to be set. |
| 103 |
* @val: Value to be set. |
| 104 |
* |
| 105 |
* Returns: |
| 106 |
* 0: Success. |
| 107 |
* -EINVAL: If any argument is invalid. |
| 108 |
*/ |
| 109 |
int avtp_pdu_set(struct avtp_common_pdu *pdu, enum avtp_field field, |
| 110 |
uint32_t val); |
| 111 |
|
| 112 |
#ifdef __cplusplus |
| 113 |
} |
| 114 |
#endif |