Amazon Kinesis Webrtc C SDK
RollingBuffer.h
Go to the documentation of this file.
1 /*******************************************
2 RTCP Rolling Buffer include file
3 *******************************************/
4 #ifndef __KINESIS_VIDEO_WEBRTC_CLIENT_RTCP_ROLLING_BUFFER_H
5 #define __KINESIS_VIDEO_WEBRTC_CLIENT_RTCP_ROLLING_BUFFER_H
6 
7 #pragma once
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 typedef STATUS (*FreeDataFunc)(PUINT64);
14 
15 typedef struct {
16  // Lock guarding the rolling buffer
17  MUTEX lock;
18  // Max size of data buffer array
19  UINT32 capacity;
20  // Head index point to next empty slot to put data
21  UINT64 headIndex;
22  // Tail index point to oldest slot with data inside
23  UINT64 tailIndex;
24  // Buffer storing pointers, each pointer point to actual data
25  PUINT64 dataBuffer;
26  // Function being called when data pointer is removed from buffer
29 
30 #define ROLLING_BUFFER_MAP_INDEX(pRollingBuffer, index) ((index) % (pRollingBuffer)->capacity)
31 
34 STATUS rollingBufferAppendData(PRollingBuffer, UINT64, PUINT64);
35 STATUS rollingBufferInsertData(PRollingBuffer, UINT64, UINT64);
36 STATUS rollingBufferExtractData(PRollingBuffer, UINT64, PUINT64);
37 STATUS rollingBufferGetSize(PRollingBuffer, PUINT32);
39 
40 #ifdef __cplusplus
41 }
42 #endif
43 #endif //__KINESIS_VIDEO_WEBRTC_CLIENT_RTCP_ROLLING_BUFFER_H
STATUS rollingBufferIsEmpty(PRollingBuffer, PBOOL)
Definition: RollingBuffer.c:178
struct RollingBuffer * PRollingBuffer
STATUS createRollingBuffer(UINT32, FreeDataFunc, PRollingBuffer *)
Definition: RollingBuffer.c:5
STATUS rollingBufferInsertData(PRollingBuffer, UINT64, UINT64)
Definition: RollingBuffer.c:109
STATUS rollingBufferExtractData(PRollingBuffer, UINT64, PUINT64)
Definition: RollingBuffer.c:137
STATUS(* FreeDataFunc)(PUINT64)
Definition: RollingBuffer.h:13
STATUS rollingBufferAppendData(PRollingBuffer, UINT64, PUINT64)
Definition: RollingBuffer.c:69
STATUS freeRollingBuffer(PRollingBuffer *)
Definition: RollingBuffer.c:36
STATUS rollingBufferGetSize(PRollingBuffer, PUINT32)
Definition: RollingBuffer.c:164
Definition: RollingBuffer.h:15
UINT32 capacity
Definition: RollingBuffer.h:19
FreeDataFunc freeDataFn
Definition: RollingBuffer.h:27
PUINT64 dataBuffer
Definition: RollingBuffer.h:25
UINT64 headIndex
Definition: RollingBuffer.h:21
MUTEX lock
Definition: RollingBuffer.h:17
UINT64 tailIndex
Definition: RollingBuffer.h:23