Revise webrtc_media_source_foreach_supported_transceiver_codec() 11/276811/1
authorSangchul Lee <sc11.lee@samsung.com>
Mon, 27 Jun 2022 01:17:33 +0000 (10:17 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Mon, 27 Jun 2022 01:22:10 +0000 (10:22 +0900)
The second paramter 'source_id' is replaced with 'source_type'.
Because supported codecs are decided by source type.

[Version] 0.3.132
[Issue Type] API

Change-Id: I37baa27a8e2fb3f1211644795a246e11585f6408
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
include/webrtc.h
packaging/capi-media-webrtc.spec
src/webrtc.c
src/webrtc_source.c
test/webrtc_test.c
test/webrtc_test_menu.c

index 14b7beca47c03b058d202524a003ef1ac932dcfd..a56dcdebcad32be4cb4827ec7108f38cb539f39a 100644 (file)
@@ -1111,10 +1111,10 @@ int webrtc_media_source_get_transceiver_direction(webrtc_h webrtc, unsigned int
 /**
  * @brief Retrieves all the supported transceiver codecs.
  * @since_tizen 7.0
- * @remarks If @a source_id is a media source of #WEBRTC_MEDIA_SOURCE_TYPE_FILE or #WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET,
+ * @remarks If @a source_type is #WEBRTC_MEDIA_SOURCE_TYPE_FILE or #WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET,
  *          this function will return #WEBRTC_ERROR_INVALID_PARAMETER.
  * @param[in] webrtc      WebRTC handle
- * @param[in] source_id   The media source id
+ * @param[in] source_type The media source type
  * @param[in] media_type  The media type
  * @param[in] callback    Callback function pointer
  * @param[in] user_data   The user data to be passed to the callback function
@@ -1127,7 +1127,7 @@ int webrtc_media_source_get_transceiver_direction(webrtc_h webrtc, unsigned int
  * @see webrtc_media_source_set_transceiver_codec()
  * @see webrtc_media_source_get_transceiver_codec()
  */
-int webrtc_media_source_foreach_supported_transceiver_codec(webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, webrtc_media_source_supported_transceiver_codec_cb callback, void *user_data);
+int webrtc_media_source_foreach_supported_transceiver_codec(webrtc_h 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);
 
 /**
  * @brief Sets the transceiver codec to the media source.
index e4ffd396b445efb24dd57c70c7d19302916a7a7b..577451d6ccc97d3930a7a04aeff16098881cd49a 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.3.131
+Version:    0.3.132
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index ce3c569ce43e0f2a720d91a82362e93bca60ad9e..aef2e7e47b0ec956266e75c59ce60e95bc25b2f2 100644 (file)
@@ -343,7 +343,7 @@ int webrtc_media_source_get_transceiver_direction(webrtc_h webrtc, unsigned int
        return _get_transceiver_direction(webrtc, source_id, media_type, direction);
 }
 
-int webrtc_media_source_foreach_supported_transceiver_codec(webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, webrtc_media_source_supported_transceiver_codec_cb callback, void *user_data)
+int webrtc_media_source_foreach_supported_transceiver_codec(webrtc_h 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)
 {
        g_autoptr(GMutexLocker) locker = NULL;
        webrtc_s *_webrtc = (webrtc_s *)webrtc;
@@ -353,7 +353,7 @@ int webrtc_media_source_foreach_supported_transceiver_codec(webrtc_h webrtc, uns
 
        locker = g_mutex_locker_new(&_webrtc->mutex);
 
-       return _foreach_supported_transceiver_codec(_webrtc, source_id, media_type, callback, user_data);
+       return _foreach_supported_transceiver_codec(_webrtc, source_type, media_type, callback, user_data);
 }
 
 int webrtc_media_source_set_transceiver_codec(webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, webrtc_transceiver_codec_e codec)
index ab1f4c1b18529472a604fc03298b36ef654a0cf2..8b7455364e8b51edf1d930de1fa730a10a898b24 100644 (file)
@@ -3128,10 +3128,9 @@ static convert_codec_func convert_codec_funcs[] = {
        [WEBRTC_MEDIA_TYPE_VIDEO] = __convert_video_codec,
 };
 
-int _foreach_supported_transceiver_codec(webrtc_s *webrtc, unsigned int source_id, webrtc_media_type_e media_type, webrtc_media_source_supported_transceiver_codec_cb callback, void *user_data)
+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 ret;
-       webrtc_gst_slot_s *source;
        const ini_item_media_source_s *ini_source;
        webrtc_transceiver_codec_e codec;
        GStrv codecs;
@@ -3141,25 +3140,32 @@ int _foreach_supported_transceiver_codec(webrtc_s *webrtc, unsigned int source_i
        RET_VAL_IF(callback == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "callback is NULL");
        RET_VAL_IF(webrtc->gst.webrtcbin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "webrtcbin is NULL");
        RET_VAL_IF(webrtc->gst.source_slots == NULL, WEBRTC_ERROR_INVALID_OPERATION, "source_slots 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((source->type == WEBRTC_MEDIA_SOURCE_TYPE_FILE), WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the file source");
-       RET_VAL_IF((source->type == WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET), WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the media packet source");
+       RET_VAL_IF((source_type == WEBRTC_MEDIA_SOURCE_TYPE_FILE), WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the file source");
+       RET_VAL_IF((source_type == WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET), WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the media packet source");
+       RET_VAL_IF((source_type > WEBRTC_MEDIA_SOURCE_TYPE_NULL), WEBRTC_ERROR_INVALID_PARAMETER, "invalid source_type");
 
-       ini_source = _ini_get_source_by_type(&webrtc->ini, source->type);
+       ini_source = _ini_get_source_by_type(&webrtc->ini, source_type);
        RET_VAL_IF(ini_source == NULL, WEBRTC_ERROR_INVALID_OPERATION, "ini_source is NULL");
 
-       if (media_type == WEBRTC_MEDIA_TYPE_AUDIO && source->media_types & MEDIA_TYPE_AUDIO) {
+       if (media_type == WEBRTC_MEDIA_TYPE_AUDIO &&
+               (source_type == WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST ||
+               source_type == WEBRTC_MEDIA_SOURCE_TYPE_MIC ||
+               source_type == WEBRTC_MEDIA_SOURCE_TYPE_NULL)) {
                codecs = ini_source->a_codecs;
 
-       } else if (media_type == WEBRTC_MEDIA_TYPE_VIDEO && source->media_types & MEDIA_TYPE_VIDEO) {
+       } else if (media_type == WEBRTC_MEDIA_TYPE_VIDEO &&
+               (source_type == WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST ||
+               source_type == WEBRTC_MEDIA_SOURCE_TYPE_CAMERA ||
+               source_type == WEBRTC_MEDIA_SOURCE_TYPE_SCREEN ||
+               source_type == WEBRTC_MEDIA_SOURCE_TYPE_NULL)) {
                codecs = ini_source->v_codecs;
 
        } else {
-               LOG_ERROR("invalid media_type[%d] for source[media_types:0x%x, id:%u]", media_type, source->media_types, source_id);
+               LOG_ERROR("invalid media_type[%d] for source_type[%u]", media_type, source_type);
                return WEBRTC_ERROR_INVALID_PARAMETER;
        }
 
-       LOG_INFO("webrtc[%p] source_id[%u] media_type[%d] callback[%p] user_data[%p]", webrtc, source_id, media_type, callback, user_data);
+       LOG_INFO("webrtc[%p] source_type[%u] media_type[%d] callback[%p] user_data[%p]", webrtc, source_type, media_type, callback, user_data);
 
        for (i = 0; i < g_strv_length(codecs); i++) {
                if ((ret = convert_codec_funcs[media_type](codecs[i], &codec)) != WEBRTC_ERROR_NONE)
index cceff768da56ca6e960b97bf3aab318c1f58bdd5..8f5b61746c431369bd1b1edd51c130e800a95cbb 100644 (file)
@@ -960,13 +960,13 @@ static bool __supported_codec_cb(webrtc_transceiver_codec_e codec, void *user_da
        return true;
 }
 
-static void _webrtc_media_source_foreach_supported_transceiver_codec(int index, unsigned int source_id, webrtc_media_type_e media_type)
+static void _webrtc_media_source_foreach_supported_transceiver_codec(int index, webrtc_media_source_type_e source_type, webrtc_media_type_e media_type)
 {
-       int ret = webrtc_media_source_foreach_supported_transceiver_codec(g_ad.conns[index].webrtc, source_id, media_type, __supported_codec_cb, NULL);
+       int ret = webrtc_media_source_foreach_supported_transceiver_codec(g_ad.conns[index].webrtc, source_type, media_type, __supported_codec_cb, NULL);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
-       g_print("webrtc_media_source_foreach_supported_transceiver_codec() success, source_id[%u], media_type[%s]\n",
-               source_id, g_webrtc_media_type_str[media_type]);
+       g_print("webrtc_media_source_foreach_supported_transceiver_codec() success, source_type[%u], media_type[%s]\n",
+               source_type, g_webrtc_media_type_str[media_type]);
 }
 
 static void _webrtc_media_source_get_transceiver_codec(int index, unsigned int source_id, webrtc_media_type_e media_type)
@@ -4652,19 +4652,19 @@ static void test_webrtc_media_source(char *cmd)
                break;
        }
        case CURRENT_STATUS_MEDIA_SOURCE_FOREACH_SUPPORTED_TRANSCEIVER_CODEC: {
-               static unsigned int id;
+               static unsigned int source_type;
                static unsigned int media_type;
                value = atoi(cmd);
 
                switch (g_ad.input_count) {
                case 0:
-                       id = value;
+                       source_type = value - 1;
                        g_ad.input_count++;
                        break;
                case 1:
                        media_type = value - 1;
-                       _webrtc_media_source_foreach_supported_transceiver_codec(0, id, media_type);
-                       id = media_type = 0;
+                       _webrtc_media_source_foreach_supported_transceiver_codec(0, source_type, media_type);
+                       source_type = media_type = 0;
                        g_ad.input_count = 0;
                        reset_menu_state();
                        break;
index 0cca0b7347a9c23de00458ee14f45370330f110d..f4f9c102951040a63faeb04b778e61039f582352 100644 (file)
@@ -375,7 +375,7 @@ void display_menu_webrtc_media_source(void)
                break;
        case CURRENT_STATUS_MEDIA_SOURCE_FOREACH_SUPPORTED_TRANSCEIVER_CODEC:
                if (get_appdata()->input_count == 0)
-                       g_print("*** input source id.\n");
+                       g_print("*** input media source type.(1:audiotest, 2:videotest, 3:mic, 4:camera, 5:screen, 6:file, 7:media packet, 8:null)\n");
                else if (get_appdata()->input_count == 1)
                        g_print("*** input media type.(1:audio 2:video)\n");
                break;