return source->source_element;
}
-static int __create_elements_for_screensrc(webrtc_s *webrtc, webrtc_gst_slot_s *source,
- GstElement **screensrc, GstElement **capsfilter, GstElement **videoconvert)
-{
- GstCaps *caps = NULL;
- gchar *caps_str = NULL;
- ini_item_media_source_s *ini_source = NULL;
-
- 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(screensrc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "screensrc is NULL");
- RET_VAL_IF(capsfilter == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "capsfilter is NULL");
- RET_VAL_IF(videoconvert == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "videoconvert is NULL");
-
- if (!(*screensrc = _create_element(__get_source_element(webrtc, WEBRTC_MEDIA_SOURCE_TYPE_SCREEN), NULL))) {
- LOG_ERROR("failed to create screensrc");
- return WEBRTC_ERROR_INVALID_OPERATION;
- }
-
- if (!(*videoconvert = _create_element(DEFAULT_ELEMENT_VIDEOCONVERT, NULL))) {
- LOG_ERROR("failed to create videoconvert");
- return WEBRTC_ERROR_INVALID_OPERATION;
- }
-
- if (!(*capsfilter = _create_element(DEFAULT_ELEMENT_CAPSFILTER, NULL))) {
- LOG_ERROR("failed to create capsfilter");
- return WEBRTC_ERROR_INVALID_OPERATION;
- }
-
- ini_source = _ini_get_source_by_type(&webrtc->ini, source->type);
- if (ini_source == NULL)
- ini_source = &webrtc->ini.media_source;
-
- caps = gst_caps_new_simple(MEDIA_TYPE_VIDEO_RAW,
- "format", G_TYPE_STRING, "BGRA",
- "framerate", GST_TYPE_FRACTION, ini_source->v_framerate, 1,
- "width", G_TYPE_INT, ini_source->v_width,
- "height", G_TYPE_INT, ini_source->v_height,
- NULL);
- caps_str = gst_caps_to_string(caps);
- LOG_INFO("capsfilter caps[%s] for screensrc", caps_str);
- g_free(caps_str);
-
- g_object_set(G_OBJECT(*capsfilter), "caps", caps, NULL);
- gst_caps_unref(caps);
-
- return WEBRTC_ERROR_NONE;
-}
-
static int __build_screensrc(webrtc_s *webrtc, webrtc_gst_slot_s *source)
{
int ret = WEBRTC_ERROR_NONE;
- GstElement *screensrc = NULL;
+ GstElement *screensrc;
+ GstElement *videoconvert;
GstElement *capsfilter1 = NULL;
- GstElement *videoconvert = NULL;
- GstElement *capsfilter2 = NULL;
GstElement *videoenc = NULL;
GstElement *videopay = NULL;
GstElement *queue = NULL;
- GstElement *capsfilter3 = NULL;
+ GstElement *capsfilter2 = NULL;
RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
source->media_types = MEDIA_TYPE_VIDEO;
- if ((ret = __create_elements_for_screensrc(webrtc, source, &screensrc, &capsfilter1, &videoconvert)) != WEBRTC_ERROR_NONE)
+ if (!(screensrc = _create_element(__get_source_element(webrtc, WEBRTC_MEDIA_SOURCE_TYPE_SCREEN), NULL)))
+ return WEBRTC_ERROR_INVALID_OPERATION;
+
+ if (!(videoconvert = _create_element(DEFAULT_ELEMENT_VIDEOCONVERT, NULL)))
goto exit;
- if ((ret = __create_rest_of_elements(webrtc, source, &capsfilter2, &videoenc, &videopay, &queue, &capsfilter3)) != WEBRTC_ERROR_NONE)
+ if ((ret = __create_rest_of_elements(webrtc, source, &capsfilter1, &videoenc, &videopay, &queue, &capsfilter2)) != WEBRTC_ERROR_NONE)
goto exit;
- gst_bin_add_many(source->bin, screensrc, capsfilter1, videoconvert, capsfilter2, videoenc, videopay, queue, capsfilter3, NULL);
- if (!gst_element_link_many(screensrc, capsfilter1, videoconvert, capsfilter2, videoenc, videopay, queue, capsfilter3, NULL)) {
+ gst_bin_add_many(source->bin, screensrc, videoconvert, capsfilter1, videoenc, videopay, queue, capsfilter2, NULL);
+ if (!gst_element_link_many(screensrc, videoconvert, capsfilter1, videoenc, videopay, queue, capsfilter2, NULL)) {
LOG_ERROR("failed to gst_element_link_many()");
ret = WEBRTC_ERROR_INVALID_OPERATION;
goto exit_with_remove_from_bin;
}
- ret = _set_ghost_pad_target(source->src_pad, capsfilter3, true);
+ ret = _set_ghost_pad_target(source->src_pad, capsfilter2, true);
if (ret != WEBRTC_ERROR_NONE)
goto exit_with_remove_from_bin;
exit_with_remove_from_bin:
/* elements will be dereferenced */
- gst_bin_remove_many(source->bin, screensrc, capsfilter1, videoconvert, capsfilter2, videoenc, videopay, queue, capsfilter3, NULL);
+ gst_bin_remove_many(source->bin, screensrc, videoconvert, capsfilter1, videoenc, videopay, queue, capsfilter2, NULL);
return ret;
exit:
SAFE_GST_OBJECT_UNREF(screensrc);
- SAFE_GST_OBJECT_UNREF(capsfilter1);
SAFE_GST_OBJECT_UNREF(videoconvert);
- SAFE_GST_OBJECT_UNREF(capsfilter2);
+ SAFE_GST_OBJECT_UNREF(capsfilter1);
SAFE_GST_OBJECT_UNREF(videoenc);
SAFE_GST_OBJECT_UNREF(videopay);
SAFE_GST_OBJECT_UNREF(queue);
- SAFE_GST_OBJECT_UNREF(capsfilter3);
+ SAFE_GST_OBJECT_UNREF(capsfilter2);
return ret;
}
#ifdef TIZEN_FEATURE_RES_MGR
webrtc->resource.need_to_acquire[MM_RESOURCE_MANAGER_RES_TYPE_CAMERA] = true;
#endif
- if (!(camerasrc = _create_element(__get_source_element(webrtc, WEBRTC_MEDIA_SOURCE_TYPE_CAMERA), NULL))) {
- LOG_ERROR("failed to create camerasrc");
+ if (!(camerasrc = _create_element(__get_source_element(webrtc, WEBRTC_MEDIA_SOURCE_TYPE_CAMERA), NULL)))
return WEBRTC_ERROR_INVALID_OPERATION;
- }
+
/* FIXME: set camera default setting from ini */
/* NOTE: in case of an element that supports tizen zerocopy format, not to emit an error in GST_STATE_PLAYING
source->media_types = MEDIA_TYPE_AUDIO;
- if (!(audiosrc = _create_element(__get_source_element(webrtc, WEBRTC_MEDIA_SOURCE_TYPE_MIC), NULL))) {
- LOG_ERROR("failed to create audiosrc");
+ if (!(audiosrc = _create_element(__get_source_element(webrtc, WEBRTC_MEDIA_SOURCE_TYPE_MIC), NULL)))
return WEBRTC_ERROR_INVALID_OPERATION;
- }
if ((ret = __create_rest_of_elements(webrtc, source, &capsfilter, &audioenc, &audiopay, &queue, &capsfilter2)) != WEBRTC_ERROR_NONE)
goto exit;
source->media_types = MEDIA_TYPE_VIDEO;
- if (!(videotestsrc = _create_element(__get_source_element(webrtc, WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST), NULL))) {
- LOG_ERROR("failed to create videotestsrc");
+ if (!(videotestsrc = _create_element(__get_source_element(webrtc, WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST), NULL)))
return WEBRTC_ERROR_INVALID_OPERATION;
- }
+
g_object_set(G_OBJECT(videotestsrc), "is-live", TRUE, "pattern", 18, NULL); /* 18: ball */
if ((ret = __create_rest_of_elements(webrtc, source, &capsfilter, &videoenc, &videopay, &queue, &capsfilter2)) != WEBRTC_ERROR_NONE)
source->media_types = MEDIA_TYPE_AUDIO;
- if (!(audiotestsrc = _create_element(__get_source_element(webrtc, WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST), NULL))) {
- LOG_ERROR("failed to create audiotestsrc");
+ if (!(audiotestsrc = _create_element(__get_source_element(webrtc, WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST), NULL)))
return WEBRTC_ERROR_INVALID_OPERATION;
- }
+
g_object_set(G_OBJECT(audiotestsrc), "is-live", TRUE, NULL);
if ((ret = __create_rest_of_elements(webrtc, source, &capsfilter, &audioenc, &audiopay, &queue, &capsfilter2)) != WEBRTC_ERROR_NONE)