2014-02-10 06:06:44 +08:00
|
|
|
/** toxav.h
|
2014-02-17 09:01:30 +08:00
|
|
|
*
|
2014-02-10 06:06:44 +08:00
|
|
|
* Copyright (C) 2013 Tox project All Rights Reserved.
|
|
|
|
*
|
|
|
|
* This file is part of Tox.
|
|
|
|
*
|
|
|
|
* Tox is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Tox is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Tox. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __TOXAV
|
|
|
|
#define __TOXAV
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
2014-06-19 05:52:34 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2014-02-16 03:44:33 +08:00
|
|
|
/* vpx_image_t */
|
|
|
|
#include <vpx/vpx_image.h>
|
|
|
|
|
2014-07-22 23:20:55 +08:00
|
|
|
typedef void ( *ToxAVCallback ) ( void *agent, int32_t call_idx, void *arg );
|
2014-02-10 06:06:44 +08:00
|
|
|
typedef struct _ToxAv ToxAv;
|
|
|
|
|
|
|
|
#ifndef __TOX_DEFINED__
|
|
|
|
#define __TOX_DEFINED__
|
|
|
|
typedef struct Tox Tox;
|
|
|
|
#endif
|
|
|
|
|
2014-02-16 03:44:33 +08:00
|
|
|
#define RTP_PAYLOAD_SIZE 65535
|
|
|
|
|
2014-02-10 06:06:44 +08:00
|
|
|
|
2014-02-17 09:01:30 +08:00
|
|
|
/**
|
2014-02-16 04:29:41 +08:00
|
|
|
* @brief Callbacks ids that handle the call states.
|
2014-02-10 06:06:44 +08:00
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
/* Requests */
|
2014-03-07 10:13:04 +08:00
|
|
|
av_OnInvite,
|
|
|
|
av_OnStart,
|
|
|
|
av_OnCancel,
|
|
|
|
av_OnReject,
|
|
|
|
av_OnEnd,
|
2014-02-17 09:01:30 +08:00
|
|
|
|
2014-02-10 06:06:44 +08:00
|
|
|
/* Responses */
|
2014-03-07 10:13:04 +08:00
|
|
|
av_OnRinging,
|
|
|
|
av_OnStarting,
|
|
|
|
av_OnEnding,
|
2014-02-17 09:01:30 +08:00
|
|
|
|
2014-02-10 06:06:44 +08:00
|
|
|
/* Protocol */
|
2014-03-15 06:10:10 +08:00
|
|
|
av_OnRequestTimeout,
|
2014-07-21 07:10:57 +08:00
|
|
|
av_OnPeerTimeout,
|
|
|
|
av_OnMediaChange
|
2014-02-10 06:06:44 +08:00
|
|
|
} ToxAvCallbackID;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Call type identifier.
|
|
|
|
*/
|
|
|
|
typedef enum {
|
2014-05-24 22:02:01 +08:00
|
|
|
TypeAudio = 192,
|
2014-02-10 06:06:44 +08:00
|
|
|
TypeVideo
|
|
|
|
} ToxAvCallType;
|
|
|
|
|
|
|
|
|
2014-07-05 00:16:53 +08:00
|
|
|
typedef enum {
|
|
|
|
av_CallNonExistant = -1,
|
|
|
|
av_CallInviting, /* when sending call invite */
|
|
|
|
av_CallStarting, /* when getting call invite */
|
|
|
|
av_CallActive,
|
|
|
|
av_CallHold,
|
|
|
|
av_CallHanged_up
|
|
|
|
} ToxAvCallState;
|
|
|
|
|
2014-02-16 04:29:41 +08:00
|
|
|
/**
|
|
|
|
* @brief Error indicators.
|
|
|
|
*/
|
2014-02-10 06:06:44 +08:00
|
|
|
typedef enum {
|
|
|
|
ErrorNone = 0,
|
|
|
|
ErrorInternal = -1, /* Internal error */
|
|
|
|
ErrorAlreadyInCall = -2, /* Already has an active call */
|
|
|
|
ErrorNoCall = -3, /* Trying to perform call action while not in a call */
|
|
|
|
ErrorInvalidState = -4, /* Trying to perform call action while in invalid state*/
|
|
|
|
ErrorNoRtpSession = -5, /* Trying to perform rtp action on invalid session */
|
|
|
|
ErrorAudioPacketLost = -6, /* Indicating packet loss */
|
|
|
|
ErrorStartingAudioRtp = -7, /* Error in toxav_prepare_transmission() */
|
|
|
|
ErrorStartingVideoRtp = -8 , /* Error in toxav_prepare_transmission() */
|
2014-03-07 10:13:04 +08:00
|
|
|
ErrorTerminatingAudioRtp = -9, /* Returned in toxav_kill_transmission() */
|
|
|
|
ErrorTerminatingVideoRtp = -10, /* Returned in toxav_kill_transmission() */
|
2014-05-03 07:46:03 +08:00
|
|
|
ErrorPacketTooLarge = -11, /* Buffer exceeds size while encoding */
|
2014-06-21 07:58:55 +08:00
|
|
|
ErrorInvalidCodecState = -12, /* Codec state not initialized */
|
2014-02-17 09:01:30 +08:00
|
|
|
|
2014-02-10 06:06:44 +08:00
|
|
|
} ToxAvError;
|
|
|
|
|
|
|
|
|
2014-03-11 07:36:47 +08:00
|
|
|
/**
|
|
|
|
* @brief Locally supported capabilities.
|
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
AudioEncoding = 1 << 0,
|
|
|
|
AudioDecoding = 1 << 1,
|
|
|
|
VideoEncoding = 1 << 2,
|
|
|
|
VideoDecoding = 1 << 3
|
|
|
|
} ToxAvCapabilities;
|
|
|
|
|
2014-04-07 05:59:18 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Encoding settings.
|
|
|
|
*/
|
|
|
|
typedef struct _ToxAvCodecSettings {
|
2014-07-27 01:29:49 +08:00
|
|
|
ToxAvCallType call_type;
|
2014-07-27 09:26:32 +08:00
|
|
|
|
2014-06-24 21:32:46 +08:00
|
|
|
uint32_t video_bitrate; /* In kbits/s */
|
2014-07-06 02:36:19 +08:00
|
|
|
uint16_t max_video_width; /* In px */
|
|
|
|
uint16_t max_video_height; /* In px */
|
2014-05-26 00:27:48 +08:00
|
|
|
|
2014-04-07 05:59:18 +08:00
|
|
|
uint32_t audio_bitrate; /* In bits/s */
|
|
|
|
uint16_t audio_frame_duration; /* In ms */
|
|
|
|
uint32_t audio_sample_rate; /* In Hz */
|
|
|
|
uint32_t audio_channels;
|
2014-07-27 06:26:58 +08:00
|
|
|
} ToxAvCSettings;
|
2014-04-07 05:59:18 +08:00
|
|
|
|
2014-07-27 06:26:58 +08:00
|
|
|
extern const ToxAvCSettings av_DefaultSettings;
|
|
|
|
extern const uint32_t av_jbufdc; /* Jitter buffer default capacity */
|
|
|
|
extern const uint32_t av_VADd; /* VAD default treshold */
|
2014-04-07 05:59:18 +08:00
|
|
|
|
2014-02-16 04:29:41 +08:00
|
|
|
/**
|
|
|
|
* @brief Start new A/V session. There can only be one session at the time. If you register more
|
|
|
|
* it will result in undefined behaviour.
|
2014-02-17 09:01:30 +08:00
|
|
|
*
|
2014-02-16 04:29:41 +08:00
|
|
|
* @param messenger The messenger handle.
|
2014-02-20 06:12:36 +08:00
|
|
|
* @param userdata The agent handling A/V session (i.e. phone).
|
2014-02-16 04:29:41 +08:00
|
|
|
* @param video_width Width of video frame.
|
|
|
|
* @param video_height Height of video frame.
|
|
|
|
* @return ToxAv*
|
|
|
|
* @retval NULL On error.
|
|
|
|
*/
|
2014-05-17 01:56:40 +08:00
|
|
|
ToxAv *toxav_new(Tox *messenger, int32_t max_calls);
|
2014-02-16 04:29:41 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Remove A/V session.
|
2014-02-17 09:01:30 +08:00
|
|
|
*
|
2014-02-16 04:29:41 +08:00
|
|
|
* @param av Handler.
|
|
|
|
* @return void
|
|
|
|
*/
|
2014-02-17 09:01:30 +08:00
|
|
|
void toxav_kill(ToxAv *av);
|
2014-02-10 06:06:44 +08:00
|
|
|
|
2014-02-16 04:29:41 +08:00
|
|
|
/**
|
|
|
|
* @brief Register callback for call state.
|
2014-02-17 09:01:30 +08:00
|
|
|
*
|
2014-07-21 07:10:57 +08:00
|
|
|
* @param av Handler.
|
2014-02-16 04:29:41 +08:00
|
|
|
* @param callback The callback
|
|
|
|
* @param id One of the ToxAvCallbackID values
|
|
|
|
* @return void
|
|
|
|
*/
|
2014-07-21 07:10:57 +08:00
|
|
|
void toxav_register_callstate_callback (ToxAv *av, ToxAVCallback callback, ToxAvCallbackID id, void *userdata);
|
|
|
|
|
|
|
|
/**
|
2014-09-10 08:31:37 +08:00
|
|
|
* @brief Register callback for receiving audio data
|
2014-07-21 07:10:57 +08:00
|
|
|
*
|
|
|
|
* @param av Handler.
|
|
|
|
* @param callback The callback
|
|
|
|
* @return void
|
|
|
|
*/
|
2014-08-02 23:29:27 +08:00
|
|
|
void toxav_register_audio_recv_callback (ToxAv *av, void (*callback)(ToxAv *, int32_t, int16_t *, int, void *),
|
|
|
|
void *user_data);
|
2014-07-21 07:10:57 +08:00
|
|
|
|
|
|
|
/**
|
2014-09-10 08:31:37 +08:00
|
|
|
* @brief Register callback for receiving video data
|
2014-07-21 07:10:57 +08:00
|
|
|
*
|
|
|
|
* @param av Handler.
|
|
|
|
* @param callback The callback
|
|
|
|
* @return void
|
|
|
|
*/
|
2014-08-02 23:29:27 +08:00
|
|
|
void toxav_register_video_recv_callback (ToxAv *av, void (*callback)(ToxAv *, int32_t, vpx_image_t *, void *),
|
|
|
|
void *user_data);
|
2014-02-10 06:06:44 +08:00
|
|
|
|
2014-02-16 04:29:41 +08:00
|
|
|
/**
|
|
|
|
* @brief Call user. Use its friend_id.
|
2014-02-17 09:01:30 +08:00
|
|
|
*
|
2014-02-16 04:29:41 +08:00
|
|
|
* @param av Handler.
|
|
|
|
* @param user The user.
|
|
|
|
* @param call_type Call type.
|
|
|
|
* @param ringing_seconds Ringing timeout.
|
|
|
|
* @return int
|
|
|
|
* @retval 0 Success.
|
|
|
|
* @retval ToxAvError On error.
|
|
|
|
*/
|
2014-07-27 09:26:32 +08:00
|
|
|
int toxav_call(ToxAv *av, int32_t *call_index, int user, const ToxAvCSettings *csettings, int ringing_seconds);
|
2014-02-16 04:29:41 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Hangup active call.
|
2014-02-17 09:01:30 +08:00
|
|
|
*
|
2014-02-16 04:29:41 +08:00
|
|
|
* @param av Handler.
|
|
|
|
* @return int
|
|
|
|
* @retval 0 Success.
|
|
|
|
* @retval ToxAvError On error.
|
|
|
|
*/
|
2014-05-17 01:56:40 +08:00
|
|
|
int toxav_hangup(ToxAv *av, int32_t call_index);
|
2014-02-16 04:29:41 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Answer incomming call.
|
2014-02-17 09:01:30 +08:00
|
|
|
*
|
2014-02-16 04:29:41 +08:00
|
|
|
* @param av Handler.
|
|
|
|
* @param call_type Answer with...
|
|
|
|
* @return int
|
|
|
|
* @retval 0 Success.
|
|
|
|
* @retval ToxAvError On error.
|
|
|
|
*/
|
2014-07-27 09:26:32 +08:00
|
|
|
int toxav_answer(ToxAv *av, int32_t call_index, const ToxAvCSettings *csettings );
|
2014-02-16 04:29:41 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Reject incomming call.
|
2014-02-17 09:01:30 +08:00
|
|
|
*
|
2014-02-16 04:29:41 +08:00
|
|
|
* @param av Handler.
|
|
|
|
* @param reason Optional reason. Set NULL if none.
|
|
|
|
* @return int
|
|
|
|
* @retval 0 Success.
|
|
|
|
* @retval ToxAvError On error.
|
|
|
|
*/
|
2014-05-17 01:56:40 +08:00
|
|
|
int toxav_reject(ToxAv *av, int32_t call_index, const char *reason);
|
2014-02-16 04:29:41 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Cancel outgoing request.
|
2014-02-17 09:01:30 +08:00
|
|
|
*
|
2014-02-16 04:29:41 +08:00
|
|
|
* @param av Handler.
|
|
|
|
* @param reason Optional reason.
|
2014-03-23 02:33:56 +08:00
|
|
|
* @param peer_id peer friend_id
|
2014-02-16 04:29:41 +08:00
|
|
|
* @return int
|
|
|
|
* @retval 0 Success.
|
|
|
|
* @retval ToxAvError On error.
|
|
|
|
*/
|
2014-05-26 00:27:48 +08:00
|
|
|
int toxav_cancel(ToxAv *av, int32_t call_index, int peer_id, const char *reason);
|
2014-02-16 04:29:41 +08:00
|
|
|
|
|
|
|
/**
|
2014-07-27 06:26:58 +08:00
|
|
|
* @brief Notify peer that we are changing call settings
|
2014-02-17 09:01:30 +08:00
|
|
|
*
|
2014-02-16 04:29:41 +08:00
|
|
|
* @param av Handler.
|
|
|
|
* @return int
|
|
|
|
* @retval 0 Success.
|
|
|
|
* @retval ToxAvError On error.
|
|
|
|
*/
|
2014-07-27 09:26:32 +08:00
|
|
|
int toxav_change_settings(ToxAv *av, int32_t call_index, const ToxAvCSettings *csettings);
|
2014-02-10 06:06:44 +08:00
|
|
|
|
2014-02-16 04:29:41 +08:00
|
|
|
/**
|
|
|
|
* @brief Terminate transmission. Note that transmission will be terminated without informing remote peer.
|
2014-02-17 09:01:30 +08:00
|
|
|
*
|
2014-02-16 04:29:41 +08:00
|
|
|
* @param av Handler.
|
|
|
|
* @return int
|
|
|
|
* @retval 0 Success.
|
|
|
|
* @retval ToxAvError On error.
|
|
|
|
*/
|
2014-05-17 01:56:40 +08:00
|
|
|
int toxav_stop_call(ToxAv *av, int32_t call_index);
|
2014-02-10 06:06:44 +08:00
|
|
|
|
2014-02-16 04:29:41 +08:00
|
|
|
/**
|
|
|
|
* @brief Must be call before any RTP transmission occurs.
|
2014-02-17 09:01:30 +08:00
|
|
|
*
|
2014-02-16 04:29:41 +08:00
|
|
|
* @param av Handler.
|
2014-03-07 10:13:04 +08:00
|
|
|
* @param support_video Is video supported ? 1 : 0
|
2014-02-16 04:29:41 +08:00
|
|
|
* @return int
|
|
|
|
* @retval 0 Success.
|
|
|
|
* @retval ToxAvError On error.
|
|
|
|
*/
|
2014-07-27 09:26:32 +08:00
|
|
|
int toxav_prepare_transmission(ToxAv *av, int32_t call_index, uint32_t jbuf_size, uint32_t VAD_treshold,
|
|
|
|
int support_video);
|
2014-02-10 06:06:44 +08:00
|
|
|
|
2014-02-16 04:29:41 +08:00
|
|
|
/**
|
|
|
|
* @brief Call this at the end of the transmission.
|
2014-02-17 09:01:30 +08:00
|
|
|
*
|
2014-02-16 04:29:41 +08:00
|
|
|
* @param av Handler.
|
|
|
|
* @return int
|
|
|
|
* @retval 0 Success.
|
|
|
|
* @retval ToxAvError On error.
|
2014-02-10 06:06:44 +08:00
|
|
|
*/
|
2014-05-26 00:27:48 +08:00
|
|
|
int toxav_kill_transmission(ToxAv *av, int32_t call_index);
|
2014-02-10 06:06:44 +08:00
|
|
|
|
2014-02-16 04:29:41 +08:00
|
|
|
/**
|
|
|
|
* @brief Encode and send video packet.
|
2014-02-17 09:01:30 +08:00
|
|
|
*
|
2014-02-16 04:29:41 +08:00
|
|
|
* @param av Handler.
|
2014-05-11 00:00:49 +08:00
|
|
|
* @param frame The encoded frame.
|
|
|
|
* @param frame_size The size of the encoded frame.
|
2014-02-16 04:29:41 +08:00
|
|
|
* @return int
|
|
|
|
* @retval 0 Success.
|
|
|
|
* @retval ToxAvError On error.
|
|
|
|
*/
|
2014-07-29 23:03:15 +08:00
|
|
|
int toxav_send_video ( ToxAv *av, int32_t call_index, const uint8_t *frame, unsigned int frame_size);
|
2014-02-10 06:06:44 +08:00
|
|
|
|
2014-02-16 04:29:41 +08:00
|
|
|
/**
|
2014-05-03 07:46:03 +08:00
|
|
|
* @brief Send audio frame.
|
2014-02-17 09:01:30 +08:00
|
|
|
*
|
2014-02-16 04:29:41 +08:00
|
|
|
* @param av Handler.
|
2014-07-29 23:03:15 +08:00
|
|
|
* @param data The audio data encoded with toxav_prepare_audio_frame().
|
|
|
|
* @param size Its size in number of bytes.
|
2014-02-16 04:29:41 +08:00
|
|
|
* @return int
|
|
|
|
* @retval 0 Success.
|
|
|
|
* @retval ToxAvError On error.
|
|
|
|
*/
|
2014-07-29 23:03:15 +08:00
|
|
|
int toxav_send_audio ( ToxAv *av, int32_t call_index, const uint8_t *frame, unsigned int size);
|
2014-02-10 06:06:44 +08:00
|
|
|
|
2014-05-11 00:00:49 +08:00
|
|
|
/**
|
|
|
|
* @brief Encode video frame
|
2014-05-26 00:27:48 +08:00
|
|
|
*
|
2014-05-11 00:00:49 +08:00
|
|
|
* @param av Handler
|
|
|
|
* @param dest Where to
|
|
|
|
* @param dest_max Max size
|
|
|
|
* @param input What to encode
|
|
|
|
* @return int
|
|
|
|
* @retval ToxAvError On error.
|
|
|
|
* @retval >0 On success
|
|
|
|
*/
|
2014-05-26 00:27:48 +08:00
|
|
|
int toxav_prepare_video_frame ( ToxAv *av, int32_t call_index, uint8_t *dest, int dest_max, vpx_image_t *input );
|
2014-05-03 07:46:03 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Encode audio frame
|
2014-05-26 00:27:48 +08:00
|
|
|
*
|
2014-05-03 07:46:03 +08:00
|
|
|
* @param av Handler
|
|
|
|
* @param dest dest
|
|
|
|
* @param dest_max Max dest size
|
|
|
|
* @param frame The frame
|
|
|
|
* @param frame_size The frame size
|
|
|
|
* @return int
|
|
|
|
* @retval ToxAvError On error.
|
|
|
|
* @retval >0 On success
|
|
|
|
*/
|
2014-05-26 00:27:48 +08:00
|
|
|
int toxav_prepare_audio_frame ( ToxAv *av, int32_t call_index, uint8_t *dest, int dest_max, const int16_t *frame,
|
|
|
|
int frame_size);
|
2014-02-10 06:06:44 +08:00
|
|
|
|
2014-02-16 04:29:41 +08:00
|
|
|
/**
|
|
|
|
* @brief Get peer transmission type. It can either be audio or video.
|
2014-02-17 09:01:30 +08:00
|
|
|
*
|
2014-02-16 04:29:41 +08:00
|
|
|
* @param av Handler.
|
|
|
|
* @param peer The peer
|
|
|
|
* @return int
|
|
|
|
* @retval ToxAvCallType On success.
|
|
|
|
* @retval ToxAvError On error.
|
|
|
|
*/
|
2014-07-27 09:26:32 +08:00
|
|
|
int toxav_get_peer_csettings ( ToxAv *av, int32_t call_index, int peer, ToxAvCSettings *dest );
|
2014-02-16 04:29:41 +08:00
|
|
|
|
2014-03-07 10:13:04 +08:00
|
|
|
/**
|
|
|
|
* @brief Get id of peer participating in conversation
|
2014-05-26 00:27:48 +08:00
|
|
|
*
|
2014-03-07 10:13:04 +08:00
|
|
|
* @param av Handler
|
|
|
|
* @param peer peer index
|
|
|
|
* @return int
|
|
|
|
* @retval ToxAvError No peer id
|
|
|
|
*/
|
2014-05-26 00:27:48 +08:00
|
|
|
int toxav_get_peer_id ( ToxAv *av, int32_t call_index, int peer );
|
2014-03-07 10:13:04 +08:00
|
|
|
|
2014-07-05 00:16:53 +08:00
|
|
|
/**
|
|
|
|
* @brief Get current call state
|
|
|
|
*
|
|
|
|
* @param av Handler
|
|
|
|
* @param call_index What call
|
|
|
|
* @return int
|
|
|
|
* @retval ToxAvCallState State id
|
|
|
|
*/
|
|
|
|
ToxAvCallState toxav_get_call_state ( ToxAv *av, int32_t call_index );
|
2014-02-16 04:29:41 +08:00
|
|
|
/**
|
2014-03-11 07:36:47 +08:00
|
|
|
* @brief Is certain capability supported
|
2014-05-26 00:27:48 +08:00
|
|
|
*
|
2014-03-07 10:13:04 +08:00
|
|
|
* @param av Handler
|
|
|
|
* @return int
|
|
|
|
* @retval 1 Yes.
|
|
|
|
* @retval 0 No.
|
|
|
|
*/
|
2014-05-26 00:27:48 +08:00
|
|
|
int toxav_capability_supported ( ToxAv *av, int32_t call_index, ToxAvCapabilities capability );
|
2014-03-07 10:13:04 +08:00
|
|
|
|
|
|
|
|
2014-05-26 00:27:48 +08:00
|
|
|
Tox *toxav_get_tox(ToxAv *av);
|
2014-06-19 05:52:34 +08:00
|
|
|
|
2014-06-22 20:39:26 +08:00
|
|
|
int toxav_has_activity ( ToxAv *av, int32_t call_index, int16_t *PCM, uint16_t frame_size, float ref_energy );
|
2014-06-21 07:58:55 +08:00
|
|
|
|
2014-11-11 06:59:14 +08:00
|
|
|
|
|
|
|
/* Create a new toxav group.
|
|
|
|
*
|
|
|
|
* return group number on success.
|
|
|
|
* return -1 on failure.
|
2014-11-11 22:48:52 +08:00
|
|
|
*
|
|
|
|
* Audio data callback format:
|
|
|
|
* audio_callback(Tox *tox, int groupnumber, int peernumber, const int16_t *pcm, unsigned int samples, uint8_t channels, unsigned int sample_rate, void *userdata)
|
2014-11-12 03:39:25 +08:00
|
|
|
*
|
|
|
|
* Note that total size of pcm in bytes is equal to (samples * channels * sizeof(int16_t)).
|
2014-11-11 06:59:14 +08:00
|
|
|
*/
|
|
|
|
int toxav_add_av_groupchat(Tox *tox, void (*audio_callback)(Tox *, int, int, const int16_t *, unsigned int, uint8_t,
|
|
|
|
unsigned int, void *), void *userdata);
|
|
|
|
|
|
|
|
/* Join a AV group (you need to have been invited first.)
|
|
|
|
*
|
|
|
|
* returns group number on success
|
|
|
|
* returns -1 on failure.
|
2014-11-11 22:48:52 +08:00
|
|
|
*
|
|
|
|
* Audio data callback format (same as the one for toxav_add_av_groupchat()):
|
|
|
|
* audio_callback(Tox *tox, int groupnumber, int peernumber, const int16_t *pcm, unsigned int samples, uint8_t channels, unsigned int sample_rate, void *userdata)
|
2014-11-12 03:39:25 +08:00
|
|
|
*
|
|
|
|
* Note that total size of pcm in bytes is equal to (samples * channels * sizeof(int16_t)).
|
2014-11-11 06:59:14 +08:00
|
|
|
*/
|
|
|
|
int toxav_join_av_groupchat(Tox *tox, int32_t friendnumber, const uint8_t *data, uint16_t length,
|
|
|
|
void (*audio_callback)(Tox *, int, int, const int16_t *, unsigned int, uint8_t, unsigned int, void *), void *userdata);
|
|
|
|
|
|
|
|
/* Send audio to the group chat.
|
|
|
|
*
|
|
|
|
* return 0 on success.
|
|
|
|
* return -1 on failure.
|
2014-11-12 03:39:25 +08:00
|
|
|
*
|
|
|
|
* Note that total size of pcm in bytes is equal to (samples * channels * sizeof(int16_t)).
|
|
|
|
*
|
|
|
|
* Valid number of samples are ((sample rate) * (audio length (Valid ones are: 2.5, 5, 10, 20, 40 or 60 ms)) / 1000)
|
|
|
|
* Valid number of channels are 1 or 2.
|
|
|
|
* Valid sample rates are 8000, 12000, 16000, 24000, or 48000.
|
|
|
|
*
|
|
|
|
* Recommended values are: samples = 960, channels = 1, sample_rate = 48000
|
|
|
|
*
|
|
|
|
* TODO: currently the only supported sample rate is 48000.
|
2014-11-11 06:59:14 +08:00
|
|
|
*/
|
|
|
|
int toxav_group_send_audio(Tox *tox, int groupnumber, const int16_t *pcm, unsigned int samples, uint8_t channels,
|
|
|
|
unsigned int sample_rate);
|
|
|
|
|
2014-06-19 05:52:34 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-07-08 04:10:10 +08:00
|
|
|
#endif /* __TOXAV */
|