summaryrefslogtreecommitdiff
path: root/include/asterisk/channel.h
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2017-02-22 11:00:57 +0000
committerJoshua Colp <jcolp@digium.com>2017-02-23 18:31:15 +0000
commit6cc890b880a6d50b3236860c3ab89e26ba59a7d3 (patch)
tree2e3c881e0f076ed443d8d47230e1597a3dbb4df5 /include/asterisk/channel.h
parent911252d7b54f8ee7af30f71e26e7a26ef881d316 (diff)
channel: Add support for writing to a specific stream.
This change adds an ast_write_stream function which allows writing a frame to a specific media stream. It also moves ast_write() to using this underneath by writing media frames provided to it to the default streams of the channel. Existing functionality (such as audiohooks, framehooks, etc) are limited to being applied to the default stream only. Unit tests have also been added which test the behavior of both non-multistream and multistream channels to confirm that the write() and write_stream() callbacks are invoked appropriately. ASTERISK-26793 Change-Id: I4df20d1b65bd4d787fce0b4b478e19d2dfea245c
Diffstat (limited to 'include/asterisk/channel.h')
-rw-r--r--include/asterisk/channel.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index 4170a8af4..80476a4e0 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -670,6 +670,9 @@ struct ast_channel_tech {
/*! \brief Write a frame, in standard format (see frame.h) */
int (* const write)(struct ast_channel *chan, struct ast_frame *frame);
+ /*! \brief Write a frame on a specific stream, in standard format (see frame.h) */
+ int (* const write_stream)(struct ast_channel *chan, int stream_num, struct ast_frame *frame);
+
/*! \brief Display or transmit text */
int (* const send_text)(struct ast_channel *chan, const char *text);
@@ -1968,6 +1971,18 @@ int ast_write_video(struct ast_channel *chan, struct ast_frame *frame);
*/
int ast_write_text(struct ast_channel *chan, struct ast_frame *frame);
+/*!
+ * \brief Write a frame to a stream
+ * This function writes the given frame to the indicated stream on the channel.
+ * \param chan destination channel of the frame
+ * \param stream_num destination stream on the channel
+ * \param frame frame that will be written
+ * \return It returns 0 on success, -1 on failure.
+ * \note If -1 is provided as the stream number and a media frame is provided the
+ * function will write to the default stream of the type of media.
+ */
+int ast_write_stream(struct ast_channel *chan, int stream_num, struct ast_frame *frame);
+
/*! \brief Send empty audio to prime a channel driver */
int ast_prod(struct ast_channel *chan);
@@ -4768,4 +4783,17 @@ struct ast_stream_topology *ast_channel_get_stream_topology(
struct ast_stream_topology *ast_channel_set_stream_topology(
struct ast_channel *chan, struct ast_stream_topology *topology);
+/*!
+ * \brief Retrieve the default stream of a specific media type on a channel
+ *
+ * \param channel The channel to get the stream from
+ * \param type The media type of the default stream
+ *
+ * \pre chan is locked
+ *
+ * \retval non-NULL success
+ * \retval NULL failure
+ */
+struct ast_stream *ast_channel_get_default_stream(struct ast_channel *chan, enum ast_media_type type);
+
#endif /* _ASTERISK_CHANNEL_H */