1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-06-27 13:06:45 +02:00

Merge new AV branch

This commit is contained in:
Jfreegman
2015-10-20 17:57:54 -04:00
29 changed files with 2261 additions and 349 deletions

View File

@ -623,32 +623,31 @@ static void chat_onGroupInvite(ToxWindow *self, Tox *m, int32_t friendnumber, ui
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Type \"/join\" to join the chat.");
}
/* Av Stuff */
/* 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 */
/* call is flagged active here */
self->is_call = true;
self->call_idx = call_index;
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.");
@ -659,40 +658,44 @@ 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);
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call started! Type: \"/hangup\" to end it.");
/* call is flagged active here */
self->is_call = true;
#ifdef SOUND_NOTIFY
stop_sound(self->ringing_sound);
#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;
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call ended!");
self->is_call = false;
#ifdef SOUND_NOTIFY
stop_sound(self->ringing_sound);
#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->is_call = false;
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Error!");
#ifdef SOUND_NOTIFY
@ -700,11 +703,14 @@ 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;
/* call is flagged active here */
self->is_call = true;
init_infobox(self);
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call started! Type: \"/hangup\" to end it.");
@ -714,13 +720,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;
self->is_call = false;
kill_infobox(self);
self->call_idx = -1;
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call canceled!");
#ifdef SOUND_NOTIFY
@ -728,39 +734,39 @@ 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;
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Rejected!");
self->is_call = false;
#ifdef SOUND_NOTIFY
stop_sound(self->ringing_sound);
#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;
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call ended!");
self->is_call = false;
#ifdef SOUND_NOTIFY
stop_sound(self->ringing_sound);
#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->is_call = false;
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "No answer!");
#ifdef SOUND_NOTIFY
@ -768,13 +774,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;
self->is_call = false;
kill_infobox(self);
self->call_idx = -1;
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Peer disconnected; call ended!");
#ifdef SOUND_NOTIFY
@ -1209,7 +1215,7 @@ ToxWindow new_chat(Tox *m, uint32_t friendnum)
ret.onRequestTimeout = &chat_onRequestTimeout;
ret.onPeerTimeout = &chat_onPeerTimeout;
ret.call_idx = -1;
ret.is_call = false;
ret.device_selection[0] = ret.device_selection[1] = -1;
ret.ringing_sound = -1;
#endif /* AUDIO */