[Asterisk-code-review] streams: Rename creates/destroys to allocs/frees (asterisk[master])
George Joseph
asteriskteam at digium.com
Thu Feb 16 08:30:59 CST 2017
George Joseph has uploaded a new change for review. ( https://gerrit.asterisk.org/4974 )
Change subject: streams: Rename creates/destroys to allocs/frees
......................................................................
streams: Rename creates/destroys to allocs/frees
To be consistent with sdp implementation.
Change-Id: I714e300939b4188f58ca66ce9d1e84b287009500
---
M include/asterisk/stream.h
M main/channel.c
M main/channel_internal_api.c
M main/stream.c
M tests/test_stream.c
5 files changed, 59 insertions(+), 59 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/74/4974/1
diff --git a/include/asterisk/stream.h b/include/asterisk/stream.h
index 9fb4660..edb00b9 100644
--- a/include/asterisk/stream.h
+++ b/include/asterisk/stream.h
@@ -84,7 +84,7 @@
*
* \since 15
*/
-struct ast_stream *ast_stream_create(const char *name, enum ast_media_type type);
+struct ast_stream *ast_stream_alloc(const char *name, enum ast_media_type type);
/*!
* \brief Destroy a media stream representation
@@ -93,7 +93,7 @@
*
* \since 15
*/
-void ast_stream_destroy(struct ast_stream *stream);
+void ast_stream_free(struct ast_stream *stream);
/*!
* \brief Create a deep clone of an existing stream
@@ -209,7 +209,7 @@
*
* \since 15
*/
-struct ast_stream_topology *ast_stream_topology_create(void);
+struct ast_stream_topology *ast_stream_topology_alloc(void);
/*!
* \brief Create a deep clone of an existing stream topology
@@ -233,7 +233,7 @@
*
* \since 15
*/
-void ast_stream_topology_destroy(struct ast_stream_topology *topology);
+void ast_stream_topology_free(struct ast_stream_topology *topology);
/*!
* \brief Append a stream to the topology
diff --git a/main/channel.c b/main/channel.c
index c74e947..1e7bc56 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -897,7 +897,7 @@
return ast_channel_unref(tmp);
}
- if (!(topology = ast_stream_topology_create())) {
+ if (!(topology = ast_stream_topology_alloc())) {
return ast_channel_unref(tmp);
}
ast_channel_internal_set_stream_topology(tmp, topology);
diff --git a/main/channel_internal_api.c b/main/channel_internal_api.c
index 235b996..1934eb9 100644
--- a/main/channel_internal_api.c
+++ b/main/channel_internal_api.c
@@ -848,7 +848,7 @@
void ast_channel_internal_set_stream_topology(struct ast_channel *chan,
struct ast_stream_topology *topology)
{
- ast_stream_topology_destroy(chan->stream_topology);
+ ast_stream_topology_free(chan->stream_topology);
chan->stream_topology = topology;
channel_set_default_streams(chan);
}
@@ -871,7 +871,7 @@
struct ast_stream_topology *new_topology;
if (!value) {
- new_topology = ast_stream_topology_create();
+ new_topology = ast_stream_topology_alloc();
} else {
new_topology = ast_stream_topology_create_from_format_cap(value);
}
@@ -1804,7 +1804,7 @@
* it even if its empty.
*/
if (!topology) {
- new_topology = ast_stream_topology_create();
+ new_topology = ast_stream_topology_alloc();
} else {
new_topology = topology;
}
diff --git a/main/stream.c b/main/stream.c
index 5112c95..aacd33f 100644
--- a/main/stream.c
+++ b/main/stream.c
@@ -69,7 +69,7 @@
AST_VECTOR(, struct ast_stream *) streams;
};
-struct ast_stream *ast_stream_create(const char *name, enum ast_media_type type)
+struct ast_stream *ast_stream_alloc(const char *name, enum ast_media_type type)
{
struct ast_stream *stream;
@@ -108,7 +108,7 @@
return new_stream;
}
-void ast_stream_destroy(struct ast_stream *stream)
+void ast_stream_free(struct ast_stream *stream)
{
if (!stream) {
return;
@@ -176,7 +176,7 @@
}
#define TOPOLOGY_INITIAL_STREAM_COUNT 2
-struct ast_stream_topology *ast_stream_topology_create(void)
+struct ast_stream_topology *ast_stream_topology_alloc(void)
{
struct ast_stream_topology *topology;
@@ -201,7 +201,7 @@
ast_assert(topology != NULL);
- new_topology = ast_stream_topology_create();
+ new_topology = ast_stream_topology_alloc();
if (!new_topology) {
return NULL;
}
@@ -211,8 +211,8 @@
ast_stream_clone(AST_VECTOR_GET(&topology->streams, i));
if (!stream || AST_VECTOR_APPEND(&new_topology->streams, stream)) {
- ast_stream_destroy(stream);
- ast_stream_topology_destroy(new_topology);
+ ast_stream_free(stream);
+ ast_stream_topology_free(new_topology);
return NULL;
}
}
@@ -220,13 +220,13 @@
return new_topology;
}
-void ast_stream_topology_destroy(struct ast_stream_topology *topology)
+void ast_stream_topology_free(struct ast_stream_topology *topology)
{
if (!topology) {
return;
}
- AST_VECTOR_CALLBACK_VOID(&topology->streams, ast_stream_destroy);
+ AST_VECTOR_CALLBACK_VOID(&topology->streams, ast_stream_free);
AST_VECTOR_FREE(&topology->streams);
ast_free(topology);
}
@@ -272,7 +272,7 @@
if (position < AST_VECTOR_SIZE(&topology->streams)) {
existing_stream = AST_VECTOR_GET(&topology->streams, position);
- ast_stream_destroy(existing_stream);
+ ast_stream_free(existing_stream);
}
stream->position = position;
@@ -293,7 +293,7 @@
ast_assert(cap != NULL);
- topology = ast_stream_topology_create();
+ topology = ast_stream_topology_alloc();
if (!topology) {
return NULL;
}
@@ -308,29 +308,29 @@
new_cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
if (!new_cap) {
- ast_stream_topology_destroy(topology);
+ ast_stream_topology_free(topology);
return NULL;
}
ast_format_cap_set_framing(new_cap, ast_format_cap_get_framing(cap));
if (ast_format_cap_append_from_cap(new_cap, cap, type)) {
ao2_cleanup(new_cap);
- ast_stream_topology_destroy(topology);
+ ast_stream_topology_free(topology);
return NULL;
}
- stream = ast_stream_create(ast_codec_media_type2str(type), type);
+ stream = ast_stream_alloc(ast_codec_media_type2str(type), type);
if (!stream) {
ao2_cleanup(new_cap);
- ast_stream_topology_destroy(topology);
+ ast_stream_topology_free(topology);
return NULL;
}
/* We're transferring the initial ref so no bump needed */
stream->formats = new_cap;
stream->state = AST_STREAM_STATE_SENDRECV;
if (ast_stream_topology_append_stream(topology, stream) == -1) {
- ast_stream_destroy(stream);
- ast_stream_topology_destroy(topology);
+ ast_stream_free(stream);
+ ast_stream_topology_free(topology);
return NULL;
}
}
diff --git a/tests/test_stream.c b/tests/test_stream.c
index 110e4e4..076b02d 100644
--- a/tests/test_stream.c
+++ b/tests/test_stream.c
@@ -40,7 +40,7 @@
AST_TEST_DEFINE(stream_create)
{
- RAII_VAR(struct ast_stream *, stream, NULL, ast_stream_destroy);
+ RAII_VAR(struct ast_stream *, stream, NULL, ast_stream_free);
switch (cmd) {
case TEST_INIT:
@@ -54,7 +54,7 @@
break;
}
- stream = ast_stream_create("test", AST_MEDIA_TYPE_AUDIO);
+ stream = ast_stream_alloc("test", AST_MEDIA_TYPE_AUDIO);
if (!stream) {
ast_test_status_update(test, "Failed to create media stream given proper arguments\n");
return AST_TEST_FAIL;
@@ -80,7 +80,7 @@
AST_TEST_DEFINE(stream_create_no_name)
{
- RAII_VAR(struct ast_stream *, stream, NULL, ast_stream_destroy);
+ RAII_VAR(struct ast_stream *, stream, NULL, ast_stream_free);
switch (cmd) {
case TEST_INIT:
@@ -94,7 +94,7 @@
break;
}
- stream = ast_stream_create(NULL, AST_MEDIA_TYPE_AUDIO);
+ stream = ast_stream_alloc(NULL, AST_MEDIA_TYPE_AUDIO);
if (!stream) {
ast_test_status_update(test, "Failed to create media stream given proper arguments\n");
return AST_TEST_FAIL;
@@ -105,7 +105,7 @@
AST_TEST_DEFINE(stream_set_type)
{
- RAII_VAR(struct ast_stream *, stream, NULL, ast_stream_destroy);
+ RAII_VAR(struct ast_stream *, stream, NULL, ast_stream_free);
switch (cmd) {
case TEST_INIT:
@@ -119,7 +119,7 @@
break;
}
- stream = ast_stream_create("test", AST_MEDIA_TYPE_AUDIO);
+ stream = ast_stream_alloc("test", AST_MEDIA_TYPE_AUDIO);
if (!stream) {
ast_test_status_update(test, "Failed to create media stream given proper arguments\n");
return AST_TEST_FAIL;
@@ -142,7 +142,7 @@
AST_TEST_DEFINE(stream_set_formats)
{
- RAII_VAR(struct ast_stream *, stream, NULL, ast_stream_destroy);
+ RAII_VAR(struct ast_stream *, stream, NULL, ast_stream_free);
RAII_VAR(struct ast_format_cap *, caps, NULL, ao2_cleanup);
switch (cmd) {
@@ -163,7 +163,7 @@
return AST_TEST_FAIL;
}
- stream = ast_stream_create("test", AST_MEDIA_TYPE_AUDIO);
+ stream = ast_stream_alloc("test", AST_MEDIA_TYPE_AUDIO);
if (!stream) {
ast_test_status_update(test, "Failed to create media stream given proper arguments\n");
return AST_TEST_FAIL;
@@ -188,7 +188,7 @@
AST_TEST_DEFINE(stream_set_state)
{
- RAII_VAR(struct ast_stream *, stream, NULL, ast_stream_destroy);
+ RAII_VAR(struct ast_stream *, stream, NULL, ast_stream_free);
switch (cmd) {
case TEST_INIT:
@@ -202,7 +202,7 @@
break;
}
- stream = ast_stream_create("test", AST_MEDIA_TYPE_AUDIO);
+ stream = ast_stream_alloc("test", AST_MEDIA_TYPE_AUDIO);
if (!stream) {
ast_test_status_update(test, "Failed to create media stream given proper arguments\n");
return AST_TEST_FAIL;
@@ -225,7 +225,7 @@
AST_TEST_DEFINE(stream_topology_create)
{
- RAII_VAR(struct ast_stream_topology *, topology, NULL, ast_stream_topology_destroy);
+ RAII_VAR(struct ast_stream_topology *, topology, NULL, ast_stream_topology_free);
switch (cmd) {
case TEST_INIT:
@@ -239,7 +239,7 @@
break;
}
- topology = ast_stream_topology_create();
+ topology = ast_stream_topology_alloc();
if (!topology) {
ast_test_status_update(test, "Failed to create media stream topology\n");
return AST_TEST_FAIL;
@@ -250,8 +250,8 @@
AST_TEST_DEFINE(stream_topology_clone)
{
- RAII_VAR(struct ast_stream_topology *, topology, NULL, ast_stream_topology_destroy);
- RAII_VAR(struct ast_stream_topology *, cloned, NULL, ast_stream_topology_destroy);
+ RAII_VAR(struct ast_stream_topology *, topology, NULL, ast_stream_topology_free);
+ RAII_VAR(struct ast_stream_topology *, cloned, NULL, ast_stream_topology_free);
struct ast_stream *audio_stream, *video_stream;
switch (cmd) {
@@ -266,13 +266,13 @@
break;
}
- topology = ast_stream_topology_create();
+ topology = ast_stream_topology_alloc();
if (!topology) {
ast_test_status_update(test, "Failed to create media stream topology\n");
return AST_TEST_FAIL;
}
- audio_stream = ast_stream_create("audio", AST_MEDIA_TYPE_AUDIO);
+ audio_stream = ast_stream_alloc("audio", AST_MEDIA_TYPE_AUDIO);
if (!audio_stream) {
ast_test_status_update(test, "Failed to create an audio stream for testing stream topology\n");
return AST_TEST_FAIL;
@@ -280,11 +280,11 @@
if (ast_stream_topology_append_stream(topology, audio_stream) == -1) {
ast_test_status_update(test, "Failed to append valid audio stream to stream topology\n");
- ast_stream_destroy(audio_stream);
+ ast_stream_free(audio_stream);
return AST_TEST_FAIL;
}
- video_stream = ast_stream_create("video", AST_MEDIA_TYPE_VIDEO);
+ video_stream = ast_stream_alloc("video", AST_MEDIA_TYPE_VIDEO);
if (!video_stream) {
ast_test_status_update(test, "Failed to create a video stream for testing stream topology\n");
return AST_TEST_FAIL;
@@ -292,7 +292,7 @@
if (ast_stream_topology_append_stream(topology, video_stream) == -1) {
ast_test_status_update(test, "Failed to append valid video stream to stream topology\n");
- ast_stream_destroy(video_stream);
+ ast_stream_free(video_stream);
return AST_TEST_FAIL;
}
@@ -322,7 +322,7 @@
AST_TEST_DEFINE(stream_topology_append_stream)
{
- RAII_VAR(struct ast_stream_topology *, topology, NULL, ast_stream_topology_destroy);
+ RAII_VAR(struct ast_stream_topology *, topology, NULL, ast_stream_topology_free);
struct ast_stream *audio_stream, *video_stream;
int position;
@@ -338,13 +338,13 @@
break;
}
- topology = ast_stream_topology_create();
+ topology = ast_stream_topology_alloc();
if (!topology) {
ast_test_status_update(test, "Failed to create media stream topology\n");
return AST_TEST_FAIL;
}
- audio_stream = ast_stream_create("audio", AST_MEDIA_TYPE_AUDIO);
+ audio_stream = ast_stream_alloc("audio", AST_MEDIA_TYPE_AUDIO);
if (!audio_stream) {
ast_test_status_update(test, "Failed to create an audio stream for testing stream topology\n");
return AST_TEST_FAIL;
@@ -353,7 +353,7 @@
position = ast_stream_topology_append_stream(topology, audio_stream);
if (position == -1) {
ast_test_status_update(test, "Failed to append valid audio stream to stream topology\n");
- ast_stream_destroy(audio_stream);
+ ast_stream_free(audio_stream);
return AST_TEST_FAIL;
} else if (position != 0) {
ast_test_status_update(test, "Appended audio stream to stream topology but position is '%d' instead of 0\n",
@@ -378,7 +378,7 @@
return AST_TEST_FAIL;
}
- video_stream = ast_stream_create("video", AST_MEDIA_TYPE_VIDEO);
+ video_stream = ast_stream_alloc("video", AST_MEDIA_TYPE_VIDEO);
if (!video_stream) {
ast_test_status_update(test, "Failed to create a video stream for testing stream topology\n");
return AST_TEST_FAIL;
@@ -387,7 +387,7 @@
position = ast_stream_topology_append_stream(topology, video_stream);
if (position == -1) {
ast_test_status_update(test, "Failed to append valid video stream to stream topology\n");
- ast_stream_destroy(video_stream);
+ ast_stream_free(video_stream);
return AST_TEST_FAIL;
} else if (position != 1) {
ast_test_status_update(test, "Appended video stream to stream topology but position is '%d' instead of 1\n",
@@ -417,7 +417,7 @@
AST_TEST_DEFINE(stream_topology_set_stream)
{
- RAII_VAR(struct ast_stream_topology *, topology, NULL, ast_stream_topology_destroy);
+ RAII_VAR(struct ast_stream_topology *, topology, NULL, ast_stream_topology_free);
struct ast_stream *audio_stream, *video_stream;
switch (cmd) {
@@ -432,13 +432,13 @@
break;
}
- topology = ast_stream_topology_create();
+ topology = ast_stream_topology_alloc();
if (!topology) {
ast_test_status_update(test, "Failed to create media stream topology\n");
return AST_TEST_FAIL;
}
- audio_stream = ast_stream_create("audio", AST_MEDIA_TYPE_AUDIO);
+ audio_stream = ast_stream_alloc("audio", AST_MEDIA_TYPE_AUDIO);
if (!audio_stream) {
ast_test_status_update(test, "Failed to create an audio stream for testing stream topology\n");
return AST_TEST_FAIL;
@@ -446,7 +446,7 @@
if (ast_stream_topology_set_stream(topology, 0, audio_stream)) {
ast_test_status_update(test, "Failed to set an audio stream to a position where it is permitted\n");
- ast_stream_destroy(audio_stream);
+ ast_stream_free(audio_stream);
return AST_TEST_FAIL;
}
@@ -467,7 +467,7 @@
return AST_TEST_FAIL;
}
- video_stream = ast_stream_create("video", AST_MEDIA_TYPE_VIDEO);
+ video_stream = ast_stream_alloc("video", AST_MEDIA_TYPE_VIDEO);
if (!video_stream) {
ast_test_status_update(test, "Failed to create a video stream for testing stream topology\n");
return AST_TEST_FAIL;
@@ -475,7 +475,7 @@
if (ast_stream_topology_set_stream(topology, 0, video_stream)) {
ast_test_status_update(test, "Failed to set a video stream to a position where it is permitted\n");
- ast_stream_destroy(video_stream);
+ ast_stream_free(video_stream);
return AST_TEST_FAIL;
}
@@ -496,7 +496,7 @@
return AST_TEST_FAIL;
}
- audio_stream = ast_stream_create("audio", AST_MEDIA_TYPE_AUDIO);
+ audio_stream = ast_stream_alloc("audio", AST_MEDIA_TYPE_AUDIO);
if (!audio_stream) {
ast_test_status_update(test, "Failed to create an audio stream for testing stream topology\n");
return AST_TEST_FAIL;
@@ -504,7 +504,7 @@
if (ast_stream_topology_set_stream(topology, 1, audio_stream)) {
ast_test_status_update(test, "Failed to set an audio stream to a position where it is permitted\n");
- ast_stream_destroy(audio_stream);
+ ast_stream_free(audio_stream);
return AST_TEST_FAIL;
}
@@ -530,7 +530,7 @@
AST_TEST_DEFINE(stream_topology_create_from_format_cap)
{
- RAII_VAR(struct ast_stream_topology *, topology, NULL, ast_stream_topology_destroy);
+ RAII_VAR(struct ast_stream_topology *, topology, NULL, ast_stream_topology_free);
RAII_VAR(struct ast_format_cap *, caps, NULL, ao2_cleanup);
switch (cmd) {
@@ -579,7 +579,7 @@
return AST_TEST_FAIL;
}
- ast_stream_topology_destroy(topology);
+ ast_stream_topology_free(topology);
topology = NULL;
ast_format_cap_append(caps, ast_format_h264, 0);
--
To view, visit https://gerrit.asterisk.org/4974
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I714e300939b4188f58ca66ce9d1e84b287009500
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: George Joseph <gjoseph at digium.com>
More information about the asterisk-code-review
mailing list