Skip to content

Commit

Permalink
Fix versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanreg committed Jun 23, 2024
1 parent 92e7d2a commit 3e33a9c
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 39 deletions.
9 changes: 9 additions & 0 deletions libavtransport/avtransport.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <string.h>

#include <avtransport/avtransport.h>
#include <avtransport/version.h>

#include "common.h"

Expand Down Expand Up @@ -88,3 +89,11 @@ void avt_log(void *ctx, enum AVTLogLevel level, const char *fmt, ...)

va_end(args);
}

uint32_t avt_version_int(void)
{
return (AVTRANSPORT_VERSION_MAJOR << 16) |
(AVTRANSPORT_VERSION_MINOR << 8) |
(AVTRANSPORT_VERSION_MICRO << 0);

}
9 changes: 5 additions & 4 deletions libavtransport/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/

#include <stdlib.h>
#include <avtransport/version.h>

#include "connection_internal.h"
#include "protocol_common.h"
Expand Down Expand Up @@ -87,14 +88,14 @@ static int send_session_start_pkt(AVTConnection *conn)
.pkt = AVT_SESSION_START_HDR(
.session_seq = conn->session_seq,
.session_flags = 0x0,
.producer_major = PROJECT_VERSION_MAJOR,
.producer_minor = PROJECT_VERSION_MINOR,
.producer_micro = PROJECT_VERSION_MICRO,
.producer_major = AVTRANSPORT_VERSION_MAJOR,
.producer_minor = AVTRANSPORT_VERSION_MINOR,
.producer_micro = AVTRANSPORT_VERSION_MICRO,
),
};

