1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2025-01-06 03:25:31 +00:00

sip: call: rework call state changes

This commit is contained in:
Evangelos Ribeiro Tzaras 2021-02-25 14:26:11 +01:00
parent 706a667547
commit 3133f25c6b
2 changed files with 27 additions and 36 deletions

View file

@ -68,30 +68,6 @@ enum {
static GParamSpec *props[PROP_LAST_PROP];
static void
change_state (CallsSipCall *self,
CallsCallState state)
{
CallsCallState old_state;
g_assert (CALLS_IS_CALL (self));
g_assert (CALLS_IS_SIP_CALL (self));
old_state = self->state;
if (old_state == state)
{
return;
}
self->state = state;
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_CALL_STATE]);
g_signal_emit_by_name (CALLS_CALL (self),
"state-changed",
state,
old_state);
}
static void
answer (CallsCall *call)
{
@ -125,7 +101,7 @@ answer (CallsCall *call)
SOATAG_AF (SOA_AF_IP4_IP6),
TAG_END ());
change_state (self, CALLS_CALL_STATE_ACTIVE);
calls_sip_call_set_state (self, CALLS_CALL_STATE_ACTIVE);
}
static void
@ -157,13 +133,13 @@ hang_up (CallsCall *call)
case CALLS_CALL_STATE_DISCONNECTED:
g_warning ("Tried hanging up already disconnected call");
return;
break;
default:
g_warning ("Hanging up not possible in state %d", self->state);
}
change_state (self, CALLS_CALL_STATE_DISCONNECTED);
calls_sip_call_set_state (self, CALLS_CALL_STATE_DISCONNECTED);
}
static void
@ -383,12 +359,25 @@ calls_sip_call_new (const gchar *number,
void
calls_sip_call_set_state (CallsSipCall *self,
CallsCallState state)
calls_sip_call_set_state (CallsSipCall *self,
CallsCallState state)
{
CallsCallState old_state;
g_return_if_fail (CALLS_IS_CALL (self));
g_return_if_fail (CALLS_IS_SIP_CALL (self));
g_print ("Changed call state to %d\n", state);
old_state = self->state;
if (old_state == state) {
return;
}
self->state = state;
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_CALL_STATE]);
g_signal_emit_by_name (CALLS_CALL (self),
"state-changed",
state,
old_state);
}

View file

@ -246,6 +246,7 @@ sip_i_state (int status,
case nua_callstate_received:
state = CALLS_CALL_STATE_INCOMING;
g_debug ("Call incoming");
break;
case nua_callstate_ready:
@ -260,7 +261,13 @@ sip_i_state (int status,
calls_sip_call_activate_media (call, FALSE);
state = CALLS_CALL_STATE_DISCONNECTED;
break;
g_hash_table_remove (origin->call_handles, nh);
calls_sip_call_set_state (call, state);
g_object_unref (G_OBJECT (call));
return;
case nua_callstate_authenticating:
g_warning ("TODO Move authentication (INVITE) here");
@ -579,12 +586,7 @@ remove_call (CallsSipOrigin *self,
if (self->oper->call_handle == nh)
self->oper->call_handle = NULL;
g_hash_table_remove (self->call_handles, nh);
nua_handle_unref (nh);
g_signal_emit_by_name (origin, "call-removed", call, reason);
g_object_unref (G_OBJECT (call));
}