Commit 1e40522b authored by Dafydd Harries's avatar Dafydd Harries

emit component-state-changed(connected) when we get connectivity check rather...

emit component-state-changed(connected) when we get connectivity check rather than when we get media

darcs-hash:20070215114702-c9803-0ed4836716ec3741535ac9e82b001045aa93e675.gz
parent 70acf53c
...@@ -537,6 +537,7 @@ static void ...@@ -537,6 +537,7 @@ static void
_handle_stun_binding_request ( _handle_stun_binding_request (
NiceAgent *agent, NiceAgent *agent,
Stream *stream, Stream *stream,
Component *component,
NiceCandidate *local, NiceCandidate *local,
NiceAddress from, NiceAddress from,
StunMessage *msg) StunMessage *msg)
...@@ -700,6 +701,18 @@ RESPOND: ...@@ -700,6 +701,18 @@ RESPOND:
stun_message_free (extra); 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; return;
ERROR: ERROR:
...@@ -745,6 +758,7 @@ static void ...@@ -745,6 +758,7 @@ static void
_handle_stun ( _handle_stun (
NiceAgent *agent, NiceAgent *agent,
Stream *stream, Stream *stream,
Component *component,
NiceCandidate *local, NiceCandidate *local,
NiceAddress from, NiceAddress from,
StunMessage *msg) StunMessage *msg)
...@@ -752,7 +766,8 @@ _handle_stun ( ...@@ -752,7 +766,8 @@ _handle_stun (
switch (msg->type) switch (msg->type)
{ {
case STUN_MESSAGE_BINDING_REQUEST: 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; break;
case STUN_MESSAGE_BINDING_RESPONSE: case STUN_MESSAGE_BINDING_RESPONSE:
/* XXX: check it matches a request we sent */ /* XXX: check it matches a request we sent */
...@@ -813,14 +828,6 @@ _nice_agent_recv ( ...@@ -813,14 +828,6 @@ _nice_agent_recv (
if ((buf[0] & 0xc0) == 0x80) if ((buf[0] & 0xc0) == 0x80)
{ {
/* looks like RTP */ /* 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; return len;
} }
else if ((buf[0] & 0xc0) == 0) else if ((buf[0] & 0xc0) == 0)
...@@ -833,7 +840,7 @@ _nice_agent_recv ( ...@@ -833,7 +840,7 @@ _nice_agent_recv (
if (msg != NULL) if (msg != NULL)
{ {
_handle_stun (agent, stream, candidate, from, msg); _handle_stun (agent, stream, component, candidate, from, msg);
stun_message_free (msg); stun_message_free (msg);
} }
} }
......
...@@ -4,23 +4,6 @@ ...@@ -4,23 +4,6 @@
#include "udp-fake.h" #include "udp-fake.h"
#include "agent.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 int
main (void) main (void)
{ {
...@@ -38,8 +21,6 @@ main (void) ...@@ -38,8 +21,6 @@ main (void)
nice_agent_add_local_address (agent, &addr); nice_agent_add_local_address (agent, &addr);
nice_agent_add_stream (agent, 1); nice_agent_add_stream (agent, 1);
g_assert (agent->local_candidates != NULL); g_assert (agent->local_candidates != NULL);
g_signal_connect (agent, "component-state-changed",
(GCallback) cb_component_state_changed, NULL);
/* recieve an RTP packet */ /* recieve an RTP packet */
...@@ -58,8 +39,6 @@ main (void) ...@@ -58,8 +39,6 @@ main (void)
g_assert (0 == strncmp (buf, "\x80lalala", 7)); g_assert (0 == strncmp (buf, "\x80lalala", 7));
} }
g_assert (cb_called);
/* clean up */ /* clean up */
g_object_unref (agent); g_object_unref (agent);
nice_udp_socket_factory_close (&factory); nice_udp_socket_factory_close (&factory);
......
...@@ -8,6 +8,24 @@ ...@@ -8,6 +8,24 @@
#include "udp-fake.h" #include "udp-fake.h"
#include "random-glib.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 static gboolean
fd_is_readable (guint fd) fd_is_readable (guint fd)
{ {
...@@ -109,6 +127,7 @@ send_connectivity_check ( ...@@ -109,6 +127,7 @@ send_connectivity_check (
g_free (username); g_free (username);
} }
int int
main (void) main (void)
{ {
...@@ -139,6 +158,9 @@ main (void) ...@@ -139,6 +158,9 @@ main (void)
nice_agent_add_remote_candidate (agent, 1, 1, NICE_CANDIDATE_TYPE_HOST, nice_agent_add_remote_candidate (agent, 1, 1, NICE_CANDIDATE_TYPE_HOST,
&remote_addr, "username", "password"); &remote_addr, "username", "password");
g_signal_connect (agent, "component-state-changed",
(GCallback) cb_component_state_changed, NULL);
/* test */ /* test */
{ {
...@@ -169,6 +191,10 @@ main (void) ...@@ -169,6 +191,10 @@ main (void)
len = nice_udp_fake_socket_pop_send (sock, &addr, 1024, buf); len = nice_udp_fake_socket_pop_send (sock, &addr, 1024, buf);
g_assert (len == 5); g_assert (len == 5);
g_assert (0 == strncmp (buf, "hello", len)); g_assert (0 == strncmp (buf, "hello", len));
/* Signal to say component is connected should have been emitted. */
g_assert (cb_called == TRUE);
} }
/* clean up */ /* clean up */
......
...@@ -146,6 +146,8 @@ main (void) ...@@ -146,6 +146,8 @@ main (void)
NiceAddress addr = {0,}; NiceAddress addr = {0,};
guint ret; guint ret;
g_type_init ();
addr.port = 1234; addr.port = 1234;
nice_udp_bsd_socket_factory_init (&factory); nice_udp_bsd_socket_factory_init (&factory);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment