qTox
Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
|
Go to the documentation of this file.
24 #include "util/compatiblerecursivemutex.h"
28 #include <QReadWriteLock>
31 #include <tox/toxav.h>
56 void setAudio(IAudioControl& newAudio);
66 bool sendCallAudio(uint32_t friendNum,
const int16_t* pcm,
size_t samples, uint8_t chans,
68 void sendCallVideo(uint32_t friendNum, std::shared_ptr<VideoFrame> frame);
69 bool sendGroupCallAudio(
int groupNum,
const int16_t* pcm,
size_t samples, uint8_t chans,
86 static void groupCallCallback(
void* tox, uint32_t group, uint32_t peer,
const int16_t* data,
87 unsigned samples, uint8_t channels, uint32_t sample_rate,
92 bool startCall(uint32_t friendNum,
bool video);
93 bool answerCall(uint32_t friendNum,
bool video);
99 void avInvite(uint32_t friendId,
bool video);
100 void avStart(uint32_t friendId,
bool video);
101 void avEnd(uint32_t friendId,
bool error =
false);
104 static void callCallback(ToxAV* toxAV, uint32_t friendNum,
bool audio,
bool video,
void*
self);
105 static void stateCallback(ToxAV*, uint32_t friendNum, uint32_t state,
void*
self);
106 static void bitrateCallback(ToxAV* toxAV, uint32_t friendNum, uint32_t arate, uint32_t vrate,
120 CoreAV(std::unique_ptr<ToxAV, ToxAVDeleter> tox, CompatibleRecursiveMutex &toxCoreLock,
126 size_t sampleCount, uint8_t channels, uint32_t samplingRate,
128 static void videoFrameCallback(ToxAV* toxAV, uint32_t friendNum, uint16_t w, uint16_t h,
129 const uint8_t* y,
const uint8_t* u,
const uint8_t* v,
130 int32_t ystride, int32_t ustride, int32_t vstride,
void*
self);
138 std::unique_ptr<ToxAV, ToxAVDeleter>
toxav;
146 std::map<uint32_t, ToxFriendCallPtr>
calls;
157 mutable QReadWriteLock
callsLock{QReadWriteLock::Recursive};
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.
std::atomic< IAudioControl * > audio
static void callCallback(ToxAV *toxAV, uint32_t friendNum, bool audio, bool video, void *self)
void avInvite(uint32_t friendId, bool video)
Sent when a friend calls us.
An abstract source of video frames.
std::unique_ptr< ToxGroupCall > ToxGroupCallPtr
bool isCallVideoEnabled(const Friend *f) const
CoreAV(std::unique_ptr< ToxAV, ToxAVDeleter > tox, CompatibleRecursiveMutex &toxCoreLock, IAudioSettings &_audioSettings, IGroupSettings &_groupSettings)
std::map< uint32_t, ToxFriendCallPtr > calls
Maps friend IDs to ToxFriendCall.
void avStart(uint32_t friendId, bool video)
Sent when a call we initiated has started.
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.
void sendNoVideo()
Signal to all peers that we're not sending video anymore.
This class is a wrapper to share a camera's captured video frames.
void start()
Starts the CoreAV main loop that calls toxav's main loop.
bool isCallOutputMuted(const Friend *f) const
Returns the calls output (speaker) mute state.
static void bitrateCallback(ToxAV *toxAV, uint32_t friendNum, uint32_t arate, uint32_t vrate, void *self)
bool isCallActive(const Friend *f) const
Checks the call status for a Tox friend.
bool answerCall(uint32_t friendNum, bool video)
void connectCallbacks(ToxAV &toxav)
std::unique_ptr< ToxFriendCall > ToxFriendCallPtr
CompatibleRecursiveMutex & coreLock
needed to synchronize with the Core thread, some toxav_* functions must not execute at the same time ...
bool cancelCall(uint32_t friendNum)
VideoSource * getVideoSourceFromCall(int callNumber) const
Get a call's video source.
void operator()(ToxAV *tox)
IGroupSettings & groupSettings
bool startCall(uint32_t friendNum, bool video)
void invalidateGroupCallPeerSource(const Group &group, ToxPk peerPk)
Called from core to make sure the source for that peer is invalidated when they leave.
This class represents a Tox Public Key, which is a part of Tox ID.
void toggleMuteCallInput(const Friend *f)
Toggles the mute state of the call's input (microphone).
static void audioFrameCallback(ToxAV *toxAV, uint32_t friendNum, const int16_t *pcm, size_t sampleCount, uint8_t channels, uint32_t samplingRate, void *self)
An ownernship and management class for AVFrames.
void muteCallOutput(const Group *g, bool mute)
Mutes or unmutes the group call's output (speaker).
std::unique_ptr< CoreAV > CoreAVPtr
static constexpr uint32_t VIDEO_DEFAULT_BITRATE
Picked at random by fair dice roll.
void setAudio(IAudioControl &newAudio)
Set the audio backend.
void sendCallVideo(uint32_t friendNum, std::shared_ptr< VideoFrame > frame)
std::unique_ptr< QThread > coreavThread
void leaveGroupCall(int groupNum)
Will not leave the group, just stop the call.
bool isGroupCallInputMuted(const Group *g) const
Returns the group calls input (microphone) state.
bool isCallStarted(const Friend *f) const
Checks the call status for a Tox friend.
bool isCallInputMuted(const Friend *f) const
Returns the calls input (microphone) mute state.
static CoreAVPtr makeCoreAV(Tox *core, CompatibleRecursiveMutex &toxCoreLock, IAudioSettings &audioSettings, IGroupSettings &groupSettings)
Factory method for CoreAV.
std::unique_ptr< ToxAV, ToxAVDeleter > toxav
void muteCallInput(const Group *g, bool mute)
Mutes or unmutes the group call's input (microphone).
bool isGroupCallOutputMuted(const Group *g) const
Returns the group calls output (speaker) state.
static void videoBitrateCallback(ToxAV *toxAV, uint32_t friendNum, uint32_t rate, void *self)
void joinGroupCall(const Group &group)
Starts a call in an existing AV groupchat.
IAudioSettings & audioSettings
static void stateCallback(ToxAV *, uint32_t friendNum, uint32_t state, void *self)
A VideoSource that emits frames received by Core.
bool sendGroupCallAudio(int groupNum, const int16_t *pcm, size_t samples, uint8_t chans, uint32_t rate) const
void toggleMuteCallOutput(const Friend *f)
Toggles the mute state of the call's output (speaker).
std::map< int, ToxGroupCallPtr > groupCalls
Maps group IDs to ToxGroupCalls.
static void audioBitrateCallback(ToxAV *toxAV, uint32_t friendNum, uint32_t rate, void *self)
void timeoutCall(uint32_t friendNum)
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)
IAudioControl * getAudio()
Get the audio backend used.
void avEnd(uint32_t friendId, bool error=false)
Sent when a call was ended by the peer.