Debian Codegraph @

src/avtp_stream.h

raw
1 /*
2 * Copyright (c) 2019, 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 #pragma GCC visibility push(hidden)
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 /* XXX: To be able to use the functions provided by this header,
40 * without needing to direct "translate" enum values, it is necessary
41 * that any format specific enum have the following fields (excluding
42 * AVTP_STREAM_FIELD_MAX) in the same order as below. For instance,
43 * some `enum avtp_newformat_field` would start like:
44 *
45 * enum avtp_newformat_field {
46 * AVTP_NEWFORMAT_FIELD_SV,
47 * AVTP_NEWFORMAT_FIELD_MR,
48 * // (other stream fields here)
49 * AVTP_NEWFORMAT_FIELD_XYZ,
50 * // (other newformat specific fields here)
51 * }
52 *
53 * This way, one can simply cast enums when calling functions from this
54 * header:
55 *
56 * avtp_stream_pdu_get(pdu, (enum avtp_stream_field) field, val);
57 *
58 * Otherwise, the mapping step would be necessary before the calls.
59 */
60 enum avtp_stream_field {
61 AVTP_STREAM_FIELD_SV,
62 AVTP_STREAM_FIELD_MR,
63 AVTP_STREAM_FIELD_TV,
64 AVTP_STREAM_FIELD_SEQ_NUM,
65 AVTP_STREAM_FIELD_TU,
66 AVTP_STREAM_FIELD_STREAM_ID,
67 AVTP_STREAM_FIELD_TIMESTAMP,
68 AVTP_STREAM_FIELD_STREAM_DATA_LEN,
69 AVTP_STREAM_FIELD_MAX
70 };
71
72 /* Get value from Stream AVTPDU field.
73 * @pdu: Pointer to PDU struct.
74 * @field: PDU field to be retrieved.
75 * @val: Pointer to variable which the retrieved value should be saved.
76 *
77 * Returns:
78 * 0: Success.
79 * -EINVAL: If any argument is invalid.
80 */
81 int avtp_stream_pdu_get(const struct avtp_stream_pdu *pdu,
82 enum avtp_stream_field field, uint64_t *val);
83
84 /* Set value from Stream AVTPDU field.
85 * @pdu: Pointer to PDU struct.
86 * @field: PDU field to be set.
87 * @val: Value to be set.
88 *
89 * Returns:
90 * 0: Success.
91 * -EINVAL: If any argument is invalid.
92 */
93 int avtp_stream_pdu_set(struct avtp_stream_pdu *pdu,
94 enum avtp_stream_field field, uint64_t val);
95
96 #ifdef __cplusplus
97 }
98 #endif
99
100 #pragma GCC visibility pop