diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-11-03 20:23:48 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-11-03 20:23:48 +0000 |
commit | 63945ebb21dee8bd7ebd7c0144fd4fcdf00feff6 (patch) | |
tree | 37bd82205fec0af0fae3635313fcf6686435b76e /protocols/Tox/src | |
parent | afeb99849818ec79199eb7af39693fc5a522f017 (diff) |
Tox: updated tox core
git-svn-id: http://svn.miranda-ng.org/main/trunk@15677 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox/src')
-rw-r--r-- | protocols/Tox/src/api_av.cpp | 88 | ||||
-rw-r--r-- | protocols/Tox/src/stdafx.h | 2 | ||||
-rw-r--r-- | protocols/Tox/src/tox_core.cpp | 29 | ||||
-rw-r--r-- | protocols/Tox/src/tox_menus.cpp | 2 | ||||
-rw-r--r-- | protocols/Tox/src/tox_multimedia.cpp | 135 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.h | 21 | ||||
-rw-r--r-- | protocols/Tox/src/tox_thread.h | 8 |
7 files changed, 156 insertions, 129 deletions
diff --git a/protocols/Tox/src/api_av.cpp b/protocols/Tox/src/api_av.cpp index 5e09dc81bd..c46e549a35 100644 --- a/protocols/Tox/src/api_av.cpp +++ b/protocols/Tox/src/api_av.cpp @@ -2,109 +2,97 @@ /* COMMON A/V FUNCTIONS */
-ToxAv *toxav_new(Tox *tox, int32_t max_calls)
+ToxAV *toxav_new(Tox *tox, TOXAV_ERR_NEW *error)
{
- return CreateFunction<ToxAv*(*)(Tox*, int32_t)>(__FUNCTION__)(tox, max_calls);
+ return CreateFunction<ToxAV*(*)(Tox*, TOXAV_ERR_NEW*)>(__FUNCTION__)(tox, error);
}
-void toxav_kill(ToxAv *av)
+void toxav_kill(ToxAV *toxAV)
{
- CreateFunction<void(*)(ToxAv*)>(__FUNCTION__)(av);
+ CreateFunction<void(*)(ToxAV*)>(__FUNCTION__)(toxAV);
}
-uint32_t toxav_do_interval(ToxAv *av)
+Tox *toxav_get_tox(const ToxAV *toxAV)
{
- return CreateFunction<uint32_t(*)(ToxAv*)>(__FUNCTION__)(av);
+ return CreateFunction<Tox*(*)(const ToxAV*)>(__FUNCTION__)(toxAV);
}
-void toxav_do(ToxAv *av)
+uint32_t toxav_iteration_interval(ToxAV *toxAV)
{
- CreateFunction<void(*)(ToxAv*)>(__FUNCTION__)(av);
+ return CreateFunction<uint32_t(*)(ToxAV*)>(__FUNCTION__)(toxAV);
}
-void toxav_register_callstate_callback(ToxAv *av, ToxAVCallback cb, ToxAvCallbackID id, void *userdata)
+void toxav_iterate(ToxAV *toxAV)
{
- CreateFunction<void(*)(ToxAv*, ToxAVCallback, ToxAvCallbackID, void*)>(__FUNCTION__)(av, cb, id, userdata);
+ CreateFunction<void(*)(ToxAV*)>(__FUNCTION__)(toxAV);
}
-int toxav_call(ToxAv *av, int32_t *call_index, int friend_id, const ToxAvCSettings *csettings, int ringing_seconds)
+bool toxav_call(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate, TOXAV_ERR_CALL *error)
{
- return CreateFunction<int(*)(ToxAv*, int32_t*, int, const ToxAvCSettings*, int)>(__FUNCTION__)(av, call_index, friend_id, csettings, ringing_seconds);
+ return CreateFunction<bool(*)(ToxAV*, int32_t, uint32_t, uint32_t, TOXAV_ERR_CALL*)>(__FUNCTION__)(toxAV, friend_number, audio_bit_rate, video_bit_rate, error);
}
-int toxav_hangup(ToxAv *av, int32_t call_index)
+void toxav_callback_call(ToxAV *toxAV, toxav_call_cb *callback, void *user_data)
{
- return CreateFunction<int(*)(ToxAv*, int32_t)>(__FUNCTION__)(av, call_index);
+ CreateFunction<void(*)(ToxAV*, toxav_call_cb, void*)>(__FUNCTION__)(toxAV, callback, user_data);
}
-int toxav_answer(ToxAv *av, int32_t call_index, const ToxAvCSettings *csettings)
+bool toxav_answer(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate, TOXAV_ERR_ANSWER *error)
{
- return CreateFunction<int(*)(ToxAv*, int32_t, const ToxAvCSettings*)>(__FUNCTION__)(av, call_index, csettings);
+ return CreateFunction<bool(*)(ToxAV*, int32_t, uint32_t, uint32_t, TOXAV_ERR_ANSWER*)>(__FUNCTION__)(toxAV, friend_number, audio_bit_rate, video_bit_rate, error);
}
-int toxav_reject(ToxAv *av, int32_t call_index, const char *reason)
+void toxav_callback_call_state(ToxAV *toxAV, toxav_call_state_cb *callback, void *user_data)
{
- return CreateFunction<int(*)(ToxAv*, int32_t, const char*)>(__FUNCTION__)(av, call_index, reason);
+ CreateFunction<void(*)(ToxAV*, toxav_call_state_cb, void*)>(__FUNCTION__)(toxAV, callback, user_data);
}
-int toxav_cancel(ToxAv *av, int32_t call_index, int peer_id, const char *reason)
+bool toxav_call_control(ToxAV *toxAV, uint32_t friend_number, TOXAV_CALL_CONTROL control, TOXAV_ERR_CALL_CONTROL *error)
{
- return CreateFunction<int(*)(ToxAv*, int32_t, int, const char*)>(__FUNCTION__)(av, call_index, peer_id, reason);
+ return CreateFunction<bool(*)(ToxAV*, uint32_t, TOXAV_CALL_CONTROL, TOXAV_ERR_CALL_CONTROL*)>(__FUNCTION__)(toxAV, friend_number, control, error);
}
-int toxav_change_settings(ToxAv *av, int32_t call_index, const ToxAvCSettings *csettings)
+bool toxav_bit_rate_set(ToxAV *toxAV, uint32_t friend_number, int32_t audio_bit_rate, int32_t video_bit_rate, TOXAV_ERR_BIT_RATE_SET *error)
{
- return CreateFunction<int(*)(ToxAv*, int32_t, const ToxAvCSettings*)>(__FUNCTION__)(av, call_index, csettings);
+ return CreateFunction<bool(*)(ToxAV*, int32_t, uint32_t, uint32_t, TOXAV_ERR_BIT_RATE_SET*)>(__FUNCTION__)(toxAV, friend_number, audio_bit_rate, video_bit_rate, error);
}
-int toxav_stop_call(ToxAv *av, int32_t call_index)
+void toxav_callback_bit_rate_status(ToxAV *toxAV, toxav_bit_rate_status_cb *callback, void *user_data)
{
- return CreateFunction<int(*)(ToxAv*, int32_t)>(__FUNCTION__)(av, call_index);
+ CreateFunction<void(*)(ToxAV*, toxav_bit_rate_status_cb, void*)>(__FUNCTION__)(toxAV, callback, user_data);
}
-int toxav_prepare_transmission(ToxAv *av, int32_t call_index, int support_video)
+bool toxav_audio_send_frame(ToxAV *toxAV, uint32_t friend_number, const int16_t *pcm, size_t sample_count, uint8_t channels, uint32_t sampling_rate, TOXAV_ERR_SEND_FRAME *error)
{
- return CreateFunction<int(*)(ToxAv*, int32_t, int)>(__FUNCTION__)(av, call_index, support_video);
+ return CreateFunction<bool(*)(ToxAV*, int32_t, const int16_t*, size_t, uint8_t, uint32_t, TOXAV_ERR_SEND_FRAME*)>(__FUNCTION__)(toxAV, friend_number, pcm, sample_count, channels, sampling_rate, error);
}
-int toxav_kill_transmission(ToxAv *av, int32_t call_index)
+bool toxav_video_send_frame(ToxAV *toxAV, uint32_t friend_number, uint16_t width, uint16_t height, const uint8_t *y, const uint8_t *u, const uint8_t *v, TOXAV_ERR_SEND_FRAME *error)
{
- return CreateFunction<int(*)(ToxAv*, int32_t)>(__FUNCTION__)(av, call_index);
+ return CreateFunction<bool(*)(ToxAV*, int32_t, int16_t, uint16_t, const uint8_t*, const uint8_t*, const uint8_t*, TOXAV_ERR_SEND_FRAME*)>(__FUNCTION__)(toxAV, friend_number, width, height, y, u, v, error);
}
-int toxav_get_peer_csettings(ToxAv *av, int32_t call_index, int peer, ToxAvCSettings *dest)
+void toxav_callback_audio_receive_frame(ToxAV *toxAV, toxav_audio_receive_frame_cb *callback, void *user_data)
{
- return CreateFunction<int(*)(ToxAv*, int32_t, int, ToxAvCSettings*)>(__FUNCTION__)(av, call_index, peer, dest);
+ CreateFunction<void(*)(ToxAV*, toxav_audio_receive_frame_cb, void*)>(__FUNCTION__)(toxAV, callback, user_data);
}
-int toxav_get_peer_id(ToxAv *av, int32_t call_index, int peer)
+void toxav_callback_video_receive_frame(ToxAV *toxAV, toxav_video_receive_frame_cb *callback, void *user_data)
{
- return CreateFunction<int(*)(ToxAv*, int32_t, int)>(__FUNCTION__)(av, call_index, peer);
+ CreateFunction<void(*)(ToxAV*, toxav_video_receive_frame_cb, void*)>(__FUNCTION__)(toxAV, callback, user_data);
}
-ToxAvCallState toxav_get_call_state(ToxAv *av, int32_t call_index)
+int toxav_add_av_groupchat(Tox *tox, void(*audio_callback)(void *, int, int, const int16_t *, unsigned int, uint8_t, unsigned int, void *), void *userdata)
{
- return CreateFunction<ToxAvCallState(*)(ToxAv*, int32_t)>(__FUNCTION__)(av, call_index);
+ return CreateFunction<int(*)(Tox*, void(*)(void*, int, int, const int16_t*, unsigned int, uint8_t, unsigned int, void*), void*)>(__FUNCTION__)(tox, audio_callback, userdata);
}
-int toxav_capability_supported(ToxAv *av, int32_t call_index, ToxAvCapabilities capability)
+int toxav_join_av_groupchat(Tox *tox, int32_t friendnumber, const uint8_t *data, uint16_t length, void(*audio_callback)(void *, int, int, const int16_t *, unsigned int, uint8_t, unsigned int, void *), void *userdata)
{
- return CreateFunction<int(*)(ToxAv*, int32_t, ToxAvCapabilities)>(__FUNCTION__)(av, call_index, capability);
+ return CreateFunction<int(*)(Tox*, int32_t, const uint8_t*, uint16_t, void(*)(void*, int, int, const int16_t*, unsigned int, uint8_t, unsigned int, void*), void*)>(__FUNCTION__)(tox, friendnumber, data, length, audio_callback, userdata);
}
-Tox *toxav_get_tox(ToxAv *av)
+int toxav_group_send_audio(Tox *tox, int groupnumber, const int16_t *pcm, unsigned int samples, uint8_t channels, unsigned int sample_rate)
{
- return CreateFunction<Tox*(*)(ToxAv*)>(__FUNCTION__)(av);
-}
-
-int toxav_get_active_count(ToxAv *av)
-{
- return CreateFunction<int(*)(ToxAv*)>(__FUNCTION__)(av);
-}
-
-/* AUDIO FUNCTIONS */
-
-void toxav_register_audio_callback(ToxAv *av, ToxAvAudioCallback cb, void *userdata)
-{
- CreateFunction<void(*)(ToxAv*, ToxAvAudioCallback, void*)>(__FUNCTION__)(av, cb, userdata);
+ return CreateFunction<int(*)(Tox*, int, const int16_t*, unsigned int, uint8_t, unsigned int)>(__FUNCTION__)(tox, groupnumber, pcm, samples, channels, sample_rate);
}
\ No newline at end of file diff --git a/protocols/Tox/src/stdafx.h b/protocols/Tox/src/stdafx.h index 537f414662..275262c787 100644 --- a/protocols/Tox/src/stdafx.h +++ b/protocols/Tox/src/stdafx.h @@ -44,7 +44,7 @@ DEFINE_PROPERTYKEY(PKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0 #include <m_assocmgr.h>
#include <tox.h>
-#include <toxav.h>
+#include <ToxAV.h>
#include <toxdns.h>
#include <toxencryptsave.h>
diff --git a/protocols/Tox/src/tox_core.cpp b/protocols/Tox/src/tox_core.cpp index a500d84be9..fd6452745a 100644 --- a/protocols/Tox/src/tox_core.cpp +++ b/protocols/Tox/src/tox_core.cpp @@ -81,18 +81,19 @@ bool CToxProto::InitToxCore(CToxThread *toxThread) // group chats
//tox_callback_group_invite(tox, OnGroupChatInvite, this);
// a/v
- if (IsWinVerVistaPlus())
- {
- /*toxAv = toxav_new(tox, TOX_MAX_CALLS);
- toxav_register_audio_callback(toxThread->toxAv, OnFriendAudio, this);
- toxav_register_callstate_callbacktox(Thread->toxAv, OnAvInvite, av_OnInvite, this);
- toxav_register_callstate_callbacktox(Thread->toxAv, OnAvStart, av_OnStart, this);
- toxav_register_callstate_callbacktox(Thread->toxAv, OnAvCancel, av_OnCancel, this);
- toxav_register_callstate_callbacktox(Thread->toxAv, OnAvReject, av_OnReject, this);
- toxav_register_callstate_callback(toxThread->toxAv, OnAvEnd, av_OnEnd, this);
- toxav_register_callstate_callback(toxThread->toxAv, OnAvCallTimeout, av_OnRequestTimeout, this);
- toxav_register_callstate_callback(toxThread->toxAv, OnAvPeerTimeout, av_OnPeerTimeout, this);*/
- }
+ //if (IsWinVerVistaPlus())
+ //{
+ // TOXAV_ERR_NEW avInitError;
+ // toxThread->toxAV = toxav_new(toxThread->tox, &avInitError);
+ // if (initError != TOX_ERR_NEW_OK)
+ // {
+ // toxav_callback_call(toxThread->toxAV, OnFriendCall, this);
+ // toxav_callback_call_state(toxThread->toxAV, OnFriendCallState, this);
+ // toxav_callback_bit_rate_status(toxThread->toxAV, OnBitrateChanged, this);
+ // toxav_callback_audio_receive_frame(toxThread->toxAV, OnFriendAudioFrame, this);
+ // //toxav_callback_video_receive_frame(toxThread->toxAV, , this);
+ // }
+ //}
uint8_t data[TOX_ADDRESS_SIZE];
tox_self_get_address(toxThread->tox, data);
@@ -118,8 +119,8 @@ bool CToxProto::InitToxCore(CToxThread *toxThread) void CToxProto::UninitToxCore(CToxThread *toxThread)
{
if (toxThread) {
- if (toxThread->toxAv)
- toxav_kill(toxThread->toxAv);
+ if (toxThread->toxAV)
+ toxav_kill(toxThread->toxAV);
if (toxThread->tox)
{
diff --git a/protocols/Tox/src/tox_menus.cpp b/protocols/Tox/src/tox_menus.cpp index 6da8d1bc93..0c99ad85cb 100644 --- a/protocols/Tox/src/tox_menus.cpp +++ b/protocols/Tox/src/tox_menus.cpp @@ -22,7 +22,7 @@ int CToxProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM) Menu_ShowItem(ContactMenuItems[CMI_AUTH_GRANT], isCtrlPressed || isGrantNeed);
bool isContactOnline = GetContactStatus(hContact) > ID_STATUS_OFFLINE;
- Menu_ShowItem(ContactMenuItems[CMI_AUDIO_CALL], toxThread->toxAv && isContactOnline);
+ Menu_ShowItem(ContactMenuItems[CMI_AUDIO_CALL], toxThread->toxAV && isContactOnline);
return 0;
}
diff --git a/protocols/Tox/src/tox_multimedia.cpp b/protocols/Tox/src/tox_multimedia.cpp index 2479f4ba95..1bbc9b5f11 100644 --- a/protocols/Tox/src/tox_multimedia.cpp +++ b/protocols/Tox/src/tox_multimedia.cpp @@ -63,19 +63,31 @@ void CToxIncomingCall::OnInitDialog() void CToxIncomingCall::OnClose()
{
- toxav_reject(m_proto->toxThread->toxAv, m_proto->calls[hContact], NULL);
+ toxav_call_control(m_proto->toxThread->toxAV, m_proto->calls[hContact], TOXAV_CALL_CONTROL_CANCEL, NULL);
Utils_SaveWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "IncomingCallWindow_");
CToxCallDlgBase::OnClose();
}
void CToxIncomingCall::OnAnswer(CCtrlBase*)
{
- ToxAvCSettings *cSettings = m_proto->GetAudioCSettings();
+ /*ToxAvCSettings *cSettings = m_proto->GetAudioCSettings();
if (cSettings == NULL)
+ return;*/
+
+ int friendNumber = m_proto->GetToxFriendNumber(hContact);
+ if (friendNumber == UINT32_MAX)
+ {
+ //mir_free(cSettings);
+ Close();
return;
+ }
- if (toxav_answer(m_proto->toxThread->toxAv, m_proto->calls[hContact], cSettings) == TOX_ERROR)
- m_proto->logger->Log(__FUNCTION__": failed to start call");
+ TOXAV_ERR_ANSWER error;
+ if (!toxav_answer(m_proto->toxThread->toxAV, friendNumber, 0, 0, &error))
+ {
+ m_proto->logger->Log(__FUNCTION__": failed to answer the call (%d)", error);
+ Close();
+ }
}
//////////////////////////////////////////////////////////////////////////////////////////////
@@ -111,30 +123,29 @@ void CToxOutgoingCall::OnClose() void CToxOutgoingCall::OnCall(CCtrlBase*)
{
- ToxAvCSettings *cSettings = m_proto->GetAudioCSettings();
+ /*ToxAvCSettings *cSettings = m_proto->GetAudioCSettings();
if (cSettings == NULL)
{
Close();
return;
- }
+ }*/
int friendNumber = m_proto->GetToxFriendNumber(hContact);
if (friendNumber == UINT32_MAX)
{
- mir_free(cSettings);
+ //mir_free(cSettings);
Close();
return;
}
- int32_t callId;
- if (toxav_call(m_proto->toxThread->toxAv, &callId, friendNumber, cSettings, 10) == TOX_ERROR)
+ TOXAV_ERR_CALL error;
+ if (!toxav_call(m_proto->toxThread->toxAV, friendNumber, 0, 0, &error))
{
- mir_free(cSettings);
- m_proto->logger->Log(__FUNCTION__": failed to start outgoing call");
+ //mir_free(cSettings);
+ m_proto->logger->Log(__FUNCTION__": failed to make a call (%d)", error);
return;
}
- mir_free(cSettings);
- m_proto->calls[hContact] = callId;
+ //mir_free(cSettings);
char *message = NULL;
TCHAR title[MAX_PATH];
@@ -150,8 +161,16 @@ void CToxOutgoingCall::OnCall(CCtrlBase*) void CToxOutgoingCall::OnCancel(CCtrlBase*)
{
+ int friendNumber = m_proto->GetToxFriendNumber(hContact);
+ if (friendNumber == UINT32_MAX)
+ {
+ //mir_free(cSettings);
+ Close();
+ return;
+ }
+
if (!call.Enabled())
- toxav_cancel(m_proto->toxThread->toxAv, m_proto->calls[hContact], 0, NULL);
+ toxav_call_control(m_proto->toxThread->toxAV, friendNumber, TOXAV_CALL_CONTROL_CANCEL, NULL);
}
//////////////////////////////////////////////////////////////////////////////////////////////
@@ -170,14 +189,22 @@ void CToxCallDialog::OnInitDialog() void CToxCallDialog::OnClose()
{
- toxav_hangup(m_proto->toxThread->toxAv, m_proto->calls[hContact]);
+ int friendNumber = m_proto->GetToxFriendNumber(hContact);
+ if (friendNumber == UINT32_MAX)
+ {
+ //mir_free(cSettings);
+ Close();
+ return;
+ }
+
+ toxav_call_control(m_proto->toxThread->toxAV, friendNumber, TOXAV_CALL_CONTROL_CANCEL, NULL);
Utils_SaveWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "CallWindow_");
CToxCallDlgBase::OnClose();
}
//////////////////////////////////////////////////////////////////////////////////////////////
-ToxAvCSettings* CToxProto::GetAudioCSettings()
+/*ToxAvCSettings* CToxProto::GetAudioCSettings()
{
ToxAvCSettings *cSettings = (ToxAvCSettings*)mir_calloc(sizeof(ToxAvCSettings));
cSettings->audio_frame_duration = 20;
@@ -249,20 +276,20 @@ ToxAvCSettings* CToxProto::GetAudioCSettings() }
return cSettings;
-}
+}*/
/* INCOMING CALL */
// incoming call flow
-void CToxProto::OnAvInvite(void*, int32_t callId, void *arg)
+void CToxProto::OnFriendCall(ToxAV *toxAV, uint32_t friend_number, bool audio_enabled, bool video_enabled, void *arg)
{
- CToxProto *proto = (CToxProto*)arg;
+ /*CToxProto *proto = (CToxProto*)arg;
- int friendNumber = toxav_get_peer_id(proto->toxThread->toxAv, callId, 0);
+ int friendNumber = toxav_get_peer_id(proto->toxThread->ToxAV, callId, 0);
if (friendNumber == TOX_ERROR)
{
proto->logger->Log(__FUNCTION__": failed to get friend number");
- toxav_reject(proto->toxThread->toxAv, callId, NULL);
+ toxav_reject(proto->toxThread->ToxAV, callId, NULL);
return;
}
@@ -270,22 +297,22 @@ void CToxProto::OnAvInvite(void*, int32_t callId, void *arg) if (hContact == NULL)
{
proto->logger->Log(__FUNCTION__": failed to find contact");
- toxav_reject(proto->toxThread->toxAv, callId, NULL);
+ toxav_reject(proto->toxThread->ToxAV, callId, NULL);
return;
}
ToxAvCSettings cSettings;
- if (toxav_get_peer_csettings(proto->toxThread->toxAv, callId, 0, &cSettings) != av_ErrorNone)
+ if (toxav_get_peer_csettings(proto->toxThread->ToxAV, callId, 0, &cSettings) != av_ErrorNone)
{
proto->logger->Log(__FUNCTION__": failed to get codec settings");
- toxav_reject(proto->toxThread->toxAv, callId, NULL);
+ toxav_reject(proto->toxThread->ToxAV, callId, NULL);
return;
}
if (cSettings.call_type != av_TypeAudio)
{
proto->logger->Log(__FUNCTION__": video call is unsupported");
- toxav_reject(proto->toxThread->toxAv, callId, Translate("Video call is unsupported"));
+ toxav_reject(proto->toxThread->ToxAV, callId, Translate("Video call is unsupported"));
return;
}
@@ -297,7 +324,15 @@ void CToxProto::OnAvInvite(void*, int32_t callId, void *arg) recv.timestamp = time(NULL);
recv.lParam = callId;
recv.szMessage = szMessage;
- ProtoChainRecv(hContact, PSR_AUDIO, hContact, (LPARAM)&recv);
+ ProtoChainRecv(hContact, PSR_AUDIO, hContact, (LPARAM)&recv);*/
+}
+
+void CToxProto::OnFriendCallState(ToxAV *toxAV, uint32_t friend_number, uint32_t state, void *user_data)
+{
+}
+
+void CToxProto::OnBitrateChanged(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate, void *arg)
+{
}
// save event to db
@@ -339,11 +374,11 @@ INT_PTR CToxProto::OnAudioRing(WPARAM, LPARAM lParam) return 0;
}
-void CToxProto::OnAvCancel(void*, int32_t callId, void *arg)
+/*void CToxProto::OnAvCancel(void*, int32_t callId, void *arg)
{
CToxProto *proto = (CToxProto*)arg;
- int friendNumber = toxav_get_peer_id(proto->toxThread->toxAv, callId, 0);
+ int friendNumber = toxav_get_peer_id(proto->toxThread->ToxAV, callId, 0);
if (friendNumber == TOX_ERROR)
{
proto->logger->Log(__FUNCTION__": failed to get friend number");
@@ -371,7 +406,7 @@ void CToxProto::OnAvCancel(void*, int32_t callId, void *arg) proto->AddEventToDb(hContact, DB_EVENT_CALL, time(NULL), DBEF_UTF, (PBYTE)message, mir_strlen(message));
WindowList_Broadcast(proto->hAudioDialogs, WM_CALL_END, hContact, 0);
-}
+}*/
/* OUTGOING CALL */
@@ -384,11 +419,11 @@ INT_PTR CToxProto::OnSendAudioCall(WPARAM hContact, LPARAM) return 0;
}
-void CToxProto::OnAvReject(void*, int32_t callId, void *arg)
+/*void CToxProto::OnAvReject(void*, int32_t callId, void *arg)
{
CToxProto *proto = (CToxProto*)arg;
- int friendNumber = toxav_get_peer_id(proto->toxThread->toxAv, callId, 0);
+ int friendNumber = toxav_get_peer_id(proto->toxThread->ToxAV, callId, 0);
if (friendNumber == TOX_ERROR)
{
proto->logger->Log(__FUNCTION__": failed to get friend number");
@@ -412,7 +447,7 @@ void CToxProto::OnAvCallTimeout(void*, int32_t callId, void *arg) {
CToxProto *proto = (CToxProto*)arg;
- int friendNumber = toxav_get_peer_id(proto->toxThread->toxAv, callId, 0);
+ int friendNumber = toxav_get_peer_id(proto->toxThread->ToxAV, callId, 0);
if (friendNumber == TOX_ERROR)
{
proto->logger->Log(__FUNCTION__": failed to get friend number");
@@ -430,7 +465,7 @@ void CToxProto::OnAvCallTimeout(void*, int32_t callId, void *arg) proto->AddEventToDb(hContact, DB_EVENT_CALL, time(NULL), DBEF_UTF, (PBYTE)message, mir_strlen(message));
WindowList_Broadcast(proto->hAudioDialogs, WM_CALL_END, hContact, 0);
-}
+}*/
/* --- */
@@ -452,23 +487,23 @@ static void CALLBACK ToxShowDialogApcProc(void *arg) callDlg->Show();
}
-void CToxProto::OnAvStart(void*, int32_t callId, void *arg)
+/*void CToxProto::OnAvStart(void*, int32_t callId, void *arg)
{
CToxProto *proto = (CToxProto*)arg;
ToxAvCSettings cSettings;
- int cSettingsError = toxav_get_peer_csettings(proto->toxThread->toxAv, callId, 0, &cSettings);
+ int cSettingsError = toxav_get_peer_csettings(proto->toxThread->ToxAV, callId, 0, &cSettings);
if (cSettingsError != av_ErrorNone)
{
proto->logger->Log(__FUNCTION__": failed to get codec settings (%d)", cSettingsError);
- toxav_hangup(proto->toxThread->toxAv, callId);
+ toxav_hangup(proto->toxThread->ToxAV, callId);
return;
}
if (cSettings.call_type != av_TypeAudio)
{
proto->logger->Log(__FUNCTION__": video call is unsupported");
- toxav_hangup(proto->toxThread->toxAv, callId);
+ toxav_hangup(proto->toxThread->ToxAV, callId);
return;
}
@@ -485,7 +520,7 @@ void CToxProto::OnAvStart(void*, int32_t callId, void *arg) if (error != MMSYSERR_NOERROR)
{
proto->logger->Log(__FUNCTION__": failed to open audio device (%d)", error);
- toxav_hangup(proto->toxThread->toxAv, callId);
+ toxav_hangup(proto->toxThread->ToxAV, callId);
TCHAR errorMessage[MAX_PATH];
waveInGetErrorText(error, errorMessage, _countof(errorMessage));
@@ -496,11 +531,11 @@ void CToxProto::OnAvStart(void*, int32_t callId, void *arg) return;
}
- int friendNumber = toxav_get_peer_id(proto->toxThread->toxAv, callId, 0);
+ int friendNumber = toxav_get_peer_id(proto->toxThread->ToxAV, callId, 0);
if (friendNumber == TOX_ERROR)
{
proto->logger->Log(__FUNCTION__": failed to get friend number");
- toxav_hangup(proto->toxThread->toxAv, callId);
+ toxav_hangup(proto->toxThread->ToxAV, callId);
return;
}
@@ -508,14 +543,14 @@ void CToxProto::OnAvStart(void*, int32_t callId, void *arg) if (hContact == NULL)
{
proto->logger->Log(__FUNCTION__": failed to find contact");
- toxav_hangup(proto->toxThread->toxAv, callId);
+ toxav_hangup(proto->toxThread->ToxAV, callId);
return;
}
- if (toxav_prepare_transmission(proto->toxThread->toxAv, callId, false) == TOX_ERROR)
+ if (toxav_prepare_transmission(proto->toxThread->ToxAV, callId, false) == TOX_ERROR)
{
proto->logger->Log(__FUNCTION__": failed to prepare audio transmition");
- toxav_hangup(proto->toxThread->toxAv, callId);
+ toxav_hangup(proto->toxThread->ToxAV, callId);
return;
}
@@ -534,9 +569,9 @@ void CToxProto::OnAvEnd(void*, int32_t callId, void *arg) waveOutReset(proto->hOutDevice);
waveOutClose(proto->hOutDevice);
- toxav_kill_transmission(proto->toxThread->toxAv, callId);
+ toxav_kill_transmission(proto->toxThread->ToxAV, callId);
- int friendNumber = toxav_get_peer_id(proto->toxThread->toxAv, callId, 0);
+ int friendNumber = toxav_get_peer_id(proto->toxThread->ToxAV, callId, 0);
if (friendNumber == TOX_ERROR)
{
proto->logger->Log(__FUNCTION__": failed to get friend number");
@@ -560,7 +595,7 @@ void CToxProto::OnAvPeerTimeout(void *av, int32_t callId, void *arg) {
CToxProto *proto = (CToxProto*)arg;
- ToxAvCallState callState = toxav_get_call_state(proto->toxThread->toxAv, callId);
+ ToxAvCallState callState = toxav_get_call_state(proto->toxThread->ToxAV, callId);
switch (callState)
{
case av_CallStarting:
@@ -575,13 +610,13 @@ void CToxProto::OnAvPeerTimeout(void *av, int32_t callId, void *arg) proto->logger->Log(__FUNCTION__": failed to handle callState");
break;
}
-}
+}*/
//////
-void CToxProto::OnFriendAudio(void*, int32_t, const int16_t *PCM, uint16_t size, void *arg)
+void CToxProto::OnFriendAudioFrame(ToxAV *toxAV, uint32_t friend_number, const int16_t *pcm, size_t sample_count, uint8_t channels, uint32_t sampling_rate, void *user_data)
{
- CToxProto *proto = (CToxProto*)arg;
+ /*CToxProto *proto = (CToxProto*)arg;
WAVEHDR *header = (WAVEHDR*)mir_calloc(sizeof(WAVEHDR));
header->dwBufferLength = size * sizeof(int16_t);
@@ -600,5 +635,5 @@ void CToxProto::OnFriendAudio(void*, int32_t, const int16_t *PCM, uint16_t size, {
proto->logger->Log(__FUNCTION__": failed to play audio samples (%d)", error);
return;
- }
+ }*/
}
\ No newline at end of file diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index fcb66f8177..aebf85148e 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -253,21 +253,24 @@ private: HWAVEOUT hOutDevice;
std::map<MCONTACT, int32_t> calls;
- ToxAvCSettings* GetAudioCSettings();
+ //ToxAvCSettings* GetAudioCSettings();
+
- static void OnFriendAudio(void *agent, int32_t callId, const int16_t *PCM, uint16_t size, void *arg);
INT_PTR __cdecl OnRecvAudioCall(WPARAM wParam, LPARAM lParam);
INT_PTR __cdecl OnAudioRing(WPARAM wParam, LPARAM lParam);
INT_PTR __cdecl OnSendAudioCall(WPARAM wParam, LPARAM);
- static void OnAvInvite(void*, int32_t callId, void *arg);
- static void OnAvStart(void*, int32_t callId, void *arg);
- static void OnAvEnd(void*, int32_t callId, void *arg);
- static void OnAvReject(void*, int32_t callId, void *arg);
- static void OnAvCancel(void*, int32_t callId, void *arg);
- static void OnAvCallTimeout(void*, int32_t callId, void *arg);
- static void OnAvPeerTimeout(void*, int32_t callId, void *arg);
+ static void OnFriendCall(ToxAV *toxAV, uint32_t friend_number, bool audio_enabled, bool video_enabled, void *arg);
+ static void OnFriendCallState(ToxAV *toxAV, uint32_t friend_number, uint32_t state, void *user_data);
+ static void OnBitrateChanged(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate, void *arg);
+ static void OnFriendAudioFrame(ToxAV *toxAV, uint32_t friend_number, const int16_t *pcm, size_t sample_count, uint8_t channels, uint32_t sampling_rate, void *user_data);
+
+ //static void OnAvEnd(void*, int32_t callId, void *arg);
+ //static void OnAvReject(void*, int32_t callId, void *arg);
+ //static void OnAvCancel(void*, int32_t callId, void *arg);
+ //static void OnAvCallTimeout(void*, int32_t callId, void *arg);
+ //static void OnAvPeerTimeout(void*, int32_t callId, void *arg);
// utils
static int MapStatus(int status);
diff --git a/protocols/Tox/src/tox_thread.h b/protocols/Tox/src/tox_thread.h index 892322b11c..6b1a013398 100644 --- a/protocols/Tox/src/tox_thread.h +++ b/protocols/Tox/src/tox_thread.h @@ -5,13 +5,13 @@ class CToxThread {
public:
Tox *tox;
- ToxAv *toxAv;
+ ToxAV *toxAV;
bool isConnected;
bool isTerminated;
mir_cs toxLock;
- CToxThread() : tox(NULL), toxAv(NULL),
+ CToxThread() : tox(NULL), toxAV(NULL),
isConnected(false), isTerminated(false) { }
void Do()
@@ -19,8 +19,8 @@ public: {
mir_cslock lock(toxLock);
tox_iterate(tox);
- if (toxAv)
- toxav_do(toxAv);
+ //if (toxAV)
+ // toxav_iterate(toxAV);
}
uint32_t interval = tox_iteration_interval(tox);
Sleep(interval);
|