lavd/avfoundation: Reindent after last commit.
[ffmpeg.git] / libavdevice / avfoundation.m
index a28dca7..9ef6c3c 100644 (file)
@@ -297,59 +297,59 @@ static int configure_video_device(AVFormatContext *s, AVCaptureDevice *video_dev
     // might raise an exception if no format list is given
     // (then fallback to default, no configuration)
     @try {
-    for (format in [video_device valueForKey:@"formats"]) {
-        CMFormatDescriptionRef formatDescription;
-        CMVideoDimensions dimensions;
+        for (format in [video_device valueForKey:@"formats"]) {
+            CMFormatDescriptionRef formatDescription;
+            CMVideoDimensions dimensions;
 
-        formatDescription = (CMFormatDescriptionRef) [format performSelector:@selector(formatDescription)];
-        dimensions = CMVideoFormatDescriptionGetDimensions(formatDescription);
+            formatDescription = (CMFormatDescriptionRef) [format performSelector:@selector(formatDescription)];
+            dimensions = CMVideoFormatDescriptionGetDimensions(formatDescription);
 
-        if ((ctx->width == 0 && ctx->height == 0) ||
-            (dimensions.width == ctx->width && dimensions.height == ctx->height)) {
+            if ((ctx->width == 0 && ctx->height == 0) ||
+                (dimensions.width == ctx->width && dimensions.height == ctx->height)) {
 
-            selected_format = format;
+                selected_format = format;
 
-            for (range in [format valueForKey:@"videoSupportedFrameRateRanges"]) {
-                double max_framerate;
+                for (range in [format valueForKey:@"videoSupportedFrameRateRanges"]) {
+                    double max_framerate;
 
-                [[range valueForKey:@"maxFrameRate"] getValue:&max_framerate];
-                if (fabs (framerate - max_framerate) < 0.01) {
-                    selected_range = range;
-                    break;
+                    [[range valueForKey:@"maxFrameRate"] getValue:&max_framerate];
+                    if (fabs (framerate - max_framerate) < 0.01) {
+                        selected_range = range;
+                        break;
+                    }
                 }
             }
         }
-    }
-
-    if (!selected_format) {
-        av_log(s, AV_LOG_ERROR, "Selected video size (%dx%d) is not supported by the device.\n",
-            ctx->width, ctx->height);
-        goto unsupported_format;
-    }
 
-    if (!selected_range) {
-        av_log(s, AV_LOG_ERROR, "Selected framerate (%f) is not supported by the device.\n",
-            framerate);
-        if (ctx->video_is_muxed) {
-            av_log(s, AV_LOG_ERROR, "Falling back to default.\n");
-        } else {
-        goto unsupported_format;
+        if (!selected_format) {
+            av_log(s, AV_LOG_ERROR, "Selected video size (%dx%d) is not supported by the device.\n",
+                ctx->width, ctx->height);
+            goto unsupported_format;
         }
-    }
 
-    if ([video_device lockForConfiguration:NULL] == YES) {
-        if (selected_format) {
-            [video_device setValue:selected_format forKey:@"activeFormat"];
+        if (!selected_range) {
+            av_log(s, AV_LOG_ERROR, "Selected framerate (%f) is not supported by the device.\n",
+                framerate);
+            if (ctx->video_is_muxed) {
+                av_log(s, AV_LOG_ERROR, "Falling back to default.\n");
+            } else {
+                goto unsupported_format;
+            }
         }
-        if (selected_range) {
-        NSValue *min_frame_duration = [selected_range valueForKey:@"minFrameDuration"];
-        [video_device setValue:min_frame_duration forKey:@"activeVideoMinFrameDuration"];
-        [video_device setValue:min_frame_duration forKey:@"activeVideoMaxFrameDuration"];
+
+        if ([video_device lockForConfiguration:NULL] == YES) {
+            if (selected_format) {
+                [video_device setValue:selected_format forKey:@"activeFormat"];
+            }
+            if (selected_range) {
+                NSValue *min_frame_duration = [selected_range valueForKey:@"minFrameDuration"];
+                [video_device setValue:min_frame_duration forKey:@"activeVideoMinFrameDuration"];
+                [video_device setValue:min_frame_duration forKey:@"activeVideoMaxFrameDuration"];
+            }
+        } else {
+            av_log(s, AV_LOG_ERROR, "Could not lock device for configuration.\n");
+            return AVERROR(EINVAL);
         }
-    } else {
-        av_log(s, AV_LOG_ERROR, "Could not lock device for configuration.\n");
-        return AVERROR(EINVAL);
-    }
     } @catch(NSException *e) {
         av_log(ctx, AV_LOG_WARNING, "Configuration of video device failed, falling back to default.\n");
     }
@@ -486,15 +486,15 @@ static int add_video_device(AVFormatContext *s, AVCaptureDevice *video_device)
 
     // set videoSettings to an empty dict for receiving raw data of muxed devices
     if (ctx->capture_raw_data) {
-    ctx->pixel_format          = pxl_fmt_spec.ff_id;
-    ctx->video_output.videoSettings = @{ };
+        ctx->pixel_format = pxl_fmt_spec.ff_id;
+        ctx->video_output.videoSettings = @{ };
     } else {
-    ctx->pixel_format          = pxl_fmt_spec.ff_id;
-    pixel_format = [NSNumber numberWithUnsignedInt:pxl_fmt_spec.avf_id];
-    capture_dict = [NSDictionary dictionaryWithObject:pixel_format
-                                               forKey:(id)kCVPixelBufferPixelFormatTypeKey];
+        ctx->pixel_format = pxl_fmt_spec.ff_id;
+        pixel_format = [NSNumber numberWithUnsignedInt:pxl_fmt_spec.avf_id];
+        capture_dict = [NSDictionary dictionaryWithObject:pixel_format
+                                                   forKey:(id)kCVPixelBufferPixelFormatTypeKey];
 
-    [ctx->video_output setVideoSettings:capture_dict];
+        [ctx->video_output setVideoSettings:capture_dict];
     }
     [ctx->video_output setAlwaysDiscardsLateVideoFrames:YES];
 
@@ -587,11 +587,11 @@ static int get_video_config(AVFormatContext *s)
     if (image_buffer) {
         image_buffer_size = CVImageBufferGetEncodedSize(image_buffer);
 
-    stream->codecpar->codec_id   = AV_CODEC_ID_RAWVIDEO;
-    stream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
-    stream->codecpar->width      = (int)image_buffer_size.width;
-    stream->codecpar->height     = (int)image_buffer_size.height;
-    stream->codecpar->format     = ctx->pixel_format;
+        stream->codecpar->codec_id   = AV_CODEC_ID_RAWVIDEO;
+        stream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+        stream->codecpar->width      = (int)image_buffer_size.width;
+        stream->codecpar->height     = (int)image_buffer_size.height;
+        stream->codecpar->format     = ctx->pixel_format;
     } else {
         stream->codecpar->codec_id   = AV_CODEC_ID_DVVIDEO;
         stream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
@@ -762,7 +762,7 @@ static int avf_read_header(AVFormatContext *s)
     if (ctx->video_device_index >= 0) {
         if (ctx->video_device_index < ctx->num_video_devices) {
             if (ctx->video_device_index < [devices count]) {
-            video_device = [devices objectAtIndex:ctx->video_device_index];
+                video_device = [devices objectAtIndex:ctx->video_device_index];
             } else {
                 video_device = [devices_muxed objectAtIndex:(ctx->video_device_index - [devices count])];
                 ctx->video_is_muxed = 1;
@@ -1025,7 +1025,7 @@ static int avf_read_packet(AVFormatContext *s, AVPacket *pkt)
             pkt->flags        |= AV_PKT_FLAG_KEY;
 
             if (image_buffer) {
-            status = copy_cvpixelbuffer(s, image_buffer, pkt);
+                status = copy_cvpixelbuffer(s, image_buffer, pkt);
             } else {
                 status = 0;
                 OSStatus ret = CMBlockBufferCopyDataBytes(block_buffer, 0, pkt->size, pkt->data);