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

# Write Shared Memory Endpoint API

> This file contains Shared mem module APIs.

**Header:** `spf/api/modules/wr_sh_mem_ep_api.h`

## Structures

### `data_cmd_wr_sh_mem_ep_data_buffer_t`

**Members**

<ParamField path="buf_addr_lsw" type="uint32_t">
  Lower 32 bits of the address of the buffer containing the data.
</ParamField>

<ParamField path="buf_addr_msw" type="uint32_t">
  Upper 32 bits of the address of the buffer containing the data.
</ParamField>

<ParamField path="mem_map_handle" type="uint32_t">
  Unique identifier for the shared memory address.
</ParamField>

<ParamField path="buf_size" type="uint32_t">
  Number of valid bytes available in the buffer for processing.
</ParamField>

<ParamField path="timestamp_lsw" type="uint32_t">
  Lower 32 bits of the 64-bit timestamp in microseconds of the first buffer sample.
</ParamField>

<ParamField path="timestamp_msw" type="uint32_t">
  Upper 32 bits of the 64-bit timestamp in microseconds of the first buffer sample.
</ParamField>

<ParamField path="flags" type="uint32_t">
  Bitfield of flags.
</ParamField>

### `data_cmd_rsp_wr_sh_mem_ep_data_buffer_done_t`

**Members**

<ParamField path="buf_addr_lsw" type="uint32_t">
  Lower 32 bits of the address of the buffer being returned.
</ParamField>

<ParamField path="buf_addr_msw" type="uint32_t">
  Upper 32 bits of the address of the buffer being returned.
</ParamField>

<ParamField path="mem_map_handle" type="uint32_t">
  Unique identifier for the shared memory address.
</ParamField>

<ParamField path="status" type="uint32_t">
  Status message (error code) that indicates whether the referenced buffer has been successfully consumed.
</ParamField>

### `data_cmd_wr_sh_mem_ep_data_buffer_v2_t`

**Members**

<ParamField path="data_buf_addr_lsw" type="uint32_t">
  Lower 32 bits of the address of the buffer containing the data.
</ParamField>

<ParamField path="data_buf_addr_msw" type="uint32_t">
  Upper 32 bits of the address of the buffer containing the data.
</ParamField>

<ParamField path="data_mem_map_handle" type="uint32_t">
  Unique identifier for the shared memory corresponding to data buffer address.
</ParamField>

<ParamField path="data_buf_size" type="uint32_t">
  Number of valid bytes available in the buffer for processing.
</ParamField>

<ParamField path="timestamp_lsw" type="uint32_t">
  Lower 32 bits of the 64-bit timestamp in microseconds of the first data buffer sample.
</ParamField>

<ParamField path="timestamp_msw" type="uint32_t">
  Upper 32 bits of the 64-bit timestamp in microseconds of the first data buffer sample.
</ParamField>

<ParamField path="flags" type="uint32_t">
  Bitfield of flags.
</ParamField>

<ParamField path="md_buf_addr_lsw" type="uint32_t">
  Lower 32 bits of the address of the buffer containing the metadata.
</ParamField>

<ParamField path="md_buf_addr_msw" type="uint32_t">
  Upper 32 bits of the address of the buffer containing the metadata.
</ParamField>

<ParamField path="md_mem_map_handle" type="uint32_t">
  Unique identifier for the shared memory corresponding to metadata buffer address.
</ParamField>

<ParamField path="md_buf_size" type="uint32_t">
  Number of valid bytes available in the metadata buffer for processing.
</ParamField>

### `data_cmd_rsp_wr_sh_mem_ep_data_buffer_done_v2_t`

**Members**

<ParamField path="data_buf_addr_lsw" type="uint32_t">
  Lower 32 bits of the address of the data buffer being returned.
</ParamField>

<ParamField path="data_buf_addr_msw" type="uint32_t">
  Upper 32 bits of the address of the data buffer being returned.
</ParamField>

<ParamField path="data_mem_map_handle" type="uint32_t">
  Unique identifier for the shared memory corresponding to data buffer address.
</ParamField>

<ParamField path="data_status" type="uint32_t">
  Status message (error code) that indicates whether the referenced data buffer has been successfully consumed.
</ParamField>

<ParamField path="md_buf_addr_lsw" type="uint32_t">
  Lower 32 bits of the address of the metadata buffer being returned.
</ParamField>

<ParamField path="md_buf_addr_msw" type="uint32_t">
  Upper 32 bits of the address of the metadata buffer being returned.
</ParamField>

<ParamField path="md_mem_map_handle" type="uint32_t">
  Unique identifier for the shared memory corresponding to metadata buffer address.
</ParamField>

<ParamField path="md_status" type="uint32_t">
  Status message (error code) that indicates whether the referenced metadata buffer has been successfully consumed.
