Skip to content

Commit

Permalink
obs-browser: Update default size
Browse files Browse the repository at this point in the history
  • Loading branch information
cg2121 committed Feb 22, 2020
1 parent 8be8910 commit 1bc8cc5
Showing 1 changed file with 49 additions and 9 deletions.
58 changes: 49 additions & 9 deletions obs-browser-plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,27 @@ static void browser_source_get_defaults(obs_data_t *settings)
obs_data_set_default_bool(settings, "reroute_audio", false);
}

static void browser_source_get_defaults_v2(obs_data_t *settings)
{
struct obs_video_info ovi;
obs_get_video_info(&ovi);

obs_data_set_default_string(settings, "url",
"https://obsproject.com/browser-source");
obs_data_set_default_int(settings, "width", ovi.base_width);
obs_data_set_default_int(settings, "height", ovi.base_height);
obs_data_set_default_int(settings, "fps", 30);
#if EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED
obs_data_set_default_bool(settings, "fps_custom", false);
#else
obs_data_set_default_bool(settings, "fps_custom", true);
#endif
obs_data_set_default_bool(settings, "shutdown", false);
obs_data_set_default_bool(settings, "restart_when_active", false);
obs_data_set_default_string(settings, "css", default_css);
obs_data_set_default_bool(settings, "reroute_audio", false);
}

static bool is_local_file_modified(obs_properties_t *props, obs_property_t *,
obs_data_t *settings)
{
Expand Down Expand Up @@ -315,19 +336,37 @@ extern "C" EXPORT void obs_browser_initialize(void)
}
}

void RegisterBrowserSource()
void RegisterBrowserSource(int version)
{
struct obs_source_info info = {};
info.id = "browser_source";
info.type = OBS_SOURCE_TYPE_INPUT;
info.output_flags = OBS_SOURCE_VIDEO |

switch (version) {
case 1:
info.id = "browser_source";
info.output_flags =
OBS_SOURCE_VIDEO |
#if CHROME_VERSION_BUILD >= 3683
OBS_SOURCE_AUDIO |
#endif
OBS_SOURCE_CUSTOM_DRAW | OBS_SOURCE_INTERACTION |
OBS_SOURCE_DO_NOT_DUPLICATE | OBS_SOURCE_CAP_OBSOLETE;
info.get_defaults = browser_source_get_defaults;
break;
case 2:
info.id = "browser_source_v2";
info.output_flags = OBS_SOURCE_VIDEO |
#if CHROME_VERSION_BUILD >= 3683
OBS_SOURCE_AUDIO |
OBS_SOURCE_AUDIO |
#endif
OBS_SOURCE_CUSTOM_DRAW | OBS_SOURCE_INTERACTION |
OBS_SOURCE_DO_NOT_DUPLICATE;
OBS_SOURCE_CUSTOM_DRAW |
OBS_SOURCE_INTERACTION |
OBS_SOURCE_DO_NOT_DUPLICATE;
info.get_defaults = browser_source_get_defaults_v2;
break;
}

info.type = OBS_SOURCE_TYPE_INPUT;
info.get_properties = browser_source_get_properties;
info.get_defaults = browser_source_get_defaults;
info.icon_type = OBS_ICON_TYPE_BROWSER;

info.get_name = [](void *) { return obs_module_text("BrowserSource"); };
Expand Down Expand Up @@ -564,7 +603,8 @@ bool obs_module_load(void)
#ifdef _WIN32
EnumAdapterCount();
#endif
RegisterBrowserSource();
RegisterBrowserSource(1);
RegisterBrowserSource(2);
obs_frontend_add_event_callback(handle_obs_frontend_event, nullptr);

#if EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED
Expand Down

0 comments on commit 1bc8cc5

Please sign in to comment.