Skip to content

way to send message to browser source #647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: streamlabs
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions libobs/obs-source.c
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,31 @@ void obs_source_reset_settings(obs_source_t *source, obs_data_t *settings)
obs_source_update(source, settings);
}

void obs_source_send_message(obs_source_t *source, obs_data_t *settings)
{
if (!obs_source_valid(source, "obs_source_send_message"))
return;

if (source->info.output_flags & OBS_SOURCE_INTERACTION) {
if (source->info.message) {
source->info.message(source->context.data, settings);
}
}
}

obs_data_array_t *obs_source_get_messages(obs_source_t *source)
{
if (!obs_source_valid(source, "obs_source_get_messages"))
return NULL;

if (source->info.output_flags & OBS_SOURCE_INTERACTION) {
if (source->info.get_messages) {
return source->info.get_messages(source->context.data);
}
}
return NULL;
}

void obs_source_update_properties(obs_source_t *source)
{
if (!obs_source_valid(source, "obs_source_update_properties"))
Expand Down
6 changes: 6 additions & 0 deletions libobs/obs-source.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,12 @@ struct obs_source_info {
/** Called when the source has been activated in the main view */
void (*activate)(void *data);

/** Called to send message to the source */
void (*message)(void *data, obs_data_t *settings);

/** Called to get messages from the source */
obs_data_array_t *(*get_messages)(void *data);

/**
* Called when the source has been deactivated from the main view
* (no longer being played/displayed)
Expand Down
3 changes: 3 additions & 0 deletions libobs/obs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1234,6 +1234,9 @@ EXPORT void obs_source_update(obs_source_t *source, obs_data_t *settings);
EXPORT void obs_source_reset_settings(obs_source_t *source,
obs_data_t *settings);

EXPORT void obs_source_send_message(obs_source_t *source, obs_data_t *settings);
EXPORT obs_data_array_t *obs_source_get_messages(obs_source_t *source);

/** Renders a video source. */
EXPORT void obs_source_video_render(obs_source_t *source);

Expand Down
Loading