Open Broadcaster Software
Free, open source software for live streaming and recording
obs_source_info Struct Reference

Data Fields

const char * id
 
enum obs_source_type type
 
uint32_t output_flags
 
const char *(* get_name )(void *type_data)
 
void *(* create )(obs_data_t *settings, obs_source_t *source)
 
void(* destroy )(void *data)
 
uint32_t(* get_width )(void *data)
 
uint32_t(* get_height )(void *data)
 
void(* get_defaults )(obs_data_t *settings)
 
obs_properties_t *(* get_properties )(void *data)
 
void(* update )(void *data, obs_data_t *settings)
 
void(* activate )(void *data)
 
void(* deactivate )(void *data)
 
void(* show )(void *data)
 
void(* hide )(void *data)
 
void(* video_tick )(void *data, float seconds)
 
void(* video_render )(void *data, gs_effect_t *effect)
 
struct obs_source_frame *(* filter_video )(void *data, struct obs_source_frame *frame)
 
struct obs_audio_data *(* filter_audio )(void *data, struct obs_audio_data *audio)
 
void(* enum_active_sources )(void *data, obs_source_enum_proc_t enum_callback, void *param)
 
void(* save )(void *data, obs_data_t *settings)
 
void(* load )(void *data, obs_data_t *settings)
 
void(* mouse_click )(void *data, const struct obs_mouse_event *event, int32_t type, bool mouse_up, uint32_t click_count)
 
void(* mouse_move )(void *data, const struct obs_mouse_event *event, bool mouse_leave)
 
void(* mouse_wheel )(void *data, const struct obs_mouse_event *event, int x_delta, int y_delta)
 
void(* focus )(void *data, bool focus)
 
void(* key_click )(void *data, const struct obs_key_event *event, bool key_up)
 
void(* filter_remove )(void *data, obs_source_t *source)
 
void * type_data
 
void(* free_type_data )(void *type_data)
 
bool(* audio_render )(void *data, uint64_t *ts_out, struct obs_source_audio_mix *audio_output, uint32_t mixers, size_t channels, size_t sample_rate)
 
void(* enum_all_sources )(void *data, obs_source_enum_proc_t enum_callback, void *param)
 
void(* transition_start )(void *data)
 
void(* transition_stop )(void *data)
 

Detailed Description

Source definition structure

Field Documentation

◆ activate

void(* obs_source_info::activate) (void *data)

Called when the source has been activated in the main view

◆ audio_render

bool(* obs_source_info::audio_render) (void *data, uint64_t *ts_out, struct obs_source_audio_mix *audio_output, uint32_t mixers, size_t channels, size_t sample_rate)

◆ create

void*(* obs_source_info::create) (obs_data_t *settings, obs_source_t *source)

Creates the source data for the source

Parameters
settingsSettings to initialize the source with
sourceSource that this data is associated with
Returns
The data associated with this source

◆ deactivate

void(* obs_source_info::deactivate) (void *data)

Called when the source has been deactivated from the main view (no longer being played/displayed)

◆ destroy

void(* obs_source_info::destroy) (void *data)

Destroys the private data for the source

Async sources must not call obs_source_output_video after returning from destroy

◆ enum_active_sources

void(* obs_source_info::enum_active_sources) (void *data, obs_source_enum_proc_t enum_callback, void *param)

Called to enumerate all active sources being used within this source. If the source has children that render audio/video it must implement this callback.

Parameters
dataFilter data
enum_callbackEnumeration callback
paramUser data to pass to callback

◆ enum_all_sources

void(* obs_source_info::enum_all_sources) (void *data, obs_source_enum_proc_t enum_callback, void *param)

Called to enumerate all active and inactive sources being used within this source. If this callback isn't implemented, enum_active_sources will be called instead.

This is typically used if a source can have inactive child sources.

Parameters
dataFilter data
enum_callbackEnumeration callback
paramUser data to pass to callback

◆ filter_audio

struct obs_audio_data*(* obs_source_info::filter_audio) (void *data, struct obs_audio_data *audio)

Called to filter raw audio data.

Note
This function is only used with filter sources.
Parameters
dataFilter data
audioAudio data to filter.
Returns
Modified or new audio data. You can directly modify the data passed and return it, or you can defer audio data for later if time is needed for processing. If you are returning new data, that data must exist until the next call to the filter_audio callback or until the filter is removed/destroyed.

◆ filter_remove

void(* obs_source_info::filter_remove) (void *data, obs_source_t *source)

Called when the filter is removed from a source

Parameters
dataFilter data
sourceSource that the filter being removed from

◆ filter_video

struct obs_source_frame*(* obs_source_info::filter_video) (void *data, struct obs_source_frame *frame)

Called to filter raw async video data.

Note
This function is only used with filter sources.
Parameters
dataFilter data
frameVideo frame to filter
Returns
New video frame data. This can defer video data to be drawn later if time is needed for processing

◆ focus

void(* obs_source_info::focus) (void *data, bool focus)

Called when interacting with a source and gain focus/lost focus event occurs.

