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);
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;
}
} 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");
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;
}
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;