From: Sangchul Lee Date: Mon, 20 Nov 2023 08:48:38 +0000 (+0900) Subject: webrtc_internal: Add webrtc_set_display_qos() X-Git-Tag: accepted/tizen/unified/20231205.171423~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=db85ac62a33b85dcbcbdfdefc4e9afe0c689eca0;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc_internal: Add webrtc_set_display_qos() [Version] 0.4.23 [Issue Type] Internal API Change-Id: I2a644795109b9534fc1ad65499c3ffb62c7ea3ec Signed-off-by: Sangchul Lee --- diff --git a/include/webrtc_internal.h b/include/webrtc_internal.h index c315e95d..4a71647f 100644 --- a/include/webrtc_internal.h +++ b/include/webrtc_internal.h @@ -169,6 +169,28 @@ int webrtc_set_ecore_wl_display(webrtc_h webrtc, unsigned int track_id, void *ec */ int webrtc_set_display_surface_id(webrtc_h webrtc, unsigned int track_id, int surface_id, int x, int y, int width, int height); +/** + * @brief Sets a display QoS. + * @since_tizen 7.0 + * @remarks Call this function within webrtc_track_added_cb(), otherwise #WEBRTC_ERROR_INVALID_OPERATION will be returned.\n + * If webrtc_set_encoded_video_frame_cb() has been called, it will return #WEBRTC_ERROR_INVALID_OPERATION.\n + * It'll set qos property of video sink that generates Quality-of-Service events upstream in some cases.\n + * The default value is @c true. + * @param[in] webrtc WebRTC handle + * @param[in] track_id The track id + * @param[in] enable Enable or not (@c true = enable, @c false = disable) + * @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(). + * @pre webrtc_set_display() or webrtc_set_display_surface_id() must be called before calling this function. + * @see webrtc_set_track_added_cb() + * @see webrtc_unset_track_added_cb() + */ +int webrtc_set_display_qos(webrtc_h webrtc, unsigned int track_id, bool enable); + /** * @internal * @brief Gets the video resolution of the video track. diff --git a/include/webrtc_private.h b/include/webrtc_private.h index 1efae2d0..b723e273 100644 --- a/include/webrtc_private.h +++ b/include/webrtc_private.h @@ -439,6 +439,7 @@ typedef struct _webrtc_display { mm_display_interface_h mm_display; webrtc_display_mode_e mode; bool visible; + bool qos; webrtc_tbm_s *tbm; GstElement *sink_element; } webrtc_display_s; @@ -803,6 +804,7 @@ int _set_display_mode_to_sink(webrtc_s *webrtc, unsigned int track_id, webrtc_di int _get_display_mode_from_sink(webrtc_s *webrtc, unsigned int track_id, webrtc_display_mode_e *mode); int _set_display_visible_to_sink(webrtc_s *webrtc, unsigned int track_id, bool visible); int _get_display_visible_from_sink(webrtc_s *webrtc, unsigned int track_id, bool *visible); +int _set_display_qos_to_sink(webrtc_s *webrtc, unsigned int track_id, bool enable); 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); diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index 3823d5b1..d5ec1944 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.4.22 +Version: 0.4.23 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_display.c b/src/webrtc_display.c index 936ee93a..ee5cd589 100644 --- a/src/webrtc_display.c +++ b/src/webrtc_display.c @@ -782,9 +782,10 @@ webrtc_display_s *_alloc_display(bool use_mm_display) g_mutex_init(&display->mutex); display->mode = WEBRTC_DISPLAY_MODE_LETTER_BOX; display->visible = true; + display->qos = true; - LOG_DEBUG("use_mm_display[%d], display[%p, mm_display:%p, mode:%u, visible:%u]", - use_mm_display, display, display->mm_display, display->mode, display->visible); + LOG_DEBUG("use_mm_display[%d], display[%p, mm_display:%p, mode:%u, visible:%u, qos:%u]", + use_mm_display, display, display->mm_display, display->mode, display->visible, display->qos); return display; } diff --git a/src/webrtc_internal.c b/src/webrtc_internal.c index 8ee4a47d..9d80bf5c 100644 --- a/src/webrtc_internal.c +++ b/src/webrtc_internal.c @@ -59,6 +59,24 @@ int webrtc_set_display_surface_id(webrtc_h webrtc, unsigned int track_id, int su return _set_display_surface_id_to_sink(webrtc, track_id, surface_id, x, y, width, height); } +int webrtc_set_display_qos(webrtc_h webrtc, unsigned int track_id, bool enable) +{ + 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(track_id == 0, WEBRTC_ERROR_INVALID_PARAMETER, "track id is 0"); + + 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"); + RET_VAL_IF(_webrtc->encoded_video_frame_cb.callback, WEBRTC_ERROR_INVALID_OPERATION, "encoded video frame callback was set"); + RET_VAL_IF(!_is_owner_of_track_build_context(_webrtc, track_id), WEBRTC_ERROR_INVALID_OPERATION, + "this function should be called within the track added callback"); + + return _set_display_qos_to_sink(webrtc, track_id, enable); +} + int webrtc_get_video_resolution(webrtc_h webrtc, unsigned int track_id, int *width, int *height) { g_autoptr(GMutexLocker) locker = NULL; diff --git a/src/webrtc_sink.c b/src/webrtc_sink.c index 7fdde98a..a5fc7cb2 100644 --- a/src/webrtc_sink.c +++ b/src/webrtc_sink.c @@ -199,6 +199,7 @@ static int __build_videosink(webrtc_s *webrtc, GstElement *decodebin, GstPad *sr "use-tbm", sink->av[AV_IDX_VIDEO].render.hw_decoder_used, "display-geometry-method", (gint)sink->display->mode, /* 0: letter box, 1: origin size, 2: full screen */ "visible", (gboolean)sink->display->visible, + "qos", (gboolean)sink->display->qos, NULL); /* FIXME: The order of setting property and display is important when 'use-tbm' is true. The reverse does not work */ @@ -223,7 +224,7 @@ static int __build_videosink(webrtc_s *webrtc, GstElement *decodebin, GstPad *sr GstCaps *caps; g_object_set(G_OBJECT(videosink), "sync", TRUE, - "qos", TRUE, + "qos", (gboolean)sink->display->qos, "signal-handoffs", TRUE, NULL); _connect_and_append_signal(&sink->signals, (GObject *)videosink, "handoff", G_CALLBACK(_video_stream_decoded_cb), sink->display); @@ -1291,6 +1292,27 @@ int _get_display_visible_from_sink(webrtc_s *webrtc, unsigned int track_id, bool return WEBRTC_ERROR_NONE; } +int _set_display_qos_to_sink(webrtc_s *webrtc, unsigned int track_id, bool enable) +{ + 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"); + + 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"); + RET_VAL_IF(sink->display == NULL, WEBRTC_ERROR_INVALID_OPERATION, "display is NULL"); + + LOG_INFO("webrtc[%p] track_id[%u] qos[%d]", webrtc, track_id, enable); + + sink->display->qos = enable; + + return WEBRTC_ERROR_NONE; +} + int _set_audio_mute_to_sink(webrtc_s *webrtc, unsigned int track_id, bool mute) { webrtc_gst_slot_s *sink;