From: Sangchul Lee Date: Fri, 29 Mar 2024 05:43:34 +0000 (+0900) Subject: webrtc_internal: Fix not to manage pt values in case of webrtc_media_source_set_paylo... X-Git-Tag: accepted/tizen/8.0/unified/20240927.145501^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=72c7a2afec53fcfaff5042c88ea1ef453a7ccd01;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc_internal: Fix not to manage pt values in case of webrtc_media_source_set_payload_type() If this function is used to set a payload type value, the value of the parameter can be used even if it is already assigned by other one. It is cherry-picked from 6c85f708f6c112dd80ecbb3cffc90b246b0b7b32 commit of tizen 9.0. [Version] 0.4.62 [Issue Type] Improvement Change-Id: I143beac2ef5737bec77c68c9d789f3ee905ca5a7 Signed-off-by: Sangchul Lee --- diff --git a/include/webrtc_private.h b/include/webrtc_private.h index c66cb4b7..995b692e 100644 --- a/include/webrtc_private.h +++ b/include/webrtc_private.h @@ -748,7 +748,6 @@ void _update_transceivers_for_offer(webrtc_s *webrtc); int _set_payload_type(webrtc_s *webrtc, webrtc_gst_slot_s *source, int av_idx, const gchar *media_type); int _get_fixed_payload_type(const gchar *media_type); void _return_payload_type(webrtc_s *webrtc, unsigned int payload_type); -int _set_manual_payload_type(webrtc_s *webrtc, unsigned int payload_type); void _check_and_add_recvonly_transceiver(webrtc_gst_slot_s *source); int _add_transceiver(webrtc_gst_slot_s *source, webrtc_media_type_e media_type, rtp_payload_info_s *payload_info); int _set_transceiver_direction(webrtc_s *webrtc, unsigned int source_id, webrtc_media_type_e media_type, webrtc_transceiver_direction_e direction); diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index c2d949d7..9f7fc0c3 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.4.61 +Version: 0.4.62 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_internal.c b/src/webrtc_internal.c index 2361c29d..e21b21d1 100644 --- a/src/webrtc_internal.c +++ b/src/webrtc_internal.c @@ -181,6 +181,8 @@ int webrtc_media_source_set_payload_type(webrtc_h webrtc, unsigned int source_id return WEBRTC_ERROR_INVALID_PARAMETER; } else if (pt == source->av[av_idx].pt) { + if (!source->av[av_idx].pt_set_by_api) + _return_payload_type(_webrtc, source->av[av_idx].pt); source->av[av_idx].pt_set_by_api = true; LOG_INFO("already payload type[%u] was set", pt == source->av[av_idx].pt); return WEBRTC_ERROR_NONE; @@ -190,12 +192,8 @@ int webrtc_media_source_set_payload_type(webrtc_h webrtc, unsigned int source_id return WEBRTC_ERROR_INVALID_PARAMETER; } - /* occupy the pt if it is not used */ - if (_set_manual_payload_type(_webrtc, pt) != 0) - return WEBRTC_ERROR_INVALID_PARAMETER; - /* release the previous pt */ - if (source->av[av_idx].pt > 0) + if (!source->av[av_idx].pt_set_by_api && source->av[av_idx].pt > 0) _return_payload_type(_webrtc, source->av[av_idx].pt); source->av[av_idx].pt = pt; diff --git a/src/webrtc_transceiver.c b/src/webrtc_transceiver.c index ee790f96..11b1c936 100644 --- a/src/webrtc_transceiver.c +++ b/src/webrtc_transceiver.c @@ -394,26 +394,6 @@ void _return_payload_type(webrtc_s *webrtc, unsigned int payload_type) webrtc->payload_types ^= bitmask; } -int _set_manual_payload_type(webrtc_s *webrtc, unsigned int payload_type) -{ - int bitmask = 0x1; - int count = 0; - - RET_VAL_IF(webrtc == NULL, -1, "webrtc is NULL"); - RET_VAL_IF(payload_type < MIN_DYNAMIC_PAYLOAD_TYPE || payload_type > MAX_DYNAMIC_PAYLOAD_TYPE, -1, "invalid payload_type(%u)", payload_type); - - while (++count != (int)(payload_type - MIN_DYNAMIC_PAYLOAD_TYPE + 1)) - bitmask <<= 1; - - if ((webrtc->payload_types & bitmask)) { - LOG_ERROR("already occupied pt[%u]", payload_type); - return -1; - } - - webrtc->payload_types |= bitmask; - return 0; -} - static int __add_transceiver_for_simulcast(webrtc_gst_slot_s *source, webrtc_media_type_e media_type) { GstWebRTCRTPTransceiver *trans;