49 info->name =
"stream_create";
50 info->category =
"/main/stream/";
51 info->summary =
"stream create unit test";
53 "Test that creating a stream results in a stream with the expected values";
89 info->name =
"stream_create_no_name";
90 info->category =
"/main/stream/";
91 info->summary =
"stream create (without a name) unit test";
93 "Test that creating a stream with no name works";
114 info->name =
"stream_set_type";
115 info->category =
"/main/stream/";
116 info->summary =
"stream type setting unit test";
118 "Test that changing the type of a stream works";
152 info->name =
"stream_set_formats";
153 info->category =
"/main/stream/";
154 info->summary =
"stream formats setting unit test";
156 "Test that changing the formats of a stream works";
197 info->name =
"stream_set_state";
198 info->category =
"/main/stream/";
199 info->summary =
"stream state setting unit test";
201 "Test that changing the state of a stream works";
232 const char *stream_track_label;
237 info->name =
"stream_metadata";
238 info->category =
"/main/stream/";
239 info->summary =
"stream metadata unit test";
241 "Test that metadata operations on a stream works";
254 if (stream_track_label) {
267 if (!stream_track_label) {
272 if (strcmp(stream_track_label, track_label) != 0) {
284 if (stream_track_label) {
298 info->name =
"stream_topology_create";
299 info->category =
"/main/stream/";
300 info->summary =
"stream topology creation unit test";
302 "Test that creating a stream topology works";
321 struct ast_stream *audio_stream, *video_stream;
324 const char *original_track_label;
325 const char *cloned_track_label;
330 info->name =
"stream_topology_clone";
331 info->category =
"/main/stream/";
332 info->summary =
"stream topology cloning unit test";
334 "Test that cloning a stream topology results in a clone with the same contents";
401 "AST_STREAM_METADATA_TRACK_LABEL");
402 if (!original_track_label) {
407 "AST_STREAM_METADATA_TRACK_LABEL");
408 if (!cloned_track_label) {
412 if (strcmp(original_track_label, cloned_track_label) != 0) {
423 "AST_STREAM_METADATA_TRACK_LABEL");
424 if (!original_track_label) {
429 "AST_STREAM_METADATA_TRACK_LABEL");
430 if (!cloned_track_label) {
434 if (strcmp(original_track_label, cloned_track_label) != 0) {
445 struct ast_stream *audio_stream, *video_stream;
450 info->name =
"stream_topology_append_stream";
451 info->category =
"/main/stream/";
452 info->summary =
"stream topology stream appending unit test";
454 "Test that appending streams to a stream topology works";
473 if (position == -1) {
477 }
else if (position != 0) {
507 if (position == -1) {
511 }
else if (position != 1) {
540 struct ast_stream *audio_stream, *video_stream;
544 info->name =
"stream_topology_set_stream";
545 info->category =
"/main/stream/";
546 info->summary =
"stream topology stream setting unit test";
548 "Test that setting streams at a specific position in a topology works";
679 info->name =
"stream_topology_del_stream";
680 info->category =
"/main/stream/";
681 info->summary =
"stream topology stream delete unit test";
683 "Test that deleting streams at a specific position in a topology works";
744 if (type != AST_MEDIA_TYPE_END - 2) {
797 info->name =
"stream_topology_create_from_format_cap";
798 info->category =
"/main/stream/";
799 info->summary =
"stream topology creation from format capabilities unit test";
801 "Test that creating a stream topology from format capabilities results in the expected streams";
885 info->name =
"stream_topology_get_first_stream_by_type";
886 info->category =
"/main/stream/";
887 info->summary =
"stream topology getting first stream by type unit test";
889 "Test that getting the first stream by type from a topology actually returns the first stream";
915 if (!second_stream) {
939 if (!fourth_stream) {
1002 info->name =
"stream_topology_create_from_channel_nativeformats";
1003 info->category =
"/main/stream/";
1004 info->summary =
"stream topology creation from channel native formats unit test";
1006 "Test that creating a stream topology from the setting of channel nativeformats results in the expected streams";
1033 mock_channel =
ast_channel_alloc(0,
AST_STATE_DOWN,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL, 0,
"TestChannel");
1034 if (!mock_channel) {
1048 ast_test_status_update(
test,
"Set nativeformats on a channel to ulaw, alaw, and h264 and received '%d' streams instead of expected 2\n",
1190 info->name =
"stream_topology_channel_set";
1191 info->category =
"/main/stream/";
1192 info->summary =
"stream topology setting on a channel unit test";
1194 "Test that setting a stream topology on a channel works";
1206 mock_channel =
ast_channel_alloc(0,
AST_STATE_DOWN,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL, 0,
"TestChannel");
1207 if (!mock_channel) {
1255 info->name =
"stream_write_non_multistream";
1256 info->category =
"/main/stream/";
1257 info->summary =
"stream writing to non-multistream capable channel test";
1259 "Test that writing frames to a non-multistream channel works as expected";
1281 mock_channel =
ast_channel_alloc(0,
AST_STATE_DOWN,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL, 0,
"TestChannel");
1282 if (!mock_channel) {
1355 info->name =
"stream_write_multistream";
1356 info->category =
"/main/stream/";
1357 info->summary =
"stream writing to multistream capable channel test";
1359 "Test that writing frames to a multistream channel works as expected";
1435 mock_channel =
ast_channel_alloc(0,
AST_STATE_DOWN,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL, 0,
"TestChannel");
1436 if (!mock_channel) {
1459 ast_test_status_update(
test,
"Successfully wrote a frame of ulaw but it ended up on the old write callback instead of write_stream\n");
1469 ast_test_status_update(
test,
"Successfully wrote a frame of ulaw to the default stream but it ended up on stream %d and not 0\n",
1483 ast_test_status_update(
test,
"Successfully wrote a frame of ulaw to the first audio stream but it ended up on the old write callback instead of write_stream\n");
1488 ast_test_status_update(
test,
"Successfully wrote a frame of ulaw to the first audio stream but it never reached the channel driver\n");
1493 ast_test_status_update(
test,
"Successfully wrote a frame of ulaw to the first audio stream but it ended up on stream %d and not 0\n",
1507 ast_test_status_update(
test,
"Successfully wrote a frame of ulaw to the second audio stream but it ended up on the old write callback instead of write_stream\n");
1512 ast_test_status_update(
test,
"Successfully wrote a frame of ulaw to the second audio stream but it never reached the channel driver\n");
1517 ast_test_status_update(
test,
"Successfully wrote a frame of ulaw to the second audio stream but it ended up on stream %d and not 1\n",
1534 ast_test_status_update(
test,
"Successfully wrote a frame of h264 but it ended up on the old write callback instead of write_stream\n");
1544 ast_test_status_update(
test,
"Successfully wrote a frame of h264 to the default stream but it ended up on stream %d and not 2\n",
1558 ast_test_status_update(
test,
"Successfully wrote a frame of h264 to the first video stream but it ended up on the old write callback instead of write_stream\n");
1563 ast_test_status_update(
test,
"Successfully wrote a frame of h264 to the first video stream but it never reached the channel driver\n");
1568 ast_test_status_update(
test,
"Successfully wrote a frame of h264 to the first video stream but it ended up on stream %d and not 2\n",
1582 ast_test_status_update(
test,
"Successfully wrote a frame of h264 to the second video stream but it ended up on the old write callback instead of write_stream\n");
1587 ast_test_status_update(
test,
"Successfully wrote a frame of h264 to the second video stream but it never reached the channel driver\n");
1592 ast_test_status_update(
test,
"Successfully wrote a frame of h264 to the second video stream but it ended up on stream %d and not 3\n",
1606 ast_test_status_update(
test,
"Successfully wrote a frame of h264 to a non-existent stream and it ended up on the old write callback\n");
1611 ast_test_status_update(
test,
"Successfully wrote a frame of h264 to a non-existent stream and it ended up on the write_stream callback\n");
1633 for (i = 0; i <
frames; i++) {
1661 mock_channel =
ast_channel_alloc(0,
AST_STATE_DOWN,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL, 0,
"TestChannel");
1662 ast_test_validate_cleanup(test, mock_channel, res,
done);
1667 ast_test_validate_cleanup(test, topology, res,
done);
1669 for (i = 0; i <
streams; i++) {
1671 ast_test_validate_cleanup(test, stream, res,
done);
1679 ast_test_validate_cleanup(test, caps, res,
done);
1687 ast_test_validate_cleanup(test, pvt, res,
done);
1699 return mock_channel;
1724 int null_frames = 0;
1726 ast_test_status_update(test,
"ChanType: %s ReadType: %s Streams: %d Frames: %d Frames per read: %d Expected Nulls: %d\n",
1729 streams, frames, frames_per_read, expected_nulls);
1731 ast_test_validate_cleanup(test, mock_channel, res,
done);
1745 ast_test_validate_cleanup(test, i == fr->
seqno, res,
done);
1747 ast_test_validate_cleanup(test, fr->
stream_num == ( i % streams ), res,
done);
1755 ast_test_validate_cleanup(test, i == frames, res,
done);
1756 ast_test_validate_cleanup(test, null_frames == expected_nulls, res,
done);
1776 info->name =
"stream_read_non_multistream";
1777 info->category =
"/main/stream/";
1778 info->summary =
"stream reading from non-multistream capable channel test";
1780 "Test that reading frames from a non-multistream channel works as expected";
1787 ast_test_validate(
test, res ==
AST_TEST_PASS,
"non multi, non read stream, 2 stream");
1790 ast_test_validate(
test, res ==
AST_TEST_PASS,
"non multi, read stream, 2 stream");
1793 ast_test_validate(
test, res ==
AST_TEST_PASS,
"non multi, non read stream, 2 stream, 3 frames per read");
1796 ast_test_validate(
test, res ==
AST_TEST_PASS,
"non multi, read stream, 2 stream, 3 frames per read");
1812 info->name =
"stream_read_multistream";
1813 info->category =
"/main/stream/";
1814 info->summary =
"stream reading from multistream capable channel test";
1816 "Test that reading frames from a multistream channel works as expected";
1823 ast_test_validate(
test, res ==
AST_TEST_PASS,
"multi, non read stream, 2 stream");
1829 ast_test_validate(
test, res ==
AST_TEST_PASS,
"multi, non read stream, 4 stream");
1835 ast_test_validate(
test, res ==
AST_TEST_PASS,
"multi, non read stream, 2 stream, 3 frames per read");
1838 ast_test_validate(
test, res ==
AST_TEST_PASS,
"multi, read stream, 2 stream, 3 frames per read");
1841 ast_test_validate(
test, res ==
AST_TEST_PASS,
"multi, non read stream, 4 stream, 3 frames per read");
1844 ast_test_validate(
test, res ==
AST_TEST_PASS,
"multi, read stream, 4 stream, 3 frames per read");
1864 info->name =
"stream_topology_change_request_from_application_non_multistream";
1865 info->category =
"/main/stream/";
1866 info->summary =
"stream topology changing on non-multistream channel test";
1868 "Test that an application trying to change the stream topology of a non-multistream channel gets a failure";
1875 ast_test_validate_cleanup(
test, mock_channel, res,
done);
1882 ast_test_validate_cleanup(
test, topology, res,
done);
1886 ast_test_validate_cleanup(
test, change_res == -1, res,
done);
1893 ast_test_validate_cleanup(
test, change_res == -1, res,
done);
1922 info->name =
"stream_topology_change_request_from_channel_non_multistream";
1923 info->category =
"/main/stream/";
1924 info->summary =
"channel requesting stream topology change to non-multistream application test";
1926 "Test that a channel requesting a stream topology change from a non-multistream application does not work";
1933 ast_test_validate_cleanup(
test, mock_channel, res,
done);
1939 ast_test_validate_cleanup(
test, topology, res,
done);
1941 request_change.
data.
ptr = topology;
1945 ast_test_validate_cleanup(
test, fr, res,
done);
1974 info->name =
"stream_topology_change_request_from_application";
1975 info->category =
"/main/stream/";
1976 info->summary =
"stream topology change request from application test";
1978 "Test that an application changing the stream topology of a multistream capable channel receives success";
1985 ast_test_validate_cleanup(
test, mock_channel, res,
done);
1992 ast_test_validate_cleanup(
test, topology, res,
done);
1996 ast_test_validate_cleanup(
test, !change_res, res,
done);
2003 ast_test_validate_cleanup(
test, !change_res, res,
done);
2032 info->name =
"stream_topology_change_request_from_channel";
2033 info->category =
"/main/stream/";
2034 info->summary =
"channel requesting stream topology change to multistream application test";
2036 "Test that a channel requesting a stream topology change from a multistream application works";
2043 ast_test_validate_cleanup(
test, mock_channel, res,
done);
2049 ast_test_validate_cleanup(
test, topology, res,
done);
2051 request_change.
data.
ptr = topology;
2055 ast_test_validate_cleanup(
test, fr, res,
done);
2079 info->name =
"format_cap_from_stream_topology";
2080 info->category =
"/main/stream/";
2081 info->summary =
"stream topology to format capabilities conversion test";
2083 "Test that converting a stream topology to format capabilities results in expected formats";
2162 #define topology_append_stream(topology, name, type, res, label) \ 2164 struct ast_stream *__stream = ast_stream_alloc((name), (type)); \ 2165 ast_test_validate_cleanup(test, __stream, res, label); \ 2166 if (ast_stream_topology_append_stream((topology), __stream) < 0) { \ 2167 ast_stream_free(__stream); \ 2168 res = AST_TEST_FAIL; \ 2177 struct ast_vector_int types = {
NULL };
2178 struct ast_vector_int v0 = {
NULL };
2179 struct ast_vector_int v1 = {
NULL };
2185 info->name =
"stream_topology_map_create";
2186 info->category =
"/main/stream/";
2187 info->summary =
"stream topology map creation unit test";
2189 "Test that creating a stream topology map works";
2305 AST_TEST_REGISTER(stream_topology_change_request_from_application_non_multistream);
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
void ast_channel_fdno_set(struct ast_channel *chan, int value)
#define ast_channel_lock(chan)
Main Channel structure associated with a channel.
#define ast_frdup(fr)
Copies a frame.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Asterisk main include file. File version handling, generic pbx functions.
unsigned int indicated_change_request
struct ast_stream_topology * ast_channel_get_stream_topology(const struct ast_channel *chan)
Retrieve the topology of streams on a channel.
struct ast_format_cap * ast_stream_topology_get_formats(struct ast_stream_topology *topology)
Create a format capabilities structure representing the topology.
void * ast_channel_tech_pvt(const struct ast_channel *chan)
int(*const write)(struct ast_channel *chan, struct ast_frame *frame)
Write a frame, in standard format (see frame.h)
static enum ast_test_result_state read_test(struct ast_test *test, struct ast_channel_tech *tech, enum CHANNEL_READ_TYPE rt, int streams, int frames, int frames_per_read, int expected_nulls)
static int mock_channel_write_stream(struct ast_channel *chan, int stream_num, struct ast_frame *fr)
enum ast_media_type ast_stream_get_type(const struct ast_stream *stream)
Get the media type of a stream.
const char * ast_codec_media_type2str(enum ast_media_type type)
Conversion function to take a media type and turn it into a string.
struct ast_frame *(*const read_stream)(struct ast_channel *chan)
Read a frame (or chain of frames from the same stream), in standard format (see frame.h), with stream num.
struct ast_frame::@264 frame_list
Universally unique identifier support.
Set when the stream has been removed/declined.
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
#define AST_TEST_REGISTER(cb)
struct ast_frame * ast_read_stream(struct ast_channel *chan)
Reads a frame, but does not filter to just the default streams.
struct ast_stream_topology * ast_stream_topology_create_from_format_cap(struct ast_format_cap *cap)
A helper function that, given a format capabilities structure, creates a topology and separates the m...
Set when the stream is not sending OR receiving media.
#define ast_str_alloca(init_len)
int ast_channel_request_stream_topology_change(struct ast_channel *chan, struct ast_stream_topology *topology, void *change_source)
Request that the stream topology of a channel change.
struct ast_stream * ast_stream_topology_get_stream(const struct ast_stream_topology *topology, unsigned int position)
Get a specific stream from the topology.
int ast_stream_topology_append_stream(struct ast_stream_topology *topology, struct ast_stream *stream)
Append a stream to the topology.
void ast_stream_set_formats(struct ast_stream *stream, struct ast_format_cap *caps)
Set the current negotiated formats of a stream.
static struct ast_frame * mock_channel_read(struct ast_channel *chan)
int ast_stream_topology_set_stream(struct ast_stream_topology *topology, unsigned int position, struct ast_stream *stream)
Set a specific position in a topology.
int ast_write_stream(struct ast_channel *chan, int stream_num, struct ast_frame *frame)
Write a frame to a stream This function writes the given frame to the indicated stream on the channel...
struct ast_frame_subclass subclass
void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value)
const struct ast_channel_tech * tech
struct ast_readq_list * ast_channel_readq(struct ast_channel *chan)
static int unload_module(void)
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
struct ast_stream * ast_stream_topology_get_first_stream_by_type(const struct ast_stream_topology *topology, enum ast_media_type type)
Gets the first active stream of a specific type from the topology.
static const struct ast_channel_tech mock_channel_old_write_tech
General Asterisk PBX channel definitions.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
#define ast_test_status_update(a, b, c...)
void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value)
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
const struct ast_format_cap * ast_stream_get_formats(const struct ast_stream *stream)
Get the current negotiated formats of a stream.
Structure to describe a channel "technology", ie a channel driver See for examples: ...
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
static const struct ast_channel_tech mock_channel_write_stream_tech
static int load_stream_readqueue(struct ast_channel *chan, int frames)
Set when the stream is sending and receiving media.
int ast_channel_stream_topology_changed(struct ast_channel *chan, struct ast_stream_topology *topology)
Provide notice to a channel that the stream topology has changed.
struct ast_stream_topology * ast_channel_set_stream_topology(struct ast_channel *chan, struct ast_stream_topology *topology)
Set the topology of streams on a channel.
void ast_stream_set_type(struct ast_stream *stream, enum ast_media_type type)
Change the media type of a stream.
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
static int mock_channel_indicate(struct ast_channel *chan, int condition, const void *data, size_t datalen)
struct ast_stream_topology * ast_stream_topology_alloc(void)
Create a stream topology.
#define AST_TEST_UNREGISTER(cb)
unsigned int wrote_stream
#define ast_channel_unlock(chan)
#define ast_calloc(num, len)
A wrapper for calloc()
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
void ast_stream_set_state(struct ast_stream *stream, enum ast_stream_state state)
Set the state of a stream.
char * ast_uuid_generate_str(char *buf, size_t size)
Generate a UUID string.
int ast_write(struct ast_channel *chan, struct ast_frame *frame)
Write a frame to a channel This function writes the given frame to the indicated channel.
static struct ast_frame * read_from_chan(enum CHANNEL_READ_TYPE rt, struct ast_channel *chan)
static const struct ast_channel_tech mock_stream_channel_tech
unsigned int indicated_changed
int ast_stream_topology_get_count(const struct ast_stream_topology *topology)
Get the number of streams in a topology.
struct ast_frame *(*const read)(struct ast_channel *chan)
Read a frame (or chain of frames from the same stream), in standard format (see frame.h)
AST_TEST_DEFINE(stream_create)
struct ast_stream_topology * ast_stream_topology_clone(const struct ast_stream_topology *topology)
Create a deep clone of an existing stream topology.
struct ast_frame ast_null_frame
void ast_stream_free(struct ast_stream *stream)
Destroy a media stream representation.
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
struct ast_stream * ast_stream_alloc(const char *name, enum ast_media_type type)
Create a new media stream representation.
static int load_module(void)
static int mock_channel_write(struct ast_channel *chan, struct ast_frame *fr)
int ast_stream_set_metadata(struct ast_stream *stream, const char *m_key, const char *value)
Set a stream metadata value.
const char * ast_stream_get_metadata(const struct ast_stream *stream, const char *m_key)
Get a stream metadata value.
Data structure associated with a single frame of data.
union ast_frame::@263 data
ast_media_type
Types of media.
void ast_stream_topology_map(const struct ast_stream_topology *topology, struct ast_vector_int *types, struct ast_vector_int *v0, struct ast_vector_int *v1)
Map a given topology's streams to the given types.
enum ast_frame_type frametype
#define topology_append_stream(topology, name, type, res, label)
struct ast_format * format
void ast_stream_topology_free(struct ast_stream_topology *topology)
Unreference and destroy a stream topology.
int ast_stream_get_position(const struct ast_stream *stream)
Get the position of the stream in the topology.
const char * ast_stream_get_name(const struct ast_stream *stream)
Get the name of a stream.
#define ASTERISK_GPL_KEY
The text the key() function should return.
static const struct ast_channel_tech mock_channel_tech
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
Asterisk module definitions.
static int check_stream_positions(struct ast_test *test, const struct ast_stream_topology *topology)
void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
static int mock_channel_hangup(struct ast_channel *chan)
static struct ast_channel * make_channel(struct ast_test *test, int streams, struct ast_channel_tech *tech)
int ast_stream_topology_del_stream(struct ast_stream_topology *topology, unsigned int position)
Delete a specified stream from the given topology.
enum ast_stream_state ast_stream_get_state(const struct ast_stream *stream)
Get the current state of a stream.
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
unsigned int position
The position of the stream in the topology.