Skip to content

Commit

Permalink
First version for uC setup.
Browse files Browse the repository at this point in the history
Signed-off-by: Naresh Nayak <[email protected]>
  • Loading branch information
nayakned committed Jun 28, 2024
1 parent 81f8df7 commit 49a439a
Show file tree
Hide file tree
Showing 14 changed files with 78 additions and 14 deletions.
1 change: 0 additions & 1 deletion examples/aaf/aaf-listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
#include <unistd.h>
#include <inttypes.h>

#include "avtp.h"
#include "avtp/aaf/PcmStream.h"
#include "common.h"
#include "avtp/CommonHeader.h"
Expand Down
1 change: 0 additions & 1 deletion examples/aaf/aaf-talker.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
#include <string.h>
#include <unistd.h>

#include "avtp.h"
#include "avtp/aaf/PcmStream.h"
#include "common.h"
#include "avtp/CommonHeader.h"
Expand Down
1 change: 0 additions & 1 deletion examples/crf/crf-listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@
#include <math.h>
#include <inttypes.h>

#include "avtp.h"
#include "avtp/Crf.h"
#include "avtp/aaf/PcmStream.h"
#include "common.h"
Expand Down
1 change: 0 additions & 1 deletion examples/crf/crf-talker.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
#include <unistd.h>
#include <math.h>

#include "avtp.h"
#include "avtp/Crf.h"
#include "common.h"
#include "avtp/CommonHeader.h"
Expand Down
1 change: 0 additions & 1 deletion examples/cvf/cvf-listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
#include <unistd.h>
#include <inttypes.h>

#include "avtp.h"
#include "avtp/cvf/Cvf.h"
#include "avtp/cvf/H264.h"
#include "avtp/CommonHeader.h"
Expand Down
1 change: 0 additions & 1 deletion examples/cvf/cvf-talker.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
#include <string.h>
#include <unistd.h>

#include "avtp.h"
#include "avtp/cvf/Cvf.h"
#include "avtp/cvf/H264.h"
#include "common.h"
Expand Down
50 changes: 48 additions & 2 deletions include/avtp/CommonHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ typedef struct {
* Enumeration over all IEEE 1722 header fields. The naming convention used is
* AVTP_<MSG_TYPE>_FIELD_<FIEL_NAME>.
*/
typedef enum {
typedef enum Avtp_CommonHeaderField{
/* Common AVTP header fields */
AVTP_COMMON_HEADER_FIELD_SUBTYPE = 0,
AVTP_COMMON_HEADER_FIELD_H,
Expand Down Expand Up @@ -104,4 +104,50 @@ int Avtp_CommonHeader_GetField(Avtp_CommonHeader_t* avtp_pdu, Avtp_CommonHeaderF
* @returns This function returns 0 if the data field was successfully set in
* the 1722 AVTP PDU.
*/
int Avtp_CommonHeader_SetField(Avtp_CommonHeader_t* avtp_pdu, Avtp_CommonHeaderField_t field, uint64_t value);
int Avtp_CommonHeader_SetField(Avtp_CommonHeader_t* avtp_pdu, Avtp_CommonHeaderField_t field, uint64_t value);

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

struct avtp_common_pdu {
uint32_t subtype_data;
uint8_t pdu_specific[0];
} __attribute__ ((__packed__));

struct avtp_stream_pdu {
uint32_t subtype_data;
uint64_t stream_id;
uint32_t avtp_time;
uint32_t format_specific;
uint32_t packet_info;
uint8_t avtp_payload[0];
} __attribute__ ((__packed__));

#define AVTP_FIELD_SUBTYPE (AVTP_COMMON_HEADER_FIELD_SUBTYPE)
#define AVTP_FIELD_VERSION (AVTP_COMMON_HEADER_FIELD_VERSION)
#define AVTP_FIELD_MAX (AVTP_COMMON_HEADER_FIELD_MAX)

/* Get value from Common AVTPDU field.
* @pdu: Pointer to PDU struct.
* @field: PDU field to be retrieved.
* @val: Pointer to variable which the retrieved value should be saved.
*
* Returns:
* 0: Success.
* -EINVAL: If any argument is invalid.
*/
int avtp_pdu_get(const struct avtp_common_pdu *pdu, Avtp_CommonHeaderField_t field,
uint32_t *val);

/* Set value from Common AVTPDU field.
* @pdu: Pointer to PDU struct.
* @field: PDU field to be set.
* @val: Value to be set.
*
* Returns:
* 0: Success.
* -EINVAL: If any argument is invalid.
*/
int avtp_pdu_set(struct avtp_common_pdu *pdu, Avtp_CommonHeaderField_t field,
uint32_t val);
1 change: 0 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ project(
avtp_lib = library(
'open1722',
[
'src/avtp.c',
'src/avtp/Utils.c',
'src/avtp/acf/Ntscf.c',
'src/avtp/acf/Tscf.c',
Expand Down
21 changes: 21 additions & 0 deletions src/avtp/CommonHeader.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,24 @@ int Avtp_CommonHeader_SetField(Avtp_CommonHeader_t* avtp_pdu, Avtp_CommonHeaderF
{
return Avtp_SetField(Avtp_CommonHeaderFieldDesc, AVTP_COMMON_HEADER_FIELD_MAX, (uint8_t*)avtp_pdu, (uint8_t)field, value);
}

/******************************************************************************
* Legacy API
*****************************************************************************/
int avtp_pdu_get(const struct avtp_common_pdu *pdu, Avtp_CommonHeaderField_t field,
uint32_t *val)
{
uint64_t temp;
int ret;
ret = Avtp_CommonHeader_GetField((Avtp_CommonHeader_t*) pdu, field, &temp);
if (val == NULL) return -EINVAL;

*val = (uint32_t)temp;
return ret;
}

int avtp_pdu_set(struct avtp_common_pdu *pdu, Avtp_CommonHeaderField_t field,
uint32_t value)
{
return Avtp_CommonHeader_SetField((Avtp_CommonHeader_t*) pdu, field, value);
}
3 changes: 2 additions & 1 deletion unit/test-aaf.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
#include <setjmp.h>
#include <cmocka.h>
#include <arpa/inet.h>
#include <errno.h>

#include "avtp.h"
#include "avtp/CommonHeader.h"
#include "avtp/aaf/PcmStream.h"

static void aaf_get_field_null_pdu(void **state)
Expand Down
2 changes: 1 addition & 1 deletion unit/test-avtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
#include <setjmp.h>
#include <cmocka.h>
#include <arpa/inet.h>
#include <errno.h>

#include "avtp.h"
#include "avtp/CommonHeader.h"

static void get_field_null_pdu(void **state)
Expand Down
3 changes: 2 additions & 1 deletion unit/test-crf.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
#include <cmocka.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <errno.h>

#include "avtp.h"
#include "avtp/CommonHeader.h"
#include "avtp/Crf.h"

static void crf_get_field_null_pdu(void **state)
Expand Down
3 changes: 2 additions & 1 deletion unit/test-cvf.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@
#include <setjmp.h>
#include <cmocka.h>
#include <arpa/inet.h>
#include <errno.h>

#include "avtp.h"
#include "avtp/CommonHeader.h"
#include "avtp/cvf/Cvf.h"
#include "avtp/cvf/H264.h"

Expand Down
3 changes: 2 additions & 1 deletion unit/test-rvf.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@
#include <cmocka.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <errno.h>

#include "avtp.h"
#include "avtp/CommonHeader.h"
#include "avtp/Rvf.h"

static void rvf_get_field_null_pdu(void **state)
Expand Down

0 comments on commit 49a439a

Please sign in to comment.