@@ -126,6 +126,27 @@ static void browser_source_get_defaults(obs_data_t *settings)
126
126
obs_data_set_default_bool (settings, " reroute_audio" , false );
127
127
}
128
128
129
+ static void browser_source_get_defaults_v2 (obs_data_t *settings)
130
+ {
131
+ struct obs_video_info ovi;
132
+ obs_get_video_info (&ovi);
133
+
134
+ obs_data_set_default_string (settings, " url" ,
135
+ " https://obsproject.com/browser-source" );
136
+ obs_data_set_default_int (settings, " width" , ovi.base_width );
137
+ obs_data_set_default_int (settings, " height" , ovi.base_height );
138
+ obs_data_set_default_int (settings, " fps" , 30 );
139
+ #if EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED
140
+ obs_data_set_default_bool (settings, " fps_custom" , false );
141
+ #else
142
+ obs_data_set_default_bool (settings, " fps_custom" , true );
143
+ #endif
144
+ obs_data_set_default_bool (settings, " shutdown" , false );
145
+ obs_data_set_default_bool (settings, " restart_when_active" , false );
146
+ obs_data_set_default_string (settings, " css" , default_css);
147
+ obs_data_set_default_bool (settings, " reroute_audio" , false );
148
+ }
149
+
129
150
static bool is_local_file_modified (obs_properties_t *props, obs_property_t *,
130
151
obs_data_t *settings)
131
152
{
@@ -325,7 +346,8 @@ void RegisterBrowserSource()
325
346
OBS_SOURCE_AUDIO |
326
347
#endif
327
348
OBS_SOURCE_CUSTOM_DRAW | OBS_SOURCE_INTERACTION |
328
- OBS_SOURCE_DO_NOT_DUPLICATE;
349
+ OBS_SOURCE_DO_NOT_DUPLICATE |
350
+ OBS_SOURCE_CAP_OBSOLETE;
329
351
info.get_properties = browser_source_get_properties;
330
352
info.get_defaults = browser_source_get_defaults;
331
353
info.icon_type = OBS_ICON_TYPE_BROWSER;
@@ -407,6 +429,98 @@ void RegisterBrowserSource()
407
429
obs_register_source (&info);
408
430
}
409
431
432
+ void RegisterBrowserSourceV2 ()
433
+ {
434
+ struct obs_source_info info = {};
435
+ info.id = " browser_source_v2" ;
436
+ info.type = OBS_SOURCE_TYPE_INPUT;
437
+ info.output_flags = OBS_SOURCE_VIDEO |
438
+ #if CHROME_VERSION_BUILD >= 3683
439
+ OBS_SOURCE_AUDIO |
440
+ #endif
441
+ OBS_SOURCE_CUSTOM_DRAW | OBS_SOURCE_INTERACTION |
442
+ OBS_SOURCE_DO_NOT_DUPLICATE;
443
+ info.get_properties = browser_source_get_properties;
444
+ info.get_defaults = browser_source_get_defaults_v2;
445
+ info.icon_type = OBS_ICON_TYPE_BROWSER;
446
+
447
+ info.get_name = [](void *) { return obs_module_text (" BrowserSource" ); };
448
+ info.create = [](obs_data_t *settings, obs_source_t *source) -> void * {
449
+ obs_browser_initialize ();
450
+ return new BrowserSource (settings, source);
451
+ };
452
+ info.destroy = [](void *data) {
453
+ delete static_cast <BrowserSource *>(data);
454
+ };
455
+ info.update = [](void *data, obs_data_t *settings) {
456
+ static_cast <BrowserSource *>(data)->Update (settings);
457
+ };
458
+ info.get_width = [](void *data) {
459
+ return (uint32_t ) static_cast <BrowserSource *>(data)->width ;
460
+ };
461
+ info.get_height = [](void *data) {
462
+ return (uint32_t ) static_cast <BrowserSource *>(data)->height ;
463
+ };
464
+ info.video_tick = [](void *data, float ) {
465
+ static_cast <BrowserSource *>(data)->Tick ();
466
+ };
467
+ info.video_render = [](void *data, gs_effect_t *) {
468
+ static_cast <BrowserSource *>(data)->Render ();
469
+ };
470
+ #if CHROME_VERSION_BUILD >= 3683
471
+ info.audio_mix = [](void *data, uint64_t *ts_out,
472
+ struct audio_output_data *audio_output,
473
+ size_t channels, size_t sample_rate) {
474
+ return static_cast <BrowserSource *>(data)->AudioMix (
475
+ ts_out, audio_output, channels, sample_rate);
476
+ };
477
+ info.enum_active_sources = [](void *data, obs_source_enum_proc_t cb,
478
+ void *param) {
479
+ static_cast <BrowserSource *>(data)->EnumAudioStreams (cb, param);
480
+ };
481
+ #endif
482
+ info.mouse_click = [](void *data, const struct obs_mouse_event *event,
483
+ int32_t type, bool mouse_up,
484
+ uint32_t click_count) {
485
+ static_cast <BrowserSource *>(data)->SendMouseClick (
486
+ event, type, mouse_up, click_count);
487
+ };
488
+ info.mouse_move = [](void *data, const struct obs_mouse_event *event,
489
+ bool mouse_leave) {
490
+ static_cast <BrowserSource *>(data)->SendMouseMove (event,
491
+ mouse_leave);
492
+ };
493
+ info.mouse_wheel = [](void *data, const struct obs_mouse_event *event,
494
+ int x_delta, int y_delta) {
495
+ static_cast <BrowserSource *>(data)->SendMouseWheel (
496
+ event, x_delta, y_delta);
497
+ };
498
+ info.focus = [](void *data, bool focus) {
499
+ static_cast <BrowserSource *>(data)->SendFocus (focus);
500
+ };
501
+ info.key_click = [](void *data, const struct obs_key_event *event,
502
+ bool key_up) {
503
+ static_cast <BrowserSource *>(data)->SendKeyClick (event, key_up);
504
+ };
505
+ info.show = [](void *data) {
506
+ static_cast <BrowserSource *>(data)->SetShowing (true );
507
+ };
508
+ info.hide = [](void *data) {
509
+ static_cast <BrowserSource *>(data)->SetShowing (false );
510
+ };
511
+ info.activate = [](void *data) {
512
+ BrowserSource *bs = static_cast <BrowserSource *>(data);
513
+ if (bs->restart )
514
+ bs->Refresh ();
515
+ bs->SetActive (true );
516
+ };
517
+ info.deactivate = [](void *data) {
518
+ static_cast <BrowserSource *>(data)->SetActive (false );
519
+ };
520
+
521
+ obs_register_source (&info);
522
+ }
523
+
410
524
/* ========================================================================= */
411
525
412
526
extern void DispatchJSEvent (std::string eventName, std::string jsonString,
@@ -565,6 +679,7 @@ bool obs_module_load(void)
565
679
EnumAdapterCount ();
566
680
#endif
567
681
RegisterBrowserSource ();
682
+ RegisterBrowserSourceV2 ();
568
683
obs_frontend_add_event_callback (handle_obs_frontend_event, nullptr );
569
684
570
685
#if EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED
0 commit comments