Skip to content

Commit

Permalink
Refactore CVF format
Browse files Browse the repository at this point in the history
Signed-off-by: Adriaan Niess <[email protected]>
  • Loading branch information
adriaan-niess committed Jun 27, 2024
1 parent de87d01 commit 17dc844
Show file tree
Hide file tree
Showing 14 changed files with 1,377 additions and 1,202 deletions.
565 changes: 282 additions & 283 deletions examples/cvf/cvf-listener.c

Large diffs are not rendered by default.

412 changes: 193 additions & 219 deletions examples/cvf/cvf-talker.c

Large diffs are not rendered by default.

103 changes: 103 additions & 0 deletions include/avtp/cvf/Cvf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* Copyright (c) 2024, COVESA
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of COVESA, Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* SPDX-License-Identifier: BSD-3-Clause
*/

#pragma once

#include <stdint.h>

#include "avtp/Utils.h"

#define AVTP_CVF_HEADER_LEN (6 * AVTP_QUADLET_SIZE)

typedef struct Avtp_Cvf {
uint8_t header[AVTP_CVF_HEADER_LEN];
uint8_t payload[0];
} Avtp_Cvf_t;

typedef enum Avtp_CvfField {
/* CVF header fields */
AVTP_CVF_FIELD_SUBTYPE,
AVTP_CVF_FIELD_SV,
AVTP_CVF_FIELD_VERSION,
AVTP_CVF_FIELD_MR,
AVTP_CVF_FIELD_RESERVED,
AVTP_CVF_FIELD_TV,
AVTP_CVF_FIELD_SEQUENCE_NUM,
AVTP_CVF_FIELD_RESERVED_2,
AVTP_CVF_FIELD_TU,
AVTP_CVF_FIELD_STREAM_ID,
AVTP_CVF_FIELD_AVTP_TIMESTAMP,
AVTP_CVF_FIELD_FORMAT,
AVTP_CVF_FIELD_FORMAT_SUBTYPE,
AVTP_CVF_FIELD_RESERVED_3,
AVTP_CVF_FIELD_STREAM_DATA_LENGTH,
AVTP_CVF_FIELD_RESERVED_4,
AVTP_CVF_FIELD_PTV,
AVTP_CVF_FIELD_M,
AVTP_CVF_FIELD_EVT,
AVTP_CVF_FIELD_RESERVED_5,
/* Count number of fields for bound checks */
AVTP_CVF_FIELD_MAX
} Avtp_CvfField_t;

typedef enum Avtp_CvfFormat {
AVTP_CVF_FORMAT_RFC = 0x2
} Avtp_CvfFormat_t;

typedef enum Avtp_CvfFormatSubtype {
AVTP_CVF_FORMAT_SUBTYPE_MJPEG = 0x0,
AVTP_CVF_FORMAT_SUBTYPE_H264 = 0x1,
AVTP_CVF_FORMAT_SUBTYPE_JPEG2000 = 0x2
} Avtp_CvfFormatSubtype_t;

int Avtp_Cvf_Init(Avtp_Cvf_t* pdu);

int Avtp_Cvf_GetField(Avtp_Cvf_t* pdu, Avtp_CvfField_t field, uint64_t* value);

int Avtp_Cvf_SetField(Avtp_Cvf_t* pdu, Avtp_CvfField_t field, uint64_t value);

/******************************************************************************
* Legacy API (deprecated)
*****************************************************************************/

/**
* @deprecated
*/
int avtp_cvf_pdu_get(void* pdu, Avtp_CvfField_t field, uint64_t *val);

/**
* @deprecated
*/
int avtp_cvf_pdu_set(void* pdu, Avtp_CvfField_t field, uint64_t val);

/**
* @deprecated
*/
int avtp_cvf_pdu_init(void* pdu, uint8_t format_subtype);

54 changes: 54 additions & 0 deletions include/avtp/cvf/H264.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2024, COVESA
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of COVESA, Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* SPDX-License-Identifier: BSD-3-Clause
*/

#pragma once

#include <stdint.h>

#include "avtp/Utils.h"

#define AVTP_H246_HEADER_LEN (1 * AVTP_QUADLET_SIZE)

