webrtc_internal: Add function to get transceiver mid 12/306412/1
authorSangchul Lee <sc11.lee@samsung.com>
Wed, 21 Feb 2024 06:19:22 +0000 (15:19 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Wed, 21 Feb 2024 06:19:22 +0000 (15:19 +0900)
webrtc_media_source_get_transceiver_mid() has been added.

[Version] 0.4.45
[Issue Type] Internal API

Change-Id: Ia69250ac27b46c68e01bbae125ebbbd103d874da
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_transceiver.c

index 7688d0f8b967b86ff1ea673e051bd5f828ddda26..c3d7755cf21c7f0448481d2bb8845f9054752b48 100644 (file)
@@ -385,6 +385,24 @@ 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);
 
+/**
+ * @brief Gets the transceiver media id of the media source.
+ * @since_tizen 8.0
+ * @remarks The @a mid should be released using free() if the value is not NULL.
+ * @param[in] webrtc      WebRTC handle
+ * @param[in] source_id   The media source id
+ * @param[in] media_type  The media type
+ * @param[out] mid        The transceiver media id
+ * @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
+ * @pre Add media source to @a webrtc to get @a source_id by calling webrtc_add_media_source().
+ * @pre Call webrtc_start() before calling this function, otherwise NULL can be set to @a mid.
+ */
+int webrtc_media_source_get_transceiver_mid(webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, char **mid);
+
 /**
  * @internal
  * @brief Gets the media type of the media source.
index 4fd339a34c173c7183e1e7de0eceddf41b94ebee..e80946ba7931e5014a926e68d3521c633fbbc006 100644 (file)
@@ -751,6 +751,7 @@ int _foreach_supported_transceiver_codec(webrtc_s *webrtc, webrtc_media_source_t
 int _add_transceiver_encoding(webrtc_s *webrtc, unsigned int source_id, webrtc_media_type_e media_type, const char *rid, int target_bitrate, int width, int height);
 int _remove_transceiver_encoding(webrtc_s *webrtc, unsigned int source_id, webrtc_media_type_e media_type, const char *rid);
 int _active_transceiver_encoding(webrtc_s *webrtc, unsigned int source_id, webrtc_media_type_e media_type, const char *rid, bool active);
+int _get_transceiver_mid(webrtc_s *webrtc, unsigned int source_id, webrtc_media_type_e media_type, char **mid);
 GstCaps *_make_rtp_caps_with_encoding(webrtc_gst_slot_s *source, bool is_audio);
 
 /* file source */
index 5ab2ee9dbde1a0a3e8c3d9b5a8c0757b0ccddf4b..c00160f3df717961b4320b1bf02bc751ffb35b63 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.4.44
+Version:    0.4.45
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 3f6e55434798c2ff7cc13d96d702fc2287f2afe3..365cec94ddc38df4106795b6da127a861cf9cc4f 100644 (file)
@@ -272,6 +272,20 @@ 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_media_source_get_transceiver_mid(webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, char **mid)
+{
+       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(source_id == 0, WEBRTC_ERROR_INVALID_PARAMETER, "source_id is 0");
+       RET_VAL_IF(mid == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "mid is NULL");
+
+       locker = g_mutex_locker_new(&_webrtc->mutex);
+
+       return _get_transceiver_mid(webrtc, source_id, media_type, mid);
+}
+
 int webrtc_media_source_get_type(webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e *media_type)
 {
        webrtc_s *_webrtc = (webrtc_s *)webrtc;
index e30db3c5cf3944a7a37362453a534e4e7424c681..a8d75e524724c91c76cabfe05f47f3462e4da0de 100644 (file)
@@ -877,3 +877,22 @@ int _active_transceiver_encoding(webrtc_s *webrtc, unsigned int source_id, webrt
 
        return __active_encoding(source, av_idx, rid, active);
 }
+
+int _get_transceiver_mid(webrtc_s *webrtc, unsigned int source_id, webrtc_media_type_e media_type, char **mid)
+{
+       webrtc_gst_slot_s *source;
+       int av_idx = (media_type == WEBRTC_MEDIA_TYPE_AUDIO) ? AV_IDX_AUDIO : AV_IDX_VIDEO;
+
+       RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
+       RET_VAL_IF((source = _get_slot_by_id(webrtc->gst.source_slots, source_id)) == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
+       RET_VAL_IF(mid == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "mid is NULL");
+
+       if (source->av[av_idx].mid)
+               *mid = strdup(source->av[av_idx].mid);
+       else
+               *mid = NULL;
+
+       LOG_INFO("source_id[%u], av_idx[%d], mid[%s]", source->id, av_idx, *mid);
+
+       return WEBRTC_ERROR_NONE;
+}