    

 ## On this page

  

 

 # shared\_memory\_image\_client

 Last update: 16.07.2025 

[Go to the documentation of this file.](shared__memory__image__client_8h.xhtml)<a id="l00001" name="l00001"></a> 1 /\* \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

<a id="l00002" name="l00002"></a> 2  \* Copyright 2017-2020 ANSYS, Inc.

<a id="l00003" name="l00003"></a> 3  \* All Rights Reserved.

<a id="l00004" name="l00004"></a> 4  \*

<a id="l00005" name="l00005"></a> 5  \* Restricted Rights Legend

<a id="l00006" name="l00006"></a> 6  \*

<a id="l00007" name="l00007"></a> 7  \* Use, duplication, or disclosure of this

<a id="l00008" name="l00008"></a> 8  \* software and its documentation by the

<a id="l00009" name="l00009"></a> 9  \* Government is subject to restrictions as

<a id="l00010" name="l00010"></a> 10  \* set forth in subdivision \[(b)(3)(ii)\] of

<a id="l00011" name="l00011"></a> 11  \* the Rights in Technical Data and Computer

<a id="l00012" name="l00012"></a> 12  \* Software clause at 52.227-7013.

<a id="l00013" name="l00013"></a> 13  \* \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

<a id="l00014" name="l00014"></a> 14  \*/

<a id="l00015" name="l00015"></a> 15 

<a id="l00016" name="l00016"></a> 16 \#ifndef \_\_\_ENSIGHT\_GRPC\_SHMEM\_CLIENT\_H\_\_\_

<a id="l00017" name="l00017"></a> 17 \#define \_\_\_ENSIGHT\_GRPC\_SHMEM\_CLIENT\_H\_\_\_

<a id="l00018" name="l00018"></a> 18 

<a id="l00075" name="l00075"></a> 75 \#ifdef \_\_cplusplus

<a id="l00076" name="l00076"></a> 76 extern "C" {

<a id="l00077" name="l00077"></a> 77 \#endif

<a id="l00078" name="l00078"></a> 78 

<a id="l00079" name="l00079"></a> 79 \#include &lt;stdint.h&gt;

<a id="l00080" name="l00080"></a> 80 

<a id="l00081" name="l00081"></a>[ 81](shared__memory__image__client_8h.xhtml#a64df229b0ac6942d9bdee4b94b2c096a) \#define IMAGESTREAM\_API\_VERSION "1.0" 

<a id="l00083" name="l00083"></a> 83 /\* SharedMemoryImageError Error values \*/

<a id="l00084" name="l00084"></a>[ 84](shared__memory__image__client_8h.xhtml#a2cc13f7eda736fddce876cf5cae2c502) \#define IMAGESTREAM\_UNCONNECTED 4 

<a id="l00085" name="l00085"></a>[ 85](shared__memory__image__client_8h.xhtml#aa17e85c9001e414b9ac1db640884b944) \#define IMAGESTREAM\_RECONNECTING 3 

<a id="l00086" name="l00086"></a>[ 86](shared__memory__image__client_8h.xhtml#a7a7491d1019b67d55ac6488c0e3cb637) \#define IMAGESTREAM\_NO\_FRAMEAVAILABLE 2 

<a id="l00087" name="l00087"></a>[ 87](shared__memory__image__client_8h.xhtml#a78414d594aa9bb3f9bcea84c768d2826) \#define IMAGESTREAM\_NO\_BUFFERAVAILABLE 1 

<a id="l00088" name="l00088"></a>[ 88](shared__memory__image__client_8h.xhtml#af995dd87ffd7dd178eef1d343f7b72bf) \#define IMAGESTREAM\_NOERROR 0 

<a id="l00089" name="l00089"></a> 89 /\* negative numbers are actual errors, positive numbers are not actually errors \*/

<a id="l00090" name="l00090"></a>[ 90](shared__memory__image__client_8h.xhtml#ac2b3e8a36182f38dab1c5fd7a700a0c6) \#define IMAGESTREAM\_BAD\_ARGS -1 

<a id="l00091" name="l00091"></a>[ 91](shared__memory__image__client_8h.xhtml#ab7873d9185a495020022f80c238142bc) \#define IMAGESTREAM\_NOT\_LOCKED -2 

<a id="l00092" name="l00092"></a>[ 92](shared__memory__image__client_8h.xhtml#a54a45d2f039e6275c28249eedfa2515d) \#define IMAGESTREAM\_BAD\_FILE\_SIZE -3 

<a id="l00093" name="l00093"></a>[ 93](shared__memory__image__client_8h.xhtml#a5b68da171a139f688d317320d0a4eb3e) \#define IMAGESTREAM\_UNABLE\_TO\_OPEN\_FILE -4 

<a id="l00094" name="l00094"></a>[ 94](shared__memory__image__client_8h.xhtml#ac7eb344cf60975382720f71182dab490) \#define IMAGESTREAM\_UNABLE\_TO\_MAP\_FILE -5 

<a id="l00095" name="l00095"></a>[ 95](shared__memory__image__client_8h.xhtml#ae37af5c9dcf1d89b30b82ca4be840cfe) \#define IMAGESTREAM\_MEMORY\_ALLOC\_ERROR -6 

<a id="l00096" name="l00096"></a>[ 96](shared__memory__image__client_8h.xhtml#ac0d310d75b0c3ff53d524a0a5fe25b6f) \#define IMAGESTREAM\_THREAD\_CREATE\_ERROR -7 

<a id="l00097" name="l00097"></a>[ 97](shared__memory__image__client_8h.xhtml#ac914cc76952081d1ccc7c520e12770b1) \#define IMAGESTREAM\_IS\_SERVER -8 

<a id="l00098" name="l00098"></a>[ 98](shared__memory__image__client_8h.xhtml#aff57dd9d671a32995d562d68fcfa5fff) \#define IMAGESTREAM\_IS\_NOTSERVER -9 

<a id="l00099" name="l00099"></a>[ 99](shared__memory__image__client_8h.xhtml#ae5bdc8c10b2aa9db85d0955c99cba2c6) \#define IMAGESTREAM\_FRAME\_TOO\_LARGE -10 

<a id="l00100" name="l00100"></a>[ 100](shared__memory__image__client_8h.xhtml#a8389f19c29b726a2bed3c5831d1fb267) \#define IMAGESTREAM\_LOCKED -11 

<a id="l00102" name="l00102"></a> 102 /\* valid stream creation options \*/

<a id="l00103" name="l00103"></a>[ 103](shared__memory__image__client_8h.xhtml#a7fbe522f7a46875a755f07c8ff69e2df) \#define IMAGESTREAM\_OPTIONS\_NONE 0x00000000 

<a id="l00104" name="l00104"></a> 104 /\* server options consume first 8 bits \*/

<a id="l00105" name="l00105"></a>[ 105](shared__memory__image__client_8h.xhtml#a536935e36e51aade42c2a49f8ecd7ae1) \#define IMAGESTREAM\_OPTIONS\_FLIPVERTICAL 0x00000100 

<a id="l00107" name="l00107"></a> 107 /\* core type definitions \*/

<a id="l00108" name="l00108"></a> 108 /\* error codes, see defines above \*/

<a id="l00109" name="l00109"></a>[ 109](shared__memory__image__client_8h.xhtml#a0496a9a3db499fa9145fe97d2e6dae9a) typedef int [SharedMemoryImageError](shared__memory__image__client_8h.xhtml#a0496a9a3db499fa9145fe97d2e6dae9a); 

<a id="l00110" name="l00110"></a> 110 /\* stream interface handle \*/

<a id="l00111" name="l00111"></a>[ 111](shared__memory__image__client_8h.xhtml#af5b8eb2ae90823f10e9a17698ea80749) typedef struct _SharedMemoryImageStream *[SharedMemoryImageStream](shared__memory__image__client_8h.xhtml#af5b8eb2ae90823f10e9a17698ea80749); 

<a id="l00112" name="l00112"></a> 112 

<a id="l00115" name="l00115"></a>[ 115](struct___shared_memory_frame.xhtml) typedef struct [\_SharedMemoryFrame](struct___shared_memory_frame.xhtml) {

<a id="l00116" name="l00116"></a>[ 116](struct___shared_memory_frame.xhtml#a412d63c3ef8e7417be98997f72f3b0e5) uint32_t [iFrame](struct___shared_memory_frame.xhtml#a412d63c3ef8e7417be98997f72f3b0e5); 

<a id="l00117" name="l00117"></a>[ 117](struct___shared_memory_frame.xhtml#a6d26bbffc622333b9f11fbadecbd6f21) uint32_t [iWidth](struct___shared_memory_frame.xhtml#a6d26bbffc622333b9f11fbadecbd6f21); 

<a id="l00118" name="l00118"></a>[ 118](struct___shared_memory_frame.xhtml#ab21b6d402e01098565be5024de341ec7) uint32_t [iHeight](struct___shared_memory_frame.xhtml#ab21b6d402e01098565be5024de341ec7); 

<a id="l00119" name="l00119"></a>[ 119](struct___shared_memory_frame.xhtml#a7cff19a44525e74c5800b1e2f9e4cc98) uint8_t *[buffer](struct___shared_memory_frame.xhtml#a7cff19a44525e74c5800b1e2f9e4cc98); 

<a id="l00120" name="l00120"></a>[ 120](shared__memory__image__client_8h.xhtml#a995c49496fcc1a41fb2d104c6473223b) } *[SharedMemoryFrame](shared__memory__image__client_8h.xhtml#a995c49496fcc1a41fb2d104c6473223b); 

<a id="l00121" name="l00121"></a> 121 

<a id="l00149" name="l00149"></a>[ 149](shared__memory__image__client_8h.xhtml#a03ba052ae823b3e39fef153db8f03ea2) [SharedMemoryImageError](shared__memory__image__client_8h.xhtml#a0496a9a3db499fa9145fe97d2e6dae9a) [SharedMemoryImageStream\_create](shared__memory__image__client_8h.xhtml#a03ba052ae823b3e39fef153db8f03ea2)(const char *filename, 

<a id="l00150" name="l00150"></a> 150 uint32_t options, [SharedMemoryImageStream](shared__memory__image__client_8h.xhtml#af5b8eb2ae90823f10e9a17698ea80749) *stream);

<a id="l00151" name="l00151"></a> 151 

<a id="l00175" name="l00175"></a>[ 175](shared__memory__image__client_8h.xhtml#afefb8f5297147640b46d1f9eb1e77c9e) [SharedMemoryImageError](shared__memory__image__client_8h.xhtml#a0496a9a3db499fa9145fe97d2e6dae9a) [SharedMemoryImageStream\_lock](shared__memory__image__client_8h.xhtml#afefb8f5297147640b46d1f9eb1e77c9e)([SharedMemoryImageStream](shared__memory__image__client_8h.xhtml#af5b8eb2ae90823f10e9a17698ea80749) stream, 

<a id="l00176" name="l00176"></a> 176 [SharedMemoryFrame](struct___shared_memory_frame.xhtml) *frame);

<a id="l00177" name="l00177"></a> 177 

<a id="l00189" name="l00189"></a>[ 189](shared__memory__image__client_8h.xhtml#ac885e449551afd5fb5a7f19c5ec785a6) [SharedMemoryImageError](shared__memory__image__client_8h.xhtml#a0496a9a3db499fa9145fe97d2e6dae9a) [SharedMemoryImageStream\_unlock](shared__memory__image__client_8h.xhtml#ac885e449551afd5fb5a7f19c5ec785a6)([SharedMemoryImageStream](shared__memory__image__client_8h.xhtml#af5b8eb2ae90823f10e9a17698ea80749) stream);

<a id="l00190" name="l00190"></a> 190 

<a id="l00200" name="l00200"></a>[ 200](shared__memory__image__client_8h.xhtml#a4ea47b6bda387b71ed5f91db329eff65) [SharedMemoryImageError](shared__memory__image__client_8h.xhtml#a0496a9a3db499fa9145fe97d2e6dae9a) [SharedMemoryImageStream\_destroy](shared__memory__image__client_8h.xhtml#a4ea47b6bda387b71ed5f91db329eff65)([SharedMemoryImageStream](shared__memory__image__client_8h.xhtml#af5b8eb2ae90823f10e9a17698ea80749) stream);

<a id="l00201" name="l00201"></a> 201 

<a id="l00211" name="l00211"></a>[ 211](shared__memory__image__client_8h.xhtml#aee181df230f340ac2841f0612176b189) const char *[SharedMemoryImageStream\_errorstring](shared__memory__image__client_8h.xhtml#aee181df230f340ac2841f0612176b189)([SharedMemoryImageError](shared__memory__image__client_8h.xhtml#a0496a9a3db499fa9145fe97d2e6dae9a) err);

<a id="l00212" name="l00212"></a> 212 

<a id="l00213" name="l00213"></a> 213 \#ifdef \_\_cplusplus

<a id="l00214" name="l00214"></a> 214 }

<a id="l00215" name="l00215"></a> 215 \#endif

<a id="l00216" name="l00216"></a> 216 

<a id="l00217" name="l00217"></a> 217 \#endif

[SharedMemoryImageStream\_create](shared__memory__image__client_8h.xhtml#a03ba052ae823b3e39fef153db8f03ea2)

SharedMemoryImageError SharedMemoryImageStream_create(const char *filename, uint32_t options, SharedMemoryImageStream *stream)

SharedMemoryImageStream_create create a stream client instance.



[SharedMemoryImageError](shared__memory__image__client_8h.xhtml#a0496a9a3db499fa9145fe97d2e6dae9a)

int SharedMemoryImageError

common error codes see the non-hex, non-string IMAGESTREAM macros

**Definition:** [shared\_memory\_image\_client.h:109](shared__memory__image__client_8h_source.xhtml#l00109)



[SharedMemoryImageStream\_destroy](shared__memory__image__client_8h.xhtml#a4ea47b6bda387b71ed5f91db329eff65)

SharedMemoryImageError SharedMemoryImageStream_destroy(SharedMemoryImageStream stream)

SharedMemoryImageStream_destroy destroy a stream interface, releasing its resources.



[SharedMemoryFrame](shared__memory__image__client_8h.xhtml#a995c49496fcc1a41fb2d104c6473223b)

struct _SharedMemoryFrame * SharedMemoryFrame

A reference to a frame of imagery. Note it does not own the buffer pointer.



[SharedMemoryImageStream\_unlock](shared__memory__image__client_8h.xhtml#ac885e449551afd5fb5a7f19c5ec785a6)

SharedMemoryImageError SharedMemoryImageStream_unlock(SharedMemoryImageStream stream)

SharedMemoryImageStream_unlock release a frame obtained by SharedMemoryImageStream_lock.



[SharedMemoryImageStream\_errorstring](shared__memory__image__client_8h.xhtml#aee181df230f340ac2841f0612176b189)

const char * SharedMemoryImageStream_errorstring(SharedMemoryImageError err)

SharedMemoryImageStream_errorstring convert an error code into a human string.



[SharedMemoryImageStream](shared__memory__image__client_8h.xhtml#af5b8eb2ae90823f10e9a17698ea80749)

struct _SharedMemoryImageStream * SharedMemoryImageStream

image transport stream pointer

**Definition:** [shared\_memory\_image\_client.h:111](shared__memory__image__client_8h_source.xhtml#l00111)



[SharedMemoryImageStream\_lock](shared__memory__image__client_8h.xhtml#afefb8f5297147640b46d1f9eb1e77c9e)

SharedMemoryImageError SharedMemoryImageStream_lock(SharedMemoryImageStream stream, SharedMemoryFrame *frame)

SharedMemoryImageStream_lock get a frame of pixels from the server.



[\_SharedMemoryFrame](struct___shared_memory_frame.xhtml)

**Definition:** [shared\_memory\_image\_client.h:115](shared__memory__image__client_8h_source.xhtml#l00115)



[\_SharedMemoryFrame::iFrame](struct___shared_memory_frame.xhtml#a412d63c3ef8e7417be98997f72f3b0e5)

uint32_t iFrame

monotonically increasing frame number

**Definition:** [shared\_memory\_image\_client.h:116](shared__memory__image__client_8h_source.xhtml#l00116)



[\_SharedMemoryFrame::iWidth](struct___shared_memory_frame.xhtml#a6d26bbffc622333b9f11fbadecbd6f21)

uint32_t iWidth

width of a frame in pixels

**Definition:** [shared\_memory\_image\_client.h:117](shared__memory__image__client_8h_source.xhtml#l00117)



[\_SharedMemoryFrame::buffer](struct___shared_memory_frame.xhtml#a7cff19a44525e74c5800b1e2f9e4cc98)

uint8_t * buffer

pointer to a packed RGBRGBRGB... (iWidth*iHeight*3) bytes array of pixels

**Definition:** [shared\_memory\_image\_client.h:119](shared__memory__image__client_8h_source.xhtml#l00119)



[\_SharedMemoryFrame::iHeight](struct___shared_memory_frame.xhtml#ab21b6d402e01098565be5024de341ec7)

uint32_t iHeight

height of a frame in pixels

**Definition:** [shared\_memory\_image\_client.h:118](shared__memory__image__client_8h_source.xhtml#l00118)