76 static const char app[] =
"StreamEcho";
81 const char *media_type;
92 ast_log(LOG_ERROR,
"%s - unable to write frame type '%s' to stream type '%s' at "
93 "position '%d'\n", ast_channel_name(chan), frame_type, media_type,
112 return stream_echo_write_error(chan, frame, num);
146 return stream_echo_write_error(chan, frame, i);
154 static int stream_echo_perform(
struct ast_channel *chan,
158 int request_change = topology != NULL;
164 if (request_change) {
167 ast_log(LOG_WARNING,
"Request stream topology change not supported "
168 "by channel '%s'\n", ast_channel_name(chan));
188 if (stream_echo_write(chan, f, type, one_to_one)) {
204 stream_echo_write(chan, &frame, type, one_to_one);
211 stream_echo_write(chan, f, type, one_to_one)) {
284 static int stream_echo_exec(
struct ast_channel *chan,
const char *data)
287 unsigned int num = 0;
300 if (ast_strlen_zero(args.num)) {
306 return stream_echo_perform(chan, NULL, AST_MEDIA_TYPE_UNKNOWN);
310 ast_log(LOG_ERROR,
"Failed to parse the first parameter '%s' into a"
311 " greater than or equal to zero\n", args.num);
315 type = ast_strlen_zero(args.type) ? AST_MEDIA_TYPE_VIDEO :
318 topology = stream_echo_topology_alloc(
321 ast_log(LOG_ERROR,
"Unable to create '%u' streams of type '%s' to"
326 res = stream_echo_perform(chan, topology, type);
335 static int unload_module(
void)
340 static int load_module(
void)
Main Channel structure associated with a channel.
Asterisk main include file. File version handling, generic pbx functions.
int ast_channel_is_multistream(struct ast_channel *chan)
Determine if a channel is multi-stream capable.
struct ast_stream_topology * ast_channel_get_stream_topology(const struct ast_channel *chan)
Retrieve the topology of streams on a channel.
enum ast_media_type ast_stream_get_type(const struct ast_stream *stream)
Get the media type of a stream.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
const char * ast_codec_media_type2str(enum ast_media_type type)
Conversion function to take a media type and turn it into a string.
enum ast_media_type ast_media_type_from_str(const char *media_type_str)
Conversion function to take a media string and convert it to a media type.
Set when the stream has been removed/declined.
struct ast_frame * ast_read_stream(struct ast_channel *chan)
Reads a frame, but does not filter to just the default streams.
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
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.
int ast_unregister_application(const char *app)
Unregister an application.
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
General Asterisk PBX channel definitions.
enum ast_media_type type
The type of media the stream is handling.
struct ast_stream * ast_channel_get_default_stream(struct ast_channel *chan, enum ast_media_type type)
Retrieve the default stream of a specific media type on a channel.
#define ast_strdupa(s)
duplicate a string in memory from the stack
Conversion utility functions.
Set when the stream is sending and receiving media.
struct ast_stream_topology * ast_stream_topology_alloc(void)
Create a stream topology.
Set when the stream is sending media only.
void ast_stream_set_state(struct ast_stream *stream, enum ast_stream_state state)
Set the state of a stream.
int ast_str_to_uint(const char *str, unsigned int *res)
Convert the given string to an unsigned integer.
int ast_stream_topology_get_count(const struct ast_stream_topology *topology)
Get the number of streams in a topology.
char * ast_frame_type2str(enum ast_frame_type frame_type, char *ftype, size_t len)
Copy the discription of a frame type into the provided string.
void ast_stream_free(struct ast_stream *stream)
Destroy a media stream representation.
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
struct ast_stream * ast_stream_clone(const struct ast_stream *stream, const char *name)
Create a deep clone of an existing stream.
Data structure associated with a single frame of data.
ast_media_type
Types of media.
enum ast_frame_type frametype
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.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
enum ast_stream_state ast_stream_get_state(const struct ast_stream *stream)
Get the current state of a stream.
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
#define AST_APP_ARG(name)
Define an application argument.