1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Mostly implemented latest toxav.h changes, but OnMediaChange still needs implementing

This commit is contained in:
Bill Winslow 2014-07-22 16:59:27 -05:00
parent aab7448384
commit e1e7d68713
2 changed files with 71 additions and 52 deletions

100
core.cpp
View File

@ -125,17 +125,17 @@ void Core::start()
tox_callback_file_control(tox, onFileControlCallback, this); tox_callback_file_control(tox, onFileControlCallback, this);
tox_callback_file_data(tox, onFileDataCallback, this); tox_callback_file_data(tox, onFileDataCallback, this);
toxav_register_callstate_callback(onAvInvite, av_OnInvite, this); toxav_register_callstate_callback(toxav, onAvInvite, av_OnInvite, this);
toxav_register_callstate_callback(onAvStart, av_OnStart, this); toxav_register_callstate_callback(toxav, onAvStart, av_OnStart, this);
toxav_register_callstate_callback(onAvCancel, av_OnCancel, this); toxav_register_callstate_callback(toxav, onAvCancel, av_OnCancel, this);
toxav_register_callstate_callback(onAvReject, av_OnReject, this); toxav_register_callstate_callback(toxav, onAvReject, av_OnReject, this);
toxav_register_callstate_callback(onAvEnd, av_OnEnd, this); toxav_register_callstate_callback(toxav, onAvEnd, av_OnEnd, this);
toxav_register_callstate_callback(onAvRinging, av_OnRinging, this); toxav_register_callstate_callback(toxav, onAvRinging, av_OnRinging, this);
toxav_register_callstate_callback(onAvStarting, av_OnStarting, this); toxav_register_callstate_callback(toxav, onAvStarting, av_OnStarting, this);
toxav_register_callstate_callback(onAvEnding, av_OnEnding, this); toxav_register_callstate_callback(toxav, onAvEnding, av_OnEnding, this);
toxav_register_callstate_callback(onAvError, av_OnError, this); toxav_register_callstate_callback(toxav, onAvMediaChange, av_OnMediaChange, this);
toxav_register_callstate_callback(onAvRequestTimeout, av_OnRequestTimeout, this); toxav_register_callstate_callback(toxav, onAvRequestTimeout, av_OnRequestTimeout, this);
toxav_register_callstate_callback(onAvPeerTimeout, av_OnPeerTimeout, this); toxav_register_callstate_callback(toxav, onAvPeerTimeout, av_OnPeerTimeout, this);
toxav_register_audio_recv_callback(toxav, playCallAudio); toxav_register_audio_recv_callback(toxav, playCallAudio);
toxav_register_video_recv_callback(toxav, playCallVideo); toxav_register_video_recv_callback(toxav, playCallVideo);
@ -990,16 +990,18 @@ void Core::sendAllFileData(Core *core, ToxFile* file)
removeFileFromQueue(true, file->friendId, file->fileNum); 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*>(core)->toxav, call_index, 0); ToxAv* toxav = static_cast<ToxAv*>(_toxav);
int friendId = toxav_get_peer_id(toxav, call_index, 0);
if (friendId < 0) if (friendId < 0)
{ {
qWarning() << "Core: Received invalid AV invite"; qWarning() << "Core: Received invalid AV invite";
return; return;
} }
int transType = toxav_get_peer_transmission_type(static_cast<Core*>(core)->toxav, call_index, 0); int transType = toxav_get_peer_transmission_type(toxav, call_index, 0);
if (transType == TypeVideo) if (transType == TypeVideo)
{ {
qDebug() << QString("Core: AV invite from %1 with video").arg(friendId); 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*>(core)->toxav, call_index, 0); ToxAv* toxav = static_cast<ToxAv*>(_toxav);
int friendId = toxav_get_peer_id(toxav, call_index, 0);
if (friendId < 0) if (friendId < 0)
{ {
qWarning() << "Core: Received invalid AV start"; qWarning() << "Core: Received invalid AV start";
return; return;
} }
int transType = toxav_get_peer_transmission_type(static_cast<Core*>(core)->toxav, call_index, 0); int transType = toxav_get_peer_transmission_type(toxav, call_index, 0);
if (transType == TypeVideo) if (transType == TypeVideo)
{ {
qDebug() << QString("Core: AV start from %1 with video").arg(friendId); qDebug() << QString("Core: AV start from %1 with video").arg(friendId);
prepareCall(friendId, call_index, static_cast<Core*>(core)->toxav, true); prepareCall(friendId, call_index, toxav, true);
emit static_cast<Core*>(core)->avStart(friendId, call_index, true); emit static_cast<Core*>(core)->avStart(friendId, call_index, true);
} }
else else
{ {
qDebug() << QString("Core: AV start from %1 without video").arg(friendId); qDebug() << QString("Core: AV start from %1 without video").arg(friendId);
prepareCall(friendId, call_index, static_cast<Core*>(core)->toxav, false); prepareCall(friendId, call_index, toxav, false);
emit static_cast<Core*>(core)->avStart(friendId, call_index, false); emit static_cast<Core*>(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*>(core)->toxav, call_index, 0); ToxAv* toxav = static_cast<ToxAv*>(_toxav);
int friendId = toxav_get_peer_id(toxav, call_index, 0);
if (friendId < 0) if (friendId < 0)
{ {
qWarning() << "Core: Received invalid AV cancel"; qWarning() << "Core: Received invalid AV cancel";
@ -1049,14 +1055,16 @@ void Core::onAvCancel(int32_t call_index, void* core)
emit static_cast<Core*>(core)->avCancel(friendId, call_index); emit static_cast<Core*>(core)->avCancel(friendId, call_index);
} }
void Core::onAvReject(int32_t, void*) void Core::onAvReject(void*, int32_t, void*)
{ {
qDebug() << "Core: AV reject"; 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*>(core)->toxav, call_index, 0); ToxAv* toxav = static_cast<ToxAv*>(_toxav);
int friendId = toxav_get_peer_id(toxav, call_index, 0);
if (friendId < 0) if (friendId < 0)
{ {
qWarning() << "Core: Received invalid AV end"; qWarning() << "Core: Received invalid AV end";
@ -1069,9 +1077,11 @@ void Core::onAvEnd(int32_t call_index, void* core)
emit static_cast<Core*>(core)->avEnd(friendId, call_index); emit static_cast<Core*>(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*>(core)->toxav, call_index, 0); ToxAv* toxav = static_cast<ToxAv*>(_toxav);
int friendId = toxav_get_peer_id(toxav, call_index, 0);
if (friendId < 0) if (friendId < 0)
{ {
qWarning() << "Core: Received invalid AV ringing"; 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*>(core)->toxav, call_index, 0); ToxAv* toxav = static_cast<ToxAv*>(_toxav);
int friendId = toxav_get_peer_id(toxav, call_index, 0);
if (friendId < 0) if (friendId < 0)
{ {
qWarning() << "Core: Received invalid AV starting"; qWarning() << "Core: Received invalid AV starting";
return; return;
} }
int transType = toxav_get_peer_transmission_type(static_cast<Core*>(core)->toxav, call_index, 0); int transType = toxav_get_peer_transmission_type(toxav, call_index, 0);
if (transType == TypeVideo) if (transType == TypeVideo)
{ {
qDebug() << QString("Core: AV starting from %1 with video").arg(friendId); qDebug() << QString("Core: AV starting from %1 with video").arg(friendId);
prepareCall(friendId, call_index, static_cast<Core*>(core)->toxav, true); prepareCall(friendId, call_index, toxav, true);
emit static_cast<Core*>(core)->avStarting(friendId, call_index, true); emit static_cast<Core*>(core)->avStarting(friendId, call_index, true);
} }
else else
{ {
qDebug() << QString("Core: AV starting from %1 without video").arg(friendId); qDebug() << QString("Core: AV starting from %1 without video").arg(friendId);
prepareCall(friendId, call_index, static_cast<Core*>(core)->toxav, false); prepareCall(friendId, call_index, toxav, false);
emit static_cast<Core*>(core)->avStarting(friendId, call_index, false); emit static_cast<Core*>(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*>(core)->toxav, call_index, 0); ToxAv* toxav = static_cast<ToxAv*>(_toxav);
int friendId = toxav_get_peer_id(toxav, call_index, 0);
if (friendId < 0) if (friendId < 0)
{ {
qWarning() << "Core: Received invalid AV ending"; qWarning() << "Core: Received invalid AV ending";
@ -1128,14 +1142,11 @@ void Core::onAvEnding(int32_t call_index, void* core)
emit static_cast<Core*>(core)->avEnding(friendId, call_index); emit static_cast<Core*>(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*>(_toxav);
}
void Core::onAvRequestTimeout(int32_t call_index, void* core) int friendId = toxav_get_peer_id(toxav, call_index, 0);
{
int friendId = toxav_get_peer_id(static_cast<Core*>(core)->toxav, call_index, 0);
if (friendId < 0) if (friendId < 0)
{ {
qWarning() << "Core: Received invalid AV request timeout"; qWarning() << "Core: Received invalid AV request timeout";
@ -1148,9 +1159,11 @@ void Core::onAvRequestTimeout(int32_t call_index, void* core)
emit static_cast<Core*>(core)->avRequestTimeout(friendId, call_index); emit static_cast<Core*>(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*>(core)->toxav, call_index, 0); ToxAv* toxav = static_cast<ToxAv*>(_toxav);
int friendId = toxav_get_peer_id(toxav, call_index, 0);
if (friendId < 0) if (friendId < 0)
{ {
qWarning() << "Core: Received invalid AV peer timeout"; qWarning() << "Core: Received invalid AV peer timeout";
@ -1163,6 +1176,11 @@ void Core::onAvPeerTimeout(int32_t call_index, void* core)
emit static_cast<Core*>(core)->avPeerTimeout(friendId, call_index); emit static_cast<Core*>(core)->avPeerTimeout(friendId, call_index);
} }
void Core::onAvMediaChange(void*, int32_t, void*)
{
// HALP, PLS COMPLETE MEH
}
void Core::answerCall(int callId) void Core::answerCall(int callId)
{ {
int friendId = toxav_get_peer_id(toxav, callId, 0); int friendId = toxav_get_peer_id(toxav, callId, 0);

23
core.h
View File

@ -230,6 +230,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 videoFrameReceived(vpx_image* frame); void videoFrameReceived(vpx_image* frame);
@ -251,17 +252,17 @@ private:
uint8_t control_type, const uint8_t *data, uint16_t length, void *core); 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 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 onAvInvite(void* toxav, int32_t call_index, void* core);
static void onAvStart(int32_t call_index, void* toxav); static void onAvStart(void* toxav, int32_t call_index, void* core);
static void onAvCancel(int32_t call_index, void* toxav); static void onAvCancel(void* toxav, int32_t call_index, void* core);
static void onAvReject(int32_t call_index, void* toxav); static void onAvReject(void* toxav, int32_t call_index, void* core);
static void onAvEnd(int32_t call_index, void* toxav); static void onAvEnd(void* toxav, int32_t call_index, void* core);
static void onAvRinging(int32_t call_index, void* toxav); static void onAvRinging(void* toxav, int32_t call_index, void* core);
static void onAvStarting(int32_t call_index, void* toxav); static void onAvStarting(void* toxav, int32_t call_index, void* core);
static void onAvEnding(int32_t call_index, void* toxav); static void onAvEnding(void* toxav, int32_t call_index, void* core);
static void onAvError(int32_t call_index, void* toxav); static void onAvRequestTimeout(void* toxav, int32_t call_index, void* core);
static void onAvRequestTimeout(int32_t call_index, void* toxav); static void onAvPeerTimeout(void* toxav, int32_t call_index, void* core);
static void onAvPeerTimeout(int32_t call_index, void* toxav); 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);