typedef struct Avtp_H264 {
uint8_t header[AVTP_H246_HEADER_LEN];
uint8_t payload[0];
} Avtp_H264_t;

typedef enum Avtp_H264Field {
/* H264 header fields */
AVTP_H264_FIELD_TIMESTAMP,
/* Count number of fields for bound checks */
AVTP_H264_FIELD_MAX,
} Avtp_H264Field_t;

int Avtp_H264_Init(Avtp_H264_t* pdu);

int Avtp_H264_GetField(Avtp_H264_t* pdu, Avtp_H264Field_t field, uint64_t* value);

int Avtp_H264_SetField(Avtp_H264_t* pdu, Avtp_H264Field_t field, uint64_t value);
61 changes: 61 additions & 0 deletions include/avtp/cvf/Jpeg2000.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright (c) 2024, COVESA
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of COVESA, Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* SPDX-License-Identifier: BSD-3-Clause
*/

#pragma once

#include <stdint.h>

#include "avtp/Utils.h"

#define AVTP_JPEG2000_HEADER_LEN (2 * AVTP_QUADLET_SIZE)

typedef struct Avtp_Jpeg2000 {
uint8_t header[AVTP_JPEG2000_HEADER_LEN];
uint8_t payload[0];
} Avtp_Jpeg2000_t;

typedef enum Avtp_Jpeg2000Field {
/* MJPEG header fields */
AVTP_JPEG2000_FIELD_TP,
AVTP_JPEG2000_FIELD_MHF,
AVTP_JPEG2000_FIELD_MH_ID,
AVTP_JPEG2000_FIELD_T,
AVTP_JPEG2000_FIELD_PRIORITY,
AVTP_JPEG2000_FIELD_TILE_NUMBER,
AVTP_JPEG2000_FIELD_RESERVED,
AVTP_JPEG2000_FIELD_FRAGMENT_OFFSET,
/* Count number of fields for bound checks */
AVTP_JPEG2000_FIELD_MAX
} Avtp_Jpeg2000Field_t;

int Avtp_Jpeg2000_Init(Avtp_Jpeg2000_t* pdu);

int Avtp_Jpeg2000_GetField(Avtp_Jpeg2000_t* pdu, Avtp_Jpeg2000Field_t field, uint64_t* value);

int Avtp_Jpeg2000_SetField(Avtp_Jpeg2000_t* pdu, Avtp_Jpeg2000Field_t field, uint64_t value);
59 changes: 59 additions & 0 deletions include/avtp/cvf/Mjpeg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright (c) 2024, COVESA
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of COVESA, Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* SPDX-License-Identifier: BSD-3-Clause
*/

#pragma once

#include <stdint.h>

#include "avtp/Utils.h"

#define AVTP_MJPEG_HEADER_LEN (2 * AVTP_QUADLET_SIZE)

typedef struct Avtp_Mjpeg {
uint8_t header[AVTP_MJPEG_HEADER_LEN];
uint8_t payload[0];
} Avtp_Mjpeg_t;

typedef enum Avtp_MjpegField {
/* MJPEG header fields */
AVTP_MJPEG_FIELD_TYPE_SPECIFIC,
AVTP_MJPEG_FIELD_FRAGMENT_OFFSET,
AVTP_MJPEG_FIELD_TYPE,
AVTP_MJPEG_FIELD_Q,
AVTP_MJPEG_FIELD_WIDTH,
AVTP_MJPEG_FIELD_HEIGHT,
/* Count number of fields for bound checks */
AVTP_MJPEG_FIELD_MAX
} Avtp_MjpegField_t;

int Avtp_Mjpeg_Init(Avtp_Mjpeg_t* pdu);

int Avtp_Mjpeg_GetField(Avtp_Mjpeg_t* pdu, Avtp_MjpegField_t field, uint64_t* value);

int Avtp_Mjpeg_SetField(Avtp_Mjpeg_t* pdu, Avtp_MjpegField_t field, uint64_t value);
107 changes: 0 additions & 107 deletions include/avtp_cvf.h

This file was deleted.

Loading

0 comments on commit 17dc844

Please sign in to comment.