mirror of
https://github.com/asterisk/asterisk.git
synced 2025-12-01 02:31:55 +00:00
Updated the AudioSocket protocol to allow sending DTMF frames.
AST_FRAME_DTMF frames are now forwarded to the server, in addition to
AST_FRAME_AUDIO frames. A new payload type AST_AUDIOSOCKET_KIND_DTMF
with value 0x03 was added to the protocol. The payload is a 1-byte
ascii representing the DTMF digit (0-9,*,#...).
UserNote: The AudioSocket protocol now forwards DTMF frames with
payload type 0x03. The payload is a 1-byte ascii representing the DTMF
digit (0-9,*,#...).
(cherry picked from commit c44e7e85ec)
125 lines
3.7 KiB
C
125 lines
3.7 KiB
C
/*
|
|
* Asterisk -- An open source telephony toolkit.
|
|
*
|
|
* Copyright (C) 2019, CyCore Systems, Inc
|
|
*
|
|
* Seán C McCord <scm@cycoresys.com
|
|
*
|
|
* See http://www.asterisk.org for more information about
|
|
* the Asterisk project. Please do not directly contact
|
|
* any of the maintainers of this project for assistance;
|
|
* the project provides a web site, mailing lists and IRC
|
|
* channels for your use.
|
|
*
|
|
* This program is free software, distributed under the terms of
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
* at the top of the source tree.
|
|
*/
|
|
|
|
/*!
|
|
* \file
|
|
* \brief AudioSocket support functions
|
|
*
|
|
* \author Seán C McCord <scm@cycoresys.com>
|
|
*
|
|
*/
|
|
|
|
#ifndef _ASTERISK_RES_AUDIOSOCKET_H
|
|
#define _ASTERISK_RES_AUDIOSOCKET_H
|
|
|
|
#if defined(__cplusplus) || defined(c_plusplus)
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include <uuid/uuid.h>
|
|
|
|
#include "asterisk/frame.h"
|
|
#include "asterisk/uuid.h"
|
|
|
|
|
|
enum ast_audiosocket_msg_kind {
|
|
/*! \brief Message indicates the channel should be hung up, direction: Sent only. */
|
|
AST_AUDIOSOCKET_KIND_HANGUP = 0x00,
|
|
|
|
/*! \brief Message contains the connection's UUID, direction: Received only. */
|
|
AST_AUDIOSOCKET_KIND_UUID = 0x01,
|
|
|
|
/*! \brief Message contains a DTMF digit, direction: Received only. */
|
|
AST_AUDIOSOCKET_KIND_DTMF = 0x03,
|
|
|
|
/*! \brief Messages contains audio data, direction: Sent and received. */
|
|
AST_AUDIOSOCKET_KIND_AUDIO = 0x10,
|
|
|
|
/*! \brief An Asterisk-side error occurred, direction: Received only. */
|
|
AST_AUDIOSOCKET_KIND_ERROR = 0xFF,
|
|
};
|
|
|
|
|
|
/*!
|
|
* \brief Send the initial message to an AudioSocket server
|
|
*
|
|
* \param server The server address, including port.
|
|
* \param chan An optional channel which will be put into autoservice during
|
|
* the connection period. If there is no channel to be autoserviced, pass NULL
|
|
* instead.
|
|
*
|
|
* \retval socket file descriptor for AudioSocket on success
|
|
* \retval -1 on error
|
|
*/
|
|
const int ast_audiosocket_connect(const char *server, struct ast_channel *chan);
|
|
|
|
/*!
|
|
* \brief Send the initial message to an AudioSocket server
|
|
*
|
|
* \param svc The file descriptor of the network socket to the AudioSocket server.
|
|
* \param id The UUID to send to the AudioSocket server to uniquely identify this connection.
|
|
*
|
|
* \retval 0 on success
|
|
* \retval -1 on error
|
|
*/
|
|
const int ast_audiosocket_init(const int svc, const char *id);
|
|
|
|
/*!
|
|
* \brief Send an Asterisk audio frame to an AudioSocket server
|
|
*
|
|
* \param svc The file descriptor of the network socket to the AudioSocket server.
|
|
* \param f The Asterisk audio frame to send.
|
|
*
|
|
* \retval 0 on success
|
|
* \retval -1 on error
|
|
*/
|
|
const int ast_audiosocket_send_frame(const int svc, const struct ast_frame *f);
|
|
|
|
/*!
|
|
* \brief Receive an Asterisk frame from an AudioSocket server
|
|
*
|
|
* This returned object is a pointer to an Asterisk frame which must be
|
|
* manually freed by the caller.
|
|
*
|
|
* \param svc The file descriptor of the network socket to the AudioSocket server.
|
|
*
|
|
* \retval A \ref ast_frame on success
|
|
* \retval NULL on error
|
|
*/
|
|
struct ast_frame *ast_audiosocket_receive_frame(const int svc);
|
|
|
|
/*!
|
|
* \brief Receive an Asterisk frame from an AudioSocket server
|
|
*
|
|
* This returned object is a pointer to an Asterisk frame which must be
|
|
* manually freed by the caller.
|
|
*
|
|
* \param svc The file descriptor of the network socket to the AudioSocket
|
|
* server.
|
|
* \param hangup Will be true if the AudioSocket server requested the channel
|
|
* be hung up, otherwise false. Used as an out-parameter only, pass NULL if
|
|
* not needed. The function return value will always be NULL when true.
|
|
*
|
|
* \retval A \ref ast_frame on success
|
|
* \retval NULL on error or when the hungup parameter is true.
|
|
*/
|
|
struct ast_frame *ast_audiosocket_receive_frame_with_hangup(const int svc,
|
|
int *const hangup);
|
|
|
|
#endif /* _ASTERISK_RES_AUDIOSOCKET_H */
|