return WEBRTC_ERROR_NONE;
exit_with_remove_from_bin:
- /* elements will be dereferenced */
__remove_elements_from_bin(source->bin, switch_src_list);
__remove_elements_from_bin(source->bin, element_list);
SAFE_G_LIST_FREE(switch_src_list);
return WEBRTC_ERROR_NONE;
exit_with_remove_from_bin:
- /* elements will be dereferenced */
__remove_elements_from_bin(source->bin, element_list);
SAFE_G_LIST_FREE(element_list);
return ret;
return WEBRTC_ERROR_NONE;
exit_with_remove_from_bin:
- /* elements will be dereferenced */
__remove_elements_from_bin(source->bin, element_list);
SAFE_G_LIST_FREE(element_list);
return ret;
return WEBRTC_ERROR_NONE;
exit_with_remove_from_bin:
- /* elements will be dereferenced */
__remove_elements_from_bin(source->bin, element_list);
SAFE_G_LIST_FREE(element_list);
return ret;
return WEBRTC_ERROR_NONE;
exit_with_remove_from_bin:
- /* elements will be dereferenced */
__remove_elements_from_bin(source->bin, element_list);
SAFE_G_LIST_FREE(element_list);
return ret;
return WEBRTC_ERROR_NONE;
exit_with_remove_from_bin:
- /* elements will be dereferenced */
__remove_elements_from_bin(source->bin, element_list);
SAFE_G_LIST_FREE(element_list);
return ret;
return WEBRTC_ERROR_NONE;
exit_with_remove_from_bin:
- /* elements will be dereferenced */
__remove_elements_from_bin(source->bin, element_list);
SAFE_G_LIST_FREE(element_list);
return WEBRTC_ERROR_INVALID_OPERATION;
return WEBRTC_ERROR_NONE;
exit_with_remove_from_bin:
- /* elements will be dereferenced */
__remove_elements_from_bin(bin, element_list);
SAFE_G_LIST_FREE(element_list);
return WEBRTC_ERROR_INVALID_OPERATION;
return _set_ghost_pad_target(*src_pad, capsfilter, true);
exit_with_remove_from_bin:
- /* elements will be dereferenced */
__remove_elements_from_bin(source->bin, element_list);
SAFE_G_LIST_FREE(element_list);
return ret;
GstElement *audiosink;
GstElement *audioconvert;
GstElement *audioresample;
+ GList *element_list = NULL;
int ret = WEBRTC_ERROR_NONE;
RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
webrtc = source->webrtc;
- if (!(audiosink = _create_element(webrtc->ini.rendering_sink.a_sink_element, NULL)))
+ if (!(audioconvert = _create_element(DEFAULT_ELEMENT_AUDIOCONVERT, NULL)))
return WEBRTC_ERROR_INVALID_OPERATION;
+ APPEND_ELEMENT(element_list, audioconvert);
+
+ if (!(audioresample = _create_element(DEFAULT_ELEMENT_AUDIORESAMPLE, NULL)))
+ goto exit;
+ APPEND_ELEMENT(element_list, audioresample);
+
+ if (!(audiosink = _create_element(webrtc->ini.rendering_sink.a_sink_element, NULL)))
+ goto exit;
+ APPEND_ELEMENT(element_list, audiosink);
if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(audiosink)), "stream-properties")) {
if (source->sound_stream_info.type) {
ret = _apply_stream_info(audiosink, source->sound_stream_info.type, source->sound_stream_info.index);
- if (ret != WEBRTC_ERROR_NONE) {
- SAFE_GST_OBJECT_UNREF(audiosink);
- return WEBRTC_ERROR_INVALID_OPERATION;
- }
+ if (ret != WEBRTC_ERROR_NONE)
+ goto exit;
}
}
g_object_set(G_OBJECT(audiosink), "sync", FALSE, NULL);
- if (!(audioconvert = _create_element(DEFAULT_ELEMENT_AUDIOCONVERT, NULL))) {
- SAFE_GST_OBJECT_UNREF(audiosink);
- return WEBRTC_ERROR_INVALID_OPERATION;
- }
-
- if (!(audioresample = _create_element(DEFAULT_ELEMENT_AUDIORESAMPLE, NULL))) {
- SAFE_GST_OBJECT_UNREF(audiosink);
- SAFE_GST_OBJECT_UNREF(audioconvert);
- return WEBRTC_ERROR_INVALID_OPERATION;
- }
+ if (!__add_elements_to_bin(GST_BIN(source->av[AV_IDX_AUDIO].render.pipeline), element_list))
+ goto exit;
- gst_bin_add_many(GST_BIN(source->av[AV_IDX_AUDIO].render.pipeline), audioconvert, audioresample, audiosink, NULL);
+ if (!__link_elements(element_list))
+ goto exit_with_remove_from_bin;
- if (!gst_element_sync_state_with_parent(audioconvert)) {
- LOG_ERROR("failed to gst_element_sync_state_with_parent() for [%s]", GST_ELEMENT_NAME(audioconvert));
- return WEBRTC_ERROR_INVALID_OPERATION;
- }
- if (!gst_element_sync_state_with_parent(audioresample)) {
- LOG_ERROR("failed to gst_element_sync_state_with_parent() for [%s]", GST_ELEMENT_NAME(audioresample));
- return WEBRTC_ERROR_INVALID_OPERATION;
+ if (!gst_element_link(link_with, audioconvert)) {
+ LOG_ERROR("failed to gst_element_link(), [%s] - [%s]", GST_ELEMENT_NAME(link_with), GST_ELEMENT_NAME(audioconvert));
+ goto exit_with_remove_from_bin;
}
- if (!gst_element_sync_state_with_parent(audiosink)) {
- LOG_ERROR("failed to gst_element_sync_state_with_parent() for [%s]", GST_ELEMENT_NAME(audiosink));
- return WEBRTC_ERROR_INVALID_OPERATION;
- }
+ if (!__sync_elements_state_with_parent(element_list))
+ goto exit_with_remove_from_bin;
- if (!gst_element_link_many(link_with, audioconvert, audioresample, audiosink, NULL)) {
- LOG_ERROR("failed to gst_element_link_many()");
- return WEBRTC_ERROR_INVALID_OPERATION;
- }
+ SAFE_G_LIST_FREE(element_list);
return WEBRTC_ERROR_NONE;
+
+exit_with_remove_from_bin:
+ __remove_elements_from_bin(source->bin, element_list);
+ SAFE_G_LIST_FREE(element_list);
+ return WEBRTC_ERROR_INVALID_OPERATION;
+exit:
+ SAFE_G_LIST_FREE_FULL(element_list, gst_object_unref);
+ return WEBRTC_ERROR_INVALID_OPERATION;
}
static int __build_loopback_videosink(webrtc_gst_slot_s *source, GstElement *link_with)
const char *videosink_factory_name;
GstElement *videosink;
GstElement *videoconvert;
+ GList *element_list = NULL;
RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
RET_VAL_IF(link_with == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "link_with is NULL");
return WEBRTC_ERROR_INVALID_OPERATION;
}
- if (!(videosink = _create_element(videosink_factory_name, NULL)))
- return WEBRTC_ERROR_INVALID_OPERATION;
-
- if (!(videoconvert = _create_element(DEFAULT_ELEMENT_VIDEOCONVERT, NULL))) {
- SAFE_GST_OBJECT_UNREF(videosink);
- return WEBRTC_ERROR_INVALID_OPERATION;
- }
-
#ifndef TIZEN_TV
if (source->display->type == WEBRTC_DISPLAY_TYPE_OVERLAY && webrtc->ini.resource_acquisition.video_overlay) {
int ret;
- if ((ret = _acquire_resource_for_type(webrtc, MM_RESOURCE_MANAGER_RES_TYPE_VIDEO_OVERLAY)) != WEBRTC_ERROR_NONE) {
- SAFE_GST_OBJECT_UNREF(videosink);
- SAFE_GST_OBJECT_UNREF(videoconvert);
+ if ((ret = _acquire_resource_for_type(webrtc, MM_RESOURCE_MANAGER_RES_TYPE_VIDEO_OVERLAY)) != WEBRTC_ERROR_NONE)
return ret;
- }
}
#endif
+
+ if (!(videoconvert = _create_element(DEFAULT_ELEMENT_VIDEOCONVERT, NULL)))
+ return WEBRTC_ERROR_INVALID_OPERATION;
+ APPEND_ELEMENT(element_list, videoconvert);
+
+ if (!(videosink = _create_element(videosink_factory_name, NULL)))
+ goto exit;
+ APPEND_ELEMENT(element_list, videosink);
+
if (source->display->type == WEBRTC_DISPLAY_TYPE_OVERLAY ||
source->display->type == WEBRTC_DISPLAY_TYPE_ECORE_WL) {
gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(videosink), source->display->overlay_surface_id);
_connect_and_append_signal(&source->signals, (GObject *)videosink, "handoff", G_CALLBACK(_video_stream_decoded_cb), source->display);
}
- gst_bin_add_many(GST_BIN(source->av[AV_IDX_VIDEO].render.pipeline), videoconvert, videosink, NULL);
+ if (!__add_elements_to_bin(GST_BIN(source->av[AV_IDX_VIDEO].render.pipeline), element_list))
+ goto exit;
- if (!gst_element_sync_state_with_parent(videoconvert)) {
- LOG_ERROR("failed to gst_element_sync_state_with_parent() for [%s]", GST_ELEMENT_NAME(videoconvert));
- return WEBRTC_ERROR_INVALID_OPERATION;
- }
+ if (!__link_elements(element_list))
+ goto exit_with_remove_from_bin;
- if (!gst_element_sync_state_with_parent(videosink)) {
- LOG_ERROR("failed to gst_element_sync_state_with_parent() for [%s]", GST_ELEMENT_NAME(videosink));
- return WEBRTC_ERROR_INVALID_OPERATION;
+ if (!gst_element_link(link_with, videoconvert)) {
+ LOG_ERROR("failed to gst_element_link(), [%s] - [%s]", GST_ELEMENT_NAME(link_with), GST_ELEMENT_NAME(videoconvert));
+ goto exit_with_remove_from_bin;
}
- if (!gst_element_link_many(link_with, videoconvert, videosink, NULL)) {
- LOG_ERROR("failed to gst_element_link_many()");
- return WEBRTC_ERROR_INVALID_OPERATION;
- }
+ if (!__sync_elements_state_with_parent(element_list))
+ goto exit_with_remove_from_bin;
source->display->sink_element = videosink;
+ SAFE_G_LIST_FREE(element_list);
+
return WEBRTC_ERROR_NONE;
+
+exit_with_remove_from_bin:
+ __remove_elements_from_bin(source->bin, element_list);
+ SAFE_G_LIST_FREE(element_list);
+ return WEBRTC_ERROR_INVALID_OPERATION;
+exit:
+ SAFE_G_LIST_FREE_FULL(element_list, gst_object_unref);
+ return WEBRTC_ERROR_INVALID_OPERATION;
}
//LCOV_EXCL_START