From: Sangchul Lee Date: Wed, 16 Jun 2021 01:31:17 +0000 (+0900) Subject: Change ordering of webrtc_media_source_type_e enum X-Git-Tag: submit/tizen/20210729.023123~50 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=57510ddf95821c0821a3eb0969f54f9b84faf37f;p=platform%2Fcore%2Fapi%2Fwebrtc.git Change ordering of webrtc_media_source_type_e enum WEBRTC_MEDIA_SOURCE_TYPE_FILE is also added to support for media files. The implementation will be updated in the near future. typedef enum { WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST, /**< Audio test */ WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST, /**< Video test */ WEBRTC_MEDIA_SOURCE_TYPE_MIC, /**< Audio from microphone */ WEBRTC_MEDIA_SOURCE_TYPE_CAMERA, /**< Camera preview */ WEBRTC_MEDIA_SOURCE_TYPE_SCREEN, /**< Screen capture */ WEBRTC_MEDIA_SOURCE_TYPE_FILE, /**< Media file */ WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET /**< Media packet */ } webrtc_media_source_type_e; Unnecessary structure is also removed. [Version] 0.2.12 [Issue Type] API Change-Id: I2d939c0aee848a44b3ea68445d31bc1696b08217 Signed-off-by: Sangchul Lee --- diff --git a/include/webrtc.h b/include/webrtc.h index 44f2df4a..e9e2208c 100644 --- a/include/webrtc.h +++ b/include/webrtc.h @@ -134,12 +134,13 @@ typedef enum { * @since_tizen 6.5 */ typedef enum { - WEBRTC_MEDIA_SOURCE_TYPE_CAMERA, /**< Camera preview */ - WEBRTC_MEDIA_SOURCE_TYPE_MIC, /**< Audio from microphone */ WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST, /**< Audio test */ WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST, /**< Video test */ - WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET, /**< Media packet */ - WEBRTC_MEDIA_SOURCE_TYPE_SCREEN /**< Screen capture */ + WEBRTC_MEDIA_SOURCE_TYPE_MIC, /**< Audio from microphone */ + WEBRTC_MEDIA_SOURCE_TYPE_CAMERA, /**< Camera preview */ + WEBRTC_MEDIA_SOURCE_TYPE_SCREEN, /**< Screen capture */ + WEBRTC_MEDIA_SOURCE_TYPE_FILE, /**< Media file */ + WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET /**< Media packet */ } webrtc_media_source_type_e; /** diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index cec6135e..7992092d 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.2.11 +Version: 0.2.12 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_ini.c b/src/webrtc_ini.c index a070db42..358c9daa 100644 --- a/src/webrtc_ini.c +++ b/src/webrtc_ini.c @@ -33,6 +33,7 @@ #define INI_CATEGORY_SOURCE_VIDEOTEST "source videotest" #define INI_CATEGORY_SOURCE_MEDIA_PACKET "source media packet" #define INI_CATEGORY_SOURCE_SCREEN "source screen" +#define INI_CATEGORY_SOURCE_FILE "source file" #define INI_CATEGORY_RENDERING_SINK "rendering sink" #define INI_CATEGORY_VPXENC_PARAMS "vpxenc params" @@ -112,28 +113,15 @@ typedef enum { INI_ITEM_TYPE_STRINGS } ini_item_type_e; -typedef enum { - MEDIA_SOURCE_TYPE_CAMERA, - MEDIA_SOURCE_TYPE_MIC, - MEDIA_SOURCE_TYPE_AUDIOTEST, - MEDIA_SOURCE_TYPE_VIDEOTEST, - MEDIA_SOURCE_TYPE_MEDIA_PACKET, - MEDIA_SOURCE_TYPE_SCREEN, - MEDIA_SOURCE_TYPE_MAX, -} media_source_type_e; - -typedef struct { - const char *name; -} ini_category_name_s; - -static ini_category_name_s category_source_names[] = { - [MEDIA_SOURCE_TYPE_CAMERA] = { INI_CATEGORY_SOURCE_CAMERA }, - [MEDIA_SOURCE_TYPE_MIC] = { INI_CATEGORY_SOURCE_MIC }, - [MEDIA_SOURCE_TYPE_AUDIOTEST] = { INI_CATEGORY_SOURCE_AUDIOTEST }, - [MEDIA_SOURCE_TYPE_VIDEOTEST] = { INI_CATEGORY_SOURCE_VIDEOTEST }, - [MEDIA_SOURCE_TYPE_MEDIA_PACKET] = { INI_CATEGORY_SOURCE_MEDIA_PACKET }, - [MEDIA_SOURCE_TYPE_SCREEN] = { INI_CATEGORY_SOURCE_SCREEN }, - [MEDIA_SOURCE_TYPE_MAX] = { NULL }, +static const char* category_source_names[] = { + [WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST] = INI_CATEGORY_SOURCE_AUDIOTEST, + [WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST] = INI_CATEGORY_SOURCE_VIDEOTEST, + [WEBRTC_MEDIA_SOURCE_TYPE_MIC] = INI_CATEGORY_SOURCE_MIC, + [WEBRTC_MEDIA_SOURCE_TYPE_CAMERA] = INI_CATEGORY_SOURCE_CAMERA, + [WEBRTC_MEDIA_SOURCE_TYPE_SCREEN] = INI_CATEGORY_SOURCE_SCREEN, + [WEBRTC_MEDIA_SOURCE_TYPE_FILE] = INI_CATEGORY_SOURCE_FILE, + [WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET] = INI_CATEGORY_SOURCE_MEDIA_PACKET, + [WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET + 1] = NULL, }; static void __dump_item(const char *prefix_str, ini_item_type_e type, void *item) @@ -193,7 +181,6 @@ static bool __is_vpx(const char *v_codec) static void __dump_ini(webrtc_ini_s *ini) { int i = 0; - const char *category_name; RET_IF(ini == NULL, "ini is NULL"); @@ -210,10 +197,10 @@ static void __dump_ini(webrtc_ini_s *ini) LOG_INFO("[%s]", INI_CATEGORY_MEDIA_SOURCE); __dump_items_of_source(&ini->media_source); - for (; (category_name = category_source_names[i].name) != NULL; i++) { - ini_item_media_source_s *source = g_hash_table_lookup(ini->sources, category_name); + for (; category_source_names[i] != NULL; i++) { + ini_item_media_source_s *source = g_hash_table_lookup(ini->sources, category_source_names[i]); if (source) { - LOG_INFO("[%s]", category_name); + LOG_INFO("[%s]", category_source_names[i]); __dump_items_of_source(source); } } @@ -401,7 +388,6 @@ static void __apply_media_source_setting(webrtc_ini_s *ini, ini_item_media_sourc int _load_ini(webrtc_s *webrtc) { webrtc_ini_s *ini; - const char *category_name; int i = 0; RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL"); @@ -433,12 +419,12 @@ int _load_ini(webrtc_s *webrtc) __apply_media_source_setting(ini, &ini->media_source, INI_CATEGORY_MEDIA_SOURCE); /* it overrides the default values above */ - for (; (category_name = category_source_names[i].name) != NULL; i++) { - if (iniparser_getsecnkeys(ini->dict, category_name) > 0) { + for (; category_source_names[i] != NULL; i++) { + if (iniparser_getsecnkeys(ini->dict, category_source_names[i]) > 0) { ini_item_media_source_s *source = g_new0(ini_item_media_source_s, 1); - __apply_media_source_setting(ini, source, category_name); - if (!g_hash_table_insert(ini->sources, g_strdup(category_name), (gpointer)source)) { - LOG_WARNING("[%s] already exist", category_name); + __apply_media_source_setting(ini, source, category_source_names[i]); + if (!g_hash_table_insert(ini->sources, g_strdup(category_source_names[i]), (gpointer)source)) { + LOG_WARNING("[%s] already exist", category_source_names[i]); continue; } } @@ -463,7 +449,7 @@ ini_item_media_source_s* _ini_get_source_by_type(webrtc_ini_s *ini, webrtc_media { RET_VAL_IF(ini == NULL, NULL, "ini is NULL"); - return (ini_item_media_source_s*)g_hash_table_lookup(ini->sources, category_source_names[type].name); + return (ini_item_media_source_s*)g_hash_table_lookup(ini->sources, category_source_names[type]); } void _unload_ini(webrtc_s *webrtc) diff --git a/src/webrtc_source.c b/src/webrtc_source.c index 70203cb2..cbe3f6ce 100644 --- a/src/webrtc_source.c +++ b/src/webrtc_source.c @@ -252,8 +252,8 @@ static GstCaps *__make_video_raw_caps_with_resolution(webrtc_gst_slot_s *source, ini_source = &ini->media_source; switch (source->type) { - case WEBRTC_MEDIA_SOURCE_TYPE_CAMERA: case WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST: + case WEBRTC_MEDIA_SOURCE_TYPE_CAMERA: case WEBRTC_MEDIA_SOURCE_TYPE_SCREEN: caps = gst_caps_new_simple(MEDIA_TYPE_VIDEO_RAW, "format", G_TYPE_STRING, ini_source->v_raw_format, @@ -285,8 +285,8 @@ static GstCaps *__make_default_raw_caps(webrtc_gst_slot_s *source, webrtc_ini_s ini_source = &ini->media_source; switch (source->type) { - case WEBRTC_MEDIA_SOURCE_TYPE_CAMERA: case WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST: + case WEBRTC_MEDIA_SOURCE_TYPE_CAMERA: case WEBRTC_MEDIA_SOURCE_TYPE_SCREEN: caps = gst_caps_new_simple(MEDIA_TYPE_VIDEO_RAW, "format", G_TYPE_STRING, ini_source->v_raw_format, @@ -298,8 +298,8 @@ static GstCaps *__make_default_raw_caps(webrtc_gst_slot_s *source, webrtc_ini_s source->video_info.height = ini_source->v_height; break; - case WEBRTC_MEDIA_SOURCE_TYPE_MIC: case WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST: + case WEBRTC_MEDIA_SOURCE_TYPE_MIC: caps = gst_caps_new_simple(MEDIA_TYPE_AUDIO_RAW, "format", G_TYPE_STRING, ini_source->a_raw_format, "channels", G_TYPE_INT, ini_source->a_channels, @@ -416,8 +416,8 @@ static GstCaps *__make_default_encoded_caps(webrtc_gst_slot_s *source, webrtc_in ini_source = &ini->media_source; switch (source->type) { - case WEBRTC_MEDIA_SOURCE_TYPE_CAMERA: case WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST: + case WEBRTC_MEDIA_SOURCE_TYPE_CAMERA: case WEBRTC_MEDIA_SOURCE_TYPE_SCREEN: _media_type = __get_video_media_type(ini_source->v_codec); RET_VAL_IF(_media_type == NULL, NULL, "_media_type is NULL"); @@ -431,8 +431,8 @@ static GstCaps *__make_default_encoded_caps(webrtc_gst_slot_s *source, webrtc_in source->video_info.height = ini_source->v_height; break; - case WEBRTC_MEDIA_SOURCE_TYPE_MIC: case WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST: + case WEBRTC_MEDIA_SOURCE_TYPE_MIC: _media_type = __get_audio_media_type(ini_source->a_codec); RET_VAL_IF(_media_type == NULL, NULL, "_media_type is NULL"); @@ -778,18 +778,18 @@ static const char *__get_default_element(webrtc_media_source_type_e type) { const char *element = NULL; - if (type == WEBRTC_MEDIA_SOURCE_TYPE_CAMERA) - element = DEFAULT_ELEMENT_CAMERASRC; - else if (type == WEBRTC_MEDIA_SOURCE_TYPE_MIC) - element = DEFAULT_ELEMENT_AUDIOSRC; - else if (type == WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST) + if (type == WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST) element = DEFAULT_ELEMENT_AUDIOTESTSRC; else if (type == WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST) element = DEFAULT_ELEMENT_VIDEOTESTSRC; - else if (type == WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET) - element = DEFAULT_ELEMENT_APPSRC; + else if (type == WEBRTC_MEDIA_SOURCE_TYPE_MIC) + element = DEFAULT_ELEMENT_AUDIOSRC; + else if (type == WEBRTC_MEDIA_SOURCE_TYPE_CAMERA) + element = DEFAULT_ELEMENT_CAMERASRC; else if (type == WEBRTC_MEDIA_SOURCE_TYPE_SCREEN) element = DEFAULT_ELEMENT_SCREENSRC; + else if (type == WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET) + element = DEFAULT_ELEMENT_APPSRC; else LOG_ERROR_IF_REACHED("type(%d)", type); @@ -1463,24 +1463,24 @@ static int __build_source_bin(webrtc_s *webrtc, webrtc_gst_slot_s *source) RET_VAL_IF(source->bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL"); switch (source->type) { - case WEBRTC_MEDIA_SOURCE_TYPE_CAMERA: - return __build_camerasrc(webrtc, source); - - case WEBRTC_MEDIA_SOURCE_TYPE_MIC: - return __build_audiosrc(webrtc, source, true); + case WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST: + return __build_audiosrc(webrtc, source, false); case WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST: return __build_videotestsrc(webrtc, source); - case WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST: - return __build_audiosrc(webrtc, source, false); + case WEBRTC_MEDIA_SOURCE_TYPE_MIC: + return __build_audiosrc(webrtc, source, true); - case WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET: - return __build_mediapacketsrc(webrtc, source); + case WEBRTC_MEDIA_SOURCE_TYPE_CAMERA: + return __build_camerasrc(webrtc, source); case WEBRTC_MEDIA_SOURCE_TYPE_SCREEN: return __build_screensrc(webrtc, source); + case WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET: + return __build_mediapacketsrc(webrtc, source); + default: LOG_ERROR_IF_REACHED("type(%d)", source->type); return WEBRTC_ERROR_INVALID_PARAMETER; @@ -1610,7 +1610,7 @@ int _add_media_source(webrtc_s *webrtc, webrtc_media_source_type_e type, unsigne RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL"); RET_VAL_IF(source_id == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source_id is NULL"); - RET_VAL_IF(type > WEBRTC_MEDIA_SOURCE_TYPE_SCREEN, WEBRTC_ERROR_INVALID_PARAMETER, "invalid source type(%d)", type); + RET_VAL_IF(type > WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET, WEBRTC_ERROR_INVALID_PARAMETER, "invalid source type(%d)", type); RET_VAL_IF(webrtc->gst.source_slots == NULL, WEBRTC_ERROR_INVALID_OPERATION, "source_slots is NULL"); /* bin_name/source will be freed by function which is set to g_hash_table_new_full() */ @@ -2306,6 +2306,10 @@ int _set_video_source_mute(webrtc_s *webrtc, unsigned int source_id, bool mute) LOG_DEBUG("source_id[%u] mute[%d]", source_id, mute); switch (source->type) { + case WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST: + ret = __mute_videotestsrc(source, mute); + break; + case WEBRTC_MEDIA_SOURCE_TYPE_CAMERA: ret = __mute_camerasrc(source, mute); break; @@ -2314,10 +2318,6 @@ int _set_video_source_mute(webrtc_s *webrtc, unsigned int source_id, bool mute) ret = __mute_videosrc(source, mute); break; - case WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST: - ret = __mute_videotestsrc(source, mute); - break; - default : LOG_ERROR_IF_REACHED("type(%d)", source->type); return WEBRTC_ERROR_INVALID_PARAMETER; @@ -2344,8 +2344,8 @@ int _set_audio_source_mute(webrtc_s *webrtc, unsigned int source_id, bool mute) } switch (source->type) { - case WEBRTC_MEDIA_SOURCE_TYPE_MIC: case WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST: + case WEBRTC_MEDIA_SOURCE_TYPE_MIC: volume = gst_bin_get_by_name(source->bin, ELEMENT_NAME_VOLUME); RET_VAL_IF(volume == NULL, WEBRTC_ERROR_INVALID_OPERATION, "volume is NULL"); @@ -2381,9 +2381,9 @@ int _get_video_source_muted(webrtc_s *webrtc, unsigned int source_id, bool *mute } switch (source->type) { + case WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST: case WEBRTC_MEDIA_SOURCE_TYPE_CAMERA: case WEBRTC_MEDIA_SOURCE_TYPE_SCREEN: - case WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST: *muted = source->video_muted; break; @@ -2412,8 +2412,8 @@ int _get_audio_source_muted(webrtc_s *webrtc, unsigned int source_id, bool *mute } switch (source->type) { - case WEBRTC_MEDIA_SOURCE_TYPE_MIC: case WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST: + case WEBRTC_MEDIA_SOURCE_TYPE_MIC: volume = gst_bin_get_by_name(source->bin, ELEMENT_NAME_VOLUME); RET_VAL_IF(volume == NULL, WEBRTC_ERROR_INVALID_OPERATION, "volume is NULL"); diff --git a/test/webrtc_test.c b/test/webrtc_test.c index 110045ec..1cf89f2f 100644 --- a/test/webrtc_test.c +++ b/test/webrtc_test.c @@ -3326,7 +3326,7 @@ static void displaymenu() display_sub_basic(); } else if (g_conns[g_conn_index].menu_state == CURRENT_STATUS_ADD_MEDIA_SOURCE) { - g_print("*** input media source type.(1:camera, 2:mic, 3:audiotest, 4:videotest, 5:media packet, 6:screen)\n"); + g_print("*** input media source type.(1:audiotest, 2:videotest, 3:mic, 4:camera, 5:screen, 6:file, 7:media packet)\n"); } else if (g_conns[g_conn_index].menu_state == CURRENT_STATUS_REMOVE_MEDIA_SOURCE) { g_print("*** input media source id to remove.\n");