static appdata_s g_ad;
+static void _webrtc_set_local_description(connection_s *conn, bool is_offer);
static void _stop_pushing_packet(int index, int source_id);
static void __file_dump(const gchar *file_name, void *src_buffer, int size);
g_ad.conns[index].encoded_audio_frame_cb_is_set = false;
g_ad.conns[index].encoded_video_frame_cb_is_set = false;
+ g_ad.conns[index].quick_start = false;
+ g_ad.conns[index].remote_conn = NULL;
+
#ifdef TIZEN_FEATURE_ESPP
_espp_deinit(index);
#endif
g_print("__offer_created_cb() is called, description[%s], user_data[%p]\n", description, user_data);
conn->offer = strdup(description);
+
+ if (conn->quick_start && conn->remote_conn) {
+ _webrtc_set_local_description(conn, true);
+ conn->remote_conn->remote_desc = strdup(description);
+ _webrtc_set_remote_description(conn->remote_conn);
+ }
}
static void __answer_created_cb(webrtc_h webrtc, const char *description, void *user_data)
g_print("__answer_created_cb() is called, description[%s], user_data[%p]\n", description, user_data);
conn->answer = strdup(description);
+
+ if (conn->quick_start && conn->remote_conn) {
+ _webrtc_set_local_description(conn, false);
+ conn->remote_conn->remote_desc = strdup(description);
+ _webrtc_set_remote_description(conn->remote_conn);
+ }
}
static void _webrtc_create_offer(connection_s *conn, bool async)
{
RET_IF(!conn, "conn is NULL");
- if (conn->is_for_room && candidate) {
+ if ((conn->is_for_room || conn->quick_start) && candidate) {
int ret = webrtc_add_ice_candidate(conn->webrtc, (const char *)candidate);
RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
if (conn->ice_candidates)
_webrtc_add_ice_candidate(conn, NULL);
}
+ } else if (conn->quick_start && current == WEBRTC_STATE_NEGOTIATING) {
+ if (conn->is_offer)
+ _webrtc_create_offer(conn, true);
}
}
g_print("__ice_candidate_cb() is invoked, conn[%p]\n", conn);
RET_IF(!conn, "conn is NULL");
+ if (conn->quick_start) {
+ _webrtc_add_ice_candidate(conn->remote_conn, candidate);
+ return;
+ }
+
g_print("\n[to SERVER > ICE]\n%s\n", candidate);
_send_ice_candidate(conn, candidate);
_webrtc_create_answer(conn, false);
_webrtc_set_local_description(conn, false);
_websocket_send_text_for_room(conn, conn->remote_peer_id, conn->answer);
+ } else if (conn->quick_start && state == WEBRTC_SIGNALING_STATE_HAVE_REMOTE_OFFER) {
+ _webrtc_create_answer(conn, true);
}
}
reset_menu_state();
}
+static void app_quick_start(char *cmd)
+{
+ switch (g_ad.menu_status) {
+ case CURRENT_STATUS_APP_QUICK_START_ONE_ON_ONE: {
+ unsigned int a_nullsrc_id;
+ unsigned int v_nullsrc_id;
+
+ /* sender */
+ g_ad.conns[0].quick_start = true;
+ g_ad.conns[0].is_offer = true;
+ g_ad.conns[0].remote_conn = &g_ad.conns[1];
+ _webrtc_create(0);
+ _webrtc_set_all_cbs(0);
+ _webrtc_add_media_source(0, WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST, NULL);
+ _webrtc_add_media_source(0, WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST, NULL);
+ _webrtc_start(0);
+
+ /* receiver */
+ g_ad.conns[1].quick_start = true;
+ g_ad.conns[1].remote_conn = &g_ad.conns[0];
+ _webrtc_create(1);
+ _webrtc_set_all_cbs(1);
+ _webrtc_add_media_source(1, WEBRTC_MEDIA_SOURCE_TYPE_NULL, &a_nullsrc_id);
+ _webrtc_add_media_source(1, WEBRTC_MEDIA_SOURCE_TYPE_NULL, &v_nullsrc_id);
+ _webrtc_media_source_set_transceiver_codec(1, a_nullsrc_id, WEBRTC_MEDIA_TYPE_AUDIO, 3); /* 3 for OPUS */
+ _webrtc_media_source_set_transceiver_codec(1, v_nullsrc_id, WEBRTC_MEDIA_TYPE_VIDEO, 4); /* 4 for VP8 */
+ _webrtc_start(1);
+
+ break;
+ }
+ }
+
+ reset_menu_state();
+}
+
static void interpret(char *cmd)
{
if (!cmd)
else if (g_ad.menu_status & TEST_MENU_APP_SIGNALING)
app_setting_and_signaling(cmd);
+ else if (g_ad.menu_status & TEST_MENU_APP_QUICK_START)
+ app_quick_start(cmd);
+
else if (g_ad.menu_status == CURRENT_STATUS_QUIT)
quit_program();
{ "sst", CURRENT_STATUS_PRIVATE_SIGNALING_SERVER_STOP, false },
{ "scc", CURRENT_STATUS_PRIVATE_SIGNALING_SERVER_CONNECT, true },
{ "scd", CURRENT_STATUS_PRIVATE_SIGNALING_SERVER_DISCONNECT, false },
+ /* quick start */
+ { "qs", CURRENT_STATUS_APP_QUICK_START_ONE_ON_ONE, false },
{ NULL, -1, false },
};
g_print("sst. *Stop signaling server\n");
g_print("scc. *Connect to signaling server\t");
g_print("scd. *Disconnect from signaling server\n");
+ g_print("---------------------------------- App. quick start -------------------------------------\n");
+ g_print("qs. Quick start - 2 peers (AV sender - AV receiver)\n");
g_print("-----------------------------------------------------------------------------------------\n");
g_print("=========================================================================================\n");
g_print(" >>> ");