summaryrefslogtreecommitdiff
path: root/pjnath
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2009-10-14 13:13:18 +0000
committerBenny Prijono <bennylp@teluu.com>2009-10-14 13:13:18 +0000
commit4533e1452749d9c4060d63971eabc7a6baeb9e1e (patch)
treeb12b132dd8af76ba68df84a2ba3d45b60824578a /pjnath
parent6bdbb51b9b880efd0f2f9d833189bdfc8e469934 (diff)
Ticket #881: send UPDATE or re-INVITE after ICE negotiation, if the default candidate has changed
- done - added pj_ice_strans_state (to be used for informational purposes for now) - added pjmedia ICE transport specific info, and display it in call dump output - misc fixes (changed pjmedia_transport_info.spec_info_cnt from int to unsigned) git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2945 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjnath')
-rw-r--r--pjnath/include/pjnath/ice_strans.h65
-rw-r--r--pjnath/src/pjnath/ice_strans.c36
2 files changed, 101 insertions, 0 deletions
diff --git a/pjnath/include/pjnath/ice_strans.h b/pjnath/include/pjnath/ice_strans.h
index 28487870..c021dde7 100644
--- a/pjnath/include/pjnath/ice_strans.h
+++ b/pjnath/include/pjnath/ice_strans.h
@@ -327,6 +327,51 @@ typedef struct pj_ice_strans_cfg
} pj_ice_strans_cfg;
+/**
+ * ICE stream transport's state.
+ */
+typedef enum pj_ice_strans_state
+{
+ /**
+ * ICE stream transport is not created.
+ */
+ PJ_ICE_STRANS_STATE_NULL,
+
+ /**
+ * ICE candidate gathering process is in progress.
+ */
+ PJ_ICE_STRANS_STATE_INIT,
+
+ /**
+ * ICE stream transport initialization/candidate gathering process is
+ * complete, ICE session may be created on this stream transport.
+ */
+ PJ_ICE_STRANS_STATE_READY,
+
+ /**
+ * New session has been created and the session is ready.
+ */
+ PJ_ICE_STRANS_STATE_SESS_READY,
+
+ /**
+ * ICE negotiation is in progress.
+ */
+ PJ_ICE_STRANS_STATE_NEGO,
+
+ /**
+ * ICE negotiation has completed successfully and media is ready
+ * to be used.
+ */
+ PJ_ICE_STRANS_STATE_RUNNING,
+
+ /**
+ * ICE negotiation has completed with failure.
+ */
+ PJ_ICE_STRANS_STATE_FAILED
+
+} pj_ice_strans_state;
+
+
/**
* Initialize ICE transport configuration with default values.
*
@@ -371,6 +416,26 @@ PJ_DECL(pj_status_t) pj_ice_strans_create(const char *name,
pj_ice_strans **p_ice_st);
/**
+ * Get ICE session state.
+ *
+ * @param ice_st The ICE stream transport.
+ *
+ * @return ICE session state.
+ */
+PJ_DECL(pj_ice_strans_state) pj_ice_strans_get_state(pj_ice_strans *ice_st);
+
+
+/**
+ * Get string representation of ICE state.
+ *
+ * @param state ICE stream transport state.
+ *
+ * @return String.
+ */
+PJ_DECL(const char*) pj_ice_strans_state_name(pj_ice_strans_state state);
+
+
+/**
* Destroy the ICE stream transport. This will destroy the ICE session
* inside the ICE stream transport, close all sockets and release all
* other resources.
diff --git a/pjnath/src/pjnath/ice_strans.c b/pjnath/src/pjnath/ice_strans.c
index 92f550d0..cf79ad9d 100644
--- a/pjnath/src/pjnath/ice_strans.c
+++ b/pjnath/src/pjnath/ice_strans.c
@@ -173,6 +173,7 @@ struct pj_ice_strans
pj_ice_strans_cb cb; /**< Application callback. */
pj_lock_t *init_lock; /**< Initialization mutex. */
+ pj_ice_strans_state state; /**< Session state. */
pj_ice_sess *ice; /**< ICE session. */
pj_time_val start_time;/**< Time when ICE was started */
@@ -488,6 +489,9 @@ PJ_DEF(pj_status_t) pj_ice_strans_create( const char *name,
ice_st->comp = (pj_ice_strans_comp**)
pj_pool_calloc(pool, comp_cnt, sizeof(pj_ice_strans_comp*));
+ /* Move state to candidate gathering */
+ ice_st->state = PJ_ICE_STRANS_STATE_INIT;
+
/* Acquire initialization mutex to prevent callback to be
* called before we finish initialization.
*/
@@ -561,6 +565,29 @@ static void destroy_ice_st(pj_ice_strans *ice_st)
pj_pool_release(ice_st->pool);
}
+/* Get ICE session state. */
+PJ_DEF(pj_ice_strans_state) pj_ice_strans_get_state(pj_ice_strans *ice_st)
+{
+ return ice_st->state;
+}
+
+/* State string */
+PJ_DEF(const char*) pj_ice_strans_state_name(pj_ice_strans_state state)
+{
+ const char *names[] = {
+ "Null",
+ "Candidate Gathering",
+ "Candidate Gathering Complete",
+ "Session Initialized",
+ "Negotiation In Progress",
+ "Negotiation Success",
+ "Negotiation Failed"
+ };
+
+ PJ_ASSERT_RETURN(state <= PJ_ICE_STRANS_STATE_FAILED, "???");
+ return names[state];
+}
+
/* Notification about failure */
static void sess_fail(pj_ice_strans *ice_st, pj_ice_strans_op op,
const char *title, pj_status_t status)
@@ -603,6 +630,7 @@ static void sess_init_update(pj_ice_strans *ice_st)
/* All candidates have been gathered */
ice_st->cb_called = PJ_TRUE;
+ ice_st->state = PJ_ICE_STRANS_STATE_READY;
if (ice_st->cb.on_ice_complete)
(*ice_st->cb.on_ice_complete)(ice_st, PJ_ICE_STRANS_OP_INIT,
PJ_SUCCESS);
@@ -782,6 +810,9 @@ PJ_DEF(pj_status_t) pj_ice_strans_init_ice(pj_ice_strans *ice_st,
}
}
+ /* ICE session is ready for negotiation */
+ ice_st->state = PJ_ICE_STRANS_STATE_SESS_READY;
+
return PJ_SUCCESS;
on_error:
@@ -982,6 +1013,7 @@ PJ_DEF(pj_status_t) pj_ice_strans_start_ice( pj_ice_strans *ice_st,
return status;
}
+ ice_st->state = PJ_ICE_STRANS_STATE_NEGO;
return status;
}
@@ -1011,6 +1043,7 @@ PJ_DEF(pj_status_t) pj_ice_strans_stop_ice(pj_ice_strans *ice_st)
ice_st->ice = NULL;
}
+ ice_st->state = PJ_ICE_STRANS_STATE_INIT;
return PJ_SUCCESS;
}
@@ -1169,6 +1202,9 @@ static void on_ice_complete(pj_ice_sess *ice, pj_status_t status)
}
}
+ ice_st->state = (status==PJ_SUCCESS) ? PJ_ICE_STRANS_STATE_RUNNING :
+ PJ_ICE_STRANS_STATE_FAILED;
+
(*ice_st->cb.on_ice_complete)(ice_st, PJ_ICE_STRANS_OP_NEGOTIATION,
status);