Display type and object can be set to each video sink pipeline.
Now it has a dependency on mm-display-interface.
[Version] 0.1.63
[Issue Type] New feature
Change-Id: I856457101cc858acec86f68a86651bac116e8fdf
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
SET(INC_DIR include)
INCLUDE_DIRECTORIES(${INC_DIR})
-SET(dependents "dlog glib-2.0 gstreamer-1.0 gstreamer-webrtc-1.0 json-glib-1.0 iniparser")
+SET(dependents "dlog glib-2.0 gstreamer-1.0 gstreamer-webrtc-1.0 json-glib-1.0 iniparser mm-common mm-display-interface")
SET(pc_dependents "capi-base-common" )
INCLUDE(FindPkgConfig)
*/
typedef void *webrtc_bytes_data_h;
+/**
+ * @brief WebRTC display handle type.
+ * @since_tizen 6.5
+ */
+typedef void *webrtc_display_h;
+
/**
* @brief Enumeration for WebRTC error.
* @since_tizen 6.5
WEBRTC_DATA_CHANNEL_TYPE_BYTES, /**< Bytes data */
} webrtc_data_channel_type_e;
+/**
+ * @brief Enumeration for WebRTC display type.
+ * @since_tizen 6.5
+ */
+typedef enum
+{
+ WEBRTC_DISPLAY_TYPE_OVERLAY, /**< Overlay */
+ WEBRTC_DISPLAY_TYPE_EVAS, /**< Evas image object */
+} webrtc_display_type_e;
+
/**
* @brief Called when an error occurs.
* @details The following error codes can be received:\n
#include <gst/webrtc/webrtc.h>
#endif
#include <iniparser.h>
+#include <mm_display_interface.h>
#ifdef __cplusplus
extern "C" {
GHashTable *sources;
} webrtc_ini_s;
+typedef struct _webrtc_callbacks {
+ void *callback;
+ void *user_data;
+} webrtc_callbacks_s;
+
+typedef struct _webrtc_display {
+ void *object;
+ int type;
+ webrtc_callbacks_s video_frame_decoded_cb;
+} webrtc_display_s;
+
typedef struct _webrtc_gst_slot_s {
unsigned int id;
GstElement *bin;
int media_types; /* values of media_type_e combined with bitwise 'or' */
int mlines[2]; /* index 0 for audio, 1 for video */
GstElement *webrtcbin;
+ webrtc_display_s display;
} webrtc_gst_slot_s;
typedef struct _webrtc_gst_s {
GHashTable *sink_slots;
} webrtc_gst_s;
-typedef struct _webrtc_callbacks {
- void *callback;
- void *user_data;
-} webrtc_callbacks_s;
-
typedef struct _webrtc_s {
webrtc_ini_s ini;
webrtc_gst_s gst;
+ mm_display_interface_h mm_display;
+
gchar *stun_server_url;
gchar *desc_offer;
gchar *desc_answer;
int _add_no_target_ghostpad_to_slot(webrtc_gst_slot_s *slot, bool is_src, GstPad **new_pad);
int _set_ghost_pad_target(GstPad *ghost_pad, GstElement *target_element, bool is_src);
int _add_rendering_sink_bin(webrtc_s *webrtc, GstPad *src_pad);
+int _set_display_to_sink(webrtc_s *webrtc, unsigned int track_id, unsigned int type, void *display);
void _sink_slot_destroy_cb(gpointer data);
void _source_slot_destroy_cb(gpointer data);
void _generate_dot(webrtc_s *webrtc, const gchar *name);
+void _init_display(webrtc_s *webrtc);
+void _deinit_display(webrtc_s *webrtc);
+int _apply_display(webrtc_s *webrtc, webrtc_display_s *display);
+
int _webrtcbin_create_offer(webrtc_s *webrtc, char **offer);
int _webrtcbin_create_answer(webrtc_s *webrtc, char **answer);
int _webrtcbin_set_session_description(webrtc_s *webrtc, const char *description, bool is_remote);
Name: capi-media-webrtc
Summary: A WebRTC library in Tizen Native API
-Version: 0.1.62
+Version: 0.1.63
Release: 0
Group: Multimedia/API
License: Apache-2.0
BuildRequires: pkgconfig(json-glib-1.0)
BuildRequires: pkgconfig(libsoup-2.4)
BuildRequires: pkgconfig(iniparser)
+BuildRequires: pkgconfig(mm-display-interface)
+BuildRequires: pkgconfig(mm-common)
%description
A WebRTC library in Tizen Native API.
_gst_init(_webrtc);
_gst_build_pipeline(_webrtc);
_init_data_channels(_webrtc);
+ _init_display(_webrtc);
_webrtc->pend_state = WEBRTC_STATE_IDLE;
_webrtc->state = _webrtc->pend_state;
_webrtc->pend_state = WEBRTC_STATE_IDLE;
_webrtc->state = _webrtc->pend_state;
+ _deinit_display(_webrtc);
_destroy_data_channels(_webrtc);
_gst_destroy_pipeline(_webrtc);
_unload_ini(_webrtc);
--- /dev/null
+/*
+ * 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"
+#include <mm_error.h>
+
+int _apply_display(webrtc_s *webrtc, webrtc_display_s *display)
+{
+ RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
+ RET_VAL_IF(display == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "sink is NULL");
+
+ switch (display->type) {
+ case WEBRTC_DISPLAY_TYPE_OVERLAY:
+ /* TODO: Implemenation */
+ LOG_DEBUG("it's OVERLAY type");
+ break;
+
+ case WEBRTC_DISPLAY_TYPE_EVAS:
+ /* TODO: Implemenation */
+ LOG_DEBUG("it's EVAS type");
+ break;
+
+ default:
+ LOG_ERROR_IF_REACHED("type(%d)", display->type);
+ return WEBRTC_ERROR_INVALID_OPERATION;
+ }
+
+ return WEBRTC_ERROR_NONE;
+}
+
+void _init_display(webrtc_s *webrtc)
+{
+ RET_IF(webrtc == NULL, "webrtc is NULL");
+
+ if (mm_display_interface_init(&webrtc->mm_display) != MM_ERROR_NONE)
+ LOG_WARNING("failed to mm_display_interface_init()");
+}
+
+void _deinit_display(webrtc_s *webrtc)
+{
+ RET_IF(webrtc == NULL, "webrtc is NULL");
+
+ if (webrtc->mm_display) {
+ mm_display_interface_deinit(webrtc->mm_display);
+ webrtc->mm_display = NULL;
+ }
+}
\ No newline at end of file
webrtc_gst_slot_s *sink;
GstElement *videoconvert;
GstElement *videosink;
+ const char *videosink_factory_name = DEFAULT_ELEMENT_VIDEOSINK;
RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
RET_VAL_IF(decodebin == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "decodebin is NULL");
return WEBRTC_ERROR_INVALID_OPERATION;
}
+ /* TODO: Implemenation per sink->display.type */
/* FIXME: get factory name from ini */
- if (!(videosink = _create_element(DEFAULT_ELEMENT_VIDEOSINK, NULL))) {
+ if (!(videosink = _create_element(videosink_factory_name, NULL))) {
LOG_ERROR("failed to create videosink");
return WEBRTC_ERROR_INVALID_OPERATION;
}
return WEBRTC_ERROR_INVALID_OPERATION;
}
+
+int _set_display_to_sink(webrtc_s *webrtc, unsigned int track_id, unsigned int type, void *display)
+{
+ webrtc_gst_slot_s *sink;
+ gchar *decodebin_name;
+
+ 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(display == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "display is NULL");
+
+ decodebin_name = g_strdup_printf("track_%u", track_id);
+
+ sink = __find_sink_slot(webrtc, decodebin_name);
+ if (sink == NULL) {
+ LOG_ERROR("could not find an item by [%s] in sink slots", decodebin_name);
+ g_free(decodebin_name);
+ return WEBRTC_ERROR_INVALID_PARAMETER;
+ }
+ g_free(decodebin_name);
+
+ RET_VAL_IF(sink->bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL");
+ RET_VAL_IF((sink->media_types & MEDIA_TYPE_VIDEO) == 0x0, WEBRTC_ERROR_INVALID_OPERATION, "it's not a video track");
+
+ sink->display.type = type;
+ sink->display.object = display;
+
+ LOG_INFO("type[%d] object[%p]", type, display);
+
+ return _apply_display(webrtc, &sink->display);
+}
\ No newline at end of file