diff --git a/src/core.cpp b/src/core.cpp index 9d49c6f18..247ca4c88 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -251,14 +251,13 @@ void Core::start() 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, onAvMediaChange, av_OnPeerCSChange, this); + toxav_register_callstate_callback(toxav, onAvMediaChange, av_OnSelfCSChange, 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, this); - toxav_register_video_recv_callback(toxav, playCallVideo, this); + toxav_register_audio_callback(playCallAudio, this); + toxav_register_video_callback(playCallVideo, this); QPixmap pic = Settings::getInstance().getSavedAvatar(getSelfId().toString()); if (!pic.isNull() && !pic.size().isEmpty()) @@ -294,6 +293,7 @@ void Core::process() static int tolerance = CORE_DISCONNECT_TOLERANCE; tox_do(tox); + toxav_do(toxav); #ifdef DEBUG //we want to see the debug messages immediately @@ -307,7 +307,7 @@ void Core::process() bootstrapDht(); } - toxTimer->start(tox_do_interval(tox)); + toxTimer->start(qMin(tox_do_interval(tox), toxav_do_interval(toxav))); } bool Core::checkConnection() diff --git a/src/core.h b/src/core.h index 98cd9399b..6214539d7 100644 --- a/src/core.h +++ b/src/core.h @@ -244,8 +244,6 @@ private: 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); @@ -256,10 +254,10 @@ private: static void prepareCall(int friendId, int callId, ToxAv *toxav, bool videoEnabled); static void cleanupCall(int callId); - static void playCallAudio(ToxAv *toxav, int32_t callId, int16_t *data, int samples, void *user_data); // Callback + static void playCallAudio(void *toxav, int32_t callId, const int16_t *data, uint16_t samples, void *user_data); // Callback static void sendCallAudio(int callId, ToxAv* toxav); static void playAudioBuffer(ALuint alSource, const int16_t *data, int samples, unsigned channels, int sampleRate); - static void playCallVideo(ToxAv* toxav, int32_t callId, vpx_image_t* img, void *user_data); + static void playCallVideo(void *toxav, int32_t callId, const vpx_image_t* img, void *user_data); void sendCallVideo(int callId); bool checkConnection(); diff --git a/src/coreav.cpp b/src/coreav.cpp index fb6ad3343..f2a48f4e5 100644 --- a/src/coreav.cpp +++ b/src/coreav.cpp @@ -45,7 +45,7 @@ void Core::prepareCall(int friendId, int callId, ToxAv* toxav, bool videoEnabled calls[callId].codecSettings.max_video_width = TOXAV_MAX_VIDEO_WIDTH; calls[callId].codecSettings.max_video_height = TOXAV_MAX_VIDEO_HEIGHT; calls[callId].videoEnabled = videoEnabled; - int r = toxav_prepare_transmission(toxav, callId, av_jbufdc, av_VADd, videoEnabled); + int r = toxav_prepare_transmission(toxav, callId, videoEnabled); if (r < 0) qWarning() << QString("Error starting call %1: toxav_prepare_transmission failed with %2").arg(callId).arg(r); @@ -79,7 +79,7 @@ void Core::onAvMediaChange(void* toxav, int32_t callId, void* core) qDebug() << "Core: Received media change from friend "<stop(); @@ -111,14 +111,14 @@ void Core::answerCall(int callId) ToxAvCSettings* transSettings = new ToxAvCSettings; int err = toxav_get_peer_csettings(toxav, callId, 0, transSettings); - if (err != ErrorNone) + if (err != av_ErrorNone) { qWarning() << "Core::answerCall: error getting call settings"; delete transSettings; return; } - if (transSettings->call_type == TypeVideo) + if (transSettings->call_type == av_TypeVideo) { qDebug() << QString("Core: answering call %1 with video").arg(callId); toxav_answer(toxav, callId, transSettings); @@ -148,7 +148,7 @@ void Core::startCall(int friendId, bool video) if (video) { qDebug() << QString("Core: Starting new call with %1 with video").arg(friendId); - cSettings.call_type = TypeVideo; + cSettings.call_type = av_TypeVideo; if (toxav_call(toxav, &callId, friendId, &cSettings, TOXAV_RINGING_TIME) == 0) { calls[callId].videoEnabled=true; @@ -163,7 +163,7 @@ void Core::startCall(int friendId, bool video) else { qDebug() << QString("Core: Starting new call with %1 without video").arg(friendId); - cSettings.call_type = TypeAudio; + cSettings.call_type = av_TypeAudio; if (toxav_call(toxav, &callId, friendId, &cSettings, TOXAV_RINGING_TIME) == 0) { calls[callId].videoEnabled=false; @@ -196,7 +196,7 @@ void Core::cleanupCall(int callId) Audio::unsuscribeInput(); } -void Core::playCallAudio(ToxAv* toxav, int32_t callId, int16_t *data, int samples, void *user_data) +void Core::playCallAudio(void* toxav, int32_t callId, const int16_t *data, uint16_t samples, void *user_data) { Q_UNUSED(user_data); @@ -207,7 +207,7 @@ void Core::playCallAudio(ToxAv* toxav, int32_t callId, int16_t *data, int sample alGenSources(1, &calls[callId].alSource); ToxAvCSettings dest; - if(toxav_get_peer_csettings(toxav, callId, 0, &dest) == 0) + if(toxav_get_peer_csettings((ToxAv*)toxav, callId, 0, &dest) == 0) playAudioBuffer(calls[callId].alSource, data, samples, dest.audio_channels, dest.audio_sample_rate); } @@ -252,7 +252,7 @@ void Core::sendCallAudio(int callId, ToxAv* toxav) calls[callId].sendAudioTimer->start(); } -void Core::playCallVideo(ToxAv*, int32_t callId, vpx_image_t* img, void *user_data) +void Core::playCallVideo(void*, int32_t callId, const vpx_image_t* img, void *user_data) { Q_UNUSED(user_data); @@ -260,8 +260,6 @@ void Core::playCallVideo(ToxAv*, int32_t callId, vpx_image_t* img, void *user_da return; calls[callId].videoSource.pushVPXFrame(img); - - vpx_img_free(img); } void Core::sendCallVideo(int callId) @@ -381,58 +379,58 @@ void Core::onAvRinging(void* _toxav, int32_t call_index, void* core) } } -void Core::onAvStarting(void* _toxav, int32_t call_index, void* core) -{ - ToxAv* toxav = static_cast(_toxav); +//void Core::onAvStarting(void* _toxav, int32_t call_index, void* core) +//{ +// 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 friendId = toxav_get_peer_id(toxav, call_index, 0); +// if (friendId < 0) +// { +// qWarning() << "Core: Received invalid AV starting"; +// return; +// } - ToxAvCSettings* transSettings = new ToxAvCSettings; - int err = toxav_get_peer_csettings(toxav, call_index, 0, transSettings); - if (err != ErrorNone) - { - qWarning() << "Core::onAvStarting: error getting call type"; - delete transSettings; - return; - } +// ToxAvCSettings* transSettings = new ToxAvCSettings; +// int err = toxav_get_peer_csettings(toxav, call_index, 0, transSettings); +// if (err != ErrorNone) +// { +// qWarning() << "Core::onAvStarting: error getting call type"; +// delete transSettings; +// return; +// } - if (transSettings->call_type == TypeVideo) - { - qDebug() << QString("Core: AV starting from %1 with video").arg(friendId); - 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, toxav, false); - emit static_cast(core)->avStarting(friendId, call_index, false); - } +// if (transSettings->call_type == TypeVideo) +// { +// qDebug() << QString("Core: AV starting from %1 with video").arg(friendId); +// 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, toxav, false); +// emit static_cast(core)->avStarting(friendId, call_index, false); +// } - delete transSettings; -} +// delete transSettings; +//} -void Core::onAvEnding(void* _toxav, int32_t call_index, void* core) -{ - ToxAv* toxav = static_cast(_toxav); +//void Core::onAvEnding(void* _toxav, int32_t call_index, void* core) +//{ +// ToxAv* toxav = static_cast(_toxav); - int friendId = toxav_get_peer_id(toxav, call_index, 0); - if (friendId < 0) - { - qWarning() << "Core: Received invalid AV ending"; - return; - } - qDebug() << QString("Core: AV ending from %1").arg(friendId); +// int friendId = toxav_get_peer_id(toxav, call_index, 0); +// if (friendId < 0) +// { +// qWarning() << "Core: Received invalid AV ending"; +// return; +// } +// qDebug() << QString("Core: AV ending from %1").arg(friendId); - cleanupCall(call_index); +// cleanupCall(call_index); - emit static_cast(core)->avEnding(friendId, call_index); -} +// emit static_cast(core)->avEnding(friendId, call_index); +//} void Core::onAvRequestTimeout(void* _toxav, int32_t call_index, void* core) { @@ -482,14 +480,14 @@ void Core::onAvInvite(void* _toxav, int32_t call_index, void* core) ToxAvCSettings* transSettings = new ToxAvCSettings; int err = toxav_get_peer_csettings(toxav, call_index, 0, transSettings); - if (err != ErrorNone) + if (err != av_ErrorNone) { qWarning() << "Core::onAvInvite: error getting call type"; delete transSettings; return; } - if (transSettings->call_type == TypeVideo) + if (transSettings->call_type == av_TypeVideo) { qDebug() << QString("Core: AV invite from %1 with video").arg(friendId); emit static_cast(core)->avInvite(friendId, call_index, true); @@ -516,14 +514,14 @@ void Core::onAvStart(void* _toxav, int32_t call_index, void* core) ToxAvCSettings* transSettings = new ToxAvCSettings; int err = toxav_get_peer_csettings(toxav, call_index, 0, transSettings); - if (err != ErrorNone) + if (err != av_ErrorNone) { qWarning() << "Core::onAvStart: error getting call type"; delete transSettings; return; } - if (transSettings->call_type == TypeVideo) + if (transSettings->call_type == av_TypeVideo) { qDebug() << QString("Core: AV start from %1 with video").arg(friendId); prepareCall(friendId, call_index, toxav, true); diff --git a/src/video/netvideosource.cpp b/src/video/netvideosource.cpp index 3e433935f..6623e03ad 100644 --- a/src/video/netvideosource.cpp +++ b/src/video/netvideosource.cpp @@ -28,7 +28,7 @@ void NetVideoSource::pushFrame(VideoFrame frame) emit frameAvailable(frame); } -void NetVideoSource::pushVPXFrame(vpx_image *image) +void NetVideoSource::pushVPXFrame(const vpx_image *image) { const int dw = image->d_w; const int dh = image->d_h; diff --git a/src/video/netvideosource.h b/src/video/netvideosource.h index ef7556e96..4ad6dfd51 100644 --- a/src/video/netvideosource.h +++ b/src/video/netvideosource.h @@ -27,7 +27,7 @@ public: NetVideoSource(); void pushFrame(VideoFrame frame); - void pushVPXFrame(vpx_image* image); + void pushVPXFrame(const vpx_image *image); virtual void subscribe() {} virtual void unsubscribe() {}