</ParamField>

### `data_cmd_wr_sh_mem_ep_eos_t`

**Members**

<ParamField path="policy" type="uint32_t">
  Policy used to raise DATA\_CMD\_RSP\_WR\_SH\_MEM\_EP\_EOS\_RENDERED WR\_SH\_MEM\_EP\_EOS\_POLICY\_LAST WR\_SH\_MEM\_EP\_EOS\_POLICY\_EACH.
</ParamField>

### `data_cmd_rsp_wr_sh_mem_ep_eos_rendered_t`

**Members**

<ParamField path="module_instance_id" type="uint32_t">
  module instance id from which the DATA\_CMD\_RSP\_WR\_SH\_MEM\_EP\_EOS\_RENDERED is being raised Invalid (0) when dropped.
</ParamField>

<ParamField path="render_status" type="uint32_t">
  Render status - 1 - Rendered.
</ParamField>

## Type Definitions

### `data_cmd_wr_sh_mem_ep_data_buffer_t`

Structure for DATA\_CMD\_WR\_SH\_MEM\_EP\_DATA\_BUFFER.

```cpp theme={null}
typedef struct data_cmd_wr_sh_mem_ep_data_buffer_t data_cmd_wr_sh_mem_ep_data_buffer_t
```

### `data_cmd_rsp_wr_sh_mem_ep_data_buffer_done_t`

```cpp theme={null}
typedef struct data_cmd_rsp_wr_sh_mem_ep_data_buffer_done_t data_cmd_rsp_wr_sh_mem_ep_data_buffer_done_t
```

### `data_cmd_wr_sh_mem_ep_data_buffer_v2_t`

Structure for DATA\_CMD\_WR\_SH\_MEM\_EP\_DATA\_BUFFER\_V2.

```cpp theme={null}
typedef struct data_cmd_wr_sh_mem_ep_data_buffer_v2_t data_cmd_wr_sh_mem_ep_data_buffer_v2_t
```

### `data_cmd_rsp_wr_sh_mem_ep_data_buffer_done_v2_t`

```cpp theme={null}
typedef struct data_cmd_rsp_wr_sh_mem_ep_data_buffer_done_v2_t data_cmd_rsp_wr_sh_mem_ep_data_buffer_done_v2_t
```

### `data_cmd_wr_sh_mem_ep_eos_t`

Structure for DATA\_CMD\_WR\_SH\_MEM\_EP\_EOS.

```cpp theme={null}
typedef struct data_cmd_wr_sh_mem_ep_eos_t data_cmd_wr_sh_mem_ep_eos_t
```

### `data_cmd_rsp_wr_sh_mem_ep_eos_rendered_t`

Structure for DATA\_CMD\_RSP\_WR\_SH\_MEM\_EP\_EOS\_RENDERED.

```cpp theme={null}
typedef struct data_cmd_rsp_wr_sh_mem_ep_eos_rendered_t data_cmd_rsp_wr_sh_mem_ep_eos_rendered_t
```

## Macros

### `DATA_CMD_WR_SH_MEM_EP_DATA_BUFFER`

```c theme={null}
#define DATA_CMD_WR_SH_MEM_EP_DATA_BUFFER 0x04001000
```

### `WR_SH_MEM_EP_BIT_MASK_TIMESTAMP_VALID_FLAG`

Definition of a timestamp valid flag bitmask.

```c theme={null}
#define WR_SH_MEM_EP_BIT_MASK_TIMESTAMP_VALID_FLAG AR_NON_GUID(0x80000000)
```

### `WR_SH_MEM_EP_SHIFT_TIMESTAMP_VALID_FLAG`

Definition of a timestamp valid flag shift value.

```c theme={null}
#define WR_SH_MEM_EP_SHIFT_TIMESTAMP_VALID_FLAG 31
```

### `WR_SH_MEM_EP_BIT_MASK_LAST_BUFFER_FLAG`

Definition of the last buffer flag bitmask.

```c theme={null}
#define WR_SH_MEM_EP_BIT_MASK_LAST_BUFFER_FLAG AR_NON_GUID(0x40000000)
```

### `WR_SH_MEM_EP_SHIFT_LAST_BUFFER_FLAG`

Definition of the last buffer flag shift value.

```c theme={null}
#define WR_SH_MEM_EP_SHIFT_LAST_BUFFER_FLAG 30
```

### `WR_SH_MEM_EP_BIT_MASK_TS_CONTINUE_FLAG`

Definition of the shift value for the timestamp continue flag.

```c theme={null}
#define WR_SH_MEM_EP_BIT_MASK_TS_CONTINUE_FLAG AR_NON_GUID(0x20000000)
```

### `WR_SH_MEM_EP_SHIFT_TS_CONTINUE_FLAG`

