<!--
{
  "documentType" : "article",
  "framework" : "professional_video_applications",
  "identifier" : "/documentation/Professional-Video-Applications/communicating-with-the-plug-in-state",
  "metadataVersion" : "0.1.0",
  "role" : "article",
  "title" : "Communicating with the plug-in state"
}
-->

# Communicating with the plug-in state

Prepare the necessary information, such as parameter values, for your FxPlug plug-in to render.

## Discussion

One of the biggest changes between FxPlug 3 and 4 is that now there is no FxPlug API access at render time. Rendering occurs out-of-process, reducing the amount of back and forth between the host app and the plug-in, which is essential for performance. Thus, if you call [`FxParameterRetrievalAPI_v6`](/documentation/professional_video_applications/FxParameterRetrievalAPI_v6) at render time, it will return *nil*.

This means that your plug-in must prepare what it needs to know to render before render time. Then, at render time, this information is provided to your plug-in. This information is called the *Plug-in State*. It’s represented by a byte-buffer of <doc://com.apple.documentation/documentation/Foundation/NSData> of your own creation that can be passed to the rendering method at render time. The content of the `NSData` object is up to you, but it typically contains parameter values from the host application’s UI, or values calculated from those parameter values.

### Prepare the plug-in state

Here, your plug-in can query parameter values, and store the required information in an NSData object as you see fit. In the `FxBrightness` example, a struct of values is filled in with plug-in parameter values and ultimately combined into an `NSData` object like this:

```swift
func pluginState(_ pluginState: AutoreleasingUnsafeMutablePointer<NSData>?, at renderTime: CMTime, quality qualityLevel: UInt) throws {
    let paramAPI = _apiManager!.api(for: FxParameterRetrievalAPI_v6.self) as! FxParameterRetrievalAPI_v6
        
    var brightness = 1.0
    paramAPI.getFloatValue(UnsafeMutablePointer<Double>(&brightness), fromParameter: 1, at: renderTime)
        
    pluginState?.pointee = NSData.init(bytes: &brightness, length: MemoryLayout.size(ofValue: brightness))
}
```

When it’s time to render, your `NSData` is handed back to you, at which point you can unpack the data, like this:

```swift
let brightness  = pluginState!.withUnsafeBytes { (ptr: UnsafePointer<Double>) -> Double in
        return ptr.pointee
}
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)