static GstCaps * gst_aravis_get_all_camera_caps (GstAravis *gst_aravis) { GstCaps *caps; gint64 *pixel_formats; double min_frame_rate, max_frame_rate; int min_height, min_width; int max_height, max_width; unsigned int n_pixel_formats, i; g_return_val_if_fail (GST_IS_ARAVIS (gst_aravis), NULL); if (!ARV_IS_CAMERA (gst_aravis->camera)) return NULL; GST_LOG_OBJECT (gst_aravis, "Get all camera caps"); arv_camera_get_width_bounds (gst_aravis->camera, &min_width, &max_width); arv_camera_get_height_bounds (gst_aravis->camera, &min_height, &max_height); pixel_formats = arv_camera_get_available_pixel_formats (gst_aravis->camera, &n_pixel_formats); arv_camera_get_frame_rate_bounds (gst_aravis->camera, &min_frame_rate, &max_frame_rate); int min_frame_rate_numerator; int min_frame_rate_denominator; gst_util_double_to_fraction (min_frame_rate, &min_frame_rate_numerator, &min_frame_rate_denominator); int max_frame_rate_numerator; int max_frame_rate_denominator; gst_util_double_to_fraction (max_frame_rate, &max_frame_rate_numerator, &max_frame_rate_denominator); caps = gst_caps_new_empty (); for (i = 0; i < n_pixel_formats; i++) { const char *caps_string; caps_string = arv_pixel_format_to_gst_0_10_caps_string (pixel_formats[i]); if (caps_string != NULL) { GstStructure *structure; structure = gst_structure_from_string (caps_string, NULL); gst_structure_set (structure, "width", GST_TYPE_INT_RANGE, min_width, max_width, "height", GST_TYPE_INT_RANGE, min_height, max_height, "framerate", GST_TYPE_FRACTION_RANGE, min_frame_rate_numerator, min_frame_rate_denominator, max_frame_rate_numerator, max_frame_rate_denominator, NULL); gst_caps_append_structure (caps, structure); } } g_free (pixel_formats); return caps; }
static void gst_aravis_fixate_caps (GstPad * pad, GstCaps * caps) { GstAravis *gst_aravis = GST_ARAVIS (gst_pad_get_parent_element (pad)); GstStructure *structure; gint width; gint height; double frame_rate; g_return_if_fail (GST_IS_ARAVIS (gst_aravis)); arv_camera_get_region (gst_aravis->camera, NULL, NULL, &width, &height); frame_rate = arv_camera_get_frame_rate (gst_aravis->camera); structure = gst_caps_get_structure (caps, 0); gst_structure_fixate_field_nearest_int (structure, "width", width); gst_structure_fixate_field_nearest_int (structure, "height", height); gst_structure_fixate_field_nearest_fraction (structure, "framerate", (double) (0.5 + frame_rate), 1); GST_LOG_OBJECT (gst_aravis, "Fixate caps"); g_object_unref (gst_aravis); }