diff options
-rw-r--r-- | agent/agent.c | 12 | ||||
-rw-r--r-- | agent/agent.h | 2 |
2 files changed, 8 insertions, 6 deletions
diff --git a/agent/agent.c b/agent/agent.c index 2711470..7c291cb 100644 --- a/agent/agent.c +++ b/agent/agent.c @@ -7,7 +7,6 @@ #include "stun.h" #include "udp.h" -#include "random.h" #include "agent.h" #include "agent-signals-marshal.h" @@ -293,6 +292,7 @@ nice_agent_init (NiceAgent *agent) { agent->next_candidate_id = 1; agent->next_stream_id = 1; + agent->rng = nice_rng_new (); } @@ -368,7 +368,6 @@ nice_agent_add_local_host_candidate ( guint component_id, NiceAddress *address) { - NiceRNG *rng; NiceCandidate *candidate; Component *component; @@ -385,10 +384,8 @@ nice_agent_add_local_host_candidate ( candidate); /* generate username/password */ - rng = nice_rng_new (); - nice_rng_generate_bytes_print (rng, 8, candidate->username); - nice_rng_generate_bytes_print (rng, 8, candidate->password); - nice_rng_free (rng); + nice_rng_generate_bytes_print (agent->rng, 8, candidate->username); + nice_rng_generate_bytes_print (agent->rng, 8, candidate->password); /* allocate socket */ /* XXX: handle error */ @@ -1213,6 +1210,9 @@ nice_agent_dispose (GObject *object) g_free (agent->stun_server); agent->stun_server = NULL; + nice_rng_free (agent->rng); + agent->rng = NULL; + if (G_OBJECT_CLASS (nice_agent_parent_class)->dispose) G_OBJECT_CLASS (nice_agent_parent_class)->dispose (object); } diff --git a/agent/agent.h b/agent/agent.h index e66f677..42c7986 100644 --- a/agent/agent.h +++ b/agent/agent.h @@ -7,6 +7,7 @@ #include "udp.h" #include "address.h" #include "candidate.h" +#include "random.h" G_BEGIN_DECLS @@ -58,6 +59,7 @@ struct _NiceAgent NiceAgentRecvFunc read_func; gpointer read_func_data; gchar *stun_server; + NiceRNG *rng; }; typedef struct _NiceAgentClass NiceAgentClass; |