I've been working on the following test program... My goal for now was
just to see the callbacks fire as I gathered local candidates...<br><br>Unfortunately,
I must be doing something wrong because my stund server never gets hit
and the only candidate type I detect is HOST... <br>
<br>I'm
pretty sure there is something wrong with my code (as opposed to my stun
server) because I can run a stun command line client against my server
and the server gets hit (i know because it prints a bunch of stuff)...
Any ideas?<br> <br> td<br><br>#include <stdio.h><br><br>extern "C"<br>{<br>#include <glib.h><br>#include <nice/nice.h><br>}<br><br>GMainContext* mainContext = NULL;<br>GMainLoop* mainLoop = NULL;<br>
NiceAgent* niceAgent = NULL;<br>NiceAddress baseAddress;<br>guint streamId = 0;<br>GSList* localCandidates = NULL;<br><br>[... cut a bunch of callback functions that just basically printed that they were called ...]<br><br>
int main( int argc, char* argv[] )<br>{<br> g_type_init();<br> g_thread_init( NULL );<br><br><br> // Create a glib application context and mainloop bject...<br> //<br> <br> mainContext = g_main_context_new();<br>
<br> mainLoop = g_main_loop_new( mainContext, FALSE );<br> <br><br> // Create our main nice agent...<br> //<br> <br> niceAgent = nice_agent_new( mainContext, NICE_COMPATIBILITY_RFC5245 );<br><br> <br>
// Specify which local interface to use...<br> //<br> <br> nice_address_set_from_string( &baseAddress, "127.0.0.1" );<br> nice_agent_add_local_address( niceAgent, &baseAddress );<br><br> <br>
// Connect callback functions...<br> //<br> <br> g_signal_connect( G_OBJECT( niceAgent ),<br> "candidate-gathering-done",<br> G_CALLBACK( cb_candidate_gathering_done ),<br>
GUINT_TO_POINTER(1) );<br><br> g_signal_connect( G_OBJECT( niceAgent ),<br> "component-state-changed",<br> G_CALLBACK( cb_component_state_changed ),<br>
GUINT_TO_POINTER(1) );<br><br> g_signal_connect( G_OBJECT( niceAgent ),<br> "initial-binding-request-received",<br> G_CALLBACK( cb_initial_binding_request_received ),<br>
GUINT_TO_POINTER(1) );<br><br> g_signal_connect( G_OBJECT( niceAgent ),<br> "new-candidate",<br> G_CALLBACK( cb_new_candidate ),<br> GUINT_TO_POINTER(1) );<br>
<br> g_signal_connect( G_OBJECT( niceAgent ),<br> "new-remote-candidate",<br> G_CALLBACK( cb_new_remote_candidate ),<br> GUINT_TO_POINTER(1) );<br>
<br> g_signal_connect( G_OBJECT( niceAgent ),<br> "new-selected-pair",<br> G_CALLBACK( cb_new_selected_pair ),<br> GUINT_TO_POINTER(1) );<br><br>
g_signal_connect( G_OBJECT( niceAgent ),<br> "reliable-transport-writable",<br> G_CALLBACK( cb_reliable_transport_writable ),<br> GUINT_TO_POINTER(1) );<br>
<br><br> // Configure Stun server information...<br> //<br><br> g_object_set( G_OBJECT( niceAgent ), "stun-server", "<a href="http://test.com">test.com</a>", NULL );<br> g_object_set( G_OBJECT( niceAgent ), "stun-server-port", 3478, NULL );<br>
<br> <br> // Create a "stream" and attach it to our agent...<br> //<br><br> streamId = nice_agent_add_stream( niceAgent, 1 );<br><br> g_object_set_data( G_OBJECT( niceAgent ), "id", GUINT_TO_POINTER(streamId) );<br>
<br><br> // Begin the local candidate gathering process...<br> //<br> <br> nice_agent_gather_candidates( niceAgent, streamId );<br><br><br> // attach recv callback handler...<br> //<br> <br> nice_agent_attach_recv( niceAgent,<br>
streamId,<br> 1,<br> mainContext,<br> cb_nice_recv,<br> GUINT_TO_POINTER(1) );<br><br>
<br><br> // Finally, start the glib MainLoop so we can start receiving events...<br> //<br> <br> g_main_loop_run( mainLoop );<br><br> while( g_main_loop_is_running( mainLoop ) );<br> <br> g_object_unref( niceAgent );<br>
<br> return 0;<br>}<br><br>