webrtc_ini: Add new item to set source element name 81/247981/2
authorSangchul Lee <sc11.lee@samsung.com>
Thu, 19 Nov 2020 03:17:58 +0000 (12:17 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Fri, 20 Nov 2020 00:25:46 +0000 (09:25 +0900)
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 <sc11.lee@samsung.com>
include/webrtc_private.h
packaging/capi-media-webrtc.spec
src/webrtc_ini.c
src/webrtc_source.c

index aa7ab50b52241bd0a1064aa5378e86ad8c27e360..d8dfc407cc415bd31d1698a04b34d1fbc984e3a0 100644 (file)
@@ -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;
index b2b0022873768f78ddc0fad75f1f14c4f920c2c6..9d7353ece772dc0ac7085cc8b8b49855bbba0574 100644 (file)
@@ -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
index 661bf762c782853d0c6cd5c1d17908f1e57c8cad..00d1eedda311a36fe17f7b7aacd60f0b5d01117a 100644 (file)
@@ -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,
index 2b4aa3feba24ae71d4c34f0906cffc64583ab889..83d509b10c5142b7b3e3db8d65193b7b72ed3f3c 100644 (file)
@@ -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;
        }