diff options
-rw-r--r-- | agent/agent.c | 27 | ||||
-rw-r--r-- | agent/test-recv.c | 21 | ||||
-rw-r--r-- | agent/test-send.c | 26 | ||||
-rw-r--r-- | nice/jingle-test-server.c | 2 |
4 files changed, 45 insertions, 31 deletions
diff --git a/agent/agent.c b/agent/agent.c index 61067cd..91a2115 100644 --- a/agent/agent.c +++ b/agent/agent.c @@ -537,6 +537,7 @@ static void _handle_stun_binding_request ( NiceAgent *agent, Stream *stream, + Component *component, NiceCandidate *local, NiceAddress from, StunMessage *msg) @@ -700,6 +701,18 @@ RESPOND: stun_message_free (extra); } + /* emit component-state-changed(connected) */ + /* XXX: probably better do this when we get the binding response */ + + { + if (component->state != NICE_COMPONENT_STATE_CONNECTED) + { + component->state = NICE_COMPONENT_STATE_CONNECTED; + g_signal_emit (agent, signals[SIGNAL_COMPONENT_STATE_CHANGED], 0, + stream->id, component->id, component->state); + } + } + return; ERROR: @@ -745,6 +758,7 @@ static void _handle_stun ( NiceAgent *agent, Stream *stream, + Component *component, NiceCandidate *local, NiceAddress from, StunMessage *msg) @@ -752,7 +766,8 @@ _handle_stun ( switch (msg->type) { case STUN_MESSAGE_BINDING_REQUEST: - _handle_stun_binding_request (agent, stream, local, from, msg); + _handle_stun_binding_request (agent, stream, component, local, from, + msg); break; case STUN_MESSAGE_BINDING_RESPONSE: /* XXX: check it matches a request we sent */ @@ -813,14 +828,6 @@ _nice_agent_recv ( if ((buf[0] & 0xc0) == 0x80) { /* looks like RTP */ - - if (component->state != NICE_COMPONENT_STATE_CONNECTED) - { - component->state = NICE_COMPONENT_STATE_CONNECTED; - g_signal_emit (agent, signals[SIGNAL_COMPONENT_STATE_CHANGED], 0, - stream->id, component->id, component->state); - } - return len; } else if ((buf[0] & 0xc0) == 0) @@ -833,7 +840,7 @@ _nice_agent_recv ( if (msg != NULL) { - _handle_stun (agent, stream, candidate, from, msg); + _handle_stun (agent, stream, component, candidate, from, msg); stun_message_free (msg); } } diff --git a/agent/test-recv.c b/agent/test-recv.c index a2e5bc7..fd06766 100644 --- a/agent/test-recv.c +++ b/agent/test-recv.c @@ -4,23 +4,6 @@ #include "udp-fake.h" #include "agent.h" -static gboolean cb_called = FALSE; - -static void -cb_component_state_changed ( - NiceAgent *agent, - guint stream_id, - guint component_id, - guint state) -{ - g_assert (agent != NULL); - g_assert (stream_id == 1); - g_assert (component_id == 1); - g_assert (state == NICE_COMPONENT_STATE_CONNECTED); - g_assert (cb_called == FALSE); - cb_called = TRUE; -} - int main (void) { @@ -38,8 +21,6 @@ main (void) nice_agent_add_local_address (agent, &addr); nice_agent_add_stream (agent, 1); g_assert (agent->local_candidates != NULL); - g_signal_connect (agent, "component-state-changed", - (GCallback) cb_component_state_changed, NULL); /* recieve an RTP packet */ @@ -58,8 +39,6 @@ main (void) g_assert (0 == strncmp (buf, "\x80lalala", 7)); } - g_assert (cb_called); - /* clean up */ g_object_unref (agent); nice_udp_socket_factory_close (&factory); diff --git a/agent/test-send.c b/agent/test-send.c index 2038fd7..289c790 100644 --- a/agent/test-send.c +++ b/agent/test-send.c @@ -8,6 +8,24 @@ #include "udp-fake.h" #include "random-glib.h" +static gboolean cb_called = FALSE; + +static void +cb_component_state_changed ( + NiceAgent *agent, + guint stream_id, + guint component_id, + guint state) +{ + g_assert (agent != NULL); + g_assert (stream_id == 1); + g_assert (component_id == 1); + g_assert (state == NICE_COMPONENT_STATE_CONNECTED); + g_assert (cb_called == FALSE); + cb_called = TRUE; +} + + static gboolean fd_is_readable (guint fd) { @@ -109,6 +127,7 @@ send_connectivity_check ( g_free (username); } + int main (void) { @@ -139,6 +158,9 @@ main (void) nice_agent_add_remote_candidate (agent, 1, 1, NICE_CANDIDATE_TYPE_HOST, &remote_addr, "username", "password"); + g_signal_connect (agent, "component-state-changed", + (GCallback) cb_component_state_changed, NULL); + /* test */ { @@ -169,6 +191,10 @@ main (void) len = nice_udp_fake_socket_pop_send (sock, &addr, 1024, buf); g_assert (len == 5); g_assert (0 == strncmp (buf, "hello", len)); + + /* Signal to say component is connected should have been emitted. */ + + g_assert (cb_called == TRUE); } /* clean up */ diff --git a/nice/jingle-test-server.c b/nice/jingle-test-server.c index 1e258ed..dd05f2f 100644 --- a/nice/jingle-test-server.c +++ b/nice/jingle-test-server.c @@ -146,6 +146,8 @@ main (void) NiceAddress addr = {0,}; guint ret; + g_type_init (); + addr.port = 1234; nice_udp_bsd_socket_factory_init (&factory); |