webrtc_internal: Add 'ssrc' outparam to webrtc_media_source_add_transceiver_encoding() 92/315092/1
authorSangchul Lee <sc11.lee@samsung.com>
Wed, 24 Jul 2024 10:17:06 +0000 (19:17 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Thu, 25 Jul 2024 02:50:15 +0000 (11:50 +0900)
[Version] 1.1.17
[Issue Type] API

Change-Id: I5b2be20c9e2c635edc9612fe64671c22f68eb73d
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
test/webrtc_test.c

index b3b7be9aefda486aa7cfe0b1ba5e30491c96015e..364f2612113ae737efc80bc05f994ab31835eee5 100644 (file)
@@ -349,6 +349,7 @@ int webrtc_media_source_get_payload_type(webrtc_h webrtc, unsigned int source_id
  * @param[in] target_bitrate  The target bitrate of the encoder
  * @param[in] width       The video width (video only)
  * @param[in] height      The video height (video only)
+ * @param[out] ssrc       The SSRC (optional, this can be NULL)
  * @return @c 0 on success,
  *         otherwise a negative error value
  * @retval #WEBRTC_ERROR_NONE    Successful
@@ -357,7 +358,7 @@ int webrtc_media_source_get_payload_type(webrtc_h webrtc, unsigned int source_id
  * @pre Add media source to @a webrtc to get @a source_id by calling webrtc_add_media_source().
  * @see webrtc_media_source_remove_transceiver_encoding()
  */
-int webrtc_media_source_add_transceiver_encoding(webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, const char *rid, int target_bitrate, int width, int height);
+int webrtc_media_source_add_transceiver_encoding(webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, const char *rid, int target_bitrate, int width, int height, int *ssrc);
 
 /**
  * @internal
index 063c504382b115104010ea5148d9e6c9e915885d..5b9e4da60a87f2264736f81a9a4d5470345be8a8 100644 (file)
@@ -761,7 +761,7 @@ int _get_transceiver_direction(webrtc_s *webrtc, unsigned int source_id, webrtc_
 int _set_transceiver_codec(webrtc_s *webrtc, unsigned int source_id, webrtc_media_type_e media_type, webrtc_transceiver_codec_e codec);
 int _get_transceiver_codec(webrtc_s *webrtc, unsigned int source_id, webrtc_media_type_e media_type, webrtc_transceiver_codec_e *codec);
 int _foreach_supported_transceiver_codec(webrtc_s *webrtc, webrtc_media_source_type_e source_type, webrtc_media_type_e media_type, webrtc_media_source_supported_transceiver_codec_cb callback, void *user_data);
-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 _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 *ssrc);
 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);
index 728e73942a1fb052619143cad3460ebf775c77a6..29030ca91ec535f2263eab557a6d9f56c336dbcc 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    1.1.16
+Version:    1.1.17
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 4135c7a211be0f08d9f57ff52e6b9d367b28184d..0c559567c925e9a8e9d92a6fd8c2eeeddfeac620 100644 (file)
@@ -309,7 +309,7 @@ int webrtc_media_source_get_payload_type(webrtc_h webrtc, unsigned int source_id
        return WEBRTC_ERROR_NONE;
 }
 
-int webrtc_media_source_add_transceiver_encoding(webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, const char *rid, int target_bitrate, int width, int height)
+int webrtc_media_source_add_transceiver_encoding(webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, const char *rid, int target_bitrate, int width, int height, int *ssrc)
 {
        g_autoptr(GMutexLocker) locker = NULL;
        webrtc_s *_webrtc = (webrtc_s *)webrtc;
@@ -319,7 +319,7 @@ int webrtc_media_source_add_transceiver_encoding(webrtc_h webrtc, unsigned int s
 
        locker = g_mutex_locker_new(&_webrtc->mutex);
 
-       return _add_transceiver_encoding(webrtc, source_id, media_type, rid, target_bitrate, width, height);
+       return _add_transceiver_encoding(webrtc, source_id, media_type, rid, target_bitrate, width, height, ssrc);
 }
 
 int webrtc_media_source_remove_transceiver_encoding(webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, const char *rid)
index e11642bb025f11a5f7a6c91029c664ef7d0d17ac..e4f0705e314a989a77c0d9b51b4de27fe1a15bac 100644 (file)
@@ -842,12 +842,12 @@ int _get_transceiver_codec(webrtc_s *webrtc, unsigned int source_id, webrtc_medi
 }
 
 //LCOV_EXCL_START
-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 _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 *ssrc)
 {
        int ret;
        webrtc_gst_slot_s *source;
        int av_idx = (media_type == WEBRTC_MEDIA_TYPE_AUDIO) ? AV_IDX_AUDIO : AV_IDX_VIDEO;
-       int ssrc;
+       int _ssrc;
 
        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");
@@ -866,17 +866,17 @@ int _add_transceiver_encoding(webrtc_s *webrtc, unsigned int source_id, webrtc_m
        if (source->type == WEBRTC_MEDIA_SOURCE_TYPE_NULL)
                LOG_DEBUG("NULL source type, skip target_bitrate[%d] width[%d] height[%d] parameters", target_bitrate, width, height);
 
-       ret = _add_source_encoding(source, av_idx, rid, target_bitrate, width, height, &ssrc);
+       ret = _add_source_encoding(source, av_idx, rid, target_bitrate, width, height, &_ssrc);
        if (ret != WEBRTC_ERROR_NONE)
                return ret;
 
        switch (source->type) {
        case WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST:
        case WEBRTC_MEDIA_SOURCE_TYPE_MIC:
-               ret = _build_audiosrc(webrtc, source, source->type == WEBRTC_MEDIA_SOURCE_TYPE_MIC, ssrc);
+               ret = _build_audiosrc(webrtc, source, source->type == WEBRTC_MEDIA_SOURCE_TYPE_MIC, _ssrc);
                break;
        case WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST:
-               ret = _build_videotestsrc(webrtc, source, ssrc);
+               ret = _build_videotestsrc(webrtc, source, _ssrc);
                break;
        case WEBRTC_MEDIA_SOURCE_TYPE_NULL:
                return WEBRTC_ERROR_NONE;
@@ -886,7 +886,12 @@ int _add_transceiver_encoding(webrtc_s *webrtc, unsigned int source_id, webrtc_m
                return WEBRTC_ERROR_INVALID_PARAMETER;
        }
 
-       return _set_transceiver_direction(webrtc, source_id, media_type, WEBRTC_TRANSCEIVER_DIRECTION_SENDONLY);
+       ret = _set_transceiver_direction(webrtc, source_id, media_type, WEBRTC_TRANSCEIVER_DIRECTION_SENDONLY);
+       if (ret == WEBRTC_ERROR_NONE) {
+               if (ssrc)
+                       *ssrc = _ssrc;
+       }
+       return ret;
 }
 
 int _remove_transceiver_encoding(webrtc_s *webrtc, unsigned int source_id, webrtc_media_type_e media_type, const char *rid)
index 81cddde041d8b5d03f94ea3f2eb03f767b536445..bad2081abfa98f4eb0db4a0f7fd4f98e26a96626 100644 (file)
@@ -1225,11 +1225,12 @@ static void _webrtc_media_source_set_payload_type(int index, unsigned int source
 
 static void _webrtc_media_source_add_transceiver_encoding(int index, unsigned int source_id, webrtc_media_type_e media_type, const char *rid, int target_bitrate, int w, int h)
 {
-       int ret = webrtc_media_source_add_transceiver_encoding(g_ad.conns[index].webrtc, source_id, media_type, rid, target_bitrate, w, h);
+       int ssrc;
+       int ret = webrtc_media_source_add_transceiver_encoding(g_ad.conns[index].webrtc, source_id, media_type, rid, target_bitrate, w, h, &ssrc);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
-       g_print("webrtc_media_source_add_transceiver_encoding() success, source_id[%u], media_type[%s], rid[%s], target_bitrate[%d], [%dx%d]\n",
-               source_id, g_webrtc_media_type_str[media_type], rid, target_bitrate, w, h);
+       g_print("webrtc_media_source_add_transceiver_encoding() success, source_id[%u], media_type[%s], rid[%s], target_bitrate[%d], [%dx%d], ssrc[%d]\n",
+               source_id, g_webrtc_media_type_str[media_type], rid, target_bitrate, w, h, ssrc);
 }
 
 static void _webrtc_media_source_remove_transceiver_encoding(int index, unsigned int source_id, webrtc_media_type_e media_type, const char *rid)