Skip to main content
Part of Shared Memory Image Transport C API the shared memory image transport API server interface. #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "shared_memory_image_client.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <pthread.h>
#include <unistd.h>
Go to the source code of this file.

Macros

Functions

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 interface is used to create/destroy a stream, albeit with unique option flags. The server does not use the SharedMemoryImageStream_lock() / SharedMemoryImageStream_unlock() functions. Instead, it calls SharedMemoryImageStream_putframe() 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() with the IMAGESTREAM_OPTIONS_SERVER option.
  3. Periodically, the server may push a new image:
    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:
Definition in file shared_memory_image_client_priv.h.

Macro Definition Documentation

IMAGESTREAM_OPTIONS_INITBUFFERHEADERS

set if the create call should initialize the buffer state Definition at line 132 of file shared_memory_image_client_priv.h.

IMAGESTREAM_OPTIONS_NOTHREADS

if set, the mutex and monitoring thread will not be created Definition at line 133 of file shared_memory_image_client_priv.h.

IMAGESTREAM_OPTIONS_SERVER

these options should be set for server streams Definition at line 135 of file shared_memory_image_client_priv.h.

Function Documentation

SharedMemoryImageStream_putframe()

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 Returns SharedMemoryImageError - the return code for the operation