Asterisk - The Open Source Telephony Project GIT-master-8924258
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
res_audiosocket.h
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2019, CyCore Systems, Inc
5 *
6 * Seán C McCord <scm@cycoresys.com
7 *
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
13 *
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
17 */
18
19/*!
20 * \file
21 * \brief AudioSocket support functions
22 *
23 * \author Seán C McCord <scm@cycoresys.com>
24 *
25 */
26
27#ifndef _ASTERISK_RES_AUDIOSOCKET_H
28#define _ASTERISK_RES_AUDIOSOCKET_H
29
30#if defined(__cplusplus) || defined(c_plusplus)
31extern "C" {
32#endif
33
34#include <uuid/uuid.h>
35
36#include "asterisk/frame.h"
37#include "asterisk/uuid.h"
38
39
41 /*! \brief Message indicates the channel should be hung up, direction: Sent only. */
43
44 /*! \brief Message contains the connection's UUID, direction: Received only. */
46
47 /*! \brief Message contains a DTMF digit, direction: Received only. */
49
50 /*! \brief Messages contains audio data, direction: Sent and received. */
52
53 /*! \brief An Asterisk-side error occurred, direction: Received only. */
55};
56
57
58/*!
59 * \brief Send the initial message to an AudioSocket server
60 *
61 * \param server The server address, including port.
62 * \param chan An optional channel which will be put into autoservice during
63 * the connection period. If there is no channel to be autoserviced, pass NULL
64 * instead.
65 *
66 * \retval socket file descriptor for AudioSocket on success
67 * \retval -1 on error
68 */
69const int ast_audiosocket_connect(const char *server, struct ast_channel *chan);
70
71/*!
72 * \brief Send the initial message to an AudioSocket server
73 *
74 * \param svc The file descriptor of the network socket to the AudioSocket server.
75 * \param id The UUID to send to the AudioSocket server to uniquely identify this connection.
76 *
77 * \retval 0 on success
78 * \retval -1 on error
79 */
80const int ast_audiosocket_init(const int svc, const char *id);
81
82/*!
83 * \brief Send an Asterisk audio frame to an AudioSocket server
84 *
85 * \param svc The file descriptor of the network socket to the AudioSocket server.
86 * \param f The Asterisk audio frame to send.
87 *
88 * \retval 0 on success
89 * \retval -1 on error
90 */
91const int ast_audiosocket_send_frame(const int svc, const struct ast_frame *f);
92
93/*!
94 * \brief Receive an Asterisk frame from an AudioSocket server
95 *
96 * This returned object is a pointer to an Asterisk frame which must be
97 * manually freed by the caller.
98 *
99 * \param svc The file descriptor of the network socket to the AudioSocket server.
100 *
101 * \retval A \ref ast_frame on success
102 * \retval NULL on error
103 */
104struct ast_frame *ast_audiosocket_receive_frame(const int svc);
105
106/*!
107 * \brief Receive an Asterisk frame from an AudioSocket server
108 *
109 * This returned object is a pointer to an Asterisk frame which must be
110 * manually freed by the caller.
111 *
112 * \param svc The file descriptor of the network socket to the AudioSocket
113 * server.
114 * \param hangup Will be true if the AudioSocket server requested the channel
115 * be hung up, otherwise false. Used as an out-parameter only, pass NULL if
116 * not needed. The function return value will always be NULL when true.
117 *
118 * \retval A \ref ast_frame on success
119 * \retval NULL on error or when the hungup parameter is true.
120 */
122 int *const hangup);
123
124#endif /* _ASTERISK_RES_AUDIOSOCKET_H */
static int hangup(void *data)
Definition: chan_pjsip.c:2520
Asterisk internal frame definitions.
const int ast_audiosocket_init(const int svc, const char *id)
Send the initial message to an AudioSocket server.
const int ast_audiosocket_send_frame(const int svc, const struct ast_frame *f)
Send an Asterisk audio frame to an AudioSocket server.
struct ast_frame * ast_audiosocket_receive_frame(const int svc)
Receive an Asterisk frame from an AudioSocket server.
ast_audiosocket_msg_kind
@ AST_AUDIOSOCKET_KIND_AUDIO
Messages contains audio data, direction: Sent and received.
@ AST_AUDIOSOCKET_KIND_HANGUP
Message indicates the channel should be hung up, direction: Sent only.
@ AST_AUDIOSOCKET_KIND_UUID
Message contains the connection's UUID, direction: Received only.
@ AST_AUDIOSOCKET_KIND_DTMF
Message contains a DTMF digit, direction: Received only.
@ AST_AUDIOSOCKET_KIND_ERROR
An Asterisk-side error occurred, direction: Received only.
struct ast_frame * ast_audiosocket_receive_frame_with_hangup(const int svc, int *const hangup)
Receive an Asterisk frame from an AudioSocket server.
const int ast_audiosocket_connect(const char *server, struct ast_channel *chan)
Send the initial message to an AudioSocket server.
Main Channel structure associated with a channel.
Data structure associated with a single frame of data.
Universally unique identifier support.