| agent.h | | agent.h | |
| | | | |
| skipping to change at line 58 | | skipping to change at line 58 | |
| * @stability: Stable | | * @stability: Stable | |
| * | | * | |
| * The #NiceAgent is your main object when using libnice. | | * The #NiceAgent is your main object when using libnice. | |
| * It is the agent that will take care of everything relating to ICE. | | * It is the agent that will take care of everything relating to ICE. | |
| * It will take care of discovering your local candidates and do | | * It will take care of discovering your local candidates and do | |
| * connectivity checks to create a stream of data between you and your pee
r. | | * connectivity checks to create a stream of data between you and your pee
r. | |
| * | | * | |
| <example> | | <example> | |
| <title>Simple example on how to use libnice</title> | | <title>Simple example on how to use libnice</title> | |
| <programlisting> | | <programlisting> | |
|
| NiceAddress base_addr; | | | |
| guint stream_id; | | guint stream_id; | |
| gchar buffer[] = "hello world!"; | | gchar buffer[] = "hello world!"; | |
| GSList *lcands = NULL; | | GSList *lcands = NULL; | |
| | | | |
| // Create a nice agent | | // Create a nice agent | |
| NiceAgent *agent = nice_agent_new (NULL, NICE_COMPATIBILITY_DRAFT19); | | NiceAgent *agent = nice_agent_new (NULL, NICE_COMPATIBILITY_DRAFT19); | |
| | | | |
| // Connect the signals | | // Connect the signals | |
| g_signal_connect (G_OBJECT (agent), "candidate-gathering-done", | | g_signal_connect (G_OBJECT (agent), "candidate-gathering-done", | |
| G_CALLBACK (cb_candidate_gathering_done), NULL); | | G_CALLBACK (cb_candidate_gathering_done), NULL); | |
|
| g_signal_connect (G_OBJECT (lagent), "component-state-changed", | | g_signal_connect (G_OBJECT (agent), "component-state-changed", | |
| G_CALLBACK (cb_component_state_changed), NULL); | | G_CALLBACK (cb_component_state_changed), NULL); | |
|
| g_signal_connect (G_OBJECT (lagent), "new-selected-pair", | | g_signal_connect (G_OBJECT (agent), "new-selected-pair", | |
| G_CALLBACK (cb_new_selected_pair), NULL); | | G_CALLBACK (cb_new_selected_pair), NULL); | |
| | | | |
| // Create a new stream with one component and start gathering candidates | | // Create a new stream with one component and start gathering candidates | |
| stream_id = nice_agent_add_stream (agent, 1); | | stream_id = nice_agent_add_stream (agent, 1); | |
| nice_agent_gather_candidates (agent, stream_id); | | nice_agent_gather_candidates (agent, stream_id); | |
| | | | |
| // Attach to the component to receive the data | | // Attach to the component to receive the data | |
| nice_agent_attach_recv (agent, stream_id, 1, NULL, | | nice_agent_attach_recv (agent, stream_id, 1, NULL, | |
| cb_nice_recv, NULL); | | cb_nice_recv, NULL); | |
| | | | |
| // ... Wait until the signal candidate-gathering-done is fired ... | | // ... Wait until the signal candidate-gathering-done is fired ... | |
| lcands = nice_agent_get_local_candidates(agent, stream_id, 1); | | lcands = nice_agent_get_local_candidates(agent, stream_id, 1); | |
| | | | |
| // ... Send local candidates to the peer and set the peer's remote candi
dates | | // ... Send local candidates to the peer and set the peer's remote candi
dates | |
| nice_agent_set_remote_candidates (agent, stream_id, 1, rcands); | | nice_agent_set_remote_candidates (agent, stream_id, 1, rcands); | |
| | | | |
| // ... Wait until the signal new-selected-pair is fired ... | | // ... Wait until the signal new-selected-pair is fired ... | |
| // Send our message! | | // Send our message! | |
|
| nice_agent_send (lagent, ls_id, 1, sizeof(buffer), buffer); | | nice_agent_send (agent, stream_id, 1, sizeof(buffer), buffer); | |
| | | | |
| // Anything received will be received through the cb_nice_recv callback | | // Anything received will be received through the cb_nice_recv callback | |
| | | | |
| // Destroy the object | | // Destroy the object | |
| g_object_unref(agent); | | g_object_unref(agent); | |
| | | | |
| </programlisting> | | </programlisting> | |
| </example> | | </example> | |
| */ | | */ | |
| | | | |
| | | | |
| skipping to change at line 609 | | skipping to change at line 608 | |
| * | | * | |
| * Returns: %TRUE on success, %FALSE on failure | | * Returns: %TRUE on success, %FALSE on failure | |
| */ | | */ | |
| gboolean | | gboolean | |
| nice_agent_set_selected_remote_candidate ( | | nice_agent_set_selected_remote_candidate ( | |
| NiceAgent *agent, | | NiceAgent *agent, | |
| guint stream_id, | | guint stream_id, | |
| guint component_id, | | guint component_id, | |
| NiceCandidate *candidate); | | NiceCandidate *candidate); | |
| | | | |
|
| | | /** | |
| | | * nice_agent_set_stream_tos: | |
| | | * @agent: The #NiceAgent Object | |
| | | * @stream_id: The ID of the stream | |
| | | * @tos: The ToS to set | |
| | | * | |
| | | * Sets the IP_TOS and/or IPV6_TCLASS field on the stream's sockets' option | |
| | | s | |
| | | * | |
| | | */ | |
| | | void nice_agent_set_stream_tos ( | |
| | | NiceAgent *agent, | |
| | | guint stream_id, | |
| | | gint tos); | |
| | | | |
| G_END_DECLS | | G_END_DECLS | |
| | | | |
| #endif /* _AGENT_H */ | | #endif /* _AGENT_H */ | |
| | | | |
End of changes. 5 change blocks. |
| 4 lines changed or deleted | | 18 lines changed or added | |
|