obs-studio/plugins/mac-avcapture/plugin-properties.h
PatTheMav 03c42e5b93 mac-avcapture: Fix crash issues on Intel-based Macs and older macOS
Fixes several possible crash issues that might occur on Intel-based Macs
and older macOS versions:

On modern macOS versions (13+) allocated memory is zero-allocated by
default which makes NULL pointer checks work correctly after allocation.

On older macOS versions this is not the case, so the OBSAVCaptureInfo
struct needs to be zero-allocated to ensure the guards in the tick and
render functions bail out correctly.

On Intel-based Macs and/or older macOS versions passing a reference to
the OBSAVCapture instance inside the OBSAVCapture struct can lead to a
crash because of a possible circular reference that cannot be resolved
at runtime.

Passing only a reference of the OBSAVCapture to libobs and incrementing
the retain count at source creation (decrementing in when the source is
destroyed) avoids this issue entirely.
2024-02-20 17:57:09 -05:00

85 lines
4.4 KiB
Objective-C

//
// plugin-properties.h
// obs-studio
//
// Created by Patrick Heyer on 2023-03-07.
//
@import Foundation;
#import <obs-properties.h>
/// Configures single source property's visibility, possible modification callback and callback payload data, as well as whether the property should be enabled
/// - Parameters:
/// - property: The source property to change
/// - enable: Whether the source property should be enabled (user-changeable)
/// - visible: Whether the source property should be visible
/// - callback: Pointer to a function that will be called if this property has been modified or the properties are reloaded
/// - capture: Optional reference to ``OBSAVCapture`` instance
void configure_property(obs_property_t *property, bool enable, bool visible, void *callback, OBSAVCapture *capture);
/// Generic callback handler for changed properties. Will update all properties of an OBSAVCapture source at once
/// - Parameters:
/// - capture: Pointer to ``OBSAVCapture`` instance
/// - properties: Pointer to properties struct associated with the source
/// - property: Pointer to the property that the callback is attached to
/// - settings: Pointer to settings associated with the source
/// - Returns: Always returns true
bool properties_changed(OBSAVCapture *capture, obs_properties_t *properties, obs_property_t *property,
obs_data_t *settings);
/// Callback handler for preset changes.
/// - Parameters:
/// - capture: Pointer to ``OBSAVCapture`` instance
/// - properties: Pointer to properties struct associated with the source
/// - property: Pointer to the property that the callback is attached to
/// - settings: Pointer to settings associated with the source
/// - Returns: Always returns true
bool properties_changed_preset(OBSAVCapture *capture, obs_properties_t *properties, obs_property_t *property,
obs_data_t *settings);
/// Callback handler for changing preset usage for an OBSAVCapture source. Switches between preset-based configuration and manual configuration
/// - Parameters:
/// - capture: Pointer to ``OBSAVCapture`` instance
/// - properties: Pointer to properties struct associated with the source
/// - property: Pointer to the property that the callback is attached to
/// - settings: Pointer to settings associated with the source
/// - Returns: Always returns true
bool properties_changed_use_preset(OBSAVCapture *capture, obs_properties_t *properties, obs_property_t *property,
obs_data_t *settings);
/// Updates preset property with description-value-pairs of presets supported by the currently selected device
/// - Parameters:
/// - capture: Pointer to ``OBSAVCapture`` instance
/// - property: Pointer to the property that the callback is attached to
/// - settings: Pointer to settings associated with the source
/// - Returns: Always returns true
bool properties_update_preset(OBSAVCapture *capture, obs_property_t *property, obs_data_t *settings);
/// Updates device property with description-value-pairs of devices available via CoreMediaIO
/// - Parameters:
/// - capture: Pointer to ``OBSAVCapture`` instance
/// - property: Pointer to the property that the callback is attached to
/// - settings: Pointer to settings associated with the source
/// - Returns: Always returns true
bool properties_update_device(OBSAVCapture *capture, obs_property_t *property, obs_data_t *settings);
/// Updates available values for all properties required in manual device configuration.
///
/// Properties updated by this call include:
/// * Resolutions
/// * Frame rates and frame rate ranges
/// * Color formats
/// * Color range
///
/// In CoreMediaIO color format, resolution and frame rate ranges are always coupled into a single format, while color range is always contained in the color format. The formats are thus compiled and de-duplicated to create a selection of all properties.
///
/// Frame rate ranges will be limited to ranges only available for a specific combination of resolution and color format.
///
/// - Parameters:
/// - capture: Pointer to ``OBSAVCapture`` instance
/// - property: Pointer to the property that the callback is attached to
/// - settings: Pointer to settings associated with the source
/// - Returns: Always returns true
bool properties_update_config(OBSAVCapture *capture, obs_properties_t *properties, obs_data_t *settings);