1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

fix(core): Use new callback API for bitrate set

This commit is contained in:
Diadlo 2018-01-31 09:31:28 +03:00
parent 2c8f03dada
commit d2deec7c55
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
2 changed files with 37 additions and 0 deletions

View File

@ -96,7 +96,12 @@ CoreAV::CoreAV(Tox* tox)
toxav_callback_call(toxav, CoreAV::callCallback, this); toxav_callback_call(toxav, CoreAV::callCallback, this);
toxav_callback_call_state(toxav, CoreAV::stateCallback, this); toxav_callback_call_state(toxav, CoreAV::stateCallback, this);
#if TOX_VERSION_IS_API_COMPATIBLE(0, 2, 0)
toxav_callback_audio_bit_rate(toxav, CoreAV::audioBitrateCallback, this);
toxav_callback_video_bit_rate(toxav, CoreAV::videoBitrateCallback, this);
#else
toxav_callback_bit_rate_status(toxav, CoreAV::bitrateCallback, this); toxav_callback_bit_rate_status(toxav, CoreAV::bitrateCallback, this);
#endif
toxav_callback_audio_receive_frame(toxav, CoreAV::audioFrameCallback, this); toxav_callback_audio_receive_frame(toxav, CoreAV::audioFrameCallback, this);
toxav_callback_video_receive_frame(toxav, CoreAV::videoFrameCallback, this); toxav_callback_video_receive_frame(toxav, CoreAV::videoFrameCallback, this);
@ -824,6 +829,36 @@ void CoreAV::bitrateCallback(ToxAV* toxav, uint32_t friendNum, uint32_t arate, u
<< ", ignoring it"; << ", ignoring it";
} }
void CoreAV::audioBitrateCallback(ToxAV* toxav, uint32_t friendNum, uint32_t rate, void* vSelf)
{
CoreAV* self = static_cast<CoreAV*>(vSelf);
// Run this slow path callback asynchronously on the AV thread to avoid deadlocks
if (QThread::currentThread() != self->coreavThread.get()) {
return (void)QMetaObject::invokeMethod(self, "audioBitrateCallback", Qt::QueuedConnection,
Q_ARG(ToxAV*, toxav), Q_ARG(uint32_t, friendNum),
Q_ARG(uint32_t, rate), Q_ARG(void*, vSelf));
}
qDebug() << "Recommended audio bitrate with" << friendNum << " is now " << rate
<< ", ignoring it";
}
void CoreAV::videoBitrateCallback(ToxAV* toxav, uint32_t friendNum, uint32_t rate, void* vSelf)
{
CoreAV* self = static_cast<CoreAV*>(vSelf);
// Run this slow path callback asynchronously on the AV thread to avoid deadlocks
if (QThread::currentThread() != self->coreavThread.get()) {
return (void)QMetaObject::invokeMethod(self, "videoBitrateCallback", Qt::QueuedConnection,
Q_ARG(ToxAV*, toxav), Q_ARG(uint32_t, friendNum),
Q_ARG(uint32_t, rate), Q_ARG(void*, vSelf));
}
qDebug() << "Recommended video bitrate with" << friendNum << " is now " << rate
<< ", ignoring it";
}
void CoreAV::audioFrameCallback(ToxAV*, uint32_t friendNum, const int16_t* pcm, size_t sampleCount, void CoreAV::audioFrameCallback(ToxAV*, uint32_t friendNum, const int16_t* pcm, size_t sampleCount,
uint8_t channels, uint32_t samplingRate, void* vSelf) uint8_t channels, uint32_t samplingRate, void* vSelf)
{ {

View File

@ -99,6 +99,8 @@ private slots:
static void stateCallback(ToxAV*, uint32_t friendNum, uint32_t state, 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, static void bitrateCallback(ToxAV* toxAV, uint32_t friendNum, uint32_t arate, uint32_t vrate,
void* self); 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);
void killTimerFromThread(); void killTimerFromThread();
private: private: