Skip to content

Commit

Permalink
Add Move Source Swap filter
Browse files Browse the repository at this point in the history
  • Loading branch information
exeldro committed May 9, 2024
1 parent 8d855b6 commit 439d566
Show file tree
Hide file tree
Showing 12 changed files with 939 additions and 28 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ target_sources(${PROJECT_NAME} PRIVATE
move-transition-override-filter.c
move-filter.c
move-source-filter.c
move-source-swap-filter.c
move-value-filter.c
move-action-filter.c
audio-move.c
Expand Down
2 changes: 1 addition & 1 deletion audio-move.c
Original file line number Diff line number Diff line change
Expand Up @@ -741,8 +741,8 @@ void audio_move_tick(void *data, float seconds)
} else {
obs_data_set_double(settings, filter->setting_name, val);
}
obs_source_update(source, settings);
obs_data_release(settings);
obs_source_update(source, NULL);
obs_source_release(source);
}
}
Expand Down
6 changes: 6 additions & 0 deletions data/locale/en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ StartDelayTo="Start Delay To"
EndDelayTo="End Delay To"
StartDelayFrom="Start Delay From"
EndDelayFrom="End Delay From"
MoveSourceSwapFilter="Move Source Swap"
Stretch="Stretch"
Swap.No="No"
Swap.Start="Start"
Swap.End="End"
Swap.Midpoint="Midpoint"
MoveValueFilter="Move Value"
MoveValue="Move Value"
Filter="Filter"
Expand Down
2 changes: 1 addition & 1 deletion move-action-filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ static void *move_action_create(obs_data_t *settings, obs_source_t *source)
struct move_action_info *move_action = bzalloc(sizeof(struct move_action_info));
move_filter_init(&move_action->move_filter, source, move_action_start);
move_action->hotkey_id = OBS_INVALID_HOTKEY_ID;
obs_source_update(source, NULL);
obs_source_update(source, settings);
return move_action;
}

Expand Down
2 changes: 1 addition & 1 deletion move-directshow-filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ static void *move_directshow_create(obs_data_t *settings, obs_source_t *source)
move_directshow->procAmpProps = new std::map<long, directshow_property>();
pthread_mutex_init(&move_directshow->mutex, nullptr);
os_event_init(&move_directshow->start_event, OS_EVENT_TYPE_AUTO);
obs_source_update(source, NULL);
obs_source_update(source, settings);
move_directshow->run = true;
pthread_create(&move_directshow->thread, NULL, move_directshow_thread, move_directshow);
return move_directshow;
Expand Down
27 changes: 10 additions & 17 deletions move-filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ bool is_move_filter(const char *filter_id)
{
if (!filter_id)
return false;
return strcmp(filter_id, MOVE_SOURCE_FILTER_ID) == 0 || strcmp(filter_id, MOVE_VALUE_FILTER_ID) == 0 ||
strcmp(filter_id, MOVE_AUDIO_VALUE_FILTER_ID) == 0 || strcmp(filter_id, MOVE_ACTION_FILTER_ID) == 0 ||
strcmp(filter_id, MOVE_AUDIO_ACTION_FILTER_ID) == 0 || strcmp(filter_id, MOVE_DIRECTSHOW_FILTER_ID) == 0;
return strcmp(filter_id, MOVE_SOURCE_FILTER_ID) == 0 || strcmp(filter_id, MOVE_SOURCE_SWAP_FILTER_ID) == 0 ||
strcmp(filter_id, MOVE_VALUE_FILTER_ID) == 0 || strcmp(filter_id, MOVE_AUDIO_VALUE_FILTER_ID) == 0 ||
strcmp(filter_id, MOVE_ACTION_FILTER_ID) == 0 || strcmp(filter_id, MOVE_AUDIO_ACTION_FILTER_ID) == 0 ||
strcmp(filter_id, MOVE_DIRECTSHOW_FILTER_ID) == 0;
}

void move_filter_init(struct move_filter *move_filter, obs_source_t *source, void (*move_start)(void *data))
Expand Down Expand Up @@ -78,10 +79,8 @@ void move_filter_start_hotkey(void *data, obs_hotkey_id id, obs_hotkey_t *hotkey
return;
}
filter = obs_source_get_filter_by_name(parent, next_move_name);
if (!filter && move_filter->get_alternative_source) {
obs_source_t *alternative_source = move_filter->get_alternative_source(move_filter);
if (alternative_source)
filter = obs_source_get_filter_by_name(alternative_source, next_move_name);
if (!filter && move_filter->get_alternative_filter) {
filter = move_filter->get_alternative_filter(move_filter, next_move_name);
}

if (filter) {
Expand Down Expand Up @@ -232,11 +231,8 @@ bool move_filter_start_internal(struct move_filter *move_filter)
obs_source_t *parent = obs_filter_get_parent(move_filter->source);
if (parent) {
obs_source_t *filter = obs_source_get_filter_by_name(parent, move_filter->simultaneous_move_name);
if (!filter && move_filter->get_alternative_source) {
obs_source_t *alternative_source = move_filter->get_alternative_source(move_filter);
if (alternative_source)
filter = obs_source_get_filter_by_name(alternative_source,
move_filter->simultaneous_move_name);
if (!filter && move_filter->get_alternative_filter) {
filter = move_filter->get_alternative_filter(move_filter, move_filter->simultaneous_move_name);
}

if (filter) {
Expand Down Expand Up @@ -280,11 +276,8 @@ extern void move_filter_ended(struct move_filter *move_filter)
if (parent) {
obs_source_t *filter = obs_source_get_filter_by_name(parent, move_filter->next_move_name);

if (!filter && move_filter->get_alternative_source) {
obs_source_t *alternative_source = move_filter->get_alternative_source(move_filter);
if (alternative_source)
filter = obs_source_get_filter_by_name(alternative_source,
move_filter->next_move_name);
if (!filter && move_filter->get_alternative_filter) {
filter = move_filter->get_alternative_filter(move_filter, move_filter->next_move_name);
}

if (filter) {
Expand Down
11 changes: 7 additions & 4 deletions move-source-filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,18 +598,21 @@ void move_source_source_rename(void *data, calldata_t *call_data)
obs_data_release(settings);
}

obs_source_t *move_source_get_source(void *data)
obs_source_t *move_source_get_source(void *data, const char *name)
{
struct move_source_info *move_source = data;
return obs_sceneitem_get_source(move_source->scene_item);
obs_source_t *source = obs_sceneitem_get_source(move_source->scene_item);
if (!source)
return NULL;
return obs_source_get_filter_by_name(source, name);
}

static void *move_source_create(obs_data_t *settings, obs_source_t *source)
{
struct move_source_info *move_source = bzalloc(sizeof(struct move_source_info));
move_filter_init(&move_source->move_filter, source, (void (*)(void *))move_source_start);
move_source->move_filter.get_alternative_source = move_source_get_source;
obs_source_update(source, NULL);
move_source->move_filter.get_alternative_filter = move_source_get_source;
obs_source_update(source, settings);
signal_handler_connect(obs_get_signal_handler(), "source_rename", move_source_source_rename, move_source);

return move_source;
Expand Down
Loading

0 comments on commit 439d566

Please sign in to comment.