From: Sangchul Lee Date: Mon, 27 Jun 2022 01:17:33 +0000 (+0900) Subject: Revise webrtc_media_source_foreach_supported_transceiver_codec() X-Git-Tag: submit/tizen/20220627.062515~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=62d909e95f0b34c69741f3727be44de4c0830ba3;p=platform%2Fcore%2Fapi%2Fwebrtc.git Revise webrtc_media_source_foreach_supported_transceiver_codec() 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 --- diff --git a/include/webrtc.h b/include/webrtc.h index 14b7beca..a56dcdeb 100644 --- a/include/webrtc.h +++ b/include/webrtc.h @@ -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. diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index e4ffd396..577451d6 100644 --- a/packaging/capi-media-webrtc.spec +++ b/packaging/capi-media-webrtc.spec @@ -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 diff --git a/src/webrtc.c b/src/webrtc.c index ce3c569c..aef2e7e4 100644 --- a/src/webrtc.c +++ b/src/webrtc.c @@ -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) diff --git a/src/webrtc_source.c b/src/webrtc_source.c index ab1f4c1b..8b745536 100644 --- a/src/webrtc_source.c +++ b/src/webrtc_source.c @@ -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) diff --git a/test/webrtc_test.c b/test/webrtc_test.c index cceff768..8f5b6174 100644 --- a/test/webrtc_test.c +++ b/test/webrtc_test.c @@ -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; diff --git a/test/webrtc_test_menu.c b/test/webrtc_test_menu.c index 0cca0b73..f4f9c102 100644 --- a/test/webrtc_test_menu.c +++ b/test/webrtc_test_menu.c @@ -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;