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";
 
 
  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";
 
 
  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;
 
 1729            streams, 
frames, frames_per_read, expected_nulls);
 
 1731    ast_test_validate_cleanup(
test, mock_channel, 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; \ 
 
 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);
 
 
Asterisk main include file. File version handling, generic pbx functions.
#define ast_calloc(num, len)
A wrapper for calloc()
General Asterisk PBX channel definitions.
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_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_channel_tech_pvt(const struct ast_channel *chan)
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value)
#define ast_channel_lock(chan)
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.
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
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.
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
struct ast_frame * ast_read_stream(struct ast_channel *chan)
Reads a frame, but does not filter to just the default streams.
void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
struct ast_stream_topology * ast_channel_get_stream_topology(const struct ast_channel *chan)
Retrieve the topology of streams on a channel.
void ast_channel_fdno_set(struct ast_channel *chan, int value)
struct ast_readq_list * ast_channel_readq(struct ast_channel *chan)
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...
void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value)
#define ast_channel_unlock(chan)
ast_media_type
Types of media.
const char * ast_codec_media_type2str(enum ast_media_type type)
Conversion function to take a media type and turn it into a string.
#define ast_frdup(fr)
Copies a frame.
@ AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE
@ AST_CONTROL_STREAM_TOPOLOGY_CHANGED
struct ast_frame ast_null_frame
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Asterisk module definitions.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
struct ast_stream_topology * ast_stream_topology_alloc(void)
Create a stream topology.
struct ast_stream * ast_stream_alloc(const char *name, enum ast_media_type type)
Create a new media stream representation.
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.
const char * ast_stream_get_metadata(const struct ast_stream *stream, const char *m_key)
Get a stream metadata value.
const char * ast_stream_get_name(const struct ast_stream *stream)
Get the name of a stream.
int ast_stream_set_metadata(struct ast_stream *stream, const char *m_key, const char *value)
Set a stream metadata value.
@ AST_STREAM_STATE_INACTIVE
Set when the stream is not sending OR receiving media.
@ AST_STREAM_STATE_REMOVED
Set when the stream has been removed/declined.
@ AST_STREAM_STATE_SENDRECV
Set when the stream is sending and receiving media.
int ast_stream_get_position(const struct ast_stream *stream)
Get the position of the stream in the topology.
void ast_stream_set_state(struct ast_stream *stream, enum ast_stream_state state)
Set the state of a stream.
int ast_stream_topology_append_stream(struct ast_stream_topology *topology, struct ast_stream *stream)
Append a stream to the topology.
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_get_count(const struct ast_stream_topology *topology)
Get the number of streams in a topology.
enum ast_stream_state ast_stream_get_state(const struct ast_stream *stream)
Get the current state of a stream.
int ast_stream_topology_del_stream(struct ast_stream_topology *topology, unsigned int position)
Delete a specified stream from the given topology.
enum ast_media_type ast_stream_get_type(const struct ast_stream *stream)
Get the media type of a stream.
void ast_stream_topology_free(struct ast_stream_topology *topology)
Unreference and destroy a stream topology.
void ast_stream_set_formats(struct ast_stream *stream, struct ast_format_cap *caps)
Set the current negotiated formats of a stream.
void ast_stream_set_type(struct ast_stream *stream, enum ast_media_type type)
Change the media type of a stream.
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...
struct ast_format_cap * ast_stream_topology_get_formats(struct ast_stream_topology *topology)
Create a format capabilities structure representing the topology.
void ast_stream_free(struct ast_stream *stream)
Destroy a media stream representation.
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.
const struct ast_format_cap * ast_stream_get_formats(const struct ast_stream *stream)
Get the current negotiated formats of a stream.
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_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.
#define ast_str_alloca(init_len)
Structure to describe a channel "technology", ie a channel driver See for examples:
int(*const write)(struct ast_channel *chan, struct ast_frame *frame)
Write a frame, in standard format (see frame.h)
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....
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....
Main Channel structure associated with a channel.
const struct ast_channel_tech * tech
struct ast_format * format
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
enum ast_frame_type frametype
union ast_frame::@239 data
struct ast_frame::@240 frame_list
Support for dynamic strings.
unsigned int position
The position of the stream in the topology.
Integer vector definition.
unsigned int wrote_stream
unsigned int indicated_changed
unsigned int indicated_change_request
#define AST_TEST_REGISTER(cb)
#define ast_test_status_update(a, b, c...)
#define AST_TEST_UNREGISTER(cb)
#define AST_TEST_DEFINE(hdr)
static int mock_channel_write_stream(struct ast_channel *chan, int stream_num, struct ast_frame *fr)
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 const struct ast_channel_tech mock_stream_channel_tech
static struct ast_frame * mock_channel_read(struct ast_channel *chan)
static int mock_channel_write(struct ast_channel *chan, struct ast_frame *fr)
static int mock_channel_indicate(struct ast_channel *chan, int condition, const void *data, size_t datalen)
static int load_stream_readqueue(struct ast_channel *chan, int frames)
static const struct ast_channel_tech mock_channel_write_stream_tech
#define topology_append_stream(topology, name, type, res, label)
static struct ast_frame * read_from_chan(enum CHANNEL_READ_TYPE rt, struct ast_channel *chan)
static struct ast_channel * make_channel(struct ast_test *test, int streams, struct ast_channel_tech *tech)
static const struct ast_channel_tech mock_channel_tech
static int load_module(void)
static int mock_channel_hangup(struct ast_channel *chan)
static int unload_module(void)
static const struct ast_channel_tech mock_channel_old_write_tech
static int check_stream_positions(struct ast_test *test, const struct ast_stream_topology *topology)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Universally unique identifier support.
char * ast_uuid_generate_str(char *buf, size_t size)
Generate a UUID string.
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.