core_unreal / core_local: Add multistream and re-negotiation.

When requesting a Local channel the requested stream topology
or a converted stream topology will now be placed onto the
resulting channels.

Frames written in on streams will now also preserve the stream
identifier as they are queued on the opposite channel.

Finally when a stream topology change is requested it is
immediately accepted and reflected on both channels. Each
channel also receives a queued frame to indicate that the
topology has changed.

ASTERISK-28938

Change-Id: I4e9d94da5230d4bd046dc755651493fce1d87186
This commit is contained in:
Joshua C. Colp
2020-06-15 08:50:54 -05:00
committed by Friendly Automation
parent 49b204ed8a
commit 563f2f94d6
3 changed files with 251 additions and 7 deletions
+19
View File
@@ -40,6 +40,7 @@ extern "C" {
/* Forward declare some struct names */
struct ast_format_cap;
struct ast_stream_topology;
/* ------------------------------------------------------------------- */
@@ -96,6 +97,7 @@ struct ast_unreal_pvt {
unsigned int flags; /*!< Private option flags */
/*! Base name of the unreal channels. exten@context or other name. */
char name[AST_MAX_EXTENSION + AST_MAX_CONTEXT + 2];
struct ast_stream_topology *reqtopology; /*!< Requested stream topology */
};
#define AST_UNREAL_IS_OUTBOUND(a, b) ((a) == (b)->chan ? 1 : 0)
@@ -146,6 +148,9 @@ struct ast_frame *ast_unreal_read(struct ast_channel *ast);
/*! Unreal channel framework struct ast_channel_tech.write callback */
int ast_unreal_write(struct ast_channel *ast, struct ast_frame *f);
/*! Unreal channel framework struct ast_channel_tech.write_stream callback */
int ast_unreal_write_stream(struct ast_channel *ast, int stream_num, struct ast_frame *f);
/*! Unreal channel framework struct ast_channel_tech.indicate callback */
int ast_unreal_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen);
@@ -187,6 +192,20 @@ void ast_unreal_destructor(void *vdoomed);
*/
struct ast_unreal_pvt *ast_unreal_alloc(size_t size, ao2_destructor_fn destructor, struct ast_format_cap *cap);
/*!
* \brief Allocate the base unreal struct for a derivative.
* \since 16.12.0
* \since 17.6.0
*
* \param size Size of the unreal struct to allocate.
* \param destructor Destructor callback.
* \param cap Format capabilities to give the unreal private struct.
*
* \retval pvt on success.
* \retval NULL on error.
*/
struct ast_unreal_pvt *ast_unreal_alloc_stream_topology(size_t size, ao2_destructor_fn destructor, struct ast_stream_topology *topology);
/*!
* \brief Create the semi1 and semi2 unreal channels.
* \since 12.0.0