From 51e901c191737af0e207749cb53b49a5daf57b37 Mon Sep 17 00:00:00 2001 From: Lynne Date: Sat, 29 Jun 2024 06:49:45 +0200 Subject: [PATCH] Add padding to option structures to avoid ABI breakage --- libavtransport/include/avtransport/avtransport.h | 3 +++ libavtransport/include/avtransport/connection.h | 15 +++++++++++++++ libavtransport/include/avtransport/receive.h | 13 ++++++++++++- libavtransport/include/avtransport/send.h | 3 +++ libavtransport/include/avtransport/stream.h | 6 ++++++ 5 files changed, 39 insertions(+), 1 deletion(-) diff --git a/libavtransport/include/avtransport/avtransport.h b/libavtransport/include/avtransport/avtransport.h index b958656..3afd34b 100644 --- a/libavtransport/include/avtransport/avtransport.h +++ b/libavtransport/include/avtransport/avtransport.h @@ -54,6 +54,9 @@ typedef struct AVTContextOptions { char producer_name[16]; /* Name of the project linking to libavtransport */ uint16_t producer_ver[3]; /* Major, minor, micro version */ + + /* Padding to allow for future options. Must always be set to 0. */ + uint8_t padding[4096 - 16*1 - 3*2 - 0*4 - 2*8]; } AVTContextOptions; /* Allocate an AVTransport context with the given context options. */ diff --git a/libavtransport/include/avtransport/connection.h b/libavtransport/include/avtransport/connection.h index 57c5697..1dafe69 100644 --- a/libavtransport/include/avtransport/connection.h +++ b/libavtransport/include/avtransport/connection.h @@ -199,6 +199,9 @@ typedef struct AVTConnectionInfo { /* Opaque pointer which will be used for the data() callback. */ void *opaque; } pkt; + + /* Padding to allow for future options. */ + uint8_t padding_u[1024 - 17*1 - 1*2 - 5*4 - 0*8]; }; /* Input options */ @@ -210,6 +213,9 @@ typedef struct AVTConnectionInfo { * automatic (very rarely), higher values increase overhead * and decrease potential errors, negative values disables decoding. */ int ldpc_iterations; + + /* Padding to allow for future options. Must always be set to 0. */ + uint8_t padding[1024 - 0*1 - 0*2 - 1*4 - 1*8]; } input_opts; struct { @@ -246,11 +252,17 @@ typedef struct AVTConnectionInfo { * - N: In addition, send one every N packets (segmentation is ignored). */ unsigned int session_start_freq; + + /* Padding to allow for future options. Must always be set to 0. */ + uint8_t padding[1024 - 0*1 - 0*2 - 1*4 - 2*8]; } output_opts; /* When greater than 0, enables asynchronous mode. * Values greater than 1 are reserved. */ int async; + + /* Padding to allow for future options. Must always be set to 0. */ + uint8_t padding[1024 - 0*1 - 0*2 - 1*4 - 0*8]; } AVTConnectionInfo; /** @@ -357,6 +369,9 @@ typedef struct AVTConnectionStatus { /* Total duration of all packets buffered (timebase: 1 nanosecond) */ int64_t buffer_duration; } tx; + + /* Padding to allow for future options. Must always be set to 0. */ + uint8_t padding[4096 - 0*1 - 0*2 - 3*4 - 10*8]; } AVTConnectionStatus; /** diff --git a/libavtransport/include/avtransport/receive.h b/libavtransport/include/avtransport/receive.h index ec318cb..e72e56c 100644 --- a/libavtransport/include/avtransport/receive.h +++ b/libavtransport/include/avtransport/receive.h @@ -32,7 +32,18 @@ #include "utils.h" typedef struct AVTReceiveOptions { - ; + /* Setting this flag to 1 enables receival of incomplete packets. + * Regions with no data are set to 0. + * + * NOTE: Data from compressed packets will only be passed if decompression + * (partially) succeeds. + * NOTE: raw audio and video packets are always passed, even if incomplete, + * as long as they are uncompressed. + */ + bool accept_incomplete; + + /* Padding to allow for future options. Must always be set to 0. */ + uint8_t padding[4096 - 1*1 - 0*2 - 0*4 - 0*8]; } AVTReceiveOptions; /* List of callbacks. All are optional. */ diff --git a/libavtransport/include/avtransport/send.h b/libavtransport/include/avtransport/send.h index 3fbb2e4..45b3715 100644 --- a/libavtransport/include/avtransport/send.h +++ b/libavtransport/include/avtransport/send.h @@ -66,6 +66,9 @@ typedef struct AVTSenderOptions { /* Set to true to enable sending hash packets for all packets with a payload. */ bool hash; + + /* Padding to allow for future options. Must always be set to 0. */ + uint8_t padding[4096 - 1*8 - 0*16 - 3*32 - 0*64]; } AVTSenderOptions; /* Open a send context and immediately send/write a stream session packet. diff --git a/libavtransport/include/avtransport/stream.h b/libavtransport/include/avtransport/stream.h index b2ae6fe..2a797b0 100644 --- a/libavtransport/include/avtransport/stream.h +++ b/libavtransport/include/avtransport/stream.h @@ -70,6 +70,9 @@ typedef struct AVTStream { /* libavtransport private stream data. Do not touch or use. */ struct AVTStreamPriv *priv; + + /* Padding to allow for future options. Must always be set to 0. */ + uint8_t padding[4096]; } AVTStream; typedef struct AVTPacket { @@ -80,6 +83,9 @@ typedef struct AVTPacket { int64_t pts; int64_t dts; int64_t duration; + + /* Padding to allow for future options. Must always be set to 0. */ + uint8_t padding[64]; } AVTPacket; #endif