Use GET_CAPS_INFO_FROM_PAD() instead of gst_pad_get_current_caps() 75/279275/2 submit/tizen/20220808.081923
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 5 Aug 2022 01:19:48 +0000 (10:19 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Fri, 5 Aug 2022 01:25:16 +0000 (10:25 +0900)
This new macro also tries to call gst_pad_query_caps()
if the gst_get_current_caps() returns NULL value.

[Version] 0.3.194
[Issue Type] Improvement

Change-Id: Iace8d594b3d5da1170445198b976cb8e7d10679a
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
include/webrtc_private.h
packaging/capi-media-webrtc.spec
src/webrtc_display.c
src/webrtc_private.c
src/webrtc_sink.c
src/webrtc_source_file.c

index f0fdbb221dd5794779fbdf789666f9c15ead4955..30e717010a7d50d7f40df33c17a834e86b7867a8 100644 (file)
@@ -170,6 +170,13 @@ do { \
        src = NULL; \
 } while (0)
 
+#define GET_CAPS_INFO_FROM_PAD(x_pad, x_caps) \
+do { \
+       x_caps = gst_pad_get_current_caps(x_pad); \
+       if (!(x_caps)) \
+               x_caps = gst_pad_query_caps(x_pad, NULL); \
+} while (0)
+
 #define PRINT_CAPS(x_caps, x_prefix) \
 do { \
        if (!(x_caps)) break; \
index e6eaf522878a8878d987a3e413be096c5ac1766a..1a3fc324c5b8ed85aeac3fe8cd0800d8ac760332 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.3.193
+Version:    0.3.194
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 1cce5b5821f12bc9b0e3029d47c8b144dacec54d..60514e24002a00c50e46f1e1cfc563e62afb9e31 100644 (file)
@@ -271,7 +271,7 @@ static video_decoded_data_info_s *__get_decoded_data_info_from_pad(GstPad *pad)
        MMPixelFormatType format;
        GstVideoInfo vinfo;
 
-       caps = gst_pad_get_current_caps(pad);
+       GET_CAPS_INFO_FROM_PAD(pad, caps);
        RET_VAL_IF(caps == NULL, NULL, "caps is NULL");
 
        if (!gst_video_info_from_caps(&vinfo, caps)) {
index fc6e61e7a4c68dabb0f5e3ee85cfa6c68db6919e..13000e5935ee561b10499d86671056227f412a43 100644 (file)
@@ -1346,7 +1346,7 @@ gchar * _get_media_type_from_pad(GstPad *pad)
 
        RET_VAL_IF(pad == NULL, NULL, "pad is NULL");
 
-       caps = gst_pad_get_current_caps(pad);
+       GET_CAPS_INFO_FROM_PAD(pad, caps);
        RET_VAL_IF(caps == NULL, NULL, "caps is NULL");
 
        media_type = g_strdup(gst_structure_get_string(gst_caps_get_structure(caps, 0), "media"));
@@ -1364,7 +1364,7 @@ gchar * _get_mime_type_from_pad(GstPad *pad)
 
        RET_VAL_IF(pad == NULL, NULL, "pad is NULL");
 
-       caps = gst_pad_get_current_caps(pad);
+       GET_CAPS_INFO_FROM_PAD(pad, caps);
        RET_VAL_IF(caps == NULL, NULL, "caps is NULL");
 
        mime_type = g_strdup(gst_structure_get_name(gst_caps_get_structure(caps, 0)));
@@ -1382,7 +1382,7 @@ int _get_payload_type_from_pad(GstPad *pad)
 
        RET_VAL_IF(pad == NULL, -1, "pad is NULL");
 
-       caps = gst_pad_get_current_caps(pad);
+       GET_CAPS_INFO_FROM_PAD(pad, caps);
        RET_VAL_IF(caps == NULL, -1, "caps is NULL");
 
        if (!gst_structure_get_int(gst_caps_get_structure(caps, 0), "payload", &pt))
index edbffddbb1ef1211c46057d5d97ce0a9d28e649a..fe4ce3b63ebc0b0c867686ff40fd5199f3bc5b29 100644 (file)
@@ -690,7 +690,7 @@ static media_format_h __make_media_format(GstPad *pad)
        RET_VAL_IF(pad == NULL, NULL, "pad is NULL");
        RET_VAL_IF(media_format_create(&format) != MEDIA_FORMAT_ERROR_NONE, NULL, "failed to media_format_create()");
 
-       caps = gst_pad_get_current_caps(pad);
+       GET_CAPS_INFO_FROM_PAD(pad, caps);
        structure = gst_caps_get_structure(caps, 0);
        mime = gst_structure_get_name(structure);
 
@@ -774,7 +774,7 @@ static int __set_codec_data_if_exist(media_packet_h packet, GstPad *pad)
        GstCaps *caps;
        const GValue *codec_data_value;
 
-       caps = gst_pad_get_current_caps(pad);
+       GET_CAPS_INFO_FROM_PAD(pad, caps);
 
        if ((codec_data_value = gst_structure_get_value(gst_caps_get_structure(caps, 0), "codec_data"))) {
                GstBuffer *codec_data;
@@ -890,7 +890,7 @@ static GstCaps* __make_caps_if_h264_or_h265(GstPad *pad)
 
        RET_VAL_IF(pad == NULL, NULL, "pad is NULL");
 
-       caps = gst_pad_get_current_caps(pad);
+       GET_CAPS_INFO_FROM_PAD(pad, caps);
        structure = gst_caps_get_structure(caps, 0);
        encoding_name = gst_structure_get_string(structure, "encoding-name");
 
@@ -924,6 +924,7 @@ int _add_forwarding_sink_bin(webrtc_s *webrtc, GstPad *src_pad, bool is_audio)
        GstElement *depayloader = NULL;
        GstElement *capsfilter = NULL;
        GstElement *fakesink = NULL;
+       GstCaps *src_caps;
        GstCaps *sink_caps;
        webrtc_gst_slot_s *sink;
 
@@ -936,7 +937,8 @@ int _add_forwarding_sink_bin(webrtc_s *webrtc, GstPad *src_pad, bool is_audio)
        track_name = g_strdup_printf("track_%u", sink->id);
        g_free(bin_name);
 
-       CREATE_ELEMENT_FROM_REGISTRY(elem_info, GST_KLASS_NAME_DEPAYLOADER_RTP, gst_pad_get_current_caps(src_pad), NULL, NULL, depayloader);
+       GET_CAPS_INFO_FROM_PAD(src_pad, src_caps);
+       CREATE_ELEMENT_FROM_REGISTRY(elem_info, GST_KLASS_NAME_DEPAYLOADER_RTP, src_caps, NULL, NULL, depayloader);
 
        if (!depayloader)
                goto error_before_insert;
index d2541b8251b7777046589ee8fd62ae33a7f33d99..b63ee8c51157c1a1fb5fc98d8e3cec50b2497340 100644 (file)
@@ -144,11 +144,13 @@ static GstElement * __create_payloader_for_filesrc_pipeline(GstPad *pad, bool is
 {
        element_info_s elem_info;
        GstElement *payloader = NULL;
+       GstCaps *caps;
 
        RET_VAL_IF(pad == NULL, NULL, "pad is NULL");
 
+       GET_CAPS_INFO_FROM_PAD(pad, caps);
        CREATE_ELEMENT_FROM_REGISTRY(elem_info, GST_KLASS_NAME_PAYLOADER_RTP,
-                                                               gst_pad_get_current_caps(pad),
+                                                               caps,
                                                                NULL,
                                                                NULL,
                                                                payloader);
@@ -238,7 +240,7 @@ static GstPadProbeReturn __fakesink_probe_cb(GstPad *pad, GstPadProbeInfo *info,
        appsrc = gst_bin_get_by_name(source->bin, _get_element_name(av_idx, ELEMENT_APPSRC));
        RET_VAL_IF(appsrc == NULL, GST_PAD_PROBE_OK, "There is no appsrc for [%s]", (av_idx == AV_IDX_AUDIO) ? "audio" : "video");
 
-       caps = gst_pad_get_current_caps(pad);
+       GET_CAPS_INFO_FROM_PAD(pad, caps);
        g_object_set(G_OBJECT(appsrc), "caps", caps, NULL);
 
        LOG_INFO("setting caps for [%s appsrc] successfully", (av_idx == AV_IDX_AUDIO) ? "audio" : "video");
@@ -721,7 +723,7 @@ static void __filesrc_pipeline_decodebin_pad_added_cb(GstElement *element, GstPa
        }
 
        source->av[av_idx].render.need_decoding = need_decoding;
-       source->av[av_idx].render.appsrc_caps = gst_pad_get_current_caps(pad);
+       GET_CAPS_INFO_FROM_PAD(pad, source->av[av_idx].render.appsrc_caps);
        _add_probe_to_pad_for_render(source, av_idx, gst_element_get_static_pad(queue, "src"), _source_data_probe_cb);
 
        SAFE_G_LIST_FREE(filesrc_element_list);