});
}
-
#define GST_AVF_CAPS_NEW(format, w, h, fps_n, fps_d) \
(gst_caps_new_simple ("video/x-raw", \
"width", G_TYPE_INT, w, \
"framerate", GST_TYPE_FRACTION, (fps_n), (fps_d), \
NULL))
+#define GST_AVF_FPS_RANGE_CAPS_NEW(format, w, h, min_fps_n, min_fps_d, max_fps_n, max_fps_d) \
+ (gst_caps_new_simple ("video/x-raw", \
+ "width", G_TYPE_INT, w, \
+ "height", G_TYPE_INT, h, \
+ "format", G_TYPE_STRING, gst_video_format_to_string (format), \
+ "framerate", GST_TYPE_FRACTION_RANGE, (min_fps_n), (min_fps_d), (max_fps_n), (max_fps_d), \
+ NULL))
+
- (GstVideoFormat)getGstVideoFormat:(NSNumber *)pixel_format
{
GstVideoFormat gst_format = GST_VIDEO_FORMAT_UNKNOWN;
formatDescription = (CMFormatDescriptionRef) [f performSelector:@selector(formatDescription)];
dimensions = CMVideoFormatDescriptionGetDimensions(formatDescription);
for (NSObject *rate in [f valueForKey:@"videoSupportedFrameRateRanges"]) {
- int fps_n, fps_d;
- gdouble max_fps;
+ int min_fps_n, min_fps_d, max_fps_n, max_fps_d;
+ gdouble min_fps, max_fps;
+
+ [[rate valueForKey:@"minFrameRate"] getValue:&min_fps];
+ gst_util_double_to_fraction (min_fps, &min_fps_n, &min_fps_d);
[[rate valueForKey:@"maxFrameRate"] getValue:&max_fps];
- gst_util_double_to_fraction (max_fps, &fps_n, &fps_d);
+ gst_util_double_to_fraction (max_fps, &max_fps_n, &max_fps_d);
for (NSNumber *pixel_format in pixel_formats) {
GstVideoFormat gst_format = [self getGstVideoFormat:pixel_format];
- if (gst_format != GST_VIDEO_FORMAT_UNKNOWN)
- gst_caps_append (result, GST_AVF_CAPS_NEW (gst_format, dimensions.width, dimensions.height, fps_n, fps_d));
+ if (gst_format != GST_VIDEO_FORMAT_UNKNOWN) {
+ if (min_fps != max_fps)
+ gst_caps_append (result, GST_AVF_FPS_RANGE_CAPS_NEW (gst_format, dimensions.width, dimensions.height, min_fps_n, min_fps_d, max_fps_n, max_fps_d));
+ else
+ gst_caps_append (result, GST_AVF_CAPS_NEW (gst_format, dimensions.width, dimensions.height, max_fps_n, max_fps_d));
+ }
if (gst_format == GST_VIDEO_FORMAT_BGRA) {
- GstCaps *rgba_caps = GST_AVF_CAPS_NEW (GST_VIDEO_FORMAT_RGBA, dimensions.width, dimensions.height, fps_n, fps_d);
+ GstCaps *rgba_caps;
+ if (min_fps != max_fps)
+ rgba_caps = GST_AVF_FPS_RANGE_CAPS_NEW (GST_VIDEO_FORMAT_RGBA, dimensions.width, dimensions.height, min_fps_n, min_fps_d, max_fps_n, max_fps_d);
+ else
+ rgba_caps = GST_AVF_CAPS_NEW (GST_VIDEO_FORMAT_RGBA, dimensions.width, dimensions.height, max_fps_n, max_fps_d);
gst_caps_set_features (rgba_caps, 0, gst_caps_features_new (GST_CAPS_FEATURE_MEMORY_GL_MEMORY, NULL));
gst_caps_append (result, rgba_caps);
}
found_format = TRUE;
[device setValue:f forKey:@"activeFormat"];
for (NSObject *rate in [f valueForKey:@"videoSupportedFrameRateRanges"]) {
- gdouble max_frame_rate;
+ gdouble min_frame_rate, max_frame_rate;
+ [[rate valueForKey:@"minFrameRate"] getValue:&min_frame_rate];
[[rate valueForKey:@"maxFrameRate"] getValue:&max_frame_rate];
- if (fabs (framerate - max_frame_rate) < 0.00001) {
+ if ((framerate >= min_frame_rate - 0.00001) &&
+ (framerate <= max_frame_rate + 0.00001)) {
NSValue *min_frame_duration, *max_frame_duration;
found_framerate = TRUE;