memcpy(p.pkt.session_start.session_uuid, conn->addr.uuid, 16);
memccpy(p.pkt.session_start.producer_name, PROJECT_NAME,
memccpy(p.pkt.session_start.producer_name, "avtransport",
'\0', sizeof(p.pkt.session_start.producer_name));

int err = avt_scheduler_push(&conn->out_scheduler, &p);
Expand Down
1 change: 1 addition & 0 deletions libavtransport/include/avtransport/avtransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "connection.h"
#include "send.h"
#include "receive.h"
#include "version.h"

enum AVTLogLevel {
AVT_LOG_QUIET = -(1 << 0),
Expand Down
6 changes: 3 additions & 3 deletions libavtransport/include/avtransport/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ avtransport_spec_pub_headers = custom_target('packet*',

# Version header
version_h_data = configuration_data()
version_h_data.set('AVTRANSPORT_API_VERSION_MAJOR', avtransport_api_version_major)
version_h_data.set('AVTRANSPORT_API_VERSION_MINOR', avtransport_api_version_minor)
version_h_data.set('AVTRANSPORT_API_VERSION_MICRO', avtransport_api_version_micro)
version_h_data.set('AVTRANSPORT_VERSION_MAJOR', avtransport_version_major)
version_h_data.set('AVTRANSPORT_VERSION_MINOR', avtransport_version_minor)
version_h_data.set('AVTRANSPORT_VERSION_MICRO', avtransport_version_micro)
version_h_target = configure_file(input: 'version.h.in',
output: 'version.h',
configuration: version_h_data
Expand Down
23 changes: 17 additions & 6 deletions libavtransport/include/avtransport/version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,27 @@
#ifndef AVTRANSPORT_VERSION_H
#define AVTRANSPORT_VERSION_H

#define AVTRANSPORT_API_VERSION_MAJOR @AVTRANSPORT_API_VERSION_MAJOR@
#define AVTRANSPORT_API_VERSION_MINOR @AVTRANSPORT_API_VERSION_MINOR@
#define AVTRANSPORT_API_VERSION_MICRO @AVTRANSPORT_API_VERSION_MICRO@
#include <stdint.h>
#include <avtransport/utils.h>

/**
* Version from which the headers were built.
*/
#define AVTRANSPORT_VERSION_MAJOR @AVTRANSPORT_VERSION_MAJOR@
#define AVTRANSPORT_VERSION_MINOR @AVTRANSPORT_VERSION_MINOR@
#define AVTRANSPORT_VERSION_MICRO @AVTRANSPORT_VERSION_MICRO@

/**
* Extract versions from the value returned by
* avtransport_version_int()
*/
#define AVTRANSPORT_API_MAJOR(v) (((v) >> 16) & 0xFF)
#define AVTRANSPORT_API_MINOR(v) (((v) >> 8) & 0xFF)
#define AVTRANSPORT_API_MICRO(v) (((v) >> 0) & 0xFF)
#define AVTRANSPORT_GET_VER_MAJOR(v) (((v) >> 16) & 0xFF)
#define AVTRANSPORT_GET_VER_MINOR(v) (((v) >> 8) & 0xFF)
#define AVTRANSPORT_GET_VER_MICRO(v) (((v) >> 0) & 0xFF)

/**
* Returns the version of the library.
*/
AVT_API uint32_t avt_version_int(void);

#endif /* AVTRANSPORT_VERSION_H */
12 changes: 6 additions & 6 deletions libavtransport/io_null.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
#include <stdlib.h>
#include <errno.h>

#include <avtransport/version.h>

#include "io_common.h"
#include "utils_internal.h"
#include "bytestream.h"
#include "packet_encode.h"

#include "config.h"

struct AVTIOCtx {
uint64_t seq;
avt_pos rpos;
Expand Down Expand Up @@ -85,11 +85,11 @@ static avt_pos null_input(AVTIOCtx *io, AVTBuffer *buf, size_t len,
union AVTPacketData pkt = { .session_start = {
.global_seq = io->seq++,
.session_flags = 0x0,
.producer_major = PROJECT_VERSION_MAJOR,
.producer_minor = PROJECT_VERSION_MINOR,
.producer_micro = PROJECT_VERSION_MICRO,
.producer_major = AVTRANSPORT_VERSION_MAJOR,
.producer_minor = AVTRANSPORT_VERSION_MINOR,
.producer_micro = AVTRANSPORT_VERSION_MICRO,
}};
memcpy(pkt.session_start.producer_name, PROJECT_NAME, strlen(PROJECT_NAME));
memcpy(pkt.session_start.producer_name, "avtransport", strlen("avtransport"));

avt_encode_session_start(&bs, pkt.session_start);

Expand Down
4 changes: 2 additions & 2 deletions libavtransport/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ endif
if host_machine.system() == 'windows'
avtransport_soversion = ''
else
avtransport_soversion = avtransport_api_version_major
avtransport_soversion = meson.project_version()
endif

avtransport_inc = include_directories('./include')
Expand Down Expand Up @@ -128,7 +128,7 @@ avtransport_lib = library('avtransport',
sources: avtransport_spec_pub_headers,
include_directories: avtransport_inc,
dependencies: avtransport_deps_list,
version: avtransport_soname_version,
version: meson.project_version(),
soversion: avtransport_soversion,
)

Expand Down
18 changes: 3 additions & 15 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,9 @@ spec_file = files('draft-avtransport-spec.bs')

# library version
avtransport_version_split = meson.project_version().split('.')
avtransport_ver_major = avtransport_version_split[0]
avtransport_ver_minor = avtransport_version_split[1]
avtransport_ver_micro = avtransport_version_split[2]

# api version
avtransport_soname_version = '0.0.4'
avtransport_api_version_split = avtransport_soname_version.split('.')
avtransport_api_version_major = avtransport_api_version_split[0]
avtransport_api_version_minor = avtransport_api_version_split[1]
avtransport_api_version_micro = avtransport_api_version_split[2]
avtransport_version_major = avtransport_version_split[0]
avtransport_version_minor = avtransport_version_split[1]
avtransport_version_micro = avtransport_version_split[2]

# Python
#============================================================================
Expand Down Expand Up @@ -153,13 +146,8 @@ endif
# Configure file
#============================================================================
conf = configuration_data()
conf.set_quoted('PROJECT_NAME', meson.project_name())
conf.set_quoted('PROJECT_VERSION_STRING', meson.project_version())

conf.set('PROJECT_VERSION_MAJOR', avtransport_ver_major)
conf.set('PROJECT_VERSION_MINOR', avtransport_ver_minor)
conf.set('PROJECT_VERSION_MICRO', avtransport_ver_micro)

conf.set('CONFIG_DEFAULT_PORT', '8212')
conf.set('CONFIG_DEFAULT_PORT_STR', '"8212"')
conf.set('CONFIG_DEFAULT_TYPE', 'AVT_PROTOCOL_UDP')
Expand Down
6 changes: 3 additions & 3 deletions tools/avcat.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ int main(int argc, char **argv)
AVTContext *avt;
AVTContextOptions ctx_opts = {
.producer_name = "avcat",
.producer_ver = { PROJECT_VERSION_MAJOR,
PROJECT_VERSION_MICRO,
PROJECT_VERSION_MINOR },
.producer_ver = { AVTRANSPORT_VERSION_MAJOR,
AVTRANSPORT_VERSION_MICRO,
AVTRANSPORT_VERSION_MINOR },
};

ret = avt_init(&avt, &ctx_opts);
Expand Down

0 comments on commit 3e33a9c

Please sign in to comment.