static void
gst_camerabin_set_video_resolution_fps (GstCameraBin * camera, gint width,
gint height, gint fps_n, gint fps_d);
+static void
+do_set_video_resolution_fps (GstCameraBin * camera, gint width,
+ gint height, gint fps_n, gint fps_d);
static void
gst_camerabin_set_image_resolution (GstCameraBin * camera, gint width,
gst_camerabin_monitor_video_source_properties (camera);
- if (camera->width > 0 && camera->height > 0) {
+ if (camera->app_width > 0 && camera->app_height > 0) {
gst_structure_set (st,
- "width", G_TYPE_INT, camera->width,
- "height", G_TYPE_INT, camera->height, NULL);
+ "width", G_TYPE_INT, camera->app_width,
+ "height", G_TYPE_INT, camera->app_height, NULL);
}
- if (camera->fps_n > 0 && camera->fps_d > 0) {
+ if (camera->app_fps_n > 0 && camera->app_fps_d > 0) {
if (camera->night_mode) {
GST_INFO_OBJECT (camera, "night mode, lowest allowed fps will be forced");
- camera->pre_night_fps_n = camera->fps_n;
- camera->pre_night_fps_d = camera->fps_d;
+ camera->pre_night_fps_n = camera->app_fps_n;
+ camera->pre_night_fps_d = camera->app_fps_d;
detect_framerate = TRUE;
} else {
gst_structure_set (st,
- "framerate", GST_TYPE_FRACTION, camera->fps_n, camera->fps_d, NULL);
+ "framerate", GST_TYPE_FRACTION, camera->app_fps_n,
+ camera->app_fps_d, NULL);
new_caps = gst_caps_new_full (st, NULL);
}
} else {
/* Remember frame rate before setting night mode */
camera->pre_night_fps_n = camera->fps_n;
camera->pre_night_fps_d = camera->fps_d;
- g_signal_emit_by_name (camera, "set-video-resolution-fps", camera->width,
- camera->height, 0, 1, NULL);
+ do_set_video_resolution_fps (camera, camera->width, camera->height, 0, 1);
} else {
GST_DEBUG ("night mode already enabled");
}
GST_DEBUG ("disabling night mode, restoring fps to %d/%d",
camera->pre_night_fps_n, camera->pre_night_fps_d);
camera->night_mode = FALSE;
- g_signal_emit_by_name (camera, "set-video-resolution-fps", camera->width,
- camera->height, camera->pre_night_fps_n, camera->pre_night_fps_d, 0);
+ do_set_video_resolution_fps (camera, camera->width, camera->height,
+ camera->pre_night_fps_n, camera->pre_night_fps_d);
}
}
}
camera->night_mode = FALSE;
camera->eos_handled = FALSE;
- camera->width = DEFAULT_WIDTH;
- camera->height = DEFAULT_HEIGHT;
- camera->fps_n = DEFAULT_FPS_N;
- camera->fps_d = DEFAULT_FPS_D;
+ camera->app_width = camera->width = DEFAULT_WIDTH;
+ camera->app_height = camera->height = DEFAULT_HEIGHT;
+ camera->app_fps_n = camera->fps_n = DEFAULT_FPS_N;
+ camera->app_fps_d = camera->fps_d = DEFAULT_FPS_D;
camera->image_capture_width = 0;
camera->image_capture_height = 0;
camera->base_crop_left = 0;
{
gint width = g_value_get_int (value);
+ camera->app_width = width;
+
if (width != camera->width) {
camera->width = width;
camera->video_capture_caps_update = TRUE;
{
gint height = g_value_get_int (value);
+ camera->app_height = height;
+
if (height != camera->height) {
camera->height = height;
camera->video_capture_caps_update = TRUE;
fps_n = gst_value_get_fraction_numerator (value);
fps_d = gst_value_get_fraction_denominator (value);
+ camera->app_fps_n = fps_n;
+ camera->app_fps_d = fps_d;
+
if (fps_n != camera->fps_n || fps_d != camera->fps_d) {
camera->fps_n = fps_n;
camera->fps_d = fps_d;
g_value_set_int (value, camera->image_capture_height);
break;
case ARG_VIDEO_CAPTURE_WIDTH:
- g_value_set_int (value, camera->width);
+ g_value_set_int (value, camera->app_width);
break;
case ARG_VIDEO_CAPTURE_HEIGHT:
- g_value_set_int (value, camera->height);
+ g_value_set_int (value, camera->app_height);
break;
case ARG_VIDEO_CAPTURE_FRAMERATE:
- gst_value_set_fraction (value, camera->fps_n, camera->fps_d);
+ gst_value_set_fraction (value, camera->app_fps_n, camera->app_fps_d);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
+/*
+ * Updates the properties (excluding the user preferred width/height/fps) and
+ * tells camerabin to update the video capture caps.
+ */
+static void
+do_set_video_resolution_fps (GstCameraBin * camera, gint width,
+ gint height, gint fps_n, gint fps_d)
+{
+ if (height != camera->height) {
+ camera->height = height;
+ camera->video_capture_caps_update = TRUE;
+ }
+ if (width != camera->width) {
+ camera->width = width;
+ camera->video_capture_caps_update = TRUE;
+ }
+ if (fps_n != camera->fps_n) {
+ camera->fps_n = fps_n;
+ camera->video_capture_caps_update = TRUE;
+ }
+ if (fps_d != camera->fps_d) {
+ camera->fps_d = fps_d;
+ camera->video_capture_caps_update = TRUE;
+ }
+
+ reset_video_capture_caps (camera);
+}
+
+/*
+ * Updates the properties (including the user preferred width/height/fps) and
+ * tells camerabin to update the video capture caps.
+ */
static void
gst_camerabin_set_video_resolution_fps (GstCameraBin * camera, gint width,
gint height, gint fps_n, gint fps_d)