From: Sangchul Lee Date: Thu, 28 Mar 2024 02:34:30 +0000 (+0900) Subject: Remove state constraint on functions for media source X-Git-Tag: accepted/tizen/unified/20240618.010058~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bad0a43de61fadcd8d07620470d223a292528b30;p=platform%2Fcore%2Fapi%2Fwebrtc.git Remove state constraint on functions for media source It allows for easing the state constraints for below functions. : webrtc_add_media_source() : webrtc_remove_media_source() : webrtc_media_source_set_transceiver_direction() : webrtc_media_source_set_transceiver_codec() : webrtc_mic_source_set_sound_stream_info() : webrtc_camera_source_set_device_id() : webrtc_media_packet_source_set_format() : webrtc_file_source_set_path() Below are internal functions. : webrtc_add_media_source_internal() : webrtc_media_source_set_payload_type() [Version] 1.0.1 [Issue Type] Release state constraints Change-Id: Idbad43285d35ccf3842e91ce31683ff748864a62 Signed-off-by: Sangchul Lee --- diff --git a/include/webrtc.h b/include/webrtc.h index 90a05d54..a9cbebf7 100644 --- a/include/webrtc.h +++ b/include/webrtc.h @@ -1038,7 +1038,8 @@ int webrtc_get_state(webrtc_h webrtc, webrtc_state_e *state); * The recorder privilege(%http://tizen.org/privilege/recorder) should be added if @a type is #WEBRTC_MEDIA_SOURCE_TYPE_MIC.\n * With @a type of #WEBRTC_MEDIA_SOURCE_TYPE_NULL, you can configure a transceiver only for receiving audio or video stream. (Since 7.0)\n * @a type of #WEBRTC_MEDIA_SOURCE_TYPE_SCREEN is not allowed to be used by third-party applications due to the security reasons. (Since 7.0)\n - * The display feature(%http://tizen.org/feature/display) is required if @a type is #WEBRTC_MEDIA_SOURCE_TYPE_SCREEN. (Since 8.0) + * The display feature(%http://tizen.org/feature/display) is required if @a type is #WEBRTC_MEDIA_SOURCE_TYPE_SCREEN. (Since 8.0)\n + * #WEBRTC_ERROR_INVALID_STATE will no longer occur. (Since 9.0) * @param[in] webrtc WebRTC handle * @param[in] type The media source type to be added * @param[out] source_id The media source id @@ -1049,8 +1050,6 @@ int webrtc_get_state(webrtc_h webrtc, webrtc_state_e *state); * @retval #WEBRTC_ERROR_PERMISSION_DENIED Permission denied * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation - * @retval #WEBRTC_ERROR_INVALID_STATE Invalid state - * @pre @a webrtc state must be set to #WEBRTC_STATE_IDLE. * @see webrtc_remove_media_source() * @see webrtc_media_source_set_transceiver_direction() * @see webrtc_media_source_get_transceiver_direction() @@ -1087,6 +1086,7 @@ int webrtc_add_media_source(webrtc_h webrtc, webrtc_media_source_type_e type, un /** * @brief Removes the media source. * @since_tizen 6.5 + * @remarks #WEBRTC_ERROR_INVALID_STATE will no longer occur. (Since 9.0) * @param[in] webrtc WebRTC handle * @param[in] source_id The media source id to be removed * @return @c 0 on success, @@ -1094,9 +1094,7 @@ int webrtc_add_media_source(webrtc_h webrtc, webrtc_media_source_type_e type, un * @retval #WEBRTC_ERROR_NONE Successful * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation - * @retval #WEBRTC_ERROR_INVALID_STATE Invalid state * @pre Add media source to @a webrtc to get @a source_id by calling webrtc_add_media_source(). - * @pre @a webrtc state must be set to #WEBRTC_STATE_IDLE. * @see webrtc_add_media_source() */ int webrtc_remove_media_source(webrtc_h webrtc, unsigned int source_id); @@ -1104,7 +1102,8 @@ int webrtc_remove_media_source(webrtc_h webrtc, unsigned int source_id); /** * @brief Sets the transceiver direction to the media source with specified media type. * @since_tizen 6.5 - * @remarks If @a source_id is a media source of #WEBRTC_MEDIA_SOURCE_TYPE_NULL, it only allows #WEBRTC_TRANSCEIVER_DIRECTION_RECVONLY. (Since 7.0) + * @remarks If @a source_id is a media source of #WEBRTC_MEDIA_SOURCE_TYPE_NULL, it only allows #WEBRTC_TRANSCEIVER_DIRECTION_RECVONLY. (Since 7.0)\n + * #WEBRTC_ERROR_INVALID_STATE will no longer occur. (Since 9.0) * @param[in] webrtc WebRTC handle * @param[in] source_id The media source id * @param[in] media_type The media type @@ -1114,10 +1113,8 @@ int webrtc_remove_media_source(webrtc_h webrtc, unsigned int source_id); * @retval #WEBRTC_ERROR_NONE Successful * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation - * @retval #WEBRTC_ERROR_INVALID_STATE Invalid state * @pre Add media source to @a webrtc to get @a source_id by calling webrtc_add_media_source(). * @pre webrtc_media_packet_source_set_format() must be called if @a source_id is a media source of #WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET. - * @pre @a webrtc state must be set to #WEBRTC_STATE_IDLE. * @see webrtc_media_source_get_transceiver_direction() */ int webrtc_media_source_set_transceiver_direction(webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, webrtc_transceiver_direction_e direction); @@ -1167,7 +1164,8 @@ int webrtc_media_source_foreach_supported_transceiver_codec(webrtc_h webrtc, web * @brief Sets the transceiver codec to the media source. * @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, - * this function will return #WEBRTC_ERROR_INVALID_PARAMETER. + * this function will return #WEBRTC_ERROR_INVALID_PARAMETER.\n + * #WEBRTC_ERROR_INVALID_STATE will no longer occur. (Since 9.0) * @param[in] webrtc WebRTC handle * @param[in] source_id The media source id * @param[in] media_type The media type @@ -1177,9 +1175,7 @@ int webrtc_media_source_foreach_supported_transceiver_codec(webrtc_h webrtc, web * @retval #WEBRTC_ERROR_NONE Successful * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation - * @retval #WEBRTC_ERROR_INVALID_STATE Invalid state * @pre Add media source to @a webrtc to get @a source_id by calling webrtc_add_media_source(). - * @pre @a webrtc state must be set to #WEBRTC_STATE_IDLE. * @see webrtc_media_source_get_transceiver_codec() * @see webrtc_media_source_foreach_supported_transceiver_codec() */ @@ -1416,7 +1412,8 @@ int webrtc_media_source_get_video_framerate(webrtc_h webrtc, unsigned int source * #SOUND_STREAM_TYPE_VOICE_RECOGNITION\n * #SOUND_STREAM_TYPE_VOIP\n * #SOUND_STREAM_TYPE_MEDIA_EXTERNAL_ONLY\n - * For more details, please refer to @ref CAPI_MEDIA_SOUND_MANAGER_MODULE. + * For more details, please refer to @ref CAPI_MEDIA_SOUND_MANAGER_MODULE.\n + * #WEBRTC_ERROR_INVALID_STATE will no longer occur. (Since 9.0) * @param[in] webrtc WebRTC handle * @param[in] source_id The mic source id * @param[in] stream_info The sound stream information @@ -1424,8 +1421,6 @@ int webrtc_media_source_get_video_framerate(webrtc_h webrtc, unsigned int source * @retval #WEBRTC_ERROR_NONE Successful * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation - * @retval #WEBRTC_ERROR_INVALID_STATE Invalid state - * @pre @a webrtc state must be set to #WEBRTC_STATE_IDLE. * @see #sound_stream_info_h * @see sound_manager_create_stream_information() * @see sound_manager_destroy_stream_information() @@ -1435,6 +1430,7 @@ int webrtc_mic_source_set_sound_stream_info(webrtc_h webrtc, unsigned int source /** * @brief Sets a camera device id to the camera source. * @since_tizen 7.0 + * @remarks #WEBRTC_ERROR_INVALID_STATE will no longer occur. (Since 9.0) * @param[in] webrtc WebRTC handle * @param[in] source_id The camera source id * @param[in] device_id The camera device id @@ -1443,9 +1439,7 @@ int webrtc_mic_source_set_sound_stream_info(webrtc_h webrtc, unsigned int source * @retval #WEBRTC_ERROR_NONE Successful * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation - * @retval #WEBRTC_ERROR_INVALID_STATE Invalid state * @pre Add camera source to @a webrtc to get @a source_id by calling webrtc_add_media_source(). - * @pre @a webrtc state must be set to #WEBRTC_STATE_IDLE. * @see webrtc_add_media_source() * @see webrtc_camera_source_get_device_id() */ @@ -1519,7 +1513,8 @@ int webrtc_media_packet_source_unset_buffer_state_changed_cb(webrtc_h webrtc, un * #MEDIA_FORMAT_VP9\n * #MEDIA_FORMAT_I420\n * #MEDIA_FORMAT_NV12\n - * For more details, please refer to @ref CAPI_MEDIA_TOOL_MEDIA_FORMAT_MODULE. + * For more details, please refer to @ref CAPI_MEDIA_TOOL_MEDIA_FORMAT_MODULE.\n + * #WEBRTC_ERROR_INVALID_STATE will no longer occur. (Since 9.0) * @param[in] webrtc WebRTC handle * @param[in] source_id The media packet source id * @param[in] format The media format @@ -1528,9 +1523,7 @@ int webrtc_media_packet_source_unset_buffer_state_changed_cb(webrtc_h webrtc, un * @retval #WEBRTC_ERROR_NONE Successful * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation - * @retval #WEBRTC_ERROR_INVALID_STATE Invalid state * @pre Add media packet source to @a webrtc to get @a source_id by calling webrtc_add_media_source(). - * @pre @a webrtc state must be set to #WEBRTC_STATE_IDLE. * @see webrtc_media_packet_source_push_packet() * @see webrtc_media_packet_source_set_buffer_state_changed_cb() */ @@ -1560,7 +1553,8 @@ int webrtc_media_packet_source_push_packet(webrtc_h webrtc, unsigned int source_ * @brief Sets media path of the file source. * @since_tizen 7.0 * @remarks %http://tizen.org/privilege/mediastorage is needed if path is relevant to internal media storage.\n - * %http://tizen.org/privilege/externalstorage is needed if path is relevant to external media storage. + * %http://tizen.org/privilege/externalstorage is needed if path is relevant to external media storage.\n + * #WEBRTC_ERROR_INVALID_STATE will no longer occur. (Since 9.0) * @param[in] webrtc WebRTC handle * @param[in] source_id The file source id * @param[in] path The media path @@ -1569,9 +1563,7 @@ int webrtc_media_packet_source_push_packet(webrtc_h webrtc, unsigned int source_ * @retval #WEBRTC_ERROR_NONE Successful * @retval #WEBRTC_ERROR_PERMISSION_DENIED Permission denied * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #WEBRTC_ERROR_INVALID_STATE Invalid state * @pre Add file source to @a webrtc to get @a source_id by calling webrtc_add_media_source(). - * @pre @a webrtc state must be set to #WEBRTC_STATE_IDLE. */ int webrtc_file_source_set_path(webrtc_h webrtc, unsigned int source_id, const char *path); diff --git a/include/webrtc_internal.h b/include/webrtc_internal.h index 3543e258..3f848432 100644 --- a/include/webrtc_internal.h +++ b/include/webrtc_internal.h @@ -261,6 +261,7 @@ int webrtc_media_source_set_video_loopback_to_ecore_wl(webrtc_h webrtc, unsigned * @internal * @brief Adds an internal media source. * @since_tizen 6.5 + * @remarks #WEBRTC_ERROR_INVALID_STATE will no longer occur. (Since 9.0) * @param[in] webrtc WebRTC handle * @param[in] type The media source type to be added * @param[out] source_id The media source id @@ -270,8 +271,6 @@ int webrtc_media_source_set_video_loopback_to_ecore_wl(webrtc_h webrtc, unsigned * @retval #WEBRTC_ERROR_NOT_SUPPORTED Not supported * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation - * @retval #WEBRTC_ERROR_INVALID_STATE Invalid state - * @pre @a webrtc state must be set to #WEBRTC_STATE_IDLE. * @see webrtc_remove_media_source() * @see webrtc_media_source_set_transceiver_direction() * @see webrtc_media_source_get_transceiver_direction() @@ -288,7 +287,8 @@ int webrtc_add_media_source_internal(webrtc_h webrtc, webrtc_media_source_type_i * @internal * @brief Sets the payload type to the media source. * @since_tizen 7.0 - * @remarks This function would be useful when @a webrtc is operated as an answerer and a remote peer is using another implementation, not this API. + * @remarks This function would be useful when @a webrtc is operated as an answerer and a remote peer is using another implementation, not this API.\n + * #WEBRTC_ERROR_INVALID_STATE will no longer occur. (Since 9.0) * @param[in] webrtc WebRTC handle * @param[in] source_id The media source id * @param[in] media_type The media type @@ -297,9 +297,7 @@ int webrtc_add_media_source_internal(webrtc_h webrtc, webrtc_media_source_type_i * otherwise a negative error value * @retval #WEBRTC_ERROR_NONE Successful * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #WEBRTC_ERROR_INVALID_STATE Invalid state * @pre Add media source to @a webrtc to get @a source_id by calling webrtc_add_media_source(). - * @pre @a webrtc state must be set to #WEBRTC_STATE_IDLE. * @see webrtc_media_source_get_payload_type() */ int webrtc_media_source_set_payload_type(webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, unsigned int pt); diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index 494ae155..b68b69bd 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: 1.0.0 +Version: 1.0.1 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc.c b/src/webrtc.c index ab481e46..be08e2d3 100644 --- a/src/webrtc.c +++ b/src/webrtc.c @@ -337,8 +337,6 @@ int webrtc_add_media_source(webrtc_h webrtc, webrtc_media_source_type_e type, un locker = g_mutex_locker_new(&_webrtc->mutex); - RET_VAL_IF(_webrtc->state != WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, "the state should be IDLE"); - return _add_media_source(webrtc, type, source_id); } @@ -351,8 +349,6 @@ int webrtc_remove_media_source(webrtc_h webrtc, unsigned int source_id) locker = g_mutex_locker_new(&_webrtc->mutex); - RET_VAL_IF(_webrtc->state != WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, "the state should be IDLE"); - return _remove_media_source(webrtc, source_id); } @@ -365,8 +361,6 @@ int webrtc_media_source_set_transceiver_direction(webrtc_h webrtc, unsigned int locker = g_mutex_locker_new(&_webrtc->mutex); - RET_VAL_IF(_webrtc->state != WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, "the state should be IDLE"); - return _set_transceiver_direction(webrtc, source_id, media_type, direction); } @@ -405,8 +399,6 @@ int webrtc_media_source_set_transceiver_codec(webrtc_h webrtc, unsigned int sour locker = g_mutex_locker_new(&_webrtc->mutex); - RET_VAL_IF(_webrtc->state != WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, "the state should be IDLE"); - return _set_transceiver_codec(webrtc, source_id, media_type, codec); } @@ -569,8 +561,6 @@ int webrtc_mic_source_set_sound_stream_info(webrtc_h webrtc, unsigned int source locker = g_mutex_locker_new(&_webrtc->mutex); - RET_VAL_IF(_webrtc->state != WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, "the state should be IDLE"); - return _set_sound_stream_info(webrtc, source_id, stream_info); } @@ -583,8 +573,6 @@ int webrtc_camera_source_set_device_id(webrtc_h webrtc, unsigned int source_id, locker = g_mutex_locker_new(&_webrtc->mutex); - RET_VAL_IF(_webrtc->state != WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, "the state should be IDLE"); - return _set_camera_device_id(webrtc, source_id, device_id); } @@ -665,8 +653,6 @@ int webrtc_media_packet_source_set_format(webrtc_h webrtc, unsigned int source_i locker = g_mutex_locker_new(&_webrtc->mutex); - RET_VAL_IF(_webrtc->state != WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, "the state should be IDLE"); - return _set_media_format(_webrtc, source_id, format); } @@ -704,8 +690,6 @@ int webrtc_file_source_set_path(webrtc_h webrtc, unsigned int source_id, const c locker = g_mutex_locker_new(&_webrtc->mutex); - RET_VAL_IF(_webrtc->state != WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, "the state should be IDLE"); - return _set_media_path(_webrtc, source_id, path); } diff --git a/src/webrtc_internal.c b/src/webrtc_internal.c index 97c38711..e71dc59e 100644 --- a/src/webrtc_internal.c +++ b/src/webrtc_internal.c @@ -141,8 +141,6 @@ int webrtc_add_media_source_internal(webrtc_h webrtc, webrtc_media_source_type_i locker = g_mutex_locker_new(&_webrtc->mutex); - RET_VAL_IF(_webrtc->state != WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, "the state should be IDLE"); - ret = _add_media_source_internal(webrtc, type, source_id); if (ret == WEBRTC_ERROR_NONE) LOG_INFO("source_id[%u]", *source_id); @@ -173,8 +171,6 @@ int webrtc_media_source_set_payload_type(webrtc_h webrtc, unsigned int source_id _media_type = _get_video_media_type(source->av[AV_IDX_VIDEO].codec); RET_VAL_IF(_media_type == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "_media_type is NULL"); - RET_VAL_IF(_webrtc->state != WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, "the state should be IDLE"); - _pt = _get_fixed_payload_type(_media_type); if (_pt != -1 && (unsigned int)_pt != pt) { LOG_ERROR("this media_type[%s] only allows fixed payload type[%d]", _media_type, _pt); @@ -239,8 +235,6 @@ int webrtc_media_source_add_transceiver_encoding(webrtc_h webrtc, unsigned int s locker = g_mutex_locker_new(&_webrtc->mutex); - RET_VAL_IF(_webrtc->state != WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, "the state should be IDLE"); - return _add_transceiver_encoding(webrtc, source_id, media_type, rid, target_bitrate, width, height); } @@ -254,8 +248,6 @@ int webrtc_media_source_remove_transceiver_encoding(webrtc_h webrtc, unsigned in locker = g_mutex_locker_new(&_webrtc->mutex); - RET_VAL_IF(_webrtc->state != WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, "the state should be IDLE"); - return _remove_transceiver_encoding(webrtc, source_id, media_type, rid); }