static GstPadProbeReturn __camerasrc_probe_cb(GstPad *pad, GstPadProbeInfo *info, gpointer u_data);
-//LCOV_EXCL_START
-static bool __link_switch_srcs(GstElement *switch_element, GList *switch_src_list)
-{
- GstElement *element;
- GList *list;
-
- RET_VAL_IF(switch_element == NULL, false, "switch_element is NULL");
- RET_VAL_IF(switch_src_list == NULL, false, "switch_src_list is NULL");
-
- for (list = switch_src_list; list; list = g_list_next(list)) {
- element = GST_ELEMENT_CAST(list->data);
- RET_VAL_IF(!gst_element_link(element, switch_element), false,
- "failed to gst_element_link(), [%s] - [%s]", GST_ELEMENT_NAME(element), GST_ELEMENT_NAME(switch_element));
-
- LOG_DEBUG("[%s] - [%s]", GST_ELEMENT_NAME(element), GST_ELEMENT_NAME(switch_element));
- }
-
- return true;
-}
-//LCOV_EXCL_STOP
-
-static bool __set_default_video_info(webrtc_gst_slot_s *source, const ini_item_media_source_s *ini_source)
-{
- RET_VAL_IF(source == NULL, false, "source is NULL");
- RET_VAL_IF(ini_source == NULL, false, "ini_source is NULL");
-
- source->video_info.origin_framerate = ini_source->v_framerate;
- source->video_info.framerate = ini_source->v_framerate;
-
- source->video_info.origin_width = ini_source->v_width;
- source->video_info.origin_height = ini_source->v_height;
- _set_video_src_resolution(source, ini_source->v_width, ini_source->v_height);
-
- if (source->type == WEBRTC_MEDIA_SOURCE_TYPE_SCREEN) {
-#ifdef TIZEN_FEATURE_UI
- int width = 0;
- int height = 0;
-
- if (_get_screen_resolution(&width, &height) != WEBRTC_ERROR_NONE) {
- if (width == 0 || height == 0) {
- LOG_WARNING("failed to _get_screen_resolution(). use values of ini");
- return true;
- }
- }
-
- source->video_info.origin_width = width;
- source->video_info.origin_height = height;
- _set_video_src_resolution(source, width, height);
-#else
- LOG_WARNING("TIZEN_FEATURE_UI is disabled, skip this function, use values of ini");
-#endif
- }
- return true;
-}
-
static int __build_src_check_params_and_get_ini_source(webrtc_s *webrtc, webrtc_gst_slot_s *source, const ini_item_media_source_s **ini_source)
{
RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
}
//LCOV_EXCL_START
-static int __build_screensrc(webrtc_s *webrtc, webrtc_gst_slot_s *source)
-{
- int ret;
- GList *switch_src_list = NULL;
- GstElement *screensrc = NULL;
- GstElement *videotestsrc = NULL;
- GstElement *videoswitch = NULL;
- const ini_item_media_source_s *ini_source;
-
- ret = __build_src_check_params_and_get_ini_source(webrtc, source, &ini_source);
- RET_VAL_IF(ret != WEBRTC_ERROR_NONE, ret, "failed to __build_src_check_params_and_get_ini_source()");
-
- ret = _add_no_target_ghostpad_to_slot(source, true, &source->av[AV_IDX_VIDEO].src_pad);
- RET_VAL_IF(ret != WEBRTC_ERROR_NONE, ret, "failed to _add_no_target_ghostpad_to_slot()");
-
- source->media_types = MEDIA_TYPE_VIDEO;
- source->zerocopy_enabled = _is_hw_encoder_used(webrtc, source->type, source->media_types);
- source->av[AV_IDX_VIDEO].raw_format = g_strdup(ini_source->v_raw_format);
- source->av[AV_IDX_VIDEO].codec = ini_source->v_codecs[0];
-
- if (!__set_default_video_info(source, ini_source))
- return WEBRTC_ERROR_INVALID_OPERATION;
-
-#if !defined(TIZEN_TV) && defined(TIZEN_FEATURE_UI)
- if (!webrtc->rotate_info.sensor_listener)
- if ((ret = _set_screen_rotation_changed_cb(webrtc)) != WEBRTC_ERROR_NONE)
- return ret;
-#endif
- if (!(screensrc = _create_element(_get_source_element(webrtc, WEBRTC_MEDIA_SOURCE_TYPE_SCREEN), ELEMENT_NAME_SCREENSRC)))
- return WEBRTC_ERROR_INVALID_OPERATION;
- APPEND_ELEMENT(switch_src_list, screensrc);
-
- _gst_set_element_properties(screensrc, ini_source->source_element_properties);
-
- if (!(videotestsrc = _create_element(DEFAULT_ELEMENT_VIDEOTESTSRC, ELEMENT_NAME_VIDEO_MUTE_SRC)))
- goto exit;
- APPEND_ELEMENT(switch_src_list, videotestsrc);
-
- g_object_set(G_OBJECT(videotestsrc),
- "is-live", TRUE,
- "pattern", 2, /* black */
- NULL);
-
- if (!_add_elements_to_bin(source->bin, switch_src_list)) {
- SAFE_G_LIST_FREE(switch_src_list);
- return WEBRTC_ERROR_INVALID_OPERATION;
- }
-
- if (!(videoswitch = _create_element(DEFAULT_ELEMENT_INPUT_SELECTOR, ELEMENT_NAME_VIDEO_SWITCH)))
- goto exit_with_remove_from_bin;
-
- if (!gst_bin_add(source->bin, videoswitch)) {
- LOG_ERROR("failed to gst_bin_add(), bin[%s], videoswitch[%s]", GST_ELEMENT_NAME(source->bin), GST_ELEMENT_NAME(videoswitch));
- SAFE_GST_OBJECT_UNREF(videoswitch);
- goto exit_with_remove_from_bin;
- }
-
- if (!__link_switch_srcs(videoswitch, switch_src_list)) {
- SAFE_GST_OBJECT_UNREF(videoswitch);
- goto exit_with_remove_from_bin;
- }
-
- return WEBRTC_ERROR_NONE;
-
-exit_with_remove_from_bin:
- _remove_elements_from_bin(source->bin, switch_src_list);
- SAFE_G_LIST_FREE(switch_src_list);
- return WEBRTC_ERROR_INVALID_OPERATION;
-exit:
- SAFE_G_LIST_FREE_FULL(switch_src_list, gst_object_unref);
- return WEBRTC_ERROR_INVALID_OPERATION;
-}
-
static int __mute_by_changing_property(webrtc_gst_slot_s *source, GstElement *videotestsrc, bool mute)
{
RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
source->av[AV_IDX_VIDEO].raw_format = g_strdup(ini_source->v_raw_format);
source->av[AV_IDX_VIDEO].codec = ini_source->v_codecs[0];
- if (!__set_default_video_info(source, ini_source))
+ if (!_set_default_video_info(source, ini_source))
return WEBRTC_ERROR_INVALID_OPERATION;
#ifndef TIZEN_TV
source->av[AV_IDX_VIDEO].raw_format = g_strdup(ini_source->v_raw_format);
source->av[AV_IDX_VIDEO].codec = ini_source->v_codecs[0];
- if (!__set_default_video_info(source, ini_source))
+ if (!_set_default_video_info(source, ini_source))
return WEBRTC_ERROR_INVALID_OPERATION;
if (!(videotestsrc = _create_element(_get_source_element(webrtc, WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST), ELEMENT_NAME_VIDEO_SRC)))
source->zerocopy_enabled = _is_hw_encoder_used(webrtc, source->type, source->media_types);
source->av[AV_IDX_VIDEO].codec = ini_source->v_codecs[0];
- if (!__set_default_video_info(source, ini_source))
+ if (!_set_default_video_info(source, ini_source))
return WEBRTC_ERROR_INVALID_OPERATION;
if (!(custom_videosrc = _create_element(_get_source_element(webrtc, WEBRTC_MEDIA_SOURCE_TYPE_CUSTOM_VIDEO), ELEMENT_NAME_VIDEO_SRC)))
return __build_camerasrc(webrtc, source);
//LCOV_EXCL_START
case WEBRTC_MEDIA_SOURCE_TYPE_SCREEN:
- return __build_screensrc(webrtc, source);
+#ifdef TIZEN_FEATURE_UI
+ return _build_screensrc(webrtc, source);
+#else
+ LOG_ERROR("TIZEN_FEATURE_UI is disabled, skip this function");
+ return WEBRTC_ERROR_INVALID_OPERATION;
+#endif
//LCOV_EXCL_STOP
case WEBRTC_MEDIA_SOURCE_TYPE_FILE:
return _build_filesrc_pipeline(webrtc, source);
int _width, _height;
float rw, rh;
int left, right, top, bottom;
-#if !defined(TIZEN_TV) && defined(TIZEN_FEATURE_UI)
+#ifndef TIZEN_TV
bool rotated = webrtc->rotate_info.rotated;
#else
bool rotated = false;
g_mutex_unlock(&webrtc->mutex);
}
-int _set_screen_rotation_changed_cb(webrtc_s *webrtc)
+static int __set_screen_rotation_changed_cb(webrtc_s *webrtc)
{
bool supported;
sensor_h *sh = NULL;
}
#endif
+static bool __link_switch_srcs(GstElement *switch_element, GList *switch_src_list)
+{
+ GstElement *element;
+ GList *list;
+
+ RET_VAL_IF(switch_element == NULL, false, "switch_element is NULL");
+ RET_VAL_IF(switch_src_list == NULL, false, "switch_src_list is NULL");
+
+ for (list = switch_src_list; list; list = g_list_next(list)) {
+ element = GST_ELEMENT_CAST(list->data);
+ RET_VAL_IF(!gst_element_link(element, switch_element), false,
+ "failed to gst_element_link(), [%s] - [%s]", GST_ELEMENT_NAME(element), GST_ELEMENT_NAME(switch_element));
+
+ LOG_DEBUG("[%s] - [%s]", GST_ELEMENT_NAME(element), GST_ELEMENT_NAME(switch_element));
+ }
+
+ return true;
+}
+
+int _build_screensrc(webrtc_s *webrtc, webrtc_gst_slot_s *source)
+{
+ int ret;
+ GList *switch_src_list = NULL;
+ GstElement *screensrc = NULL;
+ GstElement *videotestsrc = NULL;
+ GstElement *videoswitch = NULL;
+ const ini_item_media_source_s *ini_source;
+
+ RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
+ RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
+ RET_VAL_IF(source->bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL");
+
+ if (!(ini_source = _ini_get_source_by_type(&webrtc->ini, source->type))) {
+ LOG_ERROR("ini_source is NULL");
+ return WEBRTC_ERROR_INVALID_OPERATION;
+ }
+
+ ret = _add_no_target_ghostpad_to_slot(source, true, &source->av[AV_IDX_VIDEO].src_pad);
+ RET_VAL_IF(ret != WEBRTC_ERROR_NONE, ret, "failed to _add_no_target_ghostpad_to_slot()");
+
+ source->media_types = MEDIA_TYPE_VIDEO;
+ source->zerocopy_enabled = _is_hw_encoder_used(webrtc, source->type, source->media_types);
+ source->av[AV_IDX_VIDEO].raw_format = g_strdup(ini_source->v_raw_format);
+ source->av[AV_IDX_VIDEO].codec = ini_source->v_codecs[0];
+
+ if (!_set_default_video_info(source, ini_source))
+ return WEBRTC_ERROR_INVALID_OPERATION;
+
+#ifndef TIZEN_TV
+ if (!webrtc->rotate_info.sensor_listener)
+ if ((ret = __set_screen_rotation_changed_cb(webrtc)) != WEBRTC_ERROR_NONE)
+ return ret;
+#endif
+ if (!(screensrc = _create_element(_get_source_element(webrtc, WEBRTC_MEDIA_SOURCE_TYPE_SCREEN), ELEMENT_NAME_SCREENSRC)))
+ return WEBRTC_ERROR_INVALID_OPERATION;
+ APPEND_ELEMENT(switch_src_list, screensrc);
+
+ _gst_set_element_properties(screensrc, ini_source->source_element_properties);
+
+ if (!(videotestsrc = _create_element(DEFAULT_ELEMENT_VIDEOTESTSRC, ELEMENT_NAME_VIDEO_MUTE_SRC)))
+ goto exit;
+ APPEND_ELEMENT(switch_src_list, videotestsrc);
+
+ g_object_set(G_OBJECT(videotestsrc),
+ "is-live", TRUE,
+ "pattern", 2, /* black */
+ NULL);
+
+ if (!_add_elements_to_bin(source->bin, switch_src_list)) {
+ SAFE_G_LIST_FREE(switch_src_list);
+ return WEBRTC_ERROR_INVALID_OPERATION;
+ }
+
+ if (!(videoswitch = _create_element(DEFAULT_ELEMENT_INPUT_SELECTOR, ELEMENT_NAME_VIDEO_SWITCH)))
+ goto exit_with_remove_from_bin;
+
+ if (!gst_bin_add(source->bin, videoswitch)) {
+ LOG_ERROR("failed to gst_bin_add(), bin[%s], videoswitch[%s]", GST_ELEMENT_NAME(source->bin), GST_ELEMENT_NAME(videoswitch));
+ SAFE_GST_OBJECT_UNREF(videoswitch);
+ goto exit_with_remove_from_bin;
+ }
+
+ if (!__link_switch_srcs(videoswitch, switch_src_list)) {
+ SAFE_GST_OBJECT_UNREF(videoswitch);
+ goto exit_with_remove_from_bin;
+ }
+
+ return WEBRTC_ERROR_NONE;
+
+exit_with_remove_from_bin:
+ _remove_elements_from_bin(source->bin, switch_src_list);
+ SAFE_G_LIST_FREE(switch_src_list);
+ return WEBRTC_ERROR_INVALID_OPERATION;
+exit:
+ SAFE_G_LIST_FREE_FULL(switch_src_list, gst_object_unref);
+ return WEBRTC_ERROR_INVALID_OPERATION;
+}
+
bool _is_screen_source_cropped(webrtc_gst_slot_s *source)
{
GstElement *videocrop;