/* *************************************************************
* Copyright 2017-2020 ANSYS, Inc.
* All Rights Reserved.
*
* Restricted Rights Legend
*
* Use, duplication, or disclosure of this
* software and its documentation by the
* Government is subject to restrictions as
* set forth in subdivision [(b)(3)(ii)] of
* the Rights in Technical Data and Computer
* Software clause at 52.227-7013.
* *************************************************************
*/
#ifndef ___ENSIGHT_GRPC_SHMEM_CLIENT_H___
#define ___ENSIGHT_GRPC_SHMEM_CLIENT_H___
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#define IMAGESTREAM_API_VERSION "1.0"
/* SharedMemoryImageError Error values */
#define IMAGESTREAM_UNCONNECTED 4
#define IMAGESTREAM_RECONNECTING 3
#define IMAGESTREAM_NO_FRAMEAVAILABLE 2
#define IMAGESTREAM_NO_BUFFERAVAILABLE 1
#define IMAGESTREAM_NOERROR 0
/* negative numbers are actual errors, positive numbers are not actually errors */
#define IMAGESTREAM_BAD_ARGS -1
#define IMAGESTREAM_NOT_LOCKED -2
#define IMAGESTREAM_BAD_FILE_SIZE -3
#define IMAGESTREAM_UNABLE_TO_OPEN_FILE -4
#define IMAGESTREAM_UNABLE_TO_MAP_FILE -5
#define IMAGESTREAM_MEMORY_ALLOC_ERROR -6
#define IMAGESTREAM_THREAD_CREATE_ERROR -7
#define IMAGESTREAM_IS_SERVER -8
#define IMAGESTREAM_IS_NOTSERVER -9
#define IMAGESTREAM_FRAME_TOO_LARGE -10
#define IMAGESTREAM_LOCKED -11
/* valid stream creation options */
#define IMAGESTREAM_OPTIONS_NONE 0x00000000
/* server options consume first 8 bits */
#define IMAGESTREAM_OPTIONS_FLIPVERTICAL 0x00000100
/* core type definitions */
/* error codes, see defines above */
typedef int SharedMemoryImageError;
/* stream interface handle */
typedef struct _SharedMemoryImageStream *SharedMemoryImageStream;
typedef struct _SharedMemoryFrame {
uint32_t iFrame;
uint32_t iWidth;
uint32_t iHeight;
uint8_t *buffer;
} *SharedMemoryFrame;
SharedMemoryImageError SharedMemoryImageStream_create(const char *filename,
uint32_t options, SharedMemoryImageStream *stream);
SharedMemoryImageError SharedMemoryImageStream_lock(SharedMemoryImageStream stream,
SharedMemoryFrame *frame);
SharedMemoryImageError SharedMemoryImageStream_unlock(SharedMemoryImageStream stream);
SharedMemoryImageError SharedMemoryImageStream_destroy(SharedMemoryImageStream stream);
const char *SharedMemoryImageStream_errorstring(SharedMemoryImageError err);
#ifdef __cplusplus
}
#endif
#endif