summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Decina <alessandro.d@gmail.com>2016-01-27 14:36:36 +1100
committerAlessandro Decina <alessandro.d@gmail.com>2016-01-27 14:38:36 +1100
commit6f80d5c59ae6171419df1c704666da2d1148474a (patch)
tree6c5b39595237d499937d13c84a9baa4404af05da
parenta152a8342b40a73b152b66640360549fcc678926 (diff)
downloadgstreamer-plugins-bad-6f80d5c59ae6171419df1c704666da2d1148474a.tar.gz
applemedia: avfvideosrc: actually set the configured framerate
Actually set the configured framerate. Before we only used to set the first matching framerate range. On iOS where the camera reports ranges [2, 60], we used to configure the camera to output anything between 2 and 60fps.
-rw-r--r--sys/applemedia/avfvideosrc.m22
1 files changed, 15 insertions, 7 deletions
diff --git a/sys/applemedia/avfvideosrc.m b/sys/applemedia/avfvideosrc.m
index 07c878f69..af1122e0a 100644
--- a/sys/applemedia/avfvideosrc.m
+++ b/sys/applemedia/avfvideosrc.m
@@ -521,16 +521,24 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
[[rate valueForKey:@"maxFrameRate"] getValue:&max_frame_rate];
if ((framerate >= min_frame_rate - 0.00001) &&
(framerate <= max_frame_rate + 0.00001)) {
- NSValue *min_frame_duration, *max_frame_duration;
-
+ NSValue *frame_duration_value;
found_framerate = TRUE;
- min_frame_duration = [rate valueForKey:@"minFrameDuration"];
- max_frame_duration = [rate valueForKey:@"maxFrameDuration"];
- [device setValue:min_frame_duration forKey:@"activeVideoMinFrameDuration"];
+ if (min_frame_rate == max_frame_rate) {
+ /* on mac we get tight ranges and an exception is raised if the
+ * frame duration doesn't match the one reported in the range to
+ * the last decimal point
+ */
+ frame_duration_value = [rate valueForKey:@"minFrameDuration"];
+ } else {
+ double frame_duration;
+
+ gst_util_fraction_to_double (info->fps_d, info->fps_n, &frame_duration);
+ frame_duration_value = [NSNumber numberWithDouble:frame_duration];
+ }
+ [device setValue:frame_duration_value forKey:@"activeVideoMinFrameDuration"];
@try {
/* Only available on OSX >= 10.8 and iOS >= 7.0 */
- // Restrict activeVideoMaxFrameDuration to the minimum value so we get a better capture frame rate
- [device setValue:min_frame_duration forKey:@"activeVideoMaxFrameDuration"];
+ [device setValue:frame_duration_value forKey:@"activeVideoMaxFrameDuration"];
} @catch (NSException *exception) {
if (![[exception name] isEqualToString:NSUndefinedKeyException]) {
GST_WARNING ("An unexcepted error occured: %s",