From 646a6ac0d7065a162cd1daf1082604d42f6cb68c Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Fri, 25 Nov 2022 12:02:55 +0900 Subject: [PATCH] webrtc_internal: Add webrtc_get_video_resolution() API Missing preconditions are added to doxygen of some functions. [Version] 0.3.266 [Issue Type] Internal API Change-Id: I3ccfbf39e122a753023dafe16e5a13f36513a039 --- include/webrtc_internal.h | 19 +++++++++++++++++++ include/webrtc_private.h | 1 + packaging/capi-media-webrtc.spec | 2 +- src/webrtc_internal.c | 16 ++++++++++++++++ src/webrtc_sink.c | 23 +++++++++++++++++++++++ 5 files changed, 60 insertions(+), 1 deletion(-) diff --git a/include/webrtc_internal.h b/include/webrtc_internal.h index 1e5338ec..e93702de 100644 --- a/include/webrtc_internal.h +++ b/include/webrtc_internal.h @@ -115,6 +115,7 @@ int webrtc_set_ecore_wl_display(webrtc_h webrtc, unsigned int track_id, void *ec * @retval #WEBRTC_ERROR_NONE Successful * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation + * @pre webrtc_track_added_cb() must be set by calling webrtc_set_track_added_cb(). * @pre Call webrtc_set_sound_stream_info() before calling this function. * @see webrtc_get_audio_mute() */ @@ -133,11 +134,29 @@ int webrtc_set_audio_mute(webrtc_h webrtc, unsigned int track_id, bool mute); * @retval #WEBRTC_ERROR_NONE Successful * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation + * @pre webrtc_track_added_cb() must be set by calling webrtc_set_track_added_cb(). * @pre Call webrtc_set_sound_stream_info() before calling this function. * @see webrtc_set_audio_mute() */ int webrtc_get_audio_mute(webrtc_h webrtc, unsigned int track_id, bool *muted); +/** + * @internal + * @brief Gets the video resolution of the video track. + * @since_tizen 7.0 + * @param[in] webrtc WebRTC handle + * @param[in] track_id The track id + * @param[out] width The video width + * @param[out] height The video height + * @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 webrtc_track_added_cb() must be set by calling webrtc_set_track_added_cb(). + */ +int webrtc_get_video_resolution(webrtc_h webrtc, unsigned int track_id, int *width, int *height); + /** * @internal * @brief Sets a video loopback to render the video frames of the media source to an ecore wayland display. diff --git a/include/webrtc_private.h b/include/webrtc_private.h index 115c4a76..652f90d9 100644 --- a/include/webrtc_private.h +++ b/include/webrtc_private.h @@ -764,6 +764,7 @@ int _set_display_visible_to_sink(webrtc_s *webrtc, unsigned int track_id, bool v int _get_display_visible_from_sink(webrtc_s *webrtc, unsigned int track_id, bool *visible); int _set_audio_mute_to_sink(webrtc_s *webrtc, unsigned int track_id, bool mute); int _get_audio_mute_from_sink(webrtc_s *webrtc, unsigned int track_id, bool *muted); +int _get_video_resolution_from_sink(webrtc_s *webrtc, unsigned int track_id, int *width, int *height); /* sink dump */ GstPadProbeReturn _depayloaded_data_probe_cb(GstPad *pad, GstPadProbeInfo *info, gpointer user_data); diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index 5e528962..1b87e83d 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.265 +Version: 0.3.266 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_internal.c b/src/webrtc_internal.c index bea9050f..6b268904 100644 --- a/src/webrtc_internal.c +++ b/src/webrtc_internal.c @@ -70,6 +70,22 @@ int webrtc_get_audio_mute(webrtc_h webrtc, unsigned int track_id, bool *muted) return _get_audio_mute_from_sink(_webrtc, track_id, muted); } +int webrtc_get_video_resolution(webrtc_h webrtc, unsigned int track_id, int *width, int *height) +{ + 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(width == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "width is NULL"); + RET_VAL_IF(height == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "height is NULL"); + + locker = g_mutex_locker_new(&_webrtc->mutex); + + RET_VAL_IF(_webrtc->track_added_cb.callback == NULL, WEBRTC_ERROR_INVALID_OPERATION, "track added callback was not set"); + + return _get_video_resolution_from_sink(_webrtc, track_id, width, height); +} + int webrtc_media_source_set_video_loopback_to_ecore_wl(webrtc_h webrtc, unsigned int source_id, void *ecore_wl_window, unsigned int *track_id) { int ret = WEBRTC_ERROR_NONE; diff --git a/src/webrtc_sink.c b/src/webrtc_sink.c index aa44f780..ff7bba40 100644 --- a/src/webrtc_sink.c +++ b/src/webrtc_sink.c @@ -1282,4 +1282,27 @@ int _get_audio_mute_from_sink(webrtc_s *webrtc, unsigned int track_id, bool *mut return WEBRTC_ERROR_NONE; } +int _get_video_resolution_from_sink(webrtc_s *webrtc, unsigned int track_id, int *width, int *height) +{ + webrtc_gst_slot_s *sink; + + RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL"); + RET_VAL_IF(track_id == 0, WEBRTC_ERROR_INVALID_PARAMETER, "track id is 0"); + RET_VAL_IF(width == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "width is NULL"); + RET_VAL_IF(height == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "height is NULL"); + + sink = __find_sink_slot_by_id(webrtc, track_id); + RET_VAL_IF(sink == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "sink is NULL"); + RET_VAL_IF(sink->bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL"); + RET_VAL_IF(sink->encoded_frame_cb != NULL, WEBRTC_ERROR_INVALID_OPERATION, "it may be a forwarding sink for encoded frame callback"); + RET_VAL_IF((sink->media_types & MEDIA_TYPE_VIDEO) == 0x0, WEBRTC_ERROR_INVALID_OPERATION, "it's not a video track"); + + *width = sink->video_info.width; + *height = sink->video_info.height; + + LOG_INFO("webrtc[%p] track_id[%u] width[%d] height[%d]", webrtc, track_id, *width, *height); + + return WEBRTC_ERROR_NONE; +} + //LCOV_EXCL_STOP -- 2.34.1