qTox
Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
|
#include <coreav.h>
Classes | |
struct | ToxAVDeleter |
Public Types | |
using | CoreAVPtr = std::unique_ptr< CoreAV > |
Public Slots | |
bool | startCall (uint32_t friendNum, bool video) |
bool | answerCall (uint32_t friendNum, bool video) |
bool | cancelCall (uint32_t friendNum) |
void | timeoutCall (uint32_t friendNum) |
void | start () |
Starts the CoreAV main loop that calls toxav's main loop. More... | |
Signals | |
void | avInvite (uint32_t friendId, bool video) |
Sent when a friend calls us. More... | |
void | avStart (uint32_t friendId, bool video) |
Sent when a call we initiated has started. More... | |
void | avEnd (uint32_t friendId, bool error=false) |
Sent when a call was ended by the peer. More... | |
Public Member Functions | |
void | setAudio (IAudioControl &newAudio) |
Set the audio backend. More... | |
IAudioControl * | getAudio () |
Get the audio backend used. More... | |
~CoreAV () | |
bool | isCallStarted (const Friend *f) const |
Checks the call status for a Tox friend. More... | |
bool | isCallStarted (const Group *f) const |
Checks the call status for a Tox group. More... | |
bool | isCallActive (const Friend *f) const |
Checks the call status for a Tox friend. More... | |
bool | isCallActive (const Group *g) const |
Checks the call status for a Tox group. More... | |
bool | isCallVideoEnabled (const Friend *f) const |
bool | sendCallAudio (uint32_t friendNum, const int16_t *pcm, size_t samples, uint8_t chans, uint32_t rate) const |
Send audio frame to a friend. More... | |
void | sendCallVideo (uint32_t friendNum, std::shared_ptr< VideoFrame > frame) |
bool | sendGroupCallAudio (int groupNum, const int16_t *pcm, size_t samples, uint8_t chans, uint32_t rate) const |
VideoSource * | getVideoSourceFromCall (int callNumber) const |
Get a call's video source. More... | |
void | sendNoVideo () |
Signal to all peers that we're not sending video anymore. More... | |
void | joinGroupCall (const Group &group) |
Starts a call in an existing AV groupchat. More... | |
void | leaveGroupCall (int groupNum) |
Will not leave the group, just stop the call. More... | |
void | muteCallInput (const Group *g, bool mute) |
Mutes or unmutes the group call's input (microphone). More... | |
void | muteCallOutput (const Group *g, bool mute) |
Mutes or unmutes the group call's output (speaker). More... | |
bool | isGroupCallInputMuted (const Group *g) const |
Returns the group calls input (microphone) state. More... | |
bool | isGroupCallOutputMuted (const Group *g) const |
Returns the group calls output (speaker) state. More... | |
bool | isCallInputMuted (const Friend *f) const |
Returns the calls input (microphone) mute state. More... | |
bool | isCallOutputMuted (const Friend *f) const |
Returns the calls output (speaker) mute state. More... | |
void | toggleMuteCallInput (const Friend *f) |
Toggles the mute state of the call's input (microphone). More... | |
void | toggleMuteCallOutput (const Friend *f) |
Toggles the mute state of the call's output (speaker). More... | |
void | invalidateGroupCallPeerSource (const Group &group, ToxPk peerPk) |
Called from core to make sure the source for that peer is invalidated when they leave. More... | |
Static Public Member Functions | |
static CoreAVPtr | makeCoreAV (Tox *core, CompatibleRecursiveMutex &toxCoreLock, IAudioSettings &audioSettings, IGroupSettings &groupSettings) |
Factory method for CoreAV. More... | |
static void | groupCallCallback (void *tox, uint32_t group, uint32_t peer, const int16_t *data, unsigned samples, uint8_t channels, uint32_t sample_rate, void *core) |
Called from Tox API when group call receives audio data. More... | |
Private Types | |
using | ToxFriendCallPtr = std::unique_ptr< ToxFriendCall > |
using | ToxGroupCallPtr = std::unique_ptr< ToxGroupCall > |
Private Slots | |
static void | callCallback (ToxAV *toxAV, uint32_t friendNum, bool audio, bool video, void *self) |
static void | stateCallback (ToxAV *, uint32_t friendNum, uint32_t state, void *self) |
static void | bitrateCallback (ToxAV *toxAV, uint32_t friendNum, uint32_t arate, uint32_t vrate, void *self) |
static void | audioBitrateCallback (ToxAV *toxAV, uint32_t friendNum, uint32_t rate, void *self) |
static void | videoBitrateCallback (ToxAV *toxAV, uint32_t friendNum, uint32_t rate, void *self) |
Private Member Functions | |
CoreAV (std::unique_ptr< ToxAV, ToxAVDeleter > tox, CompatibleRecursiveMutex &toxCoreLock, IAudioSettings &_audioSettings, IGroupSettings &_groupSettings) | |
void | connectCallbacks (ToxAV &toxav) |
void | process () |
Static Private Member Functions | |
static void | audioFrameCallback (ToxAV *toxAV, uint32_t friendNum, const int16_t *pcm, size_t sampleCount, uint8_t channels, uint32_t samplingRate, void *self) |
static void | videoFrameCallback (ToxAV *toxAV, uint32_t friendNum, uint16_t w, uint16_t h, const uint8_t *y, const uint8_t *u, const uint8_t *v, int32_t ystride, int32_t ustride, int32_t vstride, void *self) |
Private Attributes | |
std::atomic< IAudioControl * > | audio |
std::unique_ptr< ToxAV, ToxAVDeleter > | toxav |
std::unique_ptr< QThread > | coreavThread |
QTimer * | iterateTimer = nullptr |
std::map< uint32_t, ToxFriendCallPtr > | calls |
Maps friend IDs to ToxFriendCall. More... | |
std::map< int, ToxGroupCallPtr > | groupCalls |
Maps group IDs to ToxGroupCalls. More... | |
QReadWriteLock | callsLock {QReadWriteLock::Recursive} |
CompatibleRecursiveMutex & | coreLock |
needed to synchronize with the Core thread, some toxav_* functions must not execute at the same time as tox_iterate() More... | |
IAudioSettings & | audioSettings |
IGroupSettings & | groupSettings |
Static Private Attributes | |
static constexpr uint32_t | VIDEO_DEFAULT_BITRATE = 2500 |
Picked at random by fair dice roll. More... | |
using CoreAV::CoreAVPtr = std::unique_ptr<CoreAV> |
|
private |
|
private |
CoreAV::~CoreAV | ( | ) |
|
private |
Definition at line 73 of file coreav.cpp.
|
slot |
|
staticprivateslot |
|
staticprivate |
Definition at line 842 of file coreav.cpp.
|
signal |
Sent when a call was ended by the peer.
friendId | Id of friend in call list. |
|
signal |
Sent when a friend calls us.
friendId | Id of friend in call list. |
video | False if chat is audio only, true audio and video. |
|
signal |
Sent when a call we initiated has started.
friendId | Id of friend in call list. |
video | False if chat is audio only, true audio and video. |
|
staticprivateslot |
Definition at line 811 of file coreav.cpp.
|
staticprivateslot |
|
slot |
|
private |
IAudioControl * CoreAV::getAudio | ( | ) |
Get the audio backend used.
Definition at line 153 of file coreav.cpp.
VideoSource * CoreAV::getVideoSourceFromCall | ( | int | friendNum | ) | const |
Get a call's video source.
friendNum | Id of friend in call list. |
Definition at line 527 of file coreav.cpp.
|
static |
Called from Tox API when group call receives audio data.
[in] | tox | the Tox object |
[in] | group | the group number |
[in] | peer | the peer number |
[in] | data | the audio data to playback |
[in] | samples | the audio samples |
[in] | channels | the audio channels |
[in] | sample_rate | the audio sample rate |
[in] | core | the qTox Core class |
Definition at line 467 of file coreav.cpp.
Called from core to make sure the source for that peer is invalidated when they leave.
group | Group Index |
peer | Peer Index |
Definition at line 511 of file coreav.cpp.
bool CoreAV::isCallActive | ( | const Friend * | f | ) | const |
Checks the call status for a Tox friend.
f | the friend to check |
Definition at line 217 of file coreav.cpp.
bool CoreAV::isCallActive | ( | const Group * | g | ) | const |
Checks the call status for a Tox group.
g | the group to check |
Definition at line 232 of file coreav.cpp.
bool CoreAV::isCallInputMuted | ( | const Friend * | f | ) | const |
Returns the calls input (microphone) mute state.
f | The friend to check |
Definition at line 671 of file coreav.cpp.
bool CoreAV::isCallOutputMuted | ( | const Friend * | f | ) | const |
Returns the calls output (speaker) mute state.
friendId | The friend to check |
Definition at line 688 of file coreav.cpp.
bool CoreAV::isCallStarted | ( | const Friend * | f | ) | const |
Checks the call status for a Tox friend.
f | the friend to check |
Definition at line 195 of file coreav.cpp.
bool CoreAV::isCallStarted | ( | const Group * | g | ) | const |
Checks the call status for a Tox group.
g | the group to check |
Definition at line 206 of file coreav.cpp.
bool CoreAV::isCallVideoEnabled | ( | const Friend * | f | ) | const |
Definition at line 242 of file coreav.cpp.
bool CoreAV::isGroupCallInputMuted | ( | const Group * | g | ) | const |
Returns the group calls input (microphone) state.
groupId | The group id to check |
Definition at line 635 of file coreav.cpp.
bool CoreAV::isGroupCallOutputMuted | ( | const Group * | g | ) | const |
Returns the group calls output (speaker) state.
groupId | The group id to check |
Definition at line 653 of file coreav.cpp.
void CoreAV::joinGroupCall | ( | const Group & | group | ) |
Starts a call in an existing AV groupchat.
groupId | Id of group to join |
Definition at line 545 of file coreav.cpp.
void CoreAV::leaveGroupCall | ( | int | groupId | ) |
Will not leave the group, just stop the call.
groupId | Id of group to leave |
Definition at line 571 of file coreav.cpp.
|
static |
Factory method for CoreAV.
core | pointer to the Tox instance |
Definition at line 113 of file coreav.cpp.
void CoreAV::muteCallInput | ( | const Group * | g, |
bool | mute | ||
) |
Mutes or unmutes the group call's input (microphone).
g | The group |
mute | True to mute, false to unmute |
Definition at line 605 of file coreav.cpp.
void CoreAV::muteCallOutput | ( | const Group * | g, |
bool | mute | ||
) |
Mutes or unmutes the group call's output (speaker).
g | The group |
mute | True to mute, false to unmute |
Definition at line 620 of file coreav.cpp.
|
private |
Definition at line 183 of file coreav.cpp.
bool CoreAV::sendCallAudio | ( | uint32_t | callId, |
const int16_t * | pcm, | ||
size_t | samples, | ||
uint8_t | chans, | ||
uint32_t | rate | ||
) | const |
Send audio frame to a friend.
callId | Id of friend in call list. |
pcm | An array of audio samples (Pulse-code modulation). |
samples | Number of samples in this frame. |
chans | Number of audio channels. |
rate | Audio sampling rate used in this frame. |
Definition at line 337 of file coreav.cpp.
void CoreAV::sendCallVideo | ( | uint32_t | friendNum, |
std::shared_ptr< VideoFrame > | frame | ||
) |
bool CoreAV::sendGroupCallAudio | ( | int | groupNum, |
const int16_t * | pcm, | ||
size_t | samples, | ||
uint8_t | chans, | ||
uint32_t | rate | ||
) | const |
Definition at line 580 of file coreav.cpp.
void CoreAV::sendNoVideo | ( | ) |
Signal to all peers that we're not sending video anymore.
Definition at line 704 of file coreav.cpp.
void CoreAV::setAudio | ( | IAudioControl & | newAudio | ) |
Set the audio backend.
audio | The audio backend to use |
Definition at line 142 of file coreav.cpp.
|
slot |
Starts the CoreAV main loop that calls toxav's main loop.
Definition at line 178 of file coreav.cpp.
|
slot |
|
staticprivateslot |
|
slot |
void CoreAV::toggleMuteCallInput | ( | const Friend * | f | ) |
Toggles the mute state of the call's input (microphone).
f | The friend assigned to the call |
Definition at line 429 of file coreav.cpp.
void CoreAV::toggleMuteCallOutput | ( | const Friend * | f | ) |
Toggles the mute state of the call's output (speaker).
f | The friend assigned to the call |
Definition at line 444 of file coreav.cpp.
|
staticprivateslot |
|
staticprivate |
Definition at line 864 of file coreav.cpp.
|
private |
Maps friend IDs to ToxFriendCall.
|
mutableprivate |
|
private |
|
private |
|
private |
|
private |
|
staticconstexprprivate |