|
Asterisk - The Open Source Telephony Project GIT-master-27fb039
|
Data Buffer API. More...
#include "asterisk.h"#include "asterisk/logger.h"#include "asterisk/strings.h"#include "asterisk/data_buffer.h"#include "asterisk/linkedlists.h"
Go to the source code of this file.
Data Structures | |
| struct | ast_data_buffer |
| Data buffer containing fixed number of data payloads. More... | |
| struct | data_buffer_payload_entry |
| Payload entry placed inside of the data buffer list. More... | |
Macros | |
| #define | CACHED_PAYLOAD_MAX 5 |
| The number of payloads to increment the cache by. | |
Functions | |
| struct ast_data_buffer * | ast_data_buffer_alloc (ast_data_buffer_free_callback free_fn, size_t size) |
| Allocate a data buffer. | |
| static void | ast_data_buffer_cache_adjust (struct ast_data_buffer *buffer) |
| Helper function that sets the cache to its maximum number of payloads. | |
| size_t | ast_data_buffer_count (const struct ast_data_buffer *buffer) |
| Return the number of payloads in a data buffer. | |
| void | ast_data_buffer_free (struct ast_data_buffer *buffer) |
| Free a data buffer (and all held data payloads) | |
| void * | ast_data_buffer_get (const struct ast_data_buffer *buffer, size_t pos) |
| Retrieve a data payload from the data buffer. | |
| size_t | ast_data_buffer_max (const struct ast_data_buffer *buffer) |
| Return the maximum number of payloads a data buffer can hold. | |
| int | ast_data_buffer_put (struct ast_data_buffer *buffer, size_t pos, void *payload) |
| Place a data payload at a position in the data buffer. | |
| void * | ast_data_buffer_remove (struct ast_data_buffer *buffer, size_t pos) |
| Remove a data payload from the data buffer. | |
| void * | ast_data_buffer_remove_head (struct ast_data_buffer *buffer) |
| Remove the first payload from the data buffer. | |
| void | ast_data_buffer_resize (struct ast_data_buffer *buffer, size_t size) |
| Resize a data buffer. | |
| static void | data_buffer_free_buffer_payload (struct ast_data_buffer *buffer, struct data_buffer_payload_entry *buffer_payload) |
| static struct data_buffer_payload_entry * | data_buffer_payload_alloc (void *payload, size_t pos) |
| Helper function to allocate a data payload. | |
| static void | free_fn_do_nothing (void *data) |
Data Buffer API.
Definition in file data_buffer.c.
| #define CACHED_PAYLOAD_MAX 5 |
The number of payloads to increment the cache by.
Definition at line 42 of file data_buffer.c.
| struct ast_data_buffer * ast_data_buffer_alloc | ( | ast_data_buffer_free_callback | free_fn, |
| size_t | size | ||
| ) |
Allocate a data buffer.
| free_fn | Callback function to free a data payload |
| size | The maximum number of data payloads to contain in the data buffer |
| non-NULL | success |
| NULL | failure |
Definition at line 145 of file data_buffer.c.
References ast_assert, ast_calloc, ast_data_buffer_cache_adjust(), AST_LIST_HEAD_INIT_NOLOCK, ast_data_buffer::cached_payloads, ast_data_buffer::free_fn, free_fn_do_nothing(), ast_data_buffer::max, NULL, and ast_data_buffer::payloads.
Referenced by ast_rtp_prop_set(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), and AST_TEST_DEFINE().
|
static |
Helper function that sets the cache to its maximum number of payloads.
Definition at line 100 of file data_buffer.c.
References ast_assert, ast_free, AST_LIST_INSERT_TAIL, AST_LIST_REMOVE_HEAD, ast_log, ast_data_buffer::cache_count, CACHED_PAYLOAD_MAX, ast_data_buffer::cached_payloads, ast_data_buffer::count, data_buffer_payload_alloc(), data_buffer_payload_entry::list, LOG_ERROR, ast_data_buffer::max, and NULL.
Referenced by ast_data_buffer_alloc(), ast_data_buffer_put(), and ast_data_buffer_resize().
| size_t ast_data_buffer_count | ( | const struct ast_data_buffer * | buffer | ) |
Return the number of payloads in a data buffer.
| buffer | The data buffer |
Definition at line 356 of file data_buffer.c.
References ast_assert, ast_data_buffer::count, and NULL.
Referenced by ast_rtp_read(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), and AST_TEST_DEFINE().
| void ast_data_buffer_free | ( | struct ast_data_buffer * | buffer | ) |
Free a data buffer (and all held data payloads)
| buffer | The data buffer |
Definition at line 338 of file data_buffer.c.
References ast_assert, ast_free, AST_LIST_REMOVE_HEAD, ast_data_buffer::cached_payloads, ast_data_buffer::free_fn, data_buffer_payload_entry::list, NULL, data_buffer_payload_entry::payload, and ast_data_buffer::payloads.
Referenced by ast_data_buffer_free_wrapper(), ast_rtp_destroy(), and ast_rtp_prop_set().
| void * ast_data_buffer_get | ( | const struct ast_data_buffer * | buffer, |
| size_t | pos | ||
| ) |
Retrieve a data payload from the data buffer.
| buffer | The data buffer |
| pos | The position of the data payload |
| non-NULL | success |
| NULL | failure |
Definition at line 269 of file data_buffer.c.
References ast_assert, AST_LIST_TRAVERSE, data_buffer_payload_entry::list, NULL, data_buffer_payload_entry::payload, ast_data_buffer::payloads, and data_buffer_payload_entry::pos.
Referenced by ast_rtp_read(), ast_rtp_rtcp_handle_nack(), AST_TEST_DEFINE(), and AST_TEST_DEFINE().
| size_t ast_data_buffer_max | ( | const struct ast_data_buffer * | buffer | ) |
Return the maximum number of payloads a data buffer can hold.
| buffer | The data buffer |
Definition at line 363 of file data_buffer.c.
References ast_assert, ast_data_buffer::max, and NULL.
Referenced by ast_rtp_read(), ast_rtp_rtcp_handle_nack(), AST_TEST_DEFINE(), and AST_TEST_DEFINE().
| int ast_data_buffer_put | ( | struct ast_data_buffer * | buffer, |
| size_t | pos, | ||
| void * | payload | ||
| ) |
Place a data payload at a position in the data buffer.
| buffer | The data buffer |
| pos | The position of the data payload |
| payload | The data payload |
| 0 | success |
| -1 | failure |
Definition at line 203 of file data_buffer.c.
References ast_assert, ast_data_buffer_cache_adjust(), ast_debug, AST_LIST_INSERT_BEFORE_CURRENT, AST_LIST_INSERT_TAIL, AST_LIST_REMOVE_HEAD, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_data_buffer::cache_count, ast_data_buffer::cached_payloads, ast_data_buffer::count, ast_data_buffer::free_fn, data_buffer_payload_entry::list, ast_data_buffer::max, NULL, data_buffer_payload_entry::payload, ast_data_buffer::payloads, and data_buffer_payload_entry::pos.
Referenced by ast_rtp_read(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), and rtp_raw_write().
| void * ast_data_buffer_remove | ( | struct ast_data_buffer * | buffer, |
| size_t | pos | ||
| ) |
Remove a data payload from the data buffer.
| buffer | The data buffer |
| pos | The position of the data payload |
| non-NULL | success |
| NULL | failure |
Definition at line 299 of file data_buffer.c.
References ast_assert, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, data_buffer_free_buffer_payload(), data_buffer_payload_entry::list, NULL, data_buffer_payload_entry::payload, ast_data_buffer::payloads, and data_buffer_payload_entry::pos.
Referenced by ast_rtp_read(), and AST_TEST_DEFINE().
| void * ast_data_buffer_remove_head | ( | struct ast_data_buffer * | buffer | ) |
Remove the first payload from the data buffer.
| buffer | The data buffer |
| non-NULL | success |
| NULL | failure |
Definition at line 320 of file data_buffer.c.
References ast_assert, AST_LIST_REMOVE_HEAD, ast_data_buffer::count, data_buffer_free_buffer_payload(), data_buffer_payload_entry::list, NULL, data_buffer_payload_entry::payload, and ast_data_buffer::payloads.
Referenced by AST_TEST_DEFINE().
| void ast_data_buffer_resize | ( | struct ast_data_buffer * | buffer, |
| size_t | size | ||
| ) |
Resize a data buffer.
| buffer | The data buffer |
| size | The new maximum size of the data buffer |
Definition at line 168 of file data_buffer.c.
References ast_assert, ast_data_buffer_cache_adjust(), ast_free, AST_LIST_REMOVE_HEAD, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_data_buffer::count, ast_data_buffer::free_fn, data_buffer_payload_entry::list, ast_data_buffer::max, NULL, data_buffer_payload_entry::payload, ast_data_buffer::payloads, and remove.
Referenced by ast_rtp_read(), ast_rtp_rtcp_handle_nack(), and AST_TEST_DEFINE().
|
static |
Definition at line 284 of file data_buffer.c.
References ast_free, AST_LIST_INSERT_TAIL, ast_data_buffer::cache_count, CACHED_PAYLOAD_MAX, ast_data_buffer::cached_payloads, ast_data_buffer::count, data_buffer_payload_entry::list, ast_data_buffer::max, NULL, and data_buffer_payload_entry::payload.
Referenced by ast_data_buffer_remove(), and ast_data_buffer_remove_head().
|
static |
Helper function to allocate a data payload.
Definition at line 82 of file data_buffer.c.
References ast_calloc, NULL, data_buffer_payload_entry::payload, and data_buffer_payload_entry::pos.
Referenced by ast_data_buffer_cache_adjust().
|
static |
Definition at line 74 of file data_buffer.c.
Referenced by ast_data_buffer_alloc().