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);
}