From: Sangchul Lee Date: Mon, 7 Dec 2020 06:57:58 +0000 (+0900) Subject: webrtc_internal: Add webrtc_set_ecore_wl_display() API X-Git-Tag: submit/tizen/20210729.023123~173 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F11%2F249111%2F6;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc_internal: Add webrtc_set_ecore_wl_display() API It can be utilized to set the ecore wayland window. [Version] 0.1.69 [Issue Type] API Change-Id: I036185364c75ab5c6e25c32855e7cabbbdc9bca9 Signed-off-by: Sangchul Lee --- diff --git a/include/webrtc_internal.h b/include/webrtc_internal.h new file mode 100644 index 00000000..55224cec --- /dev/null +++ b/include/webrtc_internal.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __TIZEN_MEDIA_WEBRTC_INTERNAL_H__ +#define __TIZEN_MEDIA_WEBRTC_INTERNAL_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** +* @file webrtc_internal.h +* @brief This file contains the WebRTC internal API. +*/ + +/** +* @addtogroup CAPI_MEDIA_WEBRTC_MODULE +* @{ +*/ + +/** + * @internal + * @brief Set an ecore wayland display to the media track. + * @since_tizen 6.5 + * @remarks Call this function within webrtc_track_added_cb(), otherwise #WEBRTC_ERROR_INVALID_OPERATION will be returned. + * @param[in] webrtc WebRTC handle + * @param[in] track_id The track id + * @param[in] ecore_wl_window The ecore wayland window handle + * @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(). + * @see webrtc_set_track_added_cb() + * @see webrtc_unset_track_added_cb() + */ +int webrtc_set_ecore_wl_display(webrtc_h webrtc, unsigned int track_id, void *ecore_wl_window); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __TIZEN_MEDIA_WEBRTC_INTERNAL_H__ */ diff --git a/include/webrtc_private.h b/include/webrtc_private.h index cd6e5c8e..9071c85c 100644 --- a/include/webrtc_private.h +++ b/include/webrtc_private.h @@ -153,6 +153,8 @@ do { \ g_free(dot_name); \ } while (0) +#define WEBRTC_DISPLAY_TYPE_ECORE_WL 2 + typedef enum { MEDIA_TYPE_AUDIO = 0x01, MEDIA_TYPE_VIDEO = 0x02, diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index c59435bb..88da9519 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.1.68 +Version: 0.1.69 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_display.c b/src/webrtc_display.c index 3c33b878..a47c46f9 100644 --- a/src/webrtc_display.c +++ b/src/webrtc_display.c @@ -638,19 +638,22 @@ static gboolean __set_overlay_display_idle_cb(gpointer user_data) { int ret = MM_ERROR_NONE; webrtc_display_s *display = (webrtc_display_s*)user_data; + mm_display_type_e type = MM_DISPLAY_TYPE_OVERLAY; RET_VAL_IF(display == NULL, G_SOURCE_REMOVE, "display is NULL"); + RET_VAL_IF(display->type != WEBRTC_DISPLAY_TYPE_OVERLAY && display->type != WEBRTC_DISPLAY_TYPE_ECORE_WL, G_SOURCE_REMOVE, + "invalid display type(%d)", display->type); g_mutex_lock(&display->mutex); - ret = mm_display_interface_set_display(display->mm_display, MM_DISPLAY_TYPE_OVERLAY, display->object, &display->overlay_surface_id); - if (ret != MM_ERROR_NONE) { - LOG_ERROR("failed to mm_display_interface_set_display(), ret[0x%x]", ret); - g_mutex_unlock(&display->mutex); - return G_SOURCE_REMOVE; - } + if (display->type == WEBRTC_DISPLAY_TYPE_ECORE_WL) + type = MM_DISPLAY_TYPE_OVERLAY_EXT; - LOG_INFO("overlay_surface_id[%d]", display->overlay_surface_id); + ret = mm_display_interface_set_display(display->mm_display, type, display->object, &display->overlay_surface_id); + if (ret != MM_ERROR_NONE) + LOG_ERROR("failed to mm_display_interface_set_display(), ret[0x%x]", ret); + else + LOG_INFO("overlay_surface_id[%d]", display->overlay_surface_id); g_mutex_unlock(&display->mutex); @@ -694,7 +697,7 @@ static gboolean __set_evas_display_idle_cb(gpointer user_data) int _apply_display(webrtc_display_s *display) { - RET_VAL_IF(display == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "sink is NULL"); + RET_VAL_IF(display == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "display is NULL"); switch (display->type) { case WEBRTC_DISPLAY_TYPE_OVERLAY: @@ -712,6 +715,12 @@ int _apply_display(webrtc_display_s *display) g_idle_add(__set_evas_display_idle_cb, display); break; + case WEBRTC_DISPLAY_TYPE_ECORE_WL: + LOG_DEBUG("it's ECORE_WL type"); + + g_idle_add(__set_overlay_display_idle_cb, display); + break; + default: LOG_ERROR_IF_REACHED("type(%d)", display->type); return WEBRTC_ERROR_INVALID_OPERATION; diff --git a/src/webrtc_internal.c b/src/webrtc_internal.c new file mode 100644 index 00000000..3dacc5e8 --- /dev/null +++ b/src/webrtc_internal.c @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "webrtc.h" +#include "webrtc_private.h" + +int webrtc_set_ecore_wl_display(webrtc_h webrtc, unsigned int track_id, void *ecore_wl_window) +{ + int ret = WEBRTC_ERROR_NONE; + 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"); + RET_VAL_IF(ecore_wl_window == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "ecore_wl_window is NULL"); + + g_mutex_lock(&_webrtc->mutex); + + RET_VAL_WITH_UNLOCK_IF(_webrtc->track_added_cb.callback == NULL, WEBRTC_ERROR_INVALID_OPERATION, &_webrtc->mutex, "callback was not set"); + RET_VAL_WITH_UNLOCK_IF(!_webrtc->inside_track_added_cb, WEBRTC_ERROR_INVALID_OPERATION, &_webrtc->mutex, "this function should be called within the track added callback"); + + ret = _set_display_to_sink(webrtc, track_id, WEBRTC_DISPLAY_TYPE_ECORE_WL, ecore_wl_window); + if (ret == WEBRTC_ERROR_NONE) + LOG_INFO("track_id[%u] type[%d] display[%p]", track_id, WEBRTC_DISPLAY_TYPE_ECORE_WL, ecore_wl_window); + + g_mutex_unlock(&_webrtc->mutex); + + return ret; +} diff --git a/src/webrtc_sink.c b/src/webrtc_sink.c index fbd4d727..ee40207d 100644 --- a/src/webrtc_sink.c +++ b/src/webrtc_sink.c @@ -92,7 +92,8 @@ static int __build_videosink(webrtc_s *webrtc, GstElement *decodebin, GstPad *sr } if (display_is_set) { - if (sink->display->type == WEBRTC_DISPLAY_TYPE_OVERLAY) { + if (sink->display->type == WEBRTC_DISPLAY_TYPE_OVERLAY || + sink->display->type == WEBRTC_DISPLAY_TYPE_ECORE_WL) { gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(videosink), sink->display->overlay_surface_id); } else if (sink->display->type == WEBRTC_DISPLAY_TYPE_EVAS) {