g_print("webrtc_media_source_get_mute() success, source_id[%d], mute_status[%d]\n", source_id, mute_status);
}
-static void _webrtc_create_offer(connection_s *conn)
+static void __offer_created_cb(webrtc_h webrtc, const char *description, void *user_data)
+{
+ connection_s *conn = (connection_s *)user_data;
+ g_print("__offer_created_cb() is called, description[%s], user_data[%p]\n", description, user_data);
+
+ conn->offer = strdup(description);
+}
+
+static void __answer_created_cb(webrtc_h webrtc, const char *description, void *user_data)
+{
+ connection_s *conn = (connection_s *)user_data;
+ g_print("__answer_created_cb() is called, description[%s], user_data[%p]\n", description, user_data);
+
+ conn->answer = strdup(description);
+}
+
+static void _webrtc_create_offer(connection_s *conn, bool async)
{
int ret = WEBRTC_ERROR_NONE;
conn->offer = NULL;
}
- ret = webrtc_create_offer(conn->webrtc, NULL, &conn->offer);
- RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
+ if (!async) {
+ ret = webrtc_create_offer(conn->webrtc, NULL, &conn->offer);
+ RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
- g_print("webrtc_create_offer() success\noffer:\n%s\n", conn->offer);
+ g_print("webrtc_create_offer() success\noffer:\n%s\n", conn->offer);
+ } else {
+ ret = webrtc_create_offer_async(conn->webrtc, NULL, __offer_created_cb, conn);
+ RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
+
+ g_print("webrtc_create_offer_async() success\n");
+ }
}
-static void _webrtc_create_answer(connection_s *conn)
+static void _webrtc_create_answer(connection_s *conn, bool async)
{
int ret = WEBRTC_ERROR_NONE;
conn->answer = NULL;
}
- ret = webrtc_create_answer(conn->webrtc, NULL, &conn->answer);
- RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
+ if (!async) {
+ ret = webrtc_create_answer(conn->webrtc, NULL, &conn->answer);
+ RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
- g_print("webrtc_create_answer() success\nanswer:\n%s\n", conn->answer);
+ g_print("webrtc_create_answer() success\nanswer:\n%s\n", conn->answer);
+ } else {
+ ret = webrtc_create_answer_async(conn->webrtc, NULL, __answer_created_cb, conn);
+ RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
+
+ g_print("webrtc_create_answer_async() success\n");
+ }
}
static void _webrtc_set_local_description(connection_s *conn, bool is_offer)
if (conn->is_for_room && current == WEBRTC_STATE_NEGOTIATING) {
if (conn->is_offer) {
- _webrtc_create_offer(conn);
+ _webrtc_create_offer(conn, false);
_webrtc_set_local_description(conn, true);
_websocket_connection_send_text_for_room(conn, conn->remote_peer_id, conn->offer);
} else {
g_print("__signaling_state_change_cb() is invoked, state[%d]\n", state);
if (conn->is_for_room && state == WEBRTC_SIGNALING_STATE_HAVE_REMOTE_OFFER) {
- _webrtc_create_answer(conn);
+ _webrtc_create_answer(conn, false);
_webrtc_set_local_description(conn, false);
_websocket_connection_send_text_for_room(conn, conn->remote_peer_id, conn->answer);
}
g_conns[g_conn_index].menu_state = CURRENT_STATUS_MEDIA_PACKET_SOURCE_UNSET_BUFFER_STATE_CHANGED_CB;
} else if (strncmp(cmd, "co", 2) == 0) {
- _webrtc_create_offer(&g_conns[g_conn_index]);
+ _webrtc_create_offer(&g_conns[g_conn_index], false);
} else if (strncmp(cmd, "ca", 2) == 0) {
- _webrtc_create_answer(&g_conns[g_conn_index]);
+ _webrtc_create_answer(&g_conns[g_conn_index], false);
} else if (strncmp(cmd, "sl", 2) == 0) {
g_conns[g_conn_index].menu_state = CURRENT_STATUS_SET_LOCAL_DESCRIPTION;
} else if (strncmp(cmd, "gan", 3) == 0) {
_webrtc_get_all_negotiation_states(g_conn_index);
+ } else if (strncmp(cmd, "coa", 3) == 0) {
+ _webrtc_create_offer(&g_conns[g_conn_index], true);
+
+ } else if (strncmp(cmd, "caa", 3) == 0) {
+ _webrtc_create_answer(&g_conns[g_conn_index], true);
+
} else if (strncmp(cmd, "stp", 3) == 0) {
g_conns[g_conn_index].menu_state = CURRENT_STATUS_SET_ICE_TRANSPORT_POLICY;
g_print("gtp. Get ICE transport policy\n");
g_print("co. Create offer\t");
g_print("ca. Create answer\n");
+ g_print("coa. Create offer(async)\t");
+ g_print("caa. Create answer(async)\n");
g_print("sl. Set local description\t");
g_print("sr. Set remote description\n");
g_print("ac. Add ICE candidate\n");