# Plugins

> Media linkers and hook scripts: upstream's two plugin points, registered as functions.

Symbols in this group are spelled `otio_attach_…` or `otio_detach_…` or `otio_register_…` or `otio_unregister_…`. An SDK drops that prefix.

## `attach_hook_script`

`otio_attach_hook_script` · free

Attaches the hook script `script` to the hook `hook`, after any attached already, declaring the hook if it is new.

The four hooks every read and write runs are `post_adapter_read`, `post_media_linker`, `pre_adapter_write` and `post_adapter_write`. Any other name declares a hook of the caller's own, which [`otio_node_run_hook`] runs. The script need not be registered yet, but must be by the time the hook runs.

```c
OtioStatus otio_attach_hook_script(
    const char *hook,
    const char *script,
    OtioBuffer *out_error);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `hook` | `text` | input |
| `script` | `text` | input |
| `out_error` | `text` | error |

## `detach_hook_script`

`otio_detach_hook_script` · free

Detaches every attachment of the hook script `script` from the hook `hook`. Returns whether it was attached.

```c
bool otio_detach_hook_script(const char *hook, const char *script);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `hook` | `text` | input |
| `script` | `text` | input |

## `register_hook_script`

`otio_register_hook_script` · free

Registers a hook script under `name`, replacing any registered already.

It runs only at the hooks it is attached to, with [`otio_attach_hook_script`]. `context` is handed to `function` on every call, and to `release`, which may be null, once the script is replaced or unregistered. A call that fails registers nothing and releases nothing.

```c
OtioStatus otio_register_hook_script(
    const char *name,
    OtioPluginFn function,
    void *context,
    OtioPluginReleaseFn release,
    OtioBuffer *out_error);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `name` | `text` | input |
| `function` | `plugin<hook_script>` | input |
| `context` (optional) | `context` | plugin context |
| `release` (optional) | `release` | plugin release |
| `out_error` | `text` | error |

## `register_media_linker`

`otio_register_media_linker` · free

Registers a media linker under `name`, replacing any registered already.

A read uses it when its options name it, or when the `OTIO_DEFAULT_MEDIA_LINKER` environment variable does and the options name none. `context` is handed to `function` on every call, and to `release`, which may be null, once the linker is replaced or unregistered. A call that fails registers nothing and releases nothing.

```c
OtioStatus otio_register_media_linker(
    const char *name,
    OtioPluginFn function,
    void *context,
    OtioPluginReleaseFn release,
    OtioBuffer *out_error);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `name` | `text` | input |
| `function` | `plugin<media_linker>` | input |
| `context` (optional) | `context` | plugin context |
| `release` (optional) | `release` | plugin release |
| `out_error` | `text` | error |

## `unregister_hook_script`

`otio_unregister_hook_script` · free

Unregisters the hook script registered under `name`, releasing its context. Returns whether there was one.

A hook it is still attached to fails when it runs, as upstream's does for a script its manifest lists and cannot find; detach it as well.

```c
bool otio_unregister_hook_script(const char *name);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `name` | `text` | input |

## `unregister_media_linker`

`otio_unregister_media_linker` · free

Unregisters the media linker registered under `name`, releasing its context. Returns whether there was one.

```c
bool otio_unregister_media_linker(const char *name);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `name` | `text` | input |

---

Page: https://otio-rust-docs.vercel.app/reference/plugins/
