Debian Codegraph @

include/avtp_cvf.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
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #pragma once
30
31 #include <errno.h>
32 #include <stdint.h>
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 /* CVF 'format' field values. */
39 #define AVTP_CVF_FORMAT_RFC 0x02
40
41 /* CVF 'format subtype' field values. */
42 #define AVTP_CVF_FORMAT_SUBTYPE_MJPEG 0x00
43 #define AVTP_CVF_FORMAT_SUBTYPE_H264 0x01
44 #define AVTP_CVF_FORMAT_SUBTYPE_JPEG2000 0x02
45
46 enum avtp_cvf_field {
47 AVTP_CVF_FIELD_SV,
48 AVTP_CVF_FIELD_MR,
49 AVTP_CVF_FIELD_TV,
50 AVTP_CVF_FIELD_SEQ_NUM,
51 AVTP_CVF_FIELD_TU,
52 AVTP_CVF_FIELD_STREAM_ID,
53 AVTP_CVF_FIELD_TIMESTAMP,
54 AVTP_CVF_FIELD_STREAM_DATA_LEN,
55 AVTP_CVF_FIELD_FORMAT,
56 AVTP_CVF_FIELD_FORMAT_SUBTYPE,
57 AVTP_CVF_FIELD_M,
58 AVTP_CVF_FIELD_EVT,
59 AVTP_CVF_FIELD_H264_PTV,
60 AVTP_CVF_FIELD_H264_TIMESTAMP,
61 AVTP_CVF_FIELD_MAX,
62 };
63
64 struct avtp_cvf_h264_payload {
65 uint32_t h264_header;
66 uint8_t h264_data[0];
67 } __attribute__((__packed__));
68
69 /* Get value of CVF AVTPDU field.
70 * @pdu: Pointer to PDU struct.
71 * @field: PDU field to be retrieved.
72 * @val: Pointer to variable which the retrieved value should be saved.
73 *
74 * Returns:
75 * 0: Success.
76 * -EINVAL: If any argument is invalid.
77 */
78 int avtp_cvf_pdu_get(const struct avtp_stream_pdu *pdu,
79 enum avtp_cvf_field field, uint64_t *val);
80
81 /* Set value of CVF AVTPDU field.
82 * @pdu: Pointer to PDU struct.
83 * @field: PDU field to be set.
84 * @val: Value to be set.
85 *
86 * Returns:
87 * 0: Success.
88 * -EINVAL: If any argument is invalid.
89 */
90 int avtp_cvf_pdu_set(struct avtp_stream_pdu *pdu, enum avtp_cvf_field field,
91 uint64_t val);
92
93 /* Initialize CVF AVTPDU. All AVTPDU fields are initialized with zero except
94 * 'subtype' (which is set to AVTP_SUBTYPE_CVF), 'sv' (which is set to 1),
95 * 'format' (which is set to AVTP_CVF_FORMAT_RFC) and 'format_subtype'
96 * (which is set to the `subtype` specified).
97 * @pdu: Pointer to PDU struct.
98 * @subtype: AVTP CVF Format Subtype of this AVTPDU.
99 *
100 * Return values:
101 * 0: Success.
102 * -EINVAL: If any argument is invalid.
103 */
104 int avtp_cvf_pdu_init(struct avtp_stream_pdu *pdu, uint8_t subtype);
105
106 #ifdef __cplusplus
107 }
108 #endif