Skip to content

Commit

Permalink
Add padding to option structures to avoid ABI breakage
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanreg committed Jun 29, 2024
1 parent 8fe1b46 commit 51e901c
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 1 deletion.
3 changes: 3 additions & 0 deletions libavtransport/include/avtransport/avtransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
15 changes: 15 additions & 0 deletions libavtransport/include/avtransport/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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 {
Expand Down Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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;

/**
Expand Down
13 changes: 12 additions & 1 deletion libavtransport/include/avtransport/receive.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
3 changes: 3 additions & 0 deletions libavtransport/include/avtransport/send.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions libavtransport/include/avtransport/stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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

0 comments on commit 51e901c

Please sign in to comment.