summaryrefslogtreecommitdiff
path: root/main/rtp_engine.c
diff options
context:
space:
mode:
authorGeorge Joseph <george.joseph@fairview5.com>2015-05-01 18:25:17 -0600
committerGeorge Joseph <george.joseph@fairview5.com>2015-05-04 18:45:28 -0600
commit6d5941297bddc9c6aff4292fe5d48e3041cd404a (patch)
treefe7dda9ca8a98c9923fd28ec7a4888fbed6df295 /main/rtp_engine.c
parentce21776aae2866f3c611f172c4d38fb53e806dcf (diff)
vector: Traversal, retrieval, insert and locking enhancements
Renamed AST_VECTOR_INSERT to AST_VECTOR_REPLACE because it really does replace not insert. The few users of AST_VECTOR_INSERT were refactored. Because these are macros, there should be no ABI compatibility issues. Added AST_VECTOR_INSERT_AT that actually inserts an element into the vector at a specific index pushing existing elements to the right. Added AST_VECTOR_GET_CMP that can retrieve from the vector based on a user-provided compare function. Added AST_VECTOR_CALLBACK function that will execute a function for each element in the vector. Similar to ao2_callback and ao2_callback_data functions although the vector callback can take a variable number of arguments. This should allow easy migration to a vector where a container might be too heavy. Added read/write locked vector and lock manipulation macros. Added unit tests. ASTERISK-25045 #close Change-Id: I2e07ecc709d2f5f91bcab8904e5e9340609b00e0
Diffstat (limited to 'main/rtp_engine.c')
-rw-r--r--main/rtp_engine.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/main/rtp_engine.c b/main/rtp_engine.c
index aa91b7da4..88d2db3d0 100644
--- a/main/rtp_engine.c
+++ b/main/rtp_engine.c
@@ -625,7 +625,7 @@ void ast_rtp_codecs_payloads_copy(struct ast_rtp_codecs *src, struct ast_rtp_cod
}
ast_debug(2, "Copying payload %d (%p) from %p to %p\n", i, type, src, dest);
ao2_bump(type);
- AST_VECTOR_INSERT(&dest->payloads, i, type);
+ AST_VECTOR_REPLACE(&dest->payloads, i, type);
if (instance && instance->engine && instance->engine->payload_set) {
instance->engine->payload_set(instance, i, type->asterisk_format, type->format, type->rtp_code);
@@ -662,7 +662,7 @@ void ast_rtp_codecs_payloads_set_m_type(struct ast_rtp_codecs *codecs, struct as
new_type->format = ao2_bump(static_RTP_PT[payload].format);
ast_debug(1, "Setting payload %d (%p) based on m type on %p\n", payload, new_type, codecs);
- AST_VECTOR_INSERT(&codecs->payloads, payload, new_type);
+ AST_VECTOR_REPLACE(&codecs->payloads, payload, new_type);
if (instance && instance->engine && instance->engine->payload_set) {
instance->engine->payload_set(instance, payload, new_type->asterisk_format, new_type->format, new_type->rtp_code);
@@ -727,7 +727,7 @@ int ast_rtp_codecs_payloads_set_rtpmap_type_rate(struct ast_rtp_codecs *codecs,
} else {
new_type->format = ao2_bump(t->payload_type.format);
}
- AST_VECTOR_INSERT(&codecs->payloads, pt, new_type);
+ AST_VECTOR_REPLACE(&codecs->payloads, pt, new_type);
if (instance && instance->engine && instance->engine->payload_set) {
instance->engine->payload_set(instance, pt, new_type->asterisk_format, new_type->format, new_type->rtp_code);
@@ -760,7 +760,7 @@ void ast_rtp_codecs_payloads_unset(struct ast_rtp_codecs *codecs, struct ast_rtp
if (payload < AST_VECTOR_SIZE(&codecs->payloads)) {
type = AST_VECTOR_GET(&codecs->payloads, payload);
ao2_cleanup(type);
- AST_VECTOR_INSERT(&codecs->payloads, payload, NULL);
+ AST_VECTOR_REPLACE(&codecs->payloads, payload, NULL);
}
if (instance && instance->engine && instance->engine->payload_set) {