diff --git a/core.cpp b/core.cpp index 2038131c0..d49c95266 100644 --- a/core.cpp +++ b/core.cpp @@ -125,17 +125,17 @@ void Core::start() tox_callback_file_control(tox, onFileControlCallback, this); tox_callback_file_data(tox, onFileDataCallback, this); - toxav_register_callstate_callback(onAvInvite, av_OnInvite, this); - toxav_register_callstate_callback(onAvStart, av_OnStart, this); - toxav_register_callstate_callback(onAvCancel, av_OnCancel, this); - toxav_register_callstate_callback(onAvReject, av_OnReject, this); - toxav_register_callstate_callback(onAvEnd, av_OnEnd, this); - toxav_register_callstate_callback(onAvRinging, av_OnRinging, this); - toxav_register_callstate_callback(onAvStarting, av_OnStarting, this); - toxav_register_callstate_callback(onAvEnding, av_OnEnding, this); - toxav_register_callstate_callback(onAvError, av_OnError, this); - toxav_register_callstate_callback(onAvRequestTimeout, av_OnRequestTimeout, this); - toxav_register_callstate_callback(onAvPeerTimeout, av_OnPeerTimeout, this); + toxav_register_callstate_callback(toxav, onAvInvite, av_OnInvite, this); + toxav_register_callstate_callback(toxav, onAvStart, av_OnStart, this); + toxav_register_callstate_callback(toxav, onAvCancel, av_OnCancel, this); + toxav_register_callstate_callback(toxav, onAvReject, av_OnReject, this); + toxav_register_callstate_callback(toxav, onAvEnd, av_OnEnd, this); + toxav_register_callstate_callback(toxav, onAvRinging, av_OnRinging, this); + toxav_register_callstate_callback(toxav, onAvStarting, av_OnStarting, this); + toxav_register_callstate_callback(toxav, onAvEnding, av_OnEnding, this); + toxav_register_callstate_callback(toxav, onAvMediaChange, av_OnMediaChange, this); + toxav_register_callstate_callback(toxav, onAvRequestTimeout, av_OnRequestTimeout, this); + toxav_register_callstate_callback(toxav, onAvPeerTimeout, av_OnPeerTimeout, this); toxav_register_audio_recv_callback(toxav, playCallAudio); toxav_register_video_recv_callback(toxav, playCallVideo); @@ -990,16 +990,18 @@ void Core::sendAllFileData(Core *core, ToxFile* file) removeFileFromQueue(true, file->friendId, file->fileNum); } -void Core::onAvInvite(int32_t call_index, void* core) +void Core::onAvInvite(void* _toxav, int32_t call_index, void* core) { - int friendId = toxav_get_peer_id(static_cast(core)->toxav, call_index, 0); + ToxAv* toxav = static_cast(_toxav); + + int friendId = toxav_get_peer_id(toxav, call_index, 0); if (friendId < 0) { qWarning() << "Core: Received invalid AV invite"; return; } - int transType = toxav_get_peer_transmission_type(static_cast(core)->toxav, call_index, 0); + int transType = toxav_get_peer_transmission_type(toxav, call_index, 0); if (transType == TypeVideo) { qDebug() << QString("Core: AV invite from %1 with video").arg(friendId); @@ -1012,33 +1014,37 @@ void Core::onAvInvite(int32_t call_index, void* core) } } -void Core::onAvStart(int32_t call_index, void* core) +void Core::onAvStart(void* _toxav, int32_t call_index, void* core) { - int friendId = toxav_get_peer_id(static_cast(core)->toxav, call_index, 0); + ToxAv* toxav = static_cast(_toxav); + + int friendId = toxav_get_peer_id(toxav, call_index, 0); if (friendId < 0) { qWarning() << "Core: Received invalid AV start"; return; } - int transType = toxav_get_peer_transmission_type(static_cast(core)->toxav, call_index, 0); + int transType = toxav_get_peer_transmission_type(toxav, call_index, 0); if (transType == TypeVideo) { qDebug() << QString("Core: AV start from %1 with video").arg(friendId); - prepareCall(friendId, call_index, static_cast(core)->toxav, true); + prepareCall(friendId, call_index, toxav, true); emit static_cast(core)->avStart(friendId, call_index, true); } else { qDebug() << QString("Core: AV start from %1 without video").arg(friendId); - prepareCall(friendId, call_index, static_cast(core)->toxav, false); + prepareCall(friendId, call_index, toxav, false); emit static_cast(core)->avStart(friendId, call_index, false); } } -void Core::onAvCancel(int32_t call_index, void* core) +void Core::onAvCancel(void* _toxav, int32_t call_index, void* core) { - int friendId = toxav_get_peer_id(static_cast(core)->toxav, call_index, 0); + ToxAv* toxav = static_cast(_toxav); + + int friendId = toxav_get_peer_id(toxav, call_index, 0); if (friendId < 0) { qWarning() << "Core: Received invalid AV cancel"; @@ -1049,14 +1055,16 @@ void Core::onAvCancel(int32_t call_index, void* core) emit static_cast(core)->avCancel(friendId, call_index); } -void Core::onAvReject(int32_t, void*) +void Core::onAvReject(void*, int32_t, void*) { qDebug() << "Core: AV reject"; } -void Core::onAvEnd(int32_t call_index, void* core) +void Core::onAvEnd(void* _toxav, int32_t call_index, void* core) { - int friendId = toxav_get_peer_id(static_cast(core)->toxav, call_index, 0); + ToxAv* toxav = static_cast(_toxav); + + int friendId = toxav_get_peer_id(toxav, call_index, 0); if (friendId < 0) { qWarning() << "Core: Received invalid AV end"; @@ -1069,9 +1077,11 @@ void Core::onAvEnd(int32_t call_index, void* core) emit static_cast(core)->avEnd(friendId, call_index); } -void Core::onAvRinging(int32_t call_index, void* core) +void Core::onAvRinging(void* _toxav, int32_t call_index, void* core) { - int friendId = toxav_get_peer_id(static_cast(core)->toxav, call_index, 0); + ToxAv* toxav = static_cast(_toxav); + + int friendId = toxav_get_peer_id(toxav, call_index, 0); if (friendId < 0) { qWarning() << "Core: Received invalid AV ringing"; @@ -1090,32 +1100,36 @@ void Core::onAvRinging(int32_t call_index, void* core) } } -void Core::onAvStarting(int32_t call_index, void* core) +void Core::onAvStarting(void* _toxav, int32_t call_index, void* core) { - int friendId = toxav_get_peer_id(static_cast(core)->toxav, call_index, 0); + ToxAv* toxav = static_cast(_toxav); + + int friendId = toxav_get_peer_id(toxav, call_index, 0); if (friendId < 0) { qWarning() << "Core: Received invalid AV starting"; return; } - int transType = toxav_get_peer_transmission_type(static_cast(core)->toxav, call_index, 0); + int transType = toxav_get_peer_transmission_type(toxav, call_index, 0); if (transType == TypeVideo) { qDebug() << QString("Core: AV starting from %1 with video").arg(friendId); - prepareCall(friendId, call_index, static_cast(core)->toxav, true); + prepareCall(friendId, call_index, toxav, true); emit static_cast(core)->avStarting(friendId, call_index, true); } else { qDebug() << QString("Core: AV starting from %1 without video").arg(friendId); - prepareCall(friendId, call_index, static_cast(core)->toxav, false); + prepareCall(friendId, call_index, toxav, false); emit static_cast(core)->avStarting(friendId, call_index, false); } } -void Core::onAvEnding(int32_t call_index, void* core) +void Core::onAvEnding(void* _toxav, int32_t call_index, void* core) { - int friendId = toxav_get_peer_id(static_cast(core)->toxav, call_index, 0); + ToxAv* toxav = static_cast(_toxav); + + int friendId = toxav_get_peer_id(toxav, call_index, 0); if (friendId < 0) { qWarning() << "Core: Received invalid AV ending"; @@ -1128,14 +1142,11 @@ void Core::onAvEnding(int32_t call_index, void* core) emit static_cast(core)->avEnding(friendId, call_index); } -void Core::onAvError(int32_t, void*) +void Core::onAvRequestTimeout(void* _toxav, int32_t call_index, void* core) { - qDebug() << "Core: AV error"; -} + ToxAv* toxav = static_cast(_toxav); -void Core::onAvRequestTimeout(int32_t call_index, void* core) -{ - int friendId = toxav_get_peer_id(static_cast(core)->toxav, call_index, 0); + int friendId = toxav_get_peer_id(toxav, call_index, 0); if (friendId < 0) { qWarning() << "Core: Received invalid AV request timeout"; @@ -1148,9 +1159,11 @@ void Core::onAvRequestTimeout(int32_t call_index, void* core) emit static_cast(core)->avRequestTimeout(friendId, call_index); } -void Core::onAvPeerTimeout(int32_t call_index, void* core) +void Core::onAvPeerTimeout(void* _toxav, int32_t call_index, void* core) { - int friendId = toxav_get_peer_id(static_cast(core)->toxav, call_index, 0); + ToxAv* toxav = static_cast(_toxav); + + int friendId = toxav_get_peer_id(toxav, call_index, 0); if (friendId < 0) { qWarning() << "Core: Received invalid AV peer timeout"; @@ -1163,6 +1176,11 @@ void Core::onAvPeerTimeout(int32_t call_index, void* core) emit static_cast(core)->avPeerTimeout(friendId, call_index); } +void Core::onAvMediaChange(void*, int32_t, void*) +{ + // HALP, PLS COMPLETE MEH +} + void Core::answerCall(int callId) { int friendId = toxav_get_peer_id(toxav, callId, 0); diff --git a/core.h b/core.h index 91bbee5e2..8de39b97e 100644 --- a/core.h +++ b/core.h @@ -230,6 +230,7 @@ signals: void avEnding(int friendId, int callIndex); void avRequestTimeout(int friendId, int callIndex); void avPeerTimeout(int friendId, int callIndex); + void avMediaChange(int friendId, int callIndex); void videoFrameReceived(vpx_image* frame); @@ -251,17 +252,17 @@ private: uint8_t control_type, const uint8_t *data, uint16_t length, void *core); static void onFileDataCallback(Tox *tox, int32_t friendnumber, uint8_t filenumber, const uint8_t *data, uint16_t length, void *userdata); - static void onAvInvite(int32_t call_index, void* toxav); - static void onAvStart(int32_t call_index, void* toxav); - static void onAvCancel(int32_t call_index, void* toxav); - static void onAvReject(int32_t call_index, void* toxav); - static void onAvEnd(int32_t call_index, void* toxav); - static void onAvRinging(int32_t call_index, void* toxav); - static void onAvStarting(int32_t call_index, void* toxav); - static void onAvEnding(int32_t call_index, void* toxav); - static void onAvError(int32_t call_index, void* toxav); - static void onAvRequestTimeout(int32_t call_index, void* toxav); - static void onAvPeerTimeout(int32_t call_index, void* toxav); + static void onAvInvite(void* toxav, int32_t call_index, void* core); + static void onAvStart(void* toxav, int32_t call_index, void* core); + static void onAvCancel(void* toxav, int32_t call_index, void* core); + static void onAvReject(void* toxav, int32_t call_index, void* core); + static void onAvEnd(void* toxav, int32_t call_index, void* core); + static void onAvRinging(void* toxav, int32_t call_index, void* core); + static void onAvStarting(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 onAvPeerTimeout(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 cleanupCall(int callId);