Skip to content

Commit

Permalink
gpmf-parser: manage symbol visbility for windows [MAGMA-2080]
Browse files Browse the repository at this point in the history
In order to be compliant with windows, set the visibility of the symbols to
hidden by default and import/export symbols accordingly when relevant.
  • Loading branch information
qdespinoy-gpsw committed Sep 13, 2021
1 parent 553fa8c commit 9a9bda1
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 37 deletions.
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ set_target_properties(GPMF_PARSER_BIN PROPERTIES OUTPUT_NAME "${PROJECT_NAME}")
add_library(GPMF_PARSER_LIB ${LIB_SOURCES})
set_target_properties(GPMF_PARSER_LIB PROPERTIES OUTPUT_NAME "${PROJECT_NAME}")

set_target_properties(${PROJECT_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden)

target_compile_definitions(
${PROJECT_NAME}
PUBLIC
$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:GPMFPARSER_STATIC>
PRIVATE
$<$<BOOL:${BUILD_SHARED_LIBS}>:GPMFPARSER_EXPORT>
)

if(NOT BUILD_SHARED_LIBS)
set(PC_EXTRA_C_FLAGS "-DGPMFPARSER_STATIC")
endif()

set(PC_LINK_FLAGS "-l${PROJECT_NAME}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc.in" "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc" @ONLY)

Expand Down
19 changes: 19 additions & 0 deletions GPMF_export.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

#if defined(_WIN32)
# if defined(GPMFPARSER_EXPORT)
# define GPMFPARSER_API __declspec(dllexport)
# elif defined(GPMFPARSER_STATIC)
# define GPMFPARSER_API
# else
# define GPMFPARSER_API __declspec(dllimport)
# endif
#else
# if defined(GPMFPARSER_EXPORT)
# define GPMFPARSER_API __attribute__((visibility("default")))
# elif defined(GPMFPARSER_STATIC)
# define GPMFPARSER_API
# else
# define GPMFPARSER_API __attribute__((visibility("default")))
# endif
#endif
74 changes: 38 additions & 36 deletions GPMF_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <stdint.h>
#include <stddef.h>
#include "GPMF_common.h"
#include "GPMF_export.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -58,48 +59,49 @@ typedef enum GPMF_LEVELS



// Prepare GPMF data
GPMF_ERR GPMF_Init(GPMF_stream *gs, uint32_t *buffer, uint32_t datasize); //Initialize a GPMF_stream for parsing a particular buffer.
GPMF_ERR GPMF_ResetState(GPMF_stream *gs); //Read from beginning of the buffer again
GPMF_ERR GPMF_CopyState(GPMF_stream *src, GPMF_stream *dst); //Copy state,
GPMF_ERR GPMF_Validate(GPMF_stream *gs, GPMF_LEVELS recurse); //Is the nest structure valid GPMF?

// Navigate through GPMF data
GPMF_ERR GPMF_Next(GPMF_stream *gs, GPMF_LEVELS recurse); //Step to the next GPMF KLV entrance, optionally recurse up or down nesting levels.
GPMF_ERR GPMF_FindPrev(GPMF_stream *gs, uint32_t fourCC, GPMF_LEVELS recurse); //find a previous FourCC -- at the current level only if recurse is false
GPMF_ERR GPMF_FindNext(GPMF_stream *gs, uint32_t fourCC, GPMF_LEVELS recurse); //find a particular FourCC upcoming -- at the current level only if recurse is false
GPMF_ERR GPMF_SeekToSamples(GPMF_stream *gs); //find the last FourCC in the current level, this is raw data for any STRM
// Prepare GPMF data
GPMFPARSER_API GPMF_ERR GPMF_Init(GPMF_stream *gs, uint32_t *buffer, uint32_t datasize); //Initialize a GPMF_stream for parsing a particular buffer.
GPMFPARSER_API GPMF_ERR GPMF_ResetState(GPMF_stream *gs); //Read from beginning of the buffer again
GPMFPARSER_API GPMF_ERR GPMF_CopyState(GPMF_stream *src, GPMF_stream *dst); //Copy state,
GPMFPARSER_API GPMF_ERR GPMF_Validate(GPMF_stream *gs, GPMF_LEVELS recurse); //Is the nest structure valid GPMF?

// Navigate through GPMF data
GPMFPARSER_API GPMF_ERR GPMF_Next(GPMF_stream *gs, GPMF_LEVELS recurse); //Step to the next GPMF KLV entrance, optionally recurse up or down nesting levels.
GPMFPARSER_API GPMF_ERR GPMF_FindPrev(GPMF_stream *gs, uint32_t fourCC, GPMF_LEVELS recurse); //find a previous FourCC -- at the current level only if recurse is false
GPMFPARSER_API GPMF_ERR GPMF_FindNext(GPMF_stream *gs, uint32_t fourCC, GPMF_LEVELS recurse); //find a particular FourCC upcoming -- at the current level only if recurse is false
GPMFPARSER_API GPMF_ERR GPMF_SeekToSamples(GPMF_stream *gs); //find the last FourCC in the current level, this is raw data for any STRM

// Get information about the current GPMF KLV
uint32_t GPMF_Key(GPMF_stream *gs); //return the current Key (FourCC)
GPMF_SampleType GPMF_Type(GPMF_stream *gs); //return the current Type (GPMF_Type)
uint32_t GPMF_StructSize(GPMF_stream *gs); //return the current sample structure size
uint32_t GPMF_Repeat(GPMF_stream *gs); //return the current repeat or the number of samples of this structure
uint32_t GPMF_PayloadSampleCount(GPMF_stream *gs); //return the current number of samples of this structure, supporting multisample entries.
uint32_t GPMF_ElementsInStruct(GPMF_stream *gs); //return the current number elements within the structure (e.g. 3-axis gyro)
uint32_t GPMF_RawDataSize(GPMF_stream *gs); //return the data size for the current GPMF KLV
void * GPMF_RawData(GPMF_stream *gs); //return a pointer the KLV data (which is Bigendian if the type is known.)
GPMFPARSER_API uint32_t GPMF_Key(GPMF_stream *gs); //return the current Key (FourCC)
GPMFPARSER_API GPMF_SampleType GPMF_Type(GPMF_stream *gs); //return the current Type (GPMF_Type)
GPMFPARSER_API uint32_t GPMF_StructSize(GPMF_stream *gs); //return the current sample structure size
GPMFPARSER_API uint32_t GPMF_Repeat(GPMF_stream *gs); //return the current repeat or the number of samples of this structure
GPMFPARSER_API uint32_t GPMF_PayloadSampleCount(GPMF_stream *gs); //return the current number of samples of this structure, supporting multisample entries.
GPMFPARSER_API uint32_t GPMF_ElementsInStruct(GPMF_stream *gs); //return the current number elements within the structure (e.g. 3-axis gyro)
GPMFPARSER_API uint32_t GPMF_RawDataSize(GPMF_stream *gs); //return the data size for the current GPMF KLV
GPMFPARSER_API void * GPMF_RawData(GPMF_stream *gs); //return a pointer the KLV data (which is Bigendian if the type is known.)


GPMF_ERR GPMF_Modify(GPMF_stream* gs, //find and inplace overwrite a GPMF KLV with new KLV, if the lengths match.
GPMFPARSER_API GPMF_ERR GPMF_Modify(GPMF_stream* gs, //find and inplace overwrite a GPMF KLV with new KLV, if the lengths match.
uint32_t origfourCC, uint32_t newfourCC, GPMF_SampleType newType, uint32_t newStructSize, uint32_t newRepeat, void* newData);

// Get information about where the GPMF KLV is nested
uint32_t GPMF_NestLevel(GPMF_stream *gs); //return the current nest level
uint32_t GPMF_DeviceID(GPMF_stream *gs); //return the current device ID (DVID), to seperate match sensor data from difference devices.
GPMF_ERR GPMF_DeviceName(GPMF_stream *gs, char *devicename_buf, uint32_t devicename_buf_size); //return the current device name (DVNM), to seperate match sensor data from difference devices.
GPMFPARSER_API uint32_t GPMF_NestLevel(GPMF_stream *gs); //return the current nest level
GPMFPARSER_API uint32_t GPMF_DeviceID(GPMF_stream *gs); //return the current device ID (DVID), to seperate match sensor data from difference devices.
GPMFPARSER_API GPMF_ERR GPMF_DeviceName(GPMF_stream *gs, char *devicename_buf, uint32_t devicename_buf_size); //return the current device name (DVNM), to seperate match sensor data from difference devices.

// Utilities for data types
uint32_t GPMF_SizeofType(GPMF_SampleType type); // GPMF equivalent to sizeof(type)
uint32_t GPMF_ExpandComplexTYPE(char *src, uint32_t srcsize, char *dst, uint32_t *dstsize); // GPMF using TYPE for cmple structure. { float val[16],uin32_t flags; } has type "f[8]L", this tools expands to the simpler format "ffffffffL"
uint32_t GPMF_SizeOfComplexTYPE(char *typearray, uint32_t typestringlength); // GPMF equivalent to sizeof(typedef) for complex types.
GPMF_ERR GPMF_Reserved(uint32_t key); // Test for a reverse GPMF Key, returns GPMF_OK is not reversed.
GPMFPARSER_API uint32_t GPMF_SizeofType(GPMF_SampleType type); // GPMF equivalent to sizeof(type)
GPMFPARSER_API uint32_t GPMF_ExpandComplexTYPE(char *src, uint32_t srcsize, char *dst, uint32_t *dstsize); // GPMF using TYPE for cmple structure. { float val[16],uin32_t flags; } has type "f[8]L", this tools expands to the simpler format "ffffffffL"
GPMFPARSER_API uint32_t GPMF_SizeOfComplexTYPE(char *typearray, uint32_t typestringlength); // GPMF equivalent to sizeof(typedef) for complex types.
GPMFPARSER_API GPMF_ERR GPMF_Reserved(uint32_t key); // Test for a reverse GPMF Key, returns GPMF_OK is not reversed.

//Tools for extracting sensor data
uint32_t GPMF_FormattedDataSize(GPMF_stream *gs); //return the decompressed data size for the current GPMF KLV
uint32_t GPMF_ScaledDataSize(GPMF_stream *gs, GPMF_SampleType type); //return the decompressed data size for the current GPMF KLV
GPMF_ERR GPMF_FormattedData(GPMF_stream *gs, void *buffer, uint32_t buffersize, uint32_t sample_offset, uint32_t read_samples); // extract 'n' samples into local endian memory format.
GPMF_ERR GPMF_ScaledData(GPMF_stream *gs, void *buffer, uint32_t buffersize, uint32_t sample_offset, uint32_t read_samples, GPMF_SampleType type); // extract 'n' samples into local endian memory format // return a point the KLV data.
//Tools for extracting sensor data
GPMFPARSER_API uint32_t GPMF_FormattedDataSize(GPMF_stream *gs); //return the decompressed data size for the current GPMF KLV
GPMFPARSER_API uint32_t GPMF_ScaledDataSize(GPMF_stream *gs, GPMF_SampleType type); //return the decompressed data size for the current GPMF KLV
GPMFPARSER_API GPMF_ERR GPMF_FormattedData(GPMF_stream *gs, void *buffer, uint32_t buffersize, uint32_t sample_offset, uint32_t read_samples); // extract 'n' samples into local endian memory format.
GPMFPARSER_API GPMF_ERR GPMF_ScaledData(GPMF_stream *gs, void *buffer, uint32_t buffersize, uint32_t sample_offset, uint32_t read_samples, GPMF_SampleType type); // extract 'n' samples into local endian memory format // return a point the KLV data.

//Tools for Compressed datatypes

Expand All @@ -113,11 +115,11 @@ typedef struct GPMF_codebook
} GPMF_codebook;


GPMF_ERR GPMF_AllocCodebook(size_t *cbhandle);
GPMF_ERR GPMF_FreeCodebook(size_t cbhandle);
GPMF_ERR GPMF_DecompressedSize(GPMF_stream *gs, uint32_t *neededsize);
GPMF_ERR GPMF_Decompress(GPMF_stream *gs, uint32_t *localbuf, uint32_t localbuf_size);
GPMF_ERR GPMF_Free(GPMF_stream* gs);
GPMFPARSER_API GPMF_ERR GPMF_AllocCodebook(size_t *cbhandle);
GPMFPARSER_API GPMF_ERR GPMF_FreeCodebook(size_t cbhandle);
GPMFPARSER_API GPMF_ERR GPMF_DecompressedSize(GPMF_stream *gs, uint32_t *neededsize);
GPMFPARSER_API GPMF_ERR GPMF_Decompress(GPMF_stream *gs, uint32_t *localbuf, uint32_t localbuf_size);
GPMFPARSER_API GPMF_ERR GPMF_Free(GPMF_stream* gs);


#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion gpmf-parser.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Name: @PROJECT_NAME@
Description: A low level GPMF parser
Version: 1.2.2
Libs: -L${libdir} @PC_LINK_FLAGS@
Cflags: -I${includedir} -I${includedir}/demo
Cflags: -I${includedir} -I${includedir}/demo @PC_EXTRA_C_FLAGS@

0 comments on commit 9a9bda1

Please sign in to comment.