From: Sangchul Lee Date: Fri, 5 Aug 2022 01:19:48 +0000 (+0900) Subject: Use GET_CAPS_INFO_FROM_PAD() instead of gst_pad_get_current_caps() X-Git-Tag: submit/tizen/20220808.081923^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F75%2F279275%2F2;p=platform%2Fcore%2Fapi%2Fwebrtc.git Use GET_CAPS_INFO_FROM_PAD() instead of gst_pad_get_current_caps() 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 --- diff --git a/include/webrtc_private.h b/include/webrtc_private.h index f0fdbb22..30e71701 100644 --- a/include/webrtc_private.h +++ b/include/webrtc_private.h @@ -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; \ diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index e6eaf522..1a3fc324 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.3.193 +Version: 0.3.194 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_display.c b/src/webrtc_display.c index 1cce5b58..60514e24 100644 --- a/src/webrtc_display.c +++ b/src/webrtc_display.c @@ -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)) { diff --git a/src/webrtc_private.c b/src/webrtc_private.c index fc6e61e7..13000e59 100644 --- a/src/webrtc_private.c +++ b/src/webrtc_private.c @@ -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)) diff --git a/src/webrtc_sink.c b/src/webrtc_sink.c index edbffddb..fe4ce3b6 100644 --- a/src/webrtc_sink.c +++ b/src/webrtc_sink.c @@ -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; diff --git a/src/webrtc_source_file.c b/src/webrtc_source_file.c index d2541b82..b63ee8c5 100644 --- a/src/webrtc_source_file.c +++ b/src/webrtc_source_file.c @@ -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);