webrtc_source: Add parameter to __create_rest_of_elements() to check the exact media... 31/265431/4
authorbackto.kim <backto.kim@samsung.com>
Tue, 19 Oct 2021 08:25:30 +0000 (17:25 +0900)
committerbackto.kim <backto.kim@samsung.com>
Wed, 20 Oct 2021 01:46:45 +0000 (10:46 +0900)
file source can have audio and video together in the "media type".
So, actual media type to make proper elements should not be determined only by the "media type".

[Version] 0.2.133
[Issue Type] Improvement

Change-Id: Idc9ffa36d5ca01bdf59410be78dad8c57158e0d5

packaging/capi-media-webrtc.spec
src/webrtc_source.c

index 7858b427ce1d563aac2f005b3e0154cb9e28af55..3c27a2777d59c16c45ff63b6922385d32ce7feb6 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.2.132
+Version:    0.2.133
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index ddde78f007ac47cedae8f23bc32ecd035f456432..e2dbcca6d8a56e0aff8fc5a4a293910ef99bab61 100644 (file)
@@ -846,7 +846,7 @@ static void __remove_probe_from_pad_for_render(webrtc_gst_slot_s *source, unsign
        }
 }
 
-static int __create_rest_of_elements(webrtc_s *webrtc, webrtc_gst_slot_s *source, bool need_capsfilter, GList **element_list)
+static int __create_rest_of_elements(webrtc_s *webrtc, webrtc_gst_slot_s *source, bool need_capsfilter, GList **element_list, bool is_audio)
 {
        GstElement *capsfilter = NULL;
        GstElement *encoder = NULL;
@@ -866,15 +866,9 @@ static int __create_rest_of_elements(webrtc_s *webrtc, webrtc_gst_slot_s *source
        RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
        RET_VAL_IF(element_list == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "element_list is NULL");
 
-       if (source->media_types == MEDIA_TYPE_VIDEO) {
-               encoder_klass_name = GST_KLASS_NAME_ENCODER_VIDEO;
-       } else if (source->media_types == MEDIA_TYPE_AUDIO) {
-               encoder_klass_name = GST_KLASS_NAME_ENCODER_AUDIO;
-       } else {
-               LOG_ERROR("not ready for this media_types[0x%x]", source->media_types);
-               return WEBRTC_ERROR_INVALID_OPERATION;
-       }
-       idx = GET_AV_IDX_BY_TYPE(source->media_types);
+       encoder_klass_name = is_audio ? GST_KLASS_NAME_ENCODER_AUDIO : GST_KLASS_NAME_ENCODER_VIDEO;
+
+       idx = GET_AV_IDX(is_audio);
 
        if (need_capsfilter) {
                if (!(capsfilter = _create_element(DEFAULT_ELEMENT_CAPSFILTER, ELEMENT_NAME_FIRST_CAPSFILTER)))
@@ -1303,7 +1297,7 @@ static int __build_screensrc(webrtc_s *webrtc, webrtc_gst_slot_s *source)
                APPEND_ELEMENT(element_list, videoconvert);
        }
 
-       if ((ret = __create_rest_of_elements(webrtc, source, true, &element_list)) != WEBRTC_ERROR_NONE)
+       if ((ret = __create_rest_of_elements(webrtc, source, true, &element_list, false)) != WEBRTC_ERROR_NONE)
                goto exit;
 
        if (!__add_elements_to_bin(source->bin, switch_src_list))
@@ -1384,7 +1378,7 @@ static int __build_camerasrc(webrtc_s *webrtc, webrtc_gst_slot_s *source)
        if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(camerasrc)), "empty-buffer-timeout"))
                g_object_set(G_OBJECT(camerasrc), "empty-buffer-timeout", 0, NULL);
 
-       if ((ret = __create_rest_of_elements(webrtc, source, true, &element_list)) != WEBRTC_ERROR_NONE)
+       if ((ret = __create_rest_of_elements(webrtc, source, true, &element_list, false)) != WEBRTC_ERROR_NONE)
                goto exit;
 
        if (!__add_elements_to_bin(source->bin, element_list))
@@ -1451,7 +1445,7 @@ static int __build_audiosrc(webrtc_s *webrtc, webrtc_gst_slot_s *source, bool us
                goto exit;
        APPEND_ELEMENT(element_list, volume);
 
-       if ((ret = __create_rest_of_elements(webrtc, source, true, &element_list)) != WEBRTC_ERROR_NONE)
+       if ((ret = __create_rest_of_elements(webrtc, source, true, &element_list, true)) != WEBRTC_ERROR_NONE)
                goto exit;
 
        if (!__add_elements_to_bin(source->bin, element_list))
@@ -1513,7 +1507,7 @@ static int __build_videotestsrc(webrtc_s *webrtc, webrtc_gst_slot_s *source)
                "pattern", 18, /* ball */
                NULL);
 
-       if ((ret = __create_rest_of_elements(webrtc, source, true, &element_list)) != WEBRTC_ERROR_NONE)
+       if ((ret = __create_rest_of_elements(webrtc, source, true, &element_list, false)) != WEBRTC_ERROR_NONE)
                goto exit;
 
        if (!__add_elements_to_bin(source->bin, element_list))
@@ -1570,7 +1564,7 @@ static int __build_custom_videosrc(webrtc_s *webrtc, webrtc_gst_slot_s *source)
                return WEBRTC_ERROR_INVALID_OPERATION;
        APPEND_ELEMENT(element_list, custom_videosrc);
 
-       if ((ret = __create_rest_of_elements(webrtc, source, true, &element_list)) != WEBRTC_ERROR_NONE)
+       if ((ret = __create_rest_of_elements(webrtc, source, true, &element_list, false)) != WEBRTC_ERROR_NONE)
                goto exit;
 
        if (!__add_elements_to_bin(source->bin, element_list))
@@ -1634,7 +1628,7 @@ static int __build_custom_audiosrc(webrtc_s *webrtc, webrtc_gst_slot_s *source)
                goto exit;
        APPEND_ELEMENT(element_list, volume);
 
-       if ((ret = __create_rest_of_elements(webrtc, source, true, &element_list)) != WEBRTC_ERROR_NONE)
+       if ((ret = __create_rest_of_elements(webrtc, source, true, &element_list, true)) != WEBRTC_ERROR_NONE)
                goto exit;
 
        if (!__add_elements_to_bin(source->bin, element_list))
@@ -2265,7 +2259,7 @@ static int __complete_mediapacketsrc_from_raw_format(webrtc_s *webrtc, webrtc_gs
 
        source->zerocopy_enabled = __is_hw_encoder_used(webrtc, source->type, source->media_types);
 
-       if ((ret = __create_rest_of_elements(webrtc, source, false, &element_list)) != WEBRTC_ERROR_NONE)
+       if ((ret = __create_rest_of_elements(webrtc, source, false, &element_list, (source->media_types == MEDIA_TYPE_AUDIO))) != WEBRTC_ERROR_NONE)
                return ret;
 
        if (!(sink_caps = __make_raw_caps_from_media_format(source))) {