mirror of
https://github.com/Tha14/toxic.git
synced 2025-07-01 13:36:46 +02:00
Began conversion of audio code to new ToxAV API
This commit is contained in:
66
src/chat.c
66
src/chat.c
@ -552,29 +552,27 @@ static void chat_onGroupInvite(ToxWindow *self, Tox *m, int32_t friendnumber, ui
|
||||
/* Av Stuff */
|
||||
#ifdef AUDIO
|
||||
|
||||
void chat_onInvite (ToxWindow *self, ToxAv *av, int call_index)
|
||||
void chat_onInvite (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
|
||||
{
|
||||
if (!self || self->num != toxav_get_peer_id(av, call_index, 0))
|
||||
if (!self || self->num != friend_number)
|
||||
return;
|
||||
|
||||
/* call_index is set here and reset on call end */
|
||||
|
||||
self->call_idx = call_index;
|
||||
/* friend_number is set here and reset on call end */
|
||||
self->num = (int)friend_number;
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Incoming audio call! Type: \"/answer\" or \"/reject\"");
|
||||
|
||||
if (self->ringing_sound == -1)
|
||||
sound_notify(self, call_incoming, NT_LOOP, &self->ringing_sound);
|
||||
|
||||
|
||||
if (self->active_box != -1)
|
||||
box_silent_notify2(self, NT_NOFOCUS | NT_WNDALERT_0, self->active_box, "Incoming audio call!");
|
||||
else
|
||||
box_silent_notify(self, NT_NOFOCUS | NT_WNDALERT_0, &self->active_box, self->name, "Incoming audio call!");
|
||||
}
|
||||
|
||||
void chat_onRinging (ToxWindow *self, ToxAv *av, int call_index)
|
||||
void chat_onRinging (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
|
||||
{
|
||||
if ( !self || self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0))
|
||||
if (!self || self->num != friend_number)
|
||||
return;
|
||||
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Ringing...type \"/hangup\" to cancel it.");
|
||||
@ -585,9 +583,9 @@ void chat_onRinging (ToxWindow *self, ToxAv *av, int call_index)
|
||||
#endif /* SOUND_NOTIFY */
|
||||
}
|
||||
|
||||
void chat_onStarting (ToxWindow *self, ToxAv *av, int call_index)
|
||||
void chat_onStarting (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
|
||||
{
|
||||
if ( !self || self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0))
|
||||
if (!self || self->num != friend_number)
|
||||
return;
|
||||
|
||||
init_infobox(self);
|
||||
@ -599,13 +597,13 @@ void chat_onStarting (ToxWindow *self, ToxAv *av, int call_index)
|
||||
#endif /* SOUND_NOTIFY */
|
||||
}
|
||||
|
||||
void chat_onEnding (ToxWindow *self, ToxAv *av, int call_index)
|
||||
void chat_onEnding (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
|
||||
{
|
||||
if (!self || self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0))
|
||||
if (!self || self->num != friend_number)
|
||||
return;
|
||||
|
||||
kill_infobox(self);
|
||||
self->call_idx = -1;
|
||||
//self->num = -1;
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call ended!");
|
||||
|
||||
#ifdef SOUND_NOTIFY
|
||||
@ -613,12 +611,12 @@ void chat_onEnding (ToxWindow *self, ToxAv *av, int call_index)
|
||||
#endif /* SOUND_NOTIFY */
|
||||
}
|
||||
|
||||
void chat_onError (ToxWindow *self, ToxAv *av, int call_index)
|
||||
void chat_onError (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
|
||||
{
|
||||
if (!self || self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0))
|
||||
if (!self || self->num != friend_number)
|
||||
return;
|
||||
|
||||
self->call_idx = -1;
|
||||
//self->num = -1;
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Error!");
|
||||
|
||||
#ifdef SOUND_NOTIFY
|
||||
@ -626,9 +624,9 @@ void chat_onError (ToxWindow *self, ToxAv *av, int call_index)
|
||||
#endif /* SOUND_NOTIFY */
|
||||
}
|
||||
|
||||
void chat_onStart (ToxWindow *self, ToxAv *av, int call_index)
|
||||
void chat_onStart (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
|
||||
{
|
||||
if ( !self || self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0))
|
||||
if (!self || self->num != friend_number)
|
||||
return;
|
||||
|
||||
init_infobox(self);
|
||||
@ -640,13 +638,13 @@ void chat_onStart (ToxWindow *self, ToxAv *av, int call_index)
|
||||
#endif /* SOUND_NOTIFY */
|
||||
}
|
||||
|
||||
void chat_onCancel (ToxWindow *self, ToxAv *av, int call_index)
|
||||
void chat_onCancel (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
|
||||
{
|
||||
if ( !self || self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0))
|
||||
if (!self || self->num != friend_number)
|
||||
return;
|
||||
|
||||
kill_infobox(self);
|
||||
self->call_idx = -1;
|
||||
//self->num = -1;
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call canceled!");
|
||||
|
||||
#ifdef SOUND_NOTIFY
|
||||
@ -654,12 +652,12 @@ void chat_onCancel (ToxWindow *self, ToxAv *av, int call_index)
|
||||
#endif /* SOUND_NOTIFY */
|
||||
}
|
||||
|
||||
void chat_onReject (ToxWindow *self, ToxAv *av, int call_index)
|
||||
void chat_onReject (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
|
||||
{
|
||||
if (!self || self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0))
|
||||
if (!self || self->num != friend_number)
|
||||
return;
|
||||
|
||||
self->call_idx = -1;
|
||||
//self->num = -1;
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Rejected!");
|
||||
|
||||
#ifdef SOUND_NOTIFY
|
||||
@ -667,13 +665,13 @@ void chat_onReject (ToxWindow *self, ToxAv *av, int call_index)
|
||||
#endif /* SOUND_NOTIFY */
|
||||
}
|
||||
|
||||
void chat_onEnd (ToxWindow *self, ToxAv *av, int call_index)
|
||||
void chat_onEnd (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
|
||||
{
|
||||
if (!self || self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0))
|
||||
if (!self || self->num != friend_number)
|
||||
return;
|
||||
|
||||
kill_infobox(self);
|
||||
self->call_idx = -1;
|
||||
//self->num = -1;
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call ended!");
|
||||
|
||||
#ifdef SOUND_NOTIFY
|
||||
@ -681,12 +679,12 @@ void chat_onEnd (ToxWindow *self, ToxAv *av, int call_index)
|
||||
#endif /* SOUND_NOTIFY */
|
||||
}
|
||||
|
||||
void chat_onRequestTimeout (ToxWindow *self, ToxAv *av, int call_index)
|
||||
void chat_onRequestTimeout (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
|
||||
{
|
||||
if (!self || self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0))
|
||||
if (!self || self->num != friend_number)
|
||||
return;
|
||||
|
||||
self->call_idx = -1;
|
||||
//self->num = -1;
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "No answer!");
|
||||
|
||||
#ifdef SOUND_NOTIFY
|
||||
@ -694,13 +692,13 @@ void chat_onRequestTimeout (ToxWindow *self, ToxAv *av, int call_index)
|
||||
#endif /* SOUND_NOTIFY */
|
||||
}
|
||||
|
||||
void chat_onPeerTimeout (ToxWindow *self, ToxAv *av, int call_index)
|
||||
void chat_onPeerTimeout (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
|
||||
{
|
||||
if (!self || self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0))
|
||||
if (!self || self->num != friend_number)
|
||||
return;
|
||||
|
||||
kill_infobox(self);
|
||||
self->call_idx = -1;
|
||||
//self->num = -1;
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Peer disconnected; call ended!");
|
||||
|
||||
#ifdef SOUND_NOTIFY
|
||||
@ -1130,7 +1128,7 @@ ToxWindow new_chat(Tox *m, uint32_t friendnum)
|
||||
ret.onRequestTimeout = &chat_onRequestTimeout;
|
||||
ret.onPeerTimeout = &chat_onPeerTimeout;
|
||||
|
||||
ret.call_idx = -1;
|
||||
ret.num = -1;
|
||||
ret.device_selection[0] = ret.device_selection[1] = -1;
|
||||
ret.ringing_sound = -1;
|
||||
#endif /* AUDIO */
|
||||
|
Reference in New Issue
Block a user