From 4d0735ab834be6c541e7e577fbe76c888bf4d09f Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Tue, 14 Apr 2015 20:32:40 +0000 Subject: Tox: second approach for audio support git-svn-id: http://svn.miranda-ng.org/main/trunk@12827 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/src/tox_multimedia.cpp | 58 +++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) (limited to 'protocols/Tox/src/tox_multimedia.cpp') diff --git a/protocols/Tox/src/tox_multimedia.cpp b/protocols/Tox/src/tox_multimedia.cpp index 214f35f8d0..ba795bb0d7 100644 --- a/protocols/Tox/src/tox_multimedia.cpp +++ b/protocols/Tox/src/tox_multimedia.cpp @@ -1,6 +1,62 @@ #include "common.h" -void CToxProto::OnAvInvite(void*, int32_t callId, void *arg) { } +void CToxProto::OnAvInvite(void*, int32_t callId, void *arg) +{ + CToxProto *proto = (CToxProto*)arg; + + int friendNumber = toxav_get_peer_id(proto->toxAv, callId, 0); + if (friendNumber == TOX_ERROR) + { + proto->debugLogA(__FUNCTION__": failed to get friend number"); + toxav_stop_call(proto->toxAv, callId); + return; + } + + MCONTACT hContact = proto->GetContact(friendNumber); + if (hContact == NULL) + { + proto->debugLogA(__FUNCTION__": failed to get contact"); + toxav_stop_call(proto->toxAv, callId); + return; + } + + ToxAvCSettings dest; + if (toxav_get_peer_csettings(proto->toxAv, callId, 0, &dest) != av_ErrorNone) + { + proto->debugLogA(__FUNCTION__": failed to get codec settings"); + toxav_stop_call(proto->toxAv, callId); + return; + } + + if (dest.call_type != av_TypeAudio) + { + proto->debugLogA(__FUNCTION__": video call is unsupported"); + toxav_reject(proto->toxAv, callId, Translate("Video call is unsupported")); + return; + } + + PROTORECVEVENT recv = { 0 }; + recv.timestamp = time(NULL); + recv.flags = PREF_UTF; + recv.szMessage = mir_utf8encodeT(TranslateT("Incoming call")); + ProtoChainRecv(hContact, PSR_AUDIO, hContact, (LPARAM)&recv); +} + +INT_PTR CToxProto::OnRecvAudioCall(WPARAM hContact, LPARAM lParam) +{ + PROTORECVEVENT *pre = (PROTORECVEVENT*)lParam; + + DBEVENTINFO dbei = { sizeof(dbei) }; + dbei.szModule = m_szModuleName; + dbei.timestamp = pre->timestamp; + dbei.flags = DBEF_UTF; + dbei.eventType = DB_EVENT_AUDIO_CALL; + dbei.cbBlob = (DWORD)mir_strlen(pre->szMessage) + 1; + dbei.pBlob = (PBYTE)pre->szMessage; + + return (INT_PTR)db_event_add(hContact, &dbei); +} + void CToxProto::OnAvRinging(void*, int32_t callId, void *arg) { } void CToxProto::OnAvStart(void*, int32_t callId, void *arg) { } void CToxProto::OnAvEnd(void*, int32_t callId, void *arg) { } -- cgit v1.2.3