Asterisk - The Open Source Telephony Project GIT-master-27fb039
Loading...
Searching...
No Matches
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, format: slin, direction: Sent and received. */
52
53 /*! \brief Messages contains audio data, format: slin12, direction: Sent and received. */
55
56 /*! \brief Messages contains audio data, format: slin16, direction: Sent and received. */
58
59 /*! \brief Messages contains audio data, format: slin24, direction: Sent and received. */
61
62 /*! \brief Messages contains audio data, format: slin32, direction: Sent and received. */
64
65 /*! \brief Messages contains audio data, format: slin44, direction: Sent and received. */
67
68 /*! \brief Messages contains audio data, format: slin48, direction: Sent and received. */
70
71 /*! \brief Messages contains audio data, format: slin96, direction: Sent and received. */
73
74 /*! \brief Messages contains audio data, format: slin192, direction: Sent and received. */
76
77 /*! \brief An Asterisk-side error occurred, direction: Received only. */
79};
80
81
82/*!
83 * \brief Send the initial message to an AudioSocket server
84 *
85 * \param server The server address, including port.
86 * \param chan An optional channel which will be put into autoservice during
87 * the connection period. If there is no channel to be autoserviced, pass NULL
88 * instead.
89 *
90 * \retval socket file descriptor for AudioSocket on success
91 * \retval -1 on error
92 */
93const int ast_audiosocket_connect(const char *server, struct ast_channel *chan);
94
95/*!
96 * \brief Send the initial message to an AudioSocket server
97 *
98 * \param svc The file descriptor of the network socket to the AudioSocket server.
99 * \param id The UUID to send to the AudioSocket server to uniquely identify this connection.
100 *
101 * \retval 0 on success
102 * \retval -1 on error
103 */
104const int ast_audiosocket_init(const int svc, const char *id);
105
106/*!
107 * \brief Send an Asterisk audio frame to an AudioSocket server
108 *
109 * \param svc The file descriptor of the network socket to the AudioSocket server.
110 * \param f The Asterisk audio frame to send.
111 *
112 * \retval 0 on success
113 * \retval -1 on error
114 */
115const int ast_audiosocket_send_frame(const int svc, const struct ast_frame *f);
116
117/*!
118 * \brief Receive an Asterisk frame from an AudioSocket server
119 *
120 * This returned object is a pointer to an Asterisk frame which must be
121 * manually freed by the caller.
122 *
123 * \param svc The file descriptor of the network socket to the AudioSocket server.
124 *
125 * \retval A \ref ast_frame on success
126 * \retval NULL on error
127 */
128struct ast_frame *ast_audiosocket_receive_frame(const int svc);
129
130/*!
131 * \brief Receive an Asterisk frame from an AudioSocket server
132 *
133 * This returned object is a pointer to an Asterisk frame which must be
134 * manually freed by the caller.
135 *
136 * \param svc The file descriptor of the network socket to the AudioSocket
137 * server.
138 * \param hangup Will be true if the AudioSocket server requested the channel
139 * be hung up, otherwise false. Used as an out-parameter only, pass NULL if
140 * not needed. The function return value will always be NULL when true.
141 *
142 * \retval A \ref ast_frame on success
143 * \retval NULL on error or when the hungup parameter is true.
144 */
146 int *const hangup);
147
148#endif /* _ASTERISK_RES_AUDIOSOCKET_H */
static int hangup(void *data)
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_SLIN16
Messages contains audio data, format: slin16, direction: Sent and received.
@ AST_AUDIOSOCKET_KIND_AUDIO
Messages contains audio data, format: slin, direction: Sent and received.
@ AST_AUDIOSOCKET_KIND_AUDIO_SLIN48
Messages contains audio data, format: slin48, direction: Sent and received.
@ AST_AUDIOSOCKET_KIND_HANGUP
Message indicates the channel should be hung up, direction: Sent only.
@ AST_AUDIOSOCKET_KIND_AUDIO_SLIN96
Messages contains audio data, format: slin96, direction: Sent and received.
@ AST_AUDIOSOCKET_KIND_AUDIO_SLIN192
Messages contains audio data, format: slin192, direction: Sent and received.
@ AST_AUDIOSOCKET_KIND_UUID
Message contains the connection's UUID, direction: Received only.
@ AST_AUDIOSOCKET_KIND_AUDIO_SLIN24
Messages contains audio data, format: slin24, direction: Sent and received.
@ AST_AUDIOSOCKET_KIND_AUDIO_SLIN44
Messages contains audio data, format: slin44, direction: Sent and received.
@ AST_AUDIOSOCKET_KIND_DTMF
Message contains a DTMF digit, direction: Received only.
@ AST_AUDIOSOCKET_KIND_AUDIO_SLIN12
Messages contains audio data, format: slin12, direction: Sent and received.
@ AST_AUDIOSOCKET_KIND_AUDIO_SLIN32
Messages contains audio data, format: slin32, direction: Sent and received.
@ 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.