1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-06-29 16:17:46 +02:00
toxic/src/audio_call.h

96 lines
2.4 KiB
C
Raw Normal View History

/* audio_call.h
*
*
* Copyright (C) 2014 Toxic All Rights Reserved.
*
* This file is part of Toxic.
*
* Toxic 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.
*
* Toxic 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 Toxic. If not, see <http://www.gnu.org/licenses/>.
*
2014-02-23 00:00:34 +01:00
*/
#ifndef AUDIO_CALL_H
#define AUDIO_CALL_H
2014-02-23 00:00:34 +01:00
2014-03-07 03:14:04 +01:00
#include <tox/toxav.h>
#include "audio_device.h"
2015-11-04 05:04:05 +01:00
typedef enum _AudioError {
2014-06-21 01:58:00 +02:00
ae_None = 0,
ae_StartingCaptureDevice = 1 << 0,
ae_StartingOutputDevice = 1 << 1,
ae_StartingCoreAudio = 1 << 2
2014-03-07 03:14:04 +01:00
} AudioError;
2015-08-11 13:11:09 +02:00
#ifdef VIDEO
typedef enum _VideoError {
ve_None = 0,
ve_StartingCaptureDevice = 1 << 0,
ve_StartingOutputDevice = 1 << 1,
ve_StartingCoreVideo = 1 << 2
} VideoError;
#endif /* VIDEO */
2014-11-26 21:22:34 +01:00
typedef struct Call {
pthread_t ttid; /* Transmission thread id */
bool ttas, has_output; /* Transmission thread active status (0 - stopped, 1- running) */
2015-08-11 13:11:09 +02:00
uint32_t in_idx, out_idx; /* Audio Index */
#ifdef VIDEO
uint32_t vin_idx, vout_idx; /* Video Index */
#endif /* VIDEO */
2014-11-26 21:22:34 +01:00
pthread_mutex_t mutex;
} Call;
2015-08-10 13:14:38 +02:00
struct CallControl {
2015-08-11 13:11:09 +02:00
AudioError audio_errors;
#ifdef VIDEO
VideoError video_errors;
#endif /* VIDEO */
2015-07-22 20:06:14 +02:00
ToxAV *av;
2015-08-10 13:14:38 +02:00
ToxWindow *prompt;
2015-07-22 20:06:14 +02:00
Call *calls;
uint32_t max_calls;
2015-07-22 20:06:14 +02:00
uint32_t call_state;
2015-08-11 13:11:09 +02:00
bool pending_call;
2015-07-22 20:06:14 +02:00
bool audio_enabled;
bool video_enabled;
2015-08-11 13:11:09 +02:00
2015-07-22 20:06:14 +02:00
uint32_t audio_bit_rate;
int32_t audio_frame_duration;
uint32_t audio_sample_rate;
2015-07-22 20:06:14 +02:00
uint8_t audio_channels;
2015-11-04 05:04:05 +01:00
2015-08-11 13:11:09 +02:00
uint32_t video_bit_rate;
int32_t video_frame_duration;
};
2015-07-22 20:06:14 +02:00
extern struct CallControl CallControl;
2014-11-15 02:13:08 +01:00
/* You will have to pass pointer to first member of 'windows' declared in windows.c */
ToxAV *init_audio(ToxWindow *self, Tox *tox);
2014-03-07 03:14:04 +01:00
void terminate_audio();
2014-11-26 21:22:34 +01:00
int start_transmission(ToxWindow *self, Call *call);
2015-08-10 13:14:38 +02:00
int stop_transmission(Call *call, uint32_t friend_number);
void stop_current_call(ToxWindow *self);
void init_friend_AV(uint32_t index);
void del_friend_AV(uint32_t index);
2014-12-10 00:29:07 +01:00
#endif /* AUDIO_CALL_H */