> ## Documentation Index
> Fetch the complete documentation index at: https://developer.synopsys.com/llms.txt
> Use this file to discover all available pages before exploring further.

# shared_memory_image_client_priv.h File Reference

Part of [Shared Memory Image Transport](https://developer.synopsys.com/docs/ensight/ensight-apis/2025-r2/group__shmem.md)

C API the shared memory image transport API server interface.

`#include <stdio.h>`\
&#x20;`#include <stdlib.h>`\
&#x20;`#include <string.h>`\
&#x20;`#include "shared_memory_image_client.h"`\
&#x20;`#include <sys/types.h>`\
&#x20;`#include <sys/stat.h>`\
&#x20;`#include <fcntl.h>`\
&#x20;`#include <sys/mman.h>`\
&#x20;`#include <pthread.h>`\
&#x20;`#include <unistd.h>`\


[Go to the source code of this file.](https://developer.synopsys.com/docs/ensight/ensight-apis/2025-r2/shared__memory__image__client__priv_8h_source)

## Macros

| Type | Name |
| - | - |
| #define | [IMAGESTREAM\_OPTIONS\_INITBUFFERHEADERS](#a24ac2d665ce98370e25639bba2d992b6) 0x00000001 |
| #define | [IMAGESTREAM\_OPTIONS\_NOTHREADS](#a673fd1d2f27007af83467699cb53614f) 0x00000002 |
| #define | [IMAGESTREAM\_OPTIONS\_SERVER](#aa87740042e4f5882fa4c990a6528c2e3) [IMAGESTREAM\_OPTIONS\_INITBUFFERHEADERS](#a24ac2d665ce98370e25639bba2d992b6)\|[IMAGESTREAM\_OPTIONS\_NOTHREADS](#a673fd1d2f27007af83467699cb53614f) |

## Functions

| Type | Name |
| - | - |
| DEV [SharedMemoryImageError](https://developer.synopsys.com/docs/ensight/ensight-apis/2025-r2/shared__memory__image__client_8h.md#a0496a9a3db499fa9145fe97d2e6dae9a) | [SharedMemoryImageStream\_putframe](#abe3cb5374af97eeccf691864f6e2b2ad) ([SharedMemoryImageStream](https://developer.synopsys.com/docs/ensight/ensight-apis/2025-r2/shared__memory__image__client_8h.md#af5b8eb2ae90823f10e9a17698ea80749) stream, [SharedMemoryFrame](https://developer.synopsys.com/docs/ensight/ensight-apis/2025-r2/shared__memory__image__client_8h.md#a995c49496fcc1a41fb2d104c6473223b) frame) SharedMemoryImageStream\_putframe push a new image into a server image stream channel. |

## Detailed Description

C API the shared memory image transport API server interface.

**Version**

1.0

This file describes the internal format of the shared memory system and the inner workings of the buffer state machine. It also provides the interface to a shared memory image server.\


When creating a shared memory transport server, the [shared\_memory\_image\_client.h](https://developer.synopsys.com/docs/ensight/ensight-apis/2025-r2/shared__memory__image__client_8h.md) interface is used to create/destroy a stream, albeit with unique option flags. The server does not use the [SharedMemoryImageStream\_lock()](https://developer.synopsys.com/docs/ensight/ensight-apis/2025-r2/shared__memory__image__client_8h.md#afefb8f5297147640b46d1f9eb1e77c9e) / [SharedMemoryImageStream\_unlock()](https://developer.synopsys.com/docs/ensight/ensight-apis/2025-r2/shared__memory__image__client_8h.md#ac885e449551afd5fb5a7f19c5ec785a6) functions. Instead, it calls [SharedMemoryImageStream\_putframe()](#abe3cb5374af97eeccf691864f6e2b2ad) whenever it has new imagery it wants to push to the client.

Server operations are as follows:

1. The client creates/sizes the shared memory file that is to be used and passes the filename to the server.
2. The server creates/initializes the shared memory stream by calling [SharedMemoryImageStream\_create()](https://developer.synopsys.com/docs/ensight/ensight-apis/2025-r2/shared__memory__image__client_8h.md#a03ba052ae823b3e39fef153db8f03ea2) with the IMAGESTREAM\_OPTIONS\_SERVER option.

   ```cpp theme={null}
   SharedMemoryImageStream stream;
   SharedMemoryImageError err;
   err = SharedMemoryImageStream_create("shared_memory_file",
    IMAGESTREAM_OPTIONS_SERVER, &stream);
   if (err < IMAGESTREAM_NOERROR) <handle error>
   ```
3. Periodically, the server may push a new image:

   ```cpp theme={null}
   struct _SharedMemoryFrame frame;
   frame.iFrame = 10;
   frame.iWidth = 640;
   frame.iHeight = 480;
   frame.buffer = <some application buffer at least 648x480x3 bytes in size>;
   SharedMemoryImageError err;
   err = SharedMemoryImageStream_lock(stream, &frame));
   ```

   The data passed via buffer is copied into the shared memory space. Note, in some conditions, this function does not return a fatal error (\<0), instead the error code return can report that no client has made a connection or that the frame was dropped because the client has not been responding to the frames being pushed fast enough.
4. When the communication is finished, the server should call:

   ```cpp theme={null}
   SharedMemoryImageError err = SharedMemoryImageStream_destroy(stream);
   ```

Definition in file [shared\_memory\_image\_client\_priv.h](https://developer.synopsys.com/docs/ensight/ensight-apis/2025-r2/shared__memory__image__client__priv_8h_source).

## Macro Definition Documentation

### IMAGESTREAM\_OPTIONS\_INITBUFFERHEADERS

```cpp theme={null}
#define IMAGESTREAM_OPTIONS_INITBUFFERHEADERS 0x00000001
```

set if the create call should initialize the buffer state

Definition at line [132](https://developer.synopsys.com/docs/ensight/ensight-apis/2025-r2/shared__memory__image__client__priv_8h_source) of file [shared\_memory\_image\_client\_priv.h](https://developer.synopsys.com/docs/ensight/ensight-apis/2025-r2/shared__memory__image__client__priv_8h_source).

### IMAGESTREAM\_OPTIONS\_NOTHREADS

```cpp theme={null}
#define IMAGESTREAM_OPTIONS_NOTHREADS 0x00000002
```

if set, the mutex and monitoring thread will not be created

Definition at line [133](https://developer.synopsys.com/docs/ensight/ensight-apis/2025-r2/shared__memory__image__client__priv_8h_source) of file [shared\_memory\_image\_client\_priv.h](https://developer.synopsys.com/docs/ensight/ensight-apis/2025-r2/shared__memory__image__client__priv_8h_source).

### IMAGESTREAM\_OPTIONS\_SERVER

```cpp theme={null}
#define IMAGESTREAM_OPTIONS_SERVER IMAGESTREAM_OPTIONS_INITBUFFERHEADERS | IMAGESTREAM_OPTIONS_NOTHREADS
```

these options should be set for server streams

Definition at line [135](https://developer.synopsys.com/docs/ensight/ensight-apis/2025-r2/shared__memory__image__client__priv_8h_source) of file [shared\_memory\_image\_client\_priv.h](https://developer.synopsys.com/docs/ensight/ensight-apis/2025-r2/shared__memory__image__client__priv_8h_source).

## Function Documentation

### SharedMemoryImageStream\_putframe()

```cpp theme={null}
DEV SharedMemoryImageError SharedMemoryImageStream_putframe(
    SharedMemoryImageStream stream,
    SharedMemoryFrame frame
)
```

SharedMemoryImageStream\_putframe push a new image into a server image stream channel.

This function can only be called on a shared memory image stream created in server mode (options = IMAGESTREAM\_OPTIONS\_SERVER). The caller should create a frame structure with the frame number, the image size in pixels and a pointer to the image data (row major, tightly packed, RGB byte ordering). This call will copy the data pointed to by the buffer field, so the frame structure can be discarded after this call.

Return codes: These are not technically errors, but they do provide some feedback on the current disposition of the image transport stream.

IMAGESTREAM\_UNCONNECTED - no client has connected to this stream yet. IMAGESTREAM\_NO\_BUFFERAVAILABLE - the frame has not been queued because the client has not yet read previous frames. IMAGESTREAM\_NOERROR - the image frame has been queued up to be read by the client.

**Parameters**

| Direction | Name | Description |
| - | - | - |
| \[in] | stream | - the stream to push the image into |
| \[in] | frame | - the image to push into the stream |

**Returns**

SharedMemoryImageError - the return code for the operation
