From: Sangchul Lee Date: Thu, 19 Nov 2020 03:17:58 +0000 (+0900) Subject: webrtc_ini: Add new item to set source element name X-Git-Tag: submit/tizen/20210729.023123~183 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cb23fcfe81c9030e982965a50f1ea6fb57d6f18f;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc_ini: Add new item to set source element name This item can be added in categories below. [source camera] or [source mic] or [source audiotest] or [source videotest] source element = [Version] 0.1.59 [Issue Type] Improvement Change-Id: I369278068526f15d214b5c0f5820146b9d85ec80 Signed-off-by: Sangchul Lee --- diff --git a/include/webrtc_private.h b/include/webrtc_private.h index aa7ab50b..d8dfc407 100644 --- a/include/webrtc_private.h +++ b/include/webrtc_private.h @@ -165,6 +165,7 @@ typedef struct _ini_item_general_s { } ini_item_general_s; typedef struct _ini_item_media_source_s { + const char *source_element; /* video source pipeline */ const char *v_raw_format; int v_width; diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index b2b00228..9d7353ec 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.1.58 +Version: 0.1.59 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_ini.c b/src/webrtc_ini.c index 661bf762..00d1eedd 100644 --- a/src/webrtc_ini.c +++ b/src/webrtc_ini.c @@ -40,6 +40,7 @@ #define INI_ITEM_RTP_JITTERBUFFER_LATENCY "rtp jitterbuffer latency" /* items for media source */ +#define INI_ITEM_SOURCE_ELEMENT "source element" #define INI_ITEM_VIDEO_RAW_FORMAT "video raw format" #define INI_ITEM_VIDEO_WIDTH "video width" #define INI_ITEM_VIDEO_HEIGHT "video height" @@ -127,6 +128,7 @@ static void __dump_items_of_source(ini_item_media_source_s *source) { RET_IF(source == NULL, "source is NULL"); + __dump_item(INI_ITEM_SOURCE_ELEMENT, INI_ITEM_TYPE_STRING, (void *)source->source_element); __dump_item(INI_ITEM_VIDEO_RAW_FORMAT, INI_ITEM_TYPE_STRING, (void *)source->v_raw_format); __dump_item(INI_ITEM_VIDEO_WIDTH, INI_ITEM_TYPE_INT, &source->v_width); __dump_item(INI_ITEM_VIDEO_HEIGHT, INI_ITEM_TYPE_INT, &source->v_height); @@ -281,6 +283,9 @@ static void __apply_media_source_setting(webrtc_ini_s *ini, ini_item_media_sourc if (g_strcmp0(category, INI_CATEGORY_MEDIA_SOURCE) == 0) is_default = true; + if (!is_default) + source->source_element = __ini_get_string(ini->dict, category, INI_ITEM_SOURCE_ELEMENT, NULL); + source->v_raw_format = __ini_get_string(ini->dict, category, INI_ITEM_VIDEO_RAW_FORMAT, is_default ? DEFAULT_VIDEO_RAW_FORMAT : ini->media_source.v_raw_format); source->v_width = __ini_get_int(ini->dict, category, INI_ITEM_VIDEO_WIDTH, diff --git a/src/webrtc_source.c b/src/webrtc_source.c index 2b4aa3fe..83d509b1 100644 --- a/src/webrtc_source.c +++ b/src/webrtc_source.c @@ -26,7 +26,7 @@ #define GST_KLASS_NAME_CONVERTER_AUDIO "Filter/Converter/Audio" #define GST_KLASS_NAME_CONVERTER_VIDEO "Filter/Converter/Video" -#define DEFAULT_ELEMENT_CAMERASRC "camerasrc" +#define DEFAULT_ELEMENT_CAMERASRC "v4l2src" #define DEFAULT_ELEMENT_AUDIOSRC "pulsesrc" #define DEFAULT_ELEMENT_VIDEOTESTSRC "videotestsrc" #define DEFAULT_ELEMENT_AUDIOTESTSRC "audiotestsrc" @@ -348,6 +348,39 @@ static int __create_rest_of_elements(webrtc_s *webrtc, webrtc_gst_slot_s *source return WEBRTC_ERROR_NONE; } +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) + element = DEFAULT_ELEMENT_AUDIOTESTSRC; + else if (type == WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST) + element = DEFAULT_ELEMENT_VIDEOTESTSRC; + else + LOG_ERROR_IF_REACHED("type(%d)", type); + + LOG_DEBUG("type(%d) -> element[%s]", type, element); + + return element; +} + +static const char *__get_source_element(webrtc_s *webrtc, webrtc_media_source_type_e type) +{ + ini_item_media_source_s *source; + + RET_VAL_IF(webrtc == NULL, NULL, "webrtc is NULL"); + + source = _ini_get_source_by_type(&webrtc->ini, type); + if (source == NULL || source->source_element == NULL) + return __get_default_element(type); + + return source->source_element; +} + static int __build_camerasrc(webrtc_s *webrtc, webrtc_gst_slot_s *source, GstPad *ghost_src_pad) { int ret = WEBRTC_ERROR_NONE; @@ -365,8 +398,7 @@ static int __build_camerasrc(webrtc_s *webrtc, webrtc_gst_slot_s *source, GstPad source->media_types |= MEDIA_TYPE_VIDEO; - /* FIXME: get factory name from ini */ - if (!(camerasrc = _create_element(DEFAULT_ELEMENT_CAMERASRC, NULL))) { + if (!(camerasrc = _create_element(__get_source_element(webrtc, WEBRTC_MEDIA_SOURCE_TYPE_CAMERA), NULL))) { LOG_ERROR("failed to create camerasrc"); return WEBRTC_ERROR_INVALID_OPERATION; } @@ -401,7 +433,7 @@ static int __build_audiosrc(webrtc_s *webrtc, webrtc_gst_slot_s *source, GstPad source->media_types |= MEDIA_TYPE_AUDIO; - if (!(audiosrc = _create_element(DEFAULT_ELEMENT_AUDIOSRC, NULL))) { + if (!(audiosrc = _create_element(__get_source_element(webrtc, WEBRTC_MEDIA_SOURCE_TYPE_MIC), NULL))) { LOG_ERROR("failed to create audiosrc"); return WEBRTC_ERROR_INVALID_OPERATION; } @@ -435,7 +467,7 @@ static int __build_videotestsrc(webrtc_s *webrtc, webrtc_gst_slot_s *source, Gst source->media_types |= MEDIA_TYPE_VIDEO; - if (!(videotestsrc = _create_element(DEFAULT_ELEMENT_VIDEOTESTSRC, NULL))) { + if (!(videotestsrc = _create_element(__get_source_element(webrtc, WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST), NULL))) { LOG_ERROR("failed to create videotestsrc"); return WEBRTC_ERROR_INVALID_OPERATION; } @@ -470,7 +502,7 @@ static int __build_audiotestsrc(webrtc_s *webrtc, webrtc_gst_slot_s *source, Gst source->media_types |= MEDIA_TYPE_AUDIO; - if (!(audiotestsrc = _create_element(DEFAULT_ELEMENT_AUDIOTESTSRC, NULL))) { + if (!(audiotestsrc = _create_element(__get_source_element(webrtc, WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST), NULL))) { LOG_ERROR("failed to create audiotestsrc"); return WEBRTC_ERROR_INVALID_OPERATION; }