---
title: MAFlashingLightsProcessor
framework: mediaaccessibility
role: symbol
role_heading: Class
path: mediaaccessibility/maflashinglightsprocessor
---

# MAFlashingLightsProcessor

A class that processes a framebuffer object to detect and dim sequences of flashing lights.

## Declaration

```swift
class MAFlashingLightsProcessor
```

## Overview

Overview A device with the Dim Flashing Lights setting on automatically dims the brightness of flashing effect sequences when it detects them in video content. If your app performs custom video drawing instead of using AVFoundation APIs, you can use the MAFlashingLightsProcessor class to detect and mitigate sequences of flashing effects in your video content. The following example shows how you might incorporate MAFlashingLightsProcessor into code that uses Core Video APIs. import MediaAccessibility import CoreVideo import OSLog

private let processor = MAFlashingLightsProcessor() private let logger = Logger()

func readVideoBuffer() {          // Confirm that the Dim Flashing Lights setting is on before processing video.     if !MADimFlashingLightsEnabled() { return }

// Retrieve the CVPixelBuffer from your video content.     // ...          // Get the IOSurface that backs the pixel buffer.     guard let inSurface = CVPixelBufferGetIOSurface(pixelBuffer)?.takeUnretainedValue() else {         logger.debug("Can't initialize input surface.")         return     }          // Use the properties of the pixel buffer to initialize an output IOSurface.     guard var outSurface = IOSurface(properties: [         .width: CVPixelBufferGetWidth(pixelBuffer),         .height: CVPixelBufferGetHeight(pixelBuffer),         .bytesPerRow: CVPixelBufferGetWidth(pixelBuffer) * 4,         .bytesPerElement: 4,         .pixelFormat: CVPixelBufferGetPixelFormatType(pixelBuffer)     ]) as IOSurfaceRef? else {         logger.debug("Can't initialize output surface.")         return     }          // Verify that the input IOSurface is compatible with the flashing lights processor.     if processor.canProcessSurface(inSurface) {                  // Analyze input IOSurface for flashing light sequences         // and write mitigated content to output IOSurface.         let result = processor.processSurface(inSurface, outSurface: &outSurface,                                               timestamp: CFAbsoluteTimeGetCurrent())                  if result.surfaceProcessed {             logger.debug("""             Processed content with flashing lights intensity \(result.intensityLevel)             and mitigated output with mitigation level \(result.mitigationLevel).             """)                          // Convert the mitigated output surface back to CVPixelBuffer             // and draw the video content.             // ...                      } else {             logger.debug("Can't process input surface.")         }     } } For more information, see Flashing lights.

## Topics

### Checking compatibility

- [canProcessSurface(_:)](mediaaccessibility/maflashinglightsprocessor/canprocesssurface(_:).md)

### Processing video content

- [processSurface(_:outSurface:timestamp:options:)](mediaaccessibility/maflashinglightsprocessor/processsurface(_:outsurface:timestamp:options:).md)
- [MAFlashingLightsProcessor.Result](mediaaccessibility/maflashinglightsprocessor/result.md)
- [MAFlashingLightsProcessor.OptionKey](mediaaccessibility/maflashinglightsprocessor/optionkey.md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Dim flashing lights

- [Responding to changes in the flashing lights setting](mediaaccessibility/responding-to-changes-in-the-flashing-lights-setting.md)
- [MADimFlashingLightsEnabled()](mediaaccessibility/madimflashinglightsenabled().md)
- [kMADimFlashingLightsChangedNotification](mediaaccessibility/kmadimflashinglightschangednotification.md)