Parameters
dataSource data
focusFocus state (true if focus gained)

◆ free_type_data

void(* obs_source_info::free_type_data) (void *type_data)

If defined, called to free private data on shutdown

◆ get_defaults

void(* obs_source_info::get_defaults) (obs_data_t *settings)

Gets the default settings for this source

Parameters
[out]settingsData to assign default settings to

◆ get_height

uint32_t(* obs_source_info::get_height) (void *data)

Returns the height of the source. Required if this is an input source and has non-async video

◆ get_name

const char*(* obs_source_info::get_name) (void *type_data)

Get the translated name of the source type

Parameters
type_dataThe type_data variable of this structure
Returns
The translated name of the source type

◆ get_properties

obs_properties_t*(* obs_source_info::get_properties) (void *data)

Gets the property information of this source

Returns
The properties data

◆ get_width

uint32_t(* obs_source_info::get_width) (void *data)

Returns the width of the source. Required if this is an input source and has non-async video

◆ hide

void(* obs_source_info::hide) (void *data)

Called when the source is no longer visible

◆ id

const char* obs_source_info::id

Unique string identifier for the source

◆ key_click

void(* obs_source_info::key_click) (void *data, const struct obs_key_event *event, bool key_up)

Called when interacting with a source and a key-up or key-down occurs.

Parameters
dataSource data
eventKey event properties
focusKey event type (true if mouse-up)

◆ load

void(* obs_source_info::load) (void *data, obs_data_t *settings)

Called when loading a source from saved data. This should be called after all the loading sources have actually been created because sometimes there are sources that depend on each other.

Parameters
dataSource data
settingsSettings

◆ mouse_click

void(* obs_source_info::mouse_click) (void *data, const struct obs_mouse_event *event, int32_t type, bool mouse_up, uint32_t click_count)

Called when interacting with a source and a mouse-down or mouse-up occurs.

Parameters
dataSource data
eventMouse event properties
typeMouse button pushed
mouse_upMouse event type (true if mouse-up)
click_countMouse click count (1 for single click, etc.)

◆ mouse_move

void(* obs_source_info::mouse_move) (void *data, const struct obs_mouse_event *event, bool mouse_leave)

Called when interacting with a source and a mouse-move occurs.

Parameters
dataSource data
eventMouse event properties
mouse_leaveMouse leave state (true if mouse left source)

◆ mouse_wheel

void(* obs_source_info::mouse_wheel) (void *data, const struct obs_mouse_event *event, int x_delta, int y_delta)

Called when interacting with a source and a mouse-wheel occurs.

Parameters
dataSource data
eventMouse event properties
x_deltaMovement delta in the horizontal direction
y_deltaMovement delta in the vertical direction

◆ output_flags

uint32_t obs_source_info::output_flags

Source output flags

◆ save

void(* obs_source_info::save) (void *data, obs_data_t *settings)

Called when saving a source. This is a separate function because sometimes a source needs to know when it is being saved so it doesn't always have to update the current settings until a certain point.

Parameters
dataSource data
settingsSettings

◆ show

void(* obs_source_info::show) (void *data)

Called when the source is visible

◆ transition_start

void(* obs_source_info::transition_start) (void *data)

◆ transition_stop

void(* obs_source_info::transition_stop) (void *data)

◆ type

enum obs_source_type obs_source_info::type

Type of source.

OBS_SOURCE_TYPE_INPUT for input sources, OBS_SOURCE_TYPE_FILTER for filter sources, and OBS_SOURCE_TYPE_TRANSITION for transition sources.

◆ type_data

void* obs_source_info::type_data

Private data associated with this entry

◆ update

void(* obs_source_info::update) (void *data, obs_data_t *settings)

Updates the settings for this source

Parameters
dataSource data
settingsNew settings for this source

◆ video_render

void(* obs_source_info::video_render) (void *data, gs_effect_t *effect)

Called when rendering the source with the graphics subsystem.

If this is an input/transition source, this is called to draw the source texture with the graphics subsystem using the specified effect.

If this is a filter source, it wraps source draw calls (for example applying a custom effect with custom parameters to a source). In this case, it's highly recommended to use the obs_source_process_filter function to automatically handle effect-based filter processing. However, you can implement custom draw handling as desired as well.

If the source output flags do not include SOURCE_CUSTOM_DRAW, all a source needs to do is set the "image" parameter of the effect to the desired texture, and then draw. If the output flags include SOURCE_COLOR_MATRIX, you may optionally set the "color_matrix" parameter of the effect to a custom 4x4 conversion matrix (by default it will be set to an YUV->RGB conversion matrix)

Parameters
dataSource data
effectEffect to be used with this source. If the source output flags include SOURCE_CUSTOM_DRAW, this will be NULL, and the source is expected to process with an effect manually.

◆ video_tick

void(* obs_source_info::video_tick) (void *data, float seconds)

Called each video frame with the time elapsed

Parameters
dataSource data
secondsSeconds elapsed since the last frame

The documentation for this struct was generated from the following file: