webrtc_internal: Add webrtc_set_ecore_wl_display() API 11/249111/6
authorSangchul Lee <sc11.lee@samsung.com>
Mon, 7 Dec 2020 06:57:58 +0000 (15:57 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Mon, 14 Dec 2020 05:54:52 +0000 (14:54 +0900)
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 <sc11.lee@samsung.com>
include/webrtc_internal.h [new file with mode: 0644]
include/webrtc_private.h
packaging/capi-media-webrtc.spec
src/webrtc_display.c
src/webrtc_internal.c [new file with mode: 0644]
src/webrtc_sink.c

diff --git a/include/webrtc_internal.h b/include/webrtc_internal.h
new file mode 100644 (file)
index 0000000..55224ce
--- /dev/null
@@ -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__ */
index cd6e5c8e3e66925627104590a1d62087542de75c..9071c85c9c5bad0387dd904360734fe358e8600d 100644 (file)
@@ -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,
index c59435bb384beaf8eb7589f21d79e5b4966fda61..88da9519afc30e5c734fb9cd41becbdffcfb745d 100644 (file)
@@ -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
index 3c33b878812fd9a2608e05bc3f20e90b54760fc4..a47c46f9eac1cbdf8f5f0256c97eaaef58be3b7b 100644 (file)
@@ -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 (file)
index 0000000..3dacc5e
--- /dev/null
@@ -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;
+}
index fbd4d727d0a29abe45353c9c9c7f0b58eee96de1..ee40207d6035a3ee6c0cad126b08b41e252d8d9f 100644 (file)
@@ -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) {