switch (source->type) {
case WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST:
case WEBRTC_MEDIA_SOURCE_TYPE_CAMERA:
- case WEBRTC_MEDIA_SOURCE_TYPE_SCREEN:
+ 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, source->video_info.framerate, 1,
+ "framerate", GST_TYPE_FRACTION, 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:
LOG_ERROR_IF_REACHED("type(%d)", source->type);
break;
switch (source->type) {
case WEBRTC_MEDIA_SOURCE_TYPE_CAMERA:
case WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST:
- case WEBRTC_MEDIA_SOURCE_TYPE_SCREEN:
+ 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, source->video_info.width,
- "height", G_TYPE_INT, source->video_info.height,
+ "width", G_TYPE_INT, width,
+ "height", G_TYPE_INT, height,
NULL);
source->video_info.framerate = framerate;
break;
+ }
default:
LOG_ERROR_IF_REACHED("type(%d)", source->type);
break;
case WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST:
case WEBRTC_MEDIA_SOURCE_TYPE_CAMERA:
case WEBRTC_MEDIA_SOURCE_TYPE_SCREEN:
- case WEBRTC_MEDIA_SOURCE_TYPE_CUSTOM_VIDEO:
+ 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, ini_source->v_framerate, 1,
- "width", G_TYPE_INT, ini_source->v_width,
- "height", G_TYPE_INT, ini_source->v_height,
+ "framerate", GST_TYPE_FRACTION, source->video_info.framerate, 1,
+ "width", G_TYPE_INT, source->video_info.width,
+ "height", G_TYPE_INT, source->video_info.height,
NULL);
- source->video_info.width = ini_source->v_width;
- source->video_info.height = ini_source->v_height;
- source->video_info.framerate = ini_source->v_framerate;
break;
-
+ }
case WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST:
case WEBRTC_MEDIA_SOURCE_TYPE_MIC:
case WEBRTC_MEDIA_SOURCE_TYPE_CUSTOM_AUDIO:
case WEBRTC_MEDIA_SOURCE_TYPE_CUSTOM_VIDEO:
_media_type = __get_video_media_type(ini_source->v_codec);
RET_VAL_IF(_media_type == NULL, NULL, "_media_type is NULL");
- caps = __get_caps_from_encoded_video_media_type(_media_type, ini_source->v_width, ini_source->v_height);
- source->video_info.width = ini_source->v_width;
- source->video_info.height = ini_source->v_height;
- 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;
+ 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;
case WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST:
RET_VAL_IF(!ini_source->v_drc_support, WEBRTC_ERROR_INVALID_OPERATION, "not supported dynamic resolution change");
}
- capsfilter = __find_element_in_bin(source->bin, ELEMENT_NAME_FIRST_CAPSFILTER);
- RET_VAL_IF(capsfilter == NULL, WEBRTC_ERROR_INVALID_OPERATION, "could not find the first capsfilter");
+ if ((capsfilter = __find_element_in_bin(source->bin, ELEMENT_NAME_FIRST_CAPSFILTER))) {
+ /* FIXME: check if the [width x height] is supported or not */
+ if (!(new_caps = __make_video_raw_caps_with_resolution(source, &webrtc->ini, width, height)))
+ return WEBRTC_ERROR_INVALID_OPERATION;
+ PRINT_CAPS(new_caps, "capsfilter");
- /* FIXME: check if the [width x height] is supported or not */
- if (!(new_caps = __make_video_raw_caps_with_resolution(source, &webrtc->ini, width, height)))
- return WEBRTC_ERROR_INVALID_OPERATION;
+ g_object_set(G_OBJECT(capsfilter), "caps", new_caps, NULL);
+ gst_caps_unref(new_caps);
- PRINT_CAPS(new_caps, "capsfilter");
+ } else {
+ source->video_info.width = width;
+ source->video_info.height = height;
+ }
- g_object_set(G_OBJECT(capsfilter), "caps", new_caps, NULL);
- gst_caps_unref(new_caps);
+ LOG_INFO("webrtc[%p], source_id[%u], [%dx%d]", webrtc, source_id, width, height);
return WEBRTC_ERROR_NONE;
}
webrtc_gst_slot_s *source;
GstElement *capsfilter;
GstCaps *new_caps = NULL;
- gchar *caps_str;
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(webrtc->state != WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_OPERATION, "for now, it is only supported in IDLE state");
/* FIXME: check if the framerate is supported or not */
- capsfilter = __find_element_in_bin(source->bin, ELEMENT_NAME_FIRST_CAPSFILTER);
- RET_VAL_IF(capsfilter == NULL, WEBRTC_ERROR_INVALID_OPERATION, "could not find the first capsfilter");
+ if ((capsfilter = __find_element_in_bin(source->bin, ELEMENT_NAME_FIRST_CAPSFILTER))) {
+ if (!(new_caps = __make_video_raw_caps_with_framerate(source, &webrtc->ini, framerate)))
+ return WEBRTC_ERROR_INVALID_OPERATION;
+ PRINT_CAPS(new_caps, "capsfilter");
- if (!(new_caps = __make_video_raw_caps_with_framerate(source, &webrtc->ini, framerate)))
- return WEBRTC_ERROR_INVALID_OPERATION;
+ g_object_set(G_OBJECT(capsfilter), "caps", new_caps, NULL);
+ gst_caps_unref(new_caps);
- caps_str = gst_caps_to_string(new_caps);
- LOG_INFO("capsfilter caps[%s]", caps_str);
- g_free(caps_str);
+ } else {
+ source->video_info.framerate = framerate;
+ }
- g_object_set(G_OBJECT(capsfilter), "caps", new_caps, NULL);
- gst_caps_unref(new_caps);
+ LOG_INFO("webrtc[%p], source_id[%u], framerate[%d]", webrtc, source_id, framerate);
return WEBRTC_ERROR_NONE;
}