webrtc_internal: Add functions to get local/remote description 54/305754/1 accepted/tizen/unified/20240215.130027 accepted/tizen/unified/toolchain/20240311.065203 accepted/tizen/unified/x/20240219.013905
authorSangchul Lee <sc11.lee@samsung.com>
Wed, 7 Feb 2024 07:31:43 +0000 (16:31 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Wed, 7 Feb 2024 07:32:58 +0000 (16:32 +0900)
Functions have been added as below.
 - webrtc_get_local_description()
 - webrtc_get_remote_description()

[Version] 0.4.43
[Issue Type] Internal API

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

index 2ea49a2f72eab31a15a2b360df173fccdfb5e949..7186ae9ad2d983df2f970279cfdbc06813e8cffd 100644 (file)
@@ -385,6 +385,42 @@ int webrtc_media_source_remove_transceiver_encoding(webrtc_h webrtc, unsigned in
  */
 int webrtc_media_source_active_transceiver_encoding(webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, const char *rid, bool active);
 
+/**
+ * @internal
+ * @brief Gets the local session description.
+ * @since_tizen 9.0
+ * @remarks @a description is a JSON string.\n
+ *          It will be {"sdp":{"type":"offer or answer","sdp":"..."}}.\n
+ *          The @a description should be released using free() if the value is not NULL.
+ * @param[in] webrtc       WebRTC handle
+ * @param[out] description The local session description
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #WEBRTC_ERROR_NONE    Successful
+ * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation
+ * @see webrtc_set_local_description()
+ */
+int webrtc_get_local_description(webrtc_h webrtc, char **description);
+
+/**
+ * @internal
+ * @brief Gets the remote session description.
+ * @since_tizen 9.0
+ * @remarks @a description is a JSON string.\n
+ *          It should be {"sdp":{"type":"offer or answer","sdp":"..."}}.\n
+ *          The @a description should be released using free() if the value is not NULL.
+ * @param[in] webrtc       WebRTC handle
+ * @param[out] description The remote session description
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #WEBRTC_ERROR_NONE    Successful
+ * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation
+ * @see webrtc_set_remote_description()
+ */
+int webrtc_get_remote_description(webrtc_h webrtc, char **description);
+
 /**
  * @internal
  * @brief Sets the probability of RTP packet dropping.
index 83ba7b50980a047b96ce3cb5712d9f81da52e5e5..4fd339a34c173c7183e1e7de0eceddf41b94ebee 100644 (file)
@@ -519,6 +519,8 @@ typedef struct _webrtc_s {
 
        gchar *desc_offer;
        gchar *desc_answer;
+       gchar *local_desc;
+       gchar *remote_desc;
 
        webrtc_data_recovery_type_s data_recovery_types[MAX_MLINE_NUM];
 
index 5d73a051c7ff35578c152d4780cf6d00405a9e2d..d10c2a7b8051504f6f944427b7fbabdb325b861e 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.4.42
+Version:    0.4.43
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index b3247ac60b63ddd75f441b0dc73d6f8b322359ae..eb505749518bd3e503f77252d272971cc05d2ed7 100644 (file)
@@ -272,6 +272,46 @@ int webrtc_media_source_active_transceiver_encoding(webrtc_h webrtc, unsigned in
        return _active_transceiver_encoding(webrtc, source_id, media_type, rid, active);
 }
 
+int webrtc_get_local_description(webrtc_h webrtc, char **description)
+{
+       g_autoptr(GMutexLocker) locker = NULL;
+       webrtc_s *_webrtc = (webrtc_s *)webrtc;
+
+       RET_VAL_IF(_webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
+       RET_VAL_IF(description == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "description is NULL");
+
+       locker = g_mutex_locker_new(&_webrtc->mutex);
+
+       if (_webrtc->local_desc)
+               *description = strdup(_webrtc->local_desc);
+       else
+               *description = NULL;
+
+       LOG_INFO("webrtc[%p] description: %s", _webrtc, *description);
+
+       return WEBRTC_ERROR_NONE;
+}
+
+int webrtc_get_remote_description(webrtc_h webrtc, char **description)
+{
+       g_autoptr(GMutexLocker) locker = NULL;
+       webrtc_s *_webrtc = (webrtc_s *)webrtc;
+
+       RET_VAL_IF(_webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
+       RET_VAL_IF(description == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "description is NULL");
+
+       locker = g_mutex_locker_new(&_webrtc->mutex);
+
+       if (_webrtc->remote_desc)
+               *description = strdup(_webrtc->remote_desc);
+       else
+               *description = NULL;
+
+       LOG_INFO("webrtc[%p] description: %s", _webrtc, *description);
+
+       return WEBRTC_ERROR_NONE;
+}
+
 int webrtc_set_rtp_packet_drop_probability(webrtc_h webrtc, bool sender, float probability)
 {
        webrtc_s *_webrtc = (webrtc_s *)webrtc;
index eefbddb02958fdc16925df62ac36eeb9bd50b7b1..36981e637b123779ecfcb080ad89349af67831b1 100644 (file)
@@ -1642,6 +1642,14 @@ void _gst_destroy_pipeline(webrtc_s *webrtc)
                g_free(webrtc->desc_answer);
                webrtc->desc_answer = NULL;
        }
+       if (webrtc->local_desc) {
+               g_free(webrtc->local_desc);
+               webrtc->local_desc = NULL;
+       }
+       if (webrtc->remote_desc) {
+               g_free(webrtc->remote_desc);
+               webrtc->remote_desc = NULL;
+       }
 }
 
 int _gst_pipeline_set_state(webrtc_s *webrtc, GstState state)
@@ -2038,6 +2046,13 @@ int _webrtcbin_set_session_description(webrtc_s *webrtc, const char *description
 
        LOG_DEBUG("[%s] signal is emitted", is_remote ? "set-remote-description" : "set-local-description");
 
+       if (is_remote) {
+               g_free(webrtc->remote_desc);
+               webrtc->remote_desc = g_strdup(description);
+       } else {
+               g_free(webrtc->local_desc);
+               webrtc->local_desc = g_strdup(description);
+       }
 end:
        g_free(sdp);
        g_free(type);