webrtc_internal: Fix not to manage pt values in case of webrtc_media_source_set_paylo... 49/318249/1 accepted/tizen/8.0/unified/20240927.145501
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 29 Mar 2024 05:43:34 +0000 (14:43 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Thu, 26 Sep 2024 03:17:14 +0000 (12:17 +0900)
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 <sc11.lee@samsung.com>
include/webrtc_private.h
packaging/capi-media-webrtc.spec
src/webrtc_internal.c
src/webrtc_transceiver.c

index c66cb4b772f6b47d98aa11a6b6cb1cbeb9afb946..995b692e6556a9213491c9993057ea94afc3fe58 100644 (file)
@@ -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);
index c2d949d7a5215e994e68b013ddca8938c97daddc..9f7fc0c3a9eb85441ed6520b56f82616bd85de61 100644 (file)
@@ -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
index 2361c29d1dbda25ca53a012740b3d0a13d8f7c2f..e21b21d114c91eb5095c9d435bb077eb8076d113 100644 (file)
@@ -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;
index ee790f9634d8cd18de89fa3426e36720a3827055..11b1c936eed5a634eee0190b490c0ae43644c0f5 100644 (file)
@@ -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;