From: Sangchul Lee Date: Thu, 11 Nov 2021 06:57:58 +0000 (+0900) Subject: webrtc_test: Add sub-menu to use mic only in room case X-Git-Tag: submit/tizen/20211117.074556~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F90%2F266390%2F3;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc_test: Add sub-menu to use mic only in room case Parameter of _webrtc_add_media_source() is revised. [Version] 0.3.8 [Issue Type] Add Change-Id: I8312d9f19701b2859bc736745fc54d1c79b8ab57 Signed-off-by: Sangchul Lee --- diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index 09828ba5..fdacaa48 100644 --- a/packaging/capi-media-webrtc.spec +++ b/packaging/capi-media-webrtc.spec @@ -1,6 +1,6 @@ Name: capi-media-webrtc Summary: A WebRTC library in Tizen Native API -Version: 0.3.7 +Version: 0.3.8 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/test/webrtc_test.c b/test/webrtc_test.c index 76e253ad..b971fb92 100644 --- a/test/webrtc_test.c +++ b/test/webrtc_test.c @@ -751,61 +751,48 @@ static int __get_sound_stream_info(sound_stream_info_h *stream_info) return 0; } -static void _webrtc_add_media_source(int index, int value, unsigned int *source_id) +static void _webrtc_add_media_source(int index, int type, unsigned int *source_id) { int ret = WEBRTC_ERROR_NONE; unsigned int _source_id = 0; int i; - if (value - 1 <= WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET) { - webrtc_media_source_type_e type = value - 1; - switch (type) { - case WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST ... WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET: - if (type == WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET) { - i = _get_empty_packet_sources_index(index); - RET_IF(i == -1, "media packet source can be added up to %d", MAX_MEDIA_PACKET_SOURCE_LEN); - } - ret = webrtc_add_media_source(g_conns[index].webrtc, type, &_source_id); - RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret); - - if (type == WEBRTC_MEDIA_SOURCE_TYPE_MIC) { - if (g_conns[index].source.stream_info) { - sound_manager_destroy_stream_information(g_conns[index].source.stream_info); - g_conns[index].source.stream_info = NULL; - } + switch (type) { + case WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST ... WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET: + if (type == WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET) { + i = _get_empty_packet_sources_index(index); + RET_IF(i == -1, "media packet source can be added up to %d", MAX_MEDIA_PACKET_SOURCE_LEN); + } + ret = webrtc_add_media_source(g_conns[index].webrtc, type, &_source_id); + RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret); - if (__get_sound_stream_info(&g_conns[index].source.stream_info) < 0) { - g_printerr("failed to __get_sound_stream_info()\n"); + if (type == WEBRTC_MEDIA_SOURCE_TYPE_MIC) { + if (g_conns[index].source.stream_info) { + sound_manager_destroy_stream_information(g_conns[index].source.stream_info); + g_conns[index].source.stream_info = NULL; + } - } else { - ret = webrtc_mic_source_set_sound_stream_info(g_conns[index].webrtc, _source_id, g_conns[index].source.stream_info); - if (ret != WEBRTC_ERROR_NONE) - g_printerr("failed to webrtc_mic_source_set_sound_stream_info(), ret[0x%x]\n", ret); - } + if (__get_sound_stream_info(&g_conns[index].source.stream_info) < 0) { + g_printerr("failed to __get_sound_stream_info()\n"); + } else { + ret = webrtc_mic_source_set_sound_stream_info(g_conns[index].webrtc, _source_id, g_conns[index].source.stream_info); + if (ret != WEBRTC_ERROR_NONE) + g_printerr("failed to webrtc_mic_source_set_sound_stream_info(), ret[0x%x]\n", ret); } - break; - default: - g_printerr("failed to _webrtc_add_media_source(), invalid type(%d)\n", type); - return; - } - if (type == WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET) { + + } else if (type == WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET) { g_conns[index].packet_sources[i].source_id = _source_id; g_mutex_init(&g_conns[index].packet_sources[i].mutex); g_cond_init(&g_conns[index].packet_sources[i].cond); } - - } else { - webrtc_media_source_type_internal_e type = value - 1; - switch (type) { - case WEBRTC_MEDIA_SOURCE_TYPE_CUSTOM_AUDIO: - case WEBRTC_MEDIA_SOURCE_TYPE_CUSTOM_VIDEO: - ret = webrtc_add_media_source_internal(g_conns[index].webrtc, type, &_source_id); - RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret); - break; - default: - g_printerr("failed to _webrtc_add_media_source(), invalid type(%d)\n", type); - return; - } + break; + case WEBRTC_MEDIA_SOURCE_TYPE_CUSTOM_AUDIO ... WEBRTC_MEDIA_SOURCE_TYPE_CUSTOM_VIDEO: + ret = webrtc_add_media_source_internal(g_conns[index].webrtc, type, &_source_id); + RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret); + break; + default: + g_printerr("failed to _webrtc_add_media_source(), invalid type(%d)\n", type); + return; } g_print("_webrtc_add_media_source() success, source_id[%u]\n", _source_id); @@ -3403,17 +3390,20 @@ static void __auto_configure_add_peer(gchar *peer_id, bool is_offer) switch (g_conns[i].room_source_type) { case 1: - _webrtc_add_media_source(i, WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST + 1, NULL); - _webrtc_add_media_source(i, WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST + 1, &source_id); + _webrtc_add_media_source(i, WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST, NULL); + _webrtc_add_media_source(i, WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST, &source_id); if (i == 0) /* only set loopback video of the first one */ _webrtc_media_source_set_video_loopback(i, source_id); break; case 2: - _webrtc_add_media_source(i, WEBRTC_MEDIA_SOURCE_TYPE_MIC + 1, NULL); - _webrtc_add_media_source(i, WEBRTC_MEDIA_SOURCE_TYPE_CAMERA + 1, &source_id); + _webrtc_add_media_source(i, WEBRTC_MEDIA_SOURCE_TYPE_MIC, NULL); + _webrtc_add_media_source(i, WEBRTC_MEDIA_SOURCE_TYPE_CAMERA, &source_id); if (i == 0) /* only set loopback video of the first one */ _webrtc_media_source_set_video_loopback(i, source_id); break; + case 3: + _webrtc_add_media_source(i, WEBRTC_MEDIA_SOURCE_TYPE_MIC, NULL); + break; default: return; } @@ -4382,7 +4372,7 @@ static void displaymenu() } else if (g_menu_state == CURRENT_STATUS_REQUEST_JOIN_ROOM) { if (g_cnt == 0) - g_print("*** input source type.(1:videotest/audiotest 2:camera/mic)\n"); + g_print("*** input source type.(1:audiotest/videotest 2:mic/camera 3:mic only)\n"); else if (g_cnt == 1) g_print("*** input room name to join.\n"); @@ -4445,7 +4435,7 @@ static void interpret(char *cmd) break; case CURRENT_STATUS_ADD_MEDIA_SOURCE: { value = atoi(cmd); - _webrtc_add_media_source(0, value, NULL); + _webrtc_add_media_source(0, value - 1, NULL); reset_menu_state(); break; } @@ -4733,7 +4723,7 @@ static void interpret(char *cmd) switch (g_cnt) { case 0: value = atoi(cmd); - if (value <= 0 || value > 2) { + if (value <= 0 || value > 3) { g_printerr("invalid value[%d]\n", value); reset_menu_state(); break;