mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Fix #219, handle av media changes
Can now start or stop video on demand of the peer
This commit is contained in:
parent
bd1ca80ffd
commit
3fc9cc0d83
4
core.h
4
core.h
@ -233,7 +233,7 @@ signals:
|
|||||||
void avEnding(int friendId, int callIndex);
|
void avEnding(int friendId, int callIndex);
|
||||||
void avRequestTimeout(int friendId, int callIndex);
|
void avRequestTimeout(int friendId, int callIndex);
|
||||||
void avPeerTimeout(int friendId, int callIndex);
|
void avPeerTimeout(int friendId, int callIndex);
|
||||||
void avMediaChange(int friendId, int callIndex);
|
void avMediaChange(int friendId, int callIndex, bool videoEnabled);
|
||||||
|
|
||||||
void videoFrameReceived(vpx_image* frame);
|
void videoFrameReceived(vpx_image* frame);
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ private:
|
|||||||
static void onAvEnding(void* toxav, int32_t call_index, void* core);
|
static void onAvEnding(void* toxav, int32_t call_index, void* core);
|
||||||
static void onAvRequestTimeout(void* toxav, int32_t call_index, void* core);
|
static void onAvRequestTimeout(void* toxav, int32_t call_index, void* core);
|
||||||
static void onAvPeerTimeout(void* toxav, int32_t call_index, void* core);
|
static void onAvPeerTimeout(void* toxav, int32_t call_index, void* core);
|
||||||
static void onAvMediaChange(void* toxav, int32_t call_index, void* core);
|
static void onAvMediaChange(void *toxav, int32_t call_index, void* core);
|
||||||
|
|
||||||
static void prepareCall(int friendId, int callId, ToxAv *toxav, bool videoEnabled);
|
static void prepareCall(int friendId, int callId, ToxAv *toxav, bool videoEnabled);
|
||||||
static void cleanupCall(int callId);
|
static void cleanupCall(int callId);
|
||||||
|
38
coreav.cpp
38
coreav.cpp
@ -54,19 +54,37 @@ void Core::prepareCall(int friendId, int callId, ToxAv* toxav, bool videoEnabled
|
|||||||
calls[callId].sendAudioTimer->setSingleShot(true);
|
calls[callId].sendAudioTimer->setSingleShot(true);
|
||||||
connect(calls[callId].sendAudioTimer, &QTimer::timeout, [=](){sendCallAudio(callId,toxav);});
|
connect(calls[callId].sendAudioTimer, &QTimer::timeout, [=](){sendCallAudio(callId,toxav);});
|
||||||
calls[callId].sendAudioTimer->start();
|
calls[callId].sendAudioTimer->start();
|
||||||
|
calls[callId].sendVideoTimer->setInterval(50);
|
||||||
|
calls[callId].sendVideoTimer->setSingleShot(true);
|
||||||
if (calls[callId].videoEnabled)
|
if (calls[callId].videoEnabled)
|
||||||
{
|
{
|
||||||
calls[callId].sendVideoTimer->setInterval(50);
|
|
||||||
calls[callId].sendVideoTimer->setSingleShot(true);
|
|
||||||
calls[callId].sendVideoTimer->start();
|
calls[callId].sendVideoTimer->start();
|
||||||
Widget::getInstance()->getCamera()->suscribe();
|
Widget::getInstance()->getCamera()->suscribe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::onAvMediaChange(void*, int32_t, void*)
|
void Core::onAvMediaChange(void* toxav, int32_t callId, void* core)
|
||||||
{
|
{
|
||||||
// HALP, PLS COMPLETE MEH
|
ToxAvCSettings settings;
|
||||||
qWarning() << "If you see this, please complain on GitHub about seeing me! (Don't forget to say what caused me!)";
|
toxav_get_peer_csettings((ToxAv*)toxav, callId, 0, &settings);
|
||||||
|
int friendId = toxav_get_peer_id((ToxAv*)toxav, callId, 0);
|
||||||
|
|
||||||
|
qWarning() << "Core: Received media change from friend "<<friendId;
|
||||||
|
|
||||||
|
if (settings.call_type == TypeAudio)
|
||||||
|
{
|
||||||
|
calls[callId].videoEnabled = false;
|
||||||
|
calls[callId].sendVideoTimer->stop();
|
||||||
|
Widget::getInstance()->getCamera()->unsuscribe();
|
||||||
|
emit ((Core*)core)->avMediaChange(friendId, callId, false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Widget::getInstance()->getCamera()->suscribe();
|
||||||
|
calls[callId].videoEnabled = true;
|
||||||
|
calls[callId].sendVideoTimer->start();
|
||||||
|
emit ((Core*)core)->avMediaChange(friendId, callId, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::answerCall(int callId)
|
void Core::answerCall(int callId)
|
||||||
@ -241,7 +259,9 @@ void Core::sendCallVideo(int callId)
|
|||||||
vpx_img_free(&frame);
|
vpx_img_free(&frame);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
qDebug("Core::sendCallVideo: Invalid frame (bad camera ?)");
|
qDebug("Core::sendCallVideo: Invalid frame (bad camera ?)");
|
||||||
|
}
|
||||||
|
|
||||||
calls[callId].sendVideoTimer->start();
|
calls[callId].sendVideoTimer->start();
|
||||||
}
|
}
|
||||||
@ -262,11 +282,11 @@ void Core::micMuteToggle(int callId)
|
|||||||
calls[callId].muteMic = !calls[callId].muteMic;
|
calls[callId].muteMic = !calls[callId].muteMic;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::onAvCancel(void* _toxav, int32_t call_index, void* core)
|
void Core::onAvCancel(void* _toxav, int32_t callId, void* core)
|
||||||
{
|
{
|
||||||
ToxAv* toxav = static_cast<ToxAv*>(_toxav);
|
ToxAv* toxav = static_cast<ToxAv*>(_toxav);
|
||||||
|
|
||||||
int friendId = toxav_get_peer_id(toxav, call_index, 0);
|
int friendId = toxav_get_peer_id(toxav, callId, 0);
|
||||||
if (friendId < 0)
|
if (friendId < 0)
|
||||||
{
|
{
|
||||||
qWarning() << "Core: Received invalid AV cancel";
|
qWarning() << "Core: Received invalid AV cancel";
|
||||||
@ -274,7 +294,9 @@ void Core::onAvCancel(void* _toxav, int32_t call_index, void* core)
|
|||||||
}
|
}
|
||||||
qDebug() << QString("Core: AV cancel from %1").arg(friendId);
|
qDebug() << QString("Core: AV cancel from %1").arg(friendId);
|
||||||
|
|
||||||
emit static_cast<Core*>(core)->avCancel(friendId, call_index);
|
calls[callId].active = false;
|
||||||
|
|
||||||
|
emit static_cast<Core*>(core)->avCancel(friendId, callId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::onAvReject(void*, int32_t, void*)
|
void Core::onAvReject(void*, int32_t, void*)
|
||||||
|
@ -573,6 +573,18 @@ void ChatForm::onAvPeerTimeout(int FriendId, int)
|
|||||||
netcam->hide();
|
netcam->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChatForm::onAvMediaChange(int, int, bool video)
|
||||||
|
{
|
||||||
|
if (video)
|
||||||
|
{
|
||||||
|
netcam->show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
netcam->hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ChatForm::onAnswerCallTriggered()
|
void ChatForm::onAnswerCallTriggered()
|
||||||
{
|
{
|
||||||
audioInputFlag = true;
|
audioInputFlag = true;
|
||||||
|
@ -72,6 +72,7 @@ public slots:
|
|||||||
void onAvEnding(int FriendId, int CallId);
|
void onAvEnding(int FriendId, int CallId);
|
||||||
void onAvRequestTimeout(int FriendId, int CallId);
|
void onAvRequestTimeout(int FriendId, int CallId);
|
||||||
void onAvPeerTimeout(int FriendId, int CallId);
|
void onAvPeerTimeout(int FriendId, int CallId);
|
||||||
|
void onAvMediaChange(int FriendId, int CallId, bool video);
|
||||||
void onMicMuteToggle();
|
void onMicMuteToggle();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -435,6 +435,7 @@ void Widget::addFriend(int friendId, const QString &userId)
|
|||||||
connect(core, &Core::avEnding, newfriend->chatForm, &ChatForm::onAvEnding);
|
connect(core, &Core::avEnding, newfriend->chatForm, &ChatForm::onAvEnding);
|
||||||
connect(core, &Core::avRequestTimeout, newfriend->chatForm, &ChatForm::onAvRequestTimeout);
|
connect(core, &Core::avRequestTimeout, newfriend->chatForm, &ChatForm::onAvRequestTimeout);
|
||||||
connect(core, &Core::avPeerTimeout, newfriend->chatForm, &ChatForm::onAvPeerTimeout);
|
connect(core, &Core::avPeerTimeout, newfriend->chatForm, &ChatForm::onAvPeerTimeout);
|
||||||
|
connect(core, &Core::avMediaChange, newfriend->chatForm, &ChatForm::onAvMediaChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::addFriendFailed(const QString&)
|
void Widget::addFriendFailed(const QString&)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user