From: Sangchul Lee Date: Tue, 13 Sep 2022 07:12:25 +0000 (+0900) Subject: webrtc_internal: Revise webrtc_media_source_set_payload_type() for media packet source X-Git-Tag: accepted/tizen/unified/20220919.012611~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F33%2F281133%2F1;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc_internal: Revise webrtc_media_source_set_payload_type() for media packet source This function should affect media packet source. It is fixed. [Version] 0.3.237 [Issue Type] Bug fix Change-Id: I12b49da60526d2ba93cef07e1ceea9b4e887df33 Signed-off-by: Sangchul Lee --- diff --git a/include/webrtc_private.h b/include/webrtc_private.h index 86912306..1c71f0f8 100644 --- a/include/webrtc_private.h +++ b/include/webrtc_private.h @@ -730,6 +730,7 @@ int _build_mediapacketsrc(webrtc_s *webrtc, webrtc_gst_slot_s *source); GstCaps *_make_mediapacketsrc_raw_caps_from_media_format(webrtc_gst_slot_s *source); int _push_media_packet(webrtc_s *webrtc, unsigned int source_id, media_packet_h packet); int _set_media_format(webrtc_s *webrtc, unsigned int source_id, media_format_h format); +int _update_pt_if_media_packet_source(webrtc_s *webrtc, webrtc_gst_slot_s *source); /* screen source */ int _get_screen_resolution(int *width, int *height); diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index 84ec88cd..bff8802f 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.236 +Version: 0.3.237 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_internal.c b/src/webrtc_internal.c index 45cd57c9..47735368 100644 --- a/src/webrtc_internal.c +++ b/src/webrtc_internal.c @@ -117,7 +117,7 @@ int webrtc_media_source_set_payload_type(webrtc_h webrtc, unsigned int source_id LOG_INFO("webrtc[%p] source_id[%u] media_type[%u] payload type[%u]", _webrtc, source_id, media_type, pt); - return WEBRTC_ERROR_NONE; + return _update_pt_if_media_packet_source(webrtc, source); } int webrtc_media_source_get_payload_type(webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, unsigned int *pt) diff --git a/src/webrtc_source_mediapacket.c b/src/webrtc_source_mediapacket.c index e5af6fd9..74d5329d 100644 --- a/src/webrtc_source_mediapacket.c +++ b/src/webrtc_source_mediapacket.c @@ -836,3 +836,34 @@ error: source->media_format = NULL; return ret; } + +//LCOV_EXCL_START +int _update_pt_if_media_packet_source(webrtc_s *webrtc, webrtc_gst_slot_s *source) +{ + GstCaps *sink_caps; + GstElement *capsfilter; + const char *media_type; + int idx; + + RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL"); + RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL"); + if (source->type != WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET) + return WEBRTC_ERROR_NONE; + + if (!(capsfilter = gst_bin_get_by_name(source->bin, ELEMENT_NAME_RTP_CAPSFILTER))) { + LOG_ERROR("failed to gst_bin_get_by_name() for %s", ELEMENT_NAME_RTP_CAPSFILTER); + return WEBRTC_ERROR_INVALID_OPERATION; + } + + idx = GET_AV_IDX_BY_TYPE(source->media_types); + media_type = (idx == AV_IDX_AUDIO) ? _get_audio_media_type(source->av[idx].codec) : _get_video_media_type(source->av[idx].codec); + + if (!(sink_caps = _make_rtp_caps(media_type, source->av[idx].pt, source, NULL))) + return WEBRTC_ERROR_INVALID_OPERATION; + + g_object_set(G_OBJECT(capsfilter), "caps", sink_caps, NULL); + gst_caps_unref(sink_caps); + + return WEBRTC_ERROR_NONE; +} +//LCOV_EXCL_STOP \ No newline at end of file