case WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST:
case WEBRTC_MEDIA_SOURCE_TYPE_CAMERA:
case WEBRTC_MEDIA_SOURCE_TYPE_SCREEN: {
- int framerate = source->video_info.framerate > 0 ? source->video_info.framerate : ini_source->v_framerate;
caps = gst_caps_new_simple(MEDIA_TYPE_VIDEO_RAW,
"format", G_TYPE_STRING, ini_source->v_raw_format,
- "framerate", GST_TYPE_FRACTION, framerate, 1,
+ "framerate", GST_TYPE_FRACTION, source->video_info.framerate, 1,
"width", G_TYPE_INT, width,
"height", G_TYPE_INT, height,
NULL);
- source->video_info.width = width;
- source->video_info.height = height;
break;
}
default:
case WEBRTC_MEDIA_SOURCE_TYPE_CAMERA:
case WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST:
case WEBRTC_MEDIA_SOURCE_TYPE_SCREEN: {
- int width = source->video_info.width > 0 ? source->video_info.width : ini_source->v_width;
- int height = source->video_info.height > 0 ? source->video_info.height : ini_source->v_height;
caps = gst_caps_new_simple(MEDIA_TYPE_VIDEO_RAW,
"format", G_TYPE_STRING, ini_source->v_raw_format,
"framerate", GST_TYPE_FRACTION, framerate, 1,
- "width", G_TYPE_INT, width,
- "height", G_TYPE_INT, height,
+ "width", G_TYPE_INT, source->video_info.width,
+ "height", G_TYPE_INT, source->video_info.height,
NULL);
- source->video_info.framerate = framerate;
break;
}
default:
case WEBRTC_MEDIA_SOURCE_TYPE_CAMERA:
case WEBRTC_MEDIA_SOURCE_TYPE_SCREEN:
case WEBRTC_MEDIA_SOURCE_TYPE_CUSTOM_VIDEO: {
- source->video_info.framerate = source->video_info.framerate > 0 ? source->video_info.framerate : ini_source->v_framerate;
- source->video_info.width = source->video_info.width > 0 ? source->video_info.width : ini_source->v_width;
- source->video_info.height = source->video_info.height > 0 ? source->video_info.height : ini_source->v_height;
-
caps = gst_caps_new_simple(MEDIA_TYPE_VIDEO_RAW,
"format", G_TYPE_STRING, ini_source->v_raw_format,
"framerate", GST_TYPE_FRACTION, source->video_info.framerate, 1,
case WEBRTC_MEDIA_SOURCE_TYPE_CUSTOM_VIDEO:
_media_type = __get_video_media_type(source->av[AV_IDX_VIDEO].codec);
RET_VAL_IF(_media_type == NULL, NULL, "_media_type is NULL");
-
- source->video_info.width = source->video_info.width > 0 ? source->video_info.width : ini_source->v_width;
- source->video_info.height = source->video_info.height > 0 ? source->video_info.height : ini_source->v_height;
- source->video_info.framerate = source->video_info.framerate > 0 ? source->video_info.framerate : ini_source->v_framerate;
-
caps = __get_caps_from_encoded_video_media_type(_media_type, source->video_info.width, source->video_info.height);
break;
return NULL;
}
+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.framerate = ini_source->v_framerate;
+ source->video_info.width = ini_source->v_width;
+ source->video_info.height = ini_source->v_height;
+
+ return true;
+}
+
static int __build_screensrc(webrtc_s *webrtc, webrtc_gst_slot_s *source)
{
int ret;
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 (!(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);
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->ini.resource_acquisition.camera)
webrtc->resource.need_to_acquire[MM_RESOURCE_MANAGER_RES_TYPE_CAMERA] = true;
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 (!(videotestsrc = _create_element(__get_source_element(webrtc, WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST), ELEMENT_NAME_VIDEO_SRC)))
return WEBRTC_ERROR_INVALID_OPERATION;
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))
+ 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 WEBRTC_ERROR_INVALID_OPERATION;
RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
RET_VAL_IF((source = _get_slot_by_id(webrtc->gst.source_slots, source_id)) == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "could not find source");
- RET_VAL_IF(source->type == WEBRTC_MEDIA_SOURCE_TYPE_NULL, WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the null source");
RET_VAL_IF((source->media_types & MEDIA_TYPE_VIDEO) == 0x0, WEBRTC_ERROR_INVALID_PARAMETER, "it's not a video source");
RET_VAL_IF((source->type == WEBRTC_MEDIA_SOURCE_TYPE_FILE), WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the file source");
RET_VAL_IF((source->type == WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET), WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the media packet source");
- RET_VAL_IF(source->type == WEBRTC_MEDIA_SOURCE_TYPE_NULL, WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the null source");
+ RET_VAL_IF((source->type == WEBRTC_MEDIA_SOURCE_TYPE_NULL), WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the null source");
if (webrtc->state != WEBRTC_STATE_IDLE) {
const ini_item_media_source_s *ini_source = _ini_get_source_by_type(&webrtc->ini, source->type);
g_object_set(G_OBJECT(capsfilter), "caps", new_caps, NULL);
gst_caps_unref(new_caps);
- } else {
- source->video_info.width = width;
- source->video_info.height = height;
}
+ source->video_info.width = width;
+ source->video_info.height = height;
+
LOG_INFO("webrtc[%p], source_id[%u], [%dx%d]", webrtc, source_id, width, height);
return WEBRTC_ERROR_NONE;
RET_VAL_IF(width == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "width is NULL");
RET_VAL_IF(height == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "height is NULL");
RET_VAL_IF((source = _get_slot_by_id(webrtc->gst.source_slots, source_id)) == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "could not find source");
- RET_VAL_IF(source->type == WEBRTC_MEDIA_SOURCE_TYPE_NULL, WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the null source");
RET_VAL_IF((source->media_types & MEDIA_TYPE_VIDEO) == 0x0, WEBRTC_ERROR_INVALID_PARAMETER, "it's not a video source");
RET_VAL_IF((source->type == WEBRTC_MEDIA_SOURCE_TYPE_FILE), WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the file source");
RET_VAL_IF((source->type == WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET), WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the media packet source");
- RET_VAL_IF(source->type == WEBRTC_MEDIA_SOURCE_TYPE_NULL, WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the null source");
+ RET_VAL_IF((source->type == WEBRTC_MEDIA_SOURCE_TYPE_NULL), WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the null source");
*width = source->video_info.width;
*height = source->video_info.height;
RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
RET_VAL_IF((source = _get_slot_by_id(webrtc->gst.source_slots, source_id)) == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "could not find source");
- RET_VAL_IF(source->type == WEBRTC_MEDIA_SOURCE_TYPE_NULL, WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the null source");
RET_VAL_IF((source->media_types & MEDIA_TYPE_VIDEO) == 0x0, WEBRTC_ERROR_INVALID_PARAMETER, "it's not a video source");
RET_VAL_IF((source->type == WEBRTC_MEDIA_SOURCE_TYPE_FILE), WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the file source");
RET_VAL_IF((source->type == WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET), WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the media packet source");
- RET_VAL_IF(source->type == WEBRTC_MEDIA_SOURCE_TYPE_NULL, WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the null source");
+ RET_VAL_IF((source->type == WEBRTC_MEDIA_SOURCE_TYPE_NULL), WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the null source");
/* TODO: framerate reconfiguration implementation, until then it will return error. */
RET_VAL_IF(webrtc->state != WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_OPERATION, "for now, it is only supported in IDLE state");
g_object_set(G_OBJECT(capsfilter), "caps", new_caps, NULL);
gst_caps_unref(new_caps);
- } else {
- source->video_info.framerate = framerate;
}
+ source->video_info.framerate = framerate;
+
LOG_INFO("webrtc[%p], source_id[%u], framerate[%d]", webrtc, source_id, framerate);
return WEBRTC_ERROR_NONE;
RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
RET_VAL_IF(framerate == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "framerate is NULL");
RET_VAL_IF((source = _get_slot_by_id(webrtc->gst.source_slots, source_id)) == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "could not find source");
- RET_VAL_IF(source->type == WEBRTC_MEDIA_SOURCE_TYPE_NULL, WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the null source");
RET_VAL_IF((source->media_types & MEDIA_TYPE_VIDEO) == 0x0, WEBRTC_ERROR_INVALID_PARAMETER, "it's not a video source");
RET_VAL_IF((source->type == WEBRTC_MEDIA_SOURCE_TYPE_FILE), WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the file source");
RET_VAL_IF((source->type == WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET), WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the media packet source");
- RET_VAL_IF(source->type == WEBRTC_MEDIA_SOURCE_TYPE_NULL, WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the null source");
+ RET_VAL_IF((source->type == WEBRTC_MEDIA_SOURCE_TYPE_NULL), WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the null source");
*framerate = source->video_info.framerate;