Definition of the shift value for the timestamp continue flag.

```c theme={null}
#define WR_SH_MEM_EP_SHIFT_TS_CONTINUE_FLAG 29
```

### `WR_SH_MEM_EP_BIT_MASK_EOF_FLAG`

Definition of an End of Frame (EOF) flag bitmask.

```c theme={null}
#define WR_SH_MEM_EP_BIT_MASK_EOF_FLAG AR_NON_GUID(0x00000010)
```

### `WR_SH_MEM_EP_SHIFT_EOF_FLAG`

Definition of an EOF flag shift value.

```c theme={null}
#define WR_SH_MEM_EP_SHIFT_EOF_FLAG 4
```

### `DATA_CMD_RSP_WR_SH_MEM_EP_DATA_BUFFER_DONE`

Indicates that the referenced buffer has been fully consumed and is again available to the client.

```c theme={null}
#define DATA_CMD_RSP_WR_SH_MEM_EP_DATA_BUFFER_DONE 0x05001000
```

### `DATA_CMD_WR_SH_MEM_EP_DATA_BUFFER_V2`

Data command to write a buffer and associated metadata to the shared memory end point module.

```c theme={null}
#define DATA_CMD_WR_SH_MEM_EP_DATA_BUFFER_V2 0x0400100A
```

### `DATA_CMD_RSP_WR_SH_MEM_EP_DATA_BUFFER_DONE_V2`

Indicates that the referenced write buffer has been fully consumed and is again available to the client.

```c theme={null}
#define DATA_CMD_RSP_WR_SH_MEM_EP_DATA_BUFFER_DONE_V2 0x05001004
```

### `DATA_CMD_WR_SH_MEM_EP_MEDIA_FORMAT`

Indicates an update to the media format, which applies to future buffers written to this stream.

```c theme={null}
#define DATA_CMD_WR_SH_MEM_EP_MEDIA_FORMAT 0x04001001
```

### `DATA_CMD_WR_SH_MEM_EP_EOS`

Communicates an EoS marker, which indicates that the last buffer in a stream was delivered.

```c theme={null}
#define DATA_CMD_WR_SH_MEM_EP_EOS 0x04001002
```

### `WR_SH_MEM_EP_EOS_POLICY_LAST`

EoS policy according to which last of the final end point raises the DATA\_CMD\_RSP\_WR\_SH\_MEM\_EP\_EOS\_RENDERED OR the last container which drops/renders the EoS raises the DATA\_CMD\_RSP\_WR\_SH\_MEM\_EP\_EOS\_RENDERED event.

```c theme={null}
#define WR_SH_MEM_EP_EOS_POLICY_LAST 1
```

### `WR_SH_MEM_EP_EOS_POLICY_EACH`

EoS policy according to which each of the final EP raises the DATA\_CMD\_RSP\_WR\_SH\_MEM\_EP\_EOS\_RENDERED OR the each container which drop the EoS raises the DATA\_CMD\_RSP\_WR\_SH\_MEM\_EP\_EOS\_RENDERED event.

```c theme={null}
#define WR_SH_MEM_EP_EOS_POLICY_EACH 2
```

### `DATA_CMD_RSP_WR_SH_MEM_EP_EOS_RENDERED`

Indicates that DATA\_CMD\_WR\_SH\_MEM\_EP\_EOS has been received by the final end-point.

```c theme={null}
#define DATA_CMD_RSP_WR_SH_MEM_EP_EOS_RENDERED 0x05001001
```

### `WR_SH_MEM_EP_EOS_RENDER_STATUS_RENDERED`

Render status of EoS, where EoS message is rendered on final end device.

```c theme={null}
#define WR_SH_MEM_EP_EOS_RENDER_STATUS_RENDERED 1
```

### `WR_SH_MEM_EP_EOS_RENDER_STATUS_DROPPED`

Render status of EoS, where EoS message is dropped before it reached the final end device.

```c theme={null}
#define WR_SH_MEM_EP_EOS_RENDER_STATUS_DROPPED 2
```

### `PORT_ID_WR_SHARED_MEM_EP_OUTPUT`

Output port ID of the Write Shared Memory EP.

```c theme={null}
#define PORT_ID_WR_SHARED_MEM_EP_OUTPUT 0x1
```

### `PORT_ID_WR_SHARED_MEM_EP_INPUT`

Input port ID of the Write Shared Memory EP This Port is connected only in OFFLOAD(MDF) use-cases.

```c theme={null}
#define PORT_ID_WR_SHARED_MEM_EP_INPUT 0x2
```

### `MODULE_ID_WR_SHARED_MEM_EP`

ID of the Write Shared Memory End-Point Module.

```c theme={null}
#define MODULE_ID_WR_SHARED_MEM_EP 0x07001000
```
