transition-stinger.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  1. #include <obs-module.h>
  2. #include <util/dstr.h>
  3. #define TIMING_TIME 0
  4. #define TIMING_FRAME 1
  5. #define MATTE_LAYOUT_HORIZONTAL 0
  6. #define MATTE_LAYOUT_VERTICAL 1
  7. #define MATTE_LAYOUT_SEPARATE_FILE 2
  8. enum fade_style { FADE_STYLE_FADE_OUT_FADE_IN, FADE_STYLE_CROSS_FADE };
  9. struct stinger_info {
  10. obs_source_t *source;
  11. obs_source_t *media_source;
  12. obs_source_t *matte_source;
  13. uint64_t duration_ns;
  14. uint64_t duration_frames;
  15. uint64_t transition_point_ns;
  16. uint64_t transition_point_frame;
  17. float transition_point;
  18. float transition_a_mul;
  19. float transition_b_mul;
  20. bool transitioning;
  21. bool transition_point_is_frame;
  22. int monitoring_type;
  23. enum fade_style fade_style;
  24. bool track_matte_enabled;
  25. int matte_layout;
  26. float matte_width_factor;
  27. float matte_height_factor;
  28. bool invert_matte;
  29. bool do_texrender;
  30. gs_effect_t *matte_effect;
  31. gs_eparam_t *ep_a_tex;
  32. gs_eparam_t *ep_b_tex;
  33. gs_eparam_t *ep_matte_tex;
  34. gs_eparam_t *ep_invert_matte;
  35. gs_texrender_t *matte_tex;
  36. gs_texrender_t *stinger_tex;
  37. float (*mix_a)(void *data, float t);
  38. float (*mix_b)(void *data, float t);
  39. };
  40. static const char *stinger_get_name(void *type_data)
  41. {
  42. UNUSED_PARAMETER(type_data);
  43. return obs_module_text("StingerTransition");
  44. }
  45. static float mix_a_fade_in_out(void *data, float t);
  46. static float mix_b_fade_in_out(void *data, float t);
  47. static float mix_a_cross_fade(void *data, float t);
  48. static float mix_b_cross_fade(void *data, float t);
  49. static void stinger_update(void *data, obs_data_t *settings)
  50. {
  51. struct stinger_info *s = data;
  52. const char *path = obs_data_get_string(settings, "path");
  53. bool hw_decode = obs_data_get_bool(settings, "hw_decode");
  54. obs_data_t *media_settings = obs_data_create();
  55. obs_data_set_string(media_settings, "local_file", path);
  56. obs_data_set_bool(media_settings, "hw_decode", hw_decode);
  57. obs_source_release(s->media_source);
  58. struct dstr name;
  59. dstr_init_copy(&name, obs_source_get_name(s->source));
  60. dstr_cat(&name, " (Stinger)");
  61. s->media_source = obs_source_create_private("ffmpeg_source", name.array,
  62. media_settings);
  63. dstr_free(&name);
  64. obs_data_release(media_settings);
  65. int64_t point = obs_data_get_int(settings, "transition_point");
  66. s->transition_point_is_frame = obs_data_get_int(settings, "tp_type") ==
  67. TIMING_FRAME;
  68. if (s->transition_point_is_frame)
  69. s->transition_point_frame = (uint64_t)point;
  70. else
  71. s->transition_point_ns = (uint64_t)(point * 1000000LL);
  72. bool track_matte_was_enabled = s->track_matte_enabled;
  73. s->track_matte_enabled =
  74. obs_data_get_bool(settings, "track_matte_enabled");
  75. s->matte_layout = (int)obs_data_get_int(settings, "track_matte_layout");
  76. s->matte_width_factor =
  77. (s->matte_layout == MATTE_LAYOUT_HORIZONTAL ? 2.0f : 1.0f);
  78. s->matte_height_factor =
  79. (s->matte_layout == MATTE_LAYOUT_VERTICAL ? 2.0f : 1.0f);
  80. s->invert_matte = obs_data_get_bool(settings, "invert_matte");
  81. s->do_texrender = s->track_matte_enabled &&
  82. s->matte_layout != MATTE_LAYOUT_SEPARATE_FILE;
  83. if (s->matte_source) {
  84. obs_source_release(s->matte_source);
  85. s->matte_source = NULL;
  86. }
  87. if (s->track_matte_enabled &&
  88. s->matte_layout == MATTE_LAYOUT_SEPARATE_FILE) {
  89. const char *tm_path =
  90. obs_data_get_string(settings, "track_matte_path");
  91. obs_data_t *tm_media_settings = obs_data_create();
  92. obs_data_set_string(tm_media_settings, "local_file", tm_path);
  93. s->matte_source = obs_source_create_private(
  94. "ffmpeg_source", NULL, tm_media_settings);
  95. obs_data_release(tm_media_settings);
  96. // no need to output sound from the matte video
  97. obs_source_set_muted(s->matte_source, true);
  98. }
  99. s->monitoring_type =
  100. (int)obs_data_get_int(settings, "audio_monitoring");
  101. obs_source_set_monitoring_type(s->media_source, s->monitoring_type);
  102. s->fade_style =
  103. (enum fade_style)obs_data_get_int(settings, "audio_fade_style");
  104. switch (s->fade_style) {
  105. default:
  106. case FADE_STYLE_FADE_OUT_FADE_IN:
  107. s->mix_a = mix_a_fade_in_out;
  108. s->mix_b = mix_b_fade_in_out;
  109. break;
  110. case FADE_STYLE_CROSS_FADE:
  111. s->mix_a = mix_a_cross_fade;
  112. s->mix_b = mix_b_cross_fade;
  113. break;
  114. }
  115. if (s->track_matte_enabled != track_matte_was_enabled) {
  116. obs_enter_graphics();
  117. gs_texrender_destroy(s->matte_tex);
  118. gs_texrender_destroy(s->stinger_tex);
  119. s->matte_tex = NULL;
  120. s->stinger_tex = NULL;
  121. if (s->track_matte_enabled) {
  122. s->matte_tex = gs_texrender_create(GS_RGBA, GS_ZS_NONE);
  123. s->stinger_tex =
  124. gs_texrender_create(GS_RGBA, GS_ZS_NONE);
  125. }
  126. obs_leave_graphics();
  127. }
  128. }
  129. static void *stinger_create(obs_data_t *settings, obs_source_t *source)
  130. {
  131. struct stinger_info *s = bzalloc(sizeof(*s));
  132. s->source = source;
  133. s->mix_a = mix_a_fade_in_out;
  134. s->mix_b = mix_b_fade_in_out;
  135. char *effect_file = obs_module_file("stinger_matte_transition.effect");
  136. char *error_string = NULL;
  137. obs_enter_graphics();
  138. s->matte_effect =
  139. gs_effect_create_from_file(effect_file, &error_string);
  140. obs_leave_graphics();
  141. if (!s->matte_effect) {
  142. blog(LOG_ERROR,
  143. "Could not open stinger_matte_transition.effect: %s",
  144. error_string);
  145. bfree(error_string);
  146. bfree(s);
  147. return NULL;
  148. }
  149. bfree(effect_file);
  150. s->ep_a_tex = gs_effect_get_param_by_name(s->matte_effect, "a_tex");
  151. s->ep_b_tex = gs_effect_get_param_by_name(s->matte_effect, "b_tex");
  152. s->ep_matte_tex =
  153. gs_effect_get_param_by_name(s->matte_effect, "matte_tex");
  154. s->ep_invert_matte =
  155. gs_effect_get_param_by_name(s->matte_effect, "invert_matte");
  156. obs_transition_enable_fixed(s->source, true, 0);
  157. obs_source_update(source, settings);
  158. return s;
  159. }
  160. static void stinger_destroy(void *data)
  161. {
  162. struct stinger_info *s = data;
  163. obs_source_release(s->media_source);
  164. obs_source_release(s->matte_source);
  165. obs_enter_graphics();
  166. gs_texrender_destroy(s->matte_tex);
  167. gs_texrender_destroy(s->stinger_tex);
  168. gs_effect_destroy(s->matte_effect);
  169. obs_leave_graphics();
  170. bfree(s);
  171. }
  172. static void stinger_defaults(obs_data_t *settings)
  173. {
  174. obs_data_set_default_bool(settings, "hw_decode", true);
  175. }
  176. static void stinger_matte_render(void *data, gs_texture_t *a, gs_texture_t *b,
  177. float t, uint32_t cx, uint32_t cy)
  178. {
  179. struct stinger_info *s = data;
  180. struct vec4 background;
  181. vec4_zero(&background);
  182. obs_source_t *matte_source =
  183. (s->matte_layout == MATTE_LAYOUT_SEPARATE_FILE
  184. ? s->matte_source
  185. : s->media_source);
  186. float matte_cx = (float)obs_source_get_width(matte_source) /
  187. s->matte_width_factor;
  188. float matte_cy = (float)obs_source_get_height(matte_source) /
  189. s->matte_height_factor;
  190. float width_offset = (s->matte_layout == MATTE_LAYOUT_HORIZONTAL
  191. ? (-matte_cx)
  192. : 0.0f);
  193. float height_offset =
  194. (s->matte_layout == MATTE_LAYOUT_VERTICAL ? (-matte_cy) : 0.0f);
  195. // Track matte media render
  196. if (matte_cx > 0 && matte_cy > 0) {
  197. float scale_x = (float)cx / matte_cx;
  198. float scale_y = (float)cy / matte_cy;
  199. if (gs_texrender_begin(s->matte_tex, cx, cy)) {
  200. gs_matrix_scale3f(scale_x, scale_y, 1.0f);
  201. gs_matrix_translate3f(width_offset, height_offset,
  202. 0.0f);
  203. gs_clear(GS_CLEAR_COLOR, &background, 0.0f, 0);
  204. gs_ortho(0.0f, (float)cx, 0.0f, (float)cy, -100.0f,
  205. 100.0f);
  206. obs_source_video_render(matte_source);
  207. gs_texrender_end(s->matte_tex);
  208. }
  209. }
  210. const bool previous = gs_framebuffer_srgb_enabled();
  211. gs_enable_framebuffer_srgb(true);
  212. gs_effect_set_texture(s->ep_a_tex, a);
  213. gs_effect_set_texture(s->ep_b_tex, b);
  214. gs_effect_set_texture(s->ep_matte_tex,
  215. gs_texrender_get_texture(s->matte_tex));
  216. gs_effect_set_bool(s->ep_invert_matte, s->invert_matte);
  217. while (gs_effect_loop(s->matte_effect, "StingerMatte"))
  218. gs_draw_sprite(NULL, 0, cx, cy);
  219. gs_enable_framebuffer_srgb(previous);
  220. UNUSED_PARAMETER(t);
  221. }
  222. static void stinger_texrender(struct stinger_info *s, uint32_t source_cx,
  223. uint32_t source_cy, uint32_t media_cx,
  224. uint32_t media_cy)
  225. {
  226. if (gs_texrender_begin(s->stinger_tex, source_cx, source_cy)) {
  227. float cx = (float)media_cx / s->matte_width_factor;
  228. float cy = (float)media_cy / s->matte_height_factor;
  229. gs_ortho(0.0f, cx, 0.0f, cy, -100.0f, 100.0f);
  230. gs_blend_state_push();
  231. gs_enable_blending(false);
  232. obs_source_video_render(s->media_source);
  233. gs_blend_state_pop();
  234. gs_texrender_end(s->stinger_tex);
  235. }
  236. }
  237. static void stinger_video_render(void *data, gs_effect_t *effect)
  238. {
  239. struct stinger_info *s = data;
  240. if (s->track_matte_enabled) {
  241. obs_transition_video_render(s->source, stinger_matte_render);
  242. } else {
  243. float t = obs_transition_get_time(s->source);
  244. bool use_a = t < s->transition_point;
  245. enum obs_transition_target target =
  246. use_a ? OBS_TRANSITION_SOURCE_A
  247. : OBS_TRANSITION_SOURCE_B;
  248. if (!obs_transition_video_render_direct(s->source, target))
  249. return;
  250. }
  251. /* --------------------- */
  252. uint32_t source_cx = obs_source_get_width(s->source);
  253. uint32_t source_cy = obs_source_get_height(s->source);
  254. float source_cxf = (float)source_cx;
  255. float source_cyf = (float)source_cy;
  256. uint32_t media_cx = obs_source_get_width(s->media_source);
  257. uint32_t media_cy = obs_source_get_height(s->media_source);
  258. if (!media_cx || !media_cy)
  259. return;
  260. if (s->do_texrender) {
  261. stinger_texrender(s, source_cx, source_cy, media_cx, media_cy);
  262. gs_effect_t *e = obs_get_base_effect(OBS_EFFECT_DEFAULT);
  263. gs_eparam_t *p = gs_effect_get_param_by_name(e, "image");
  264. gs_texture_t *tex = gs_texrender_get_texture(s->stinger_tex);
  265. gs_effect_set_texture(p, tex);
  266. while (gs_effect_loop(e, "Draw"))
  267. gs_draw_sprite(NULL, 0, source_cx, source_cy);
  268. } else {
  269. gs_matrix_push();
  270. gs_matrix_scale3f(source_cxf / (float)media_cx,
  271. source_cyf / (float)media_cy, 1.0f);
  272. obs_source_video_render(s->media_source);
  273. gs_matrix_pop();
  274. }
  275. UNUSED_PARAMETER(effect);
  276. }
  277. static void stinger_video_tick(void *data, float seconds)
  278. {
  279. struct stinger_info *s = data;
  280. if (s->track_matte_enabled) {
  281. gs_texrender_reset(s->stinger_tex);
  282. gs_texrender_reset(s->matte_tex);
  283. }
  284. UNUSED_PARAMETER(seconds);
  285. }
  286. static inline float calc_fade(float t, float mul)
  287. {
  288. t *= mul;
  289. return t > 1.0f ? 1.0f : t;
  290. }
  291. static float mix_a_fade_in_out(void *data, float t)
  292. {
  293. struct stinger_info *s = data;
  294. return 1.0f - calc_fade(t, s->transition_a_mul);
  295. }
  296. static float mix_b_fade_in_out(void *data, float t)
  297. {
  298. struct stinger_info *s = data;
  299. return 1.0f - calc_fade(1.0f - t, s->transition_b_mul);
  300. }
  301. static float mix_a_cross_fade(void *data, float t)
  302. {
  303. UNUSED_PARAMETER(data);
  304. return 1.0f - t;
  305. }
  306. static float mix_b_cross_fade(void *data, float t)
  307. {
  308. UNUSED_PARAMETER(data);
  309. return t;
  310. }
  311. static bool stinger_audio_render(void *data, uint64_t *ts_out,
  312. struct obs_source_audio_mix *audio,
  313. uint32_t mixers, size_t channels,
  314. size_t sample_rate)
  315. {
  316. struct stinger_info *s = data;
  317. uint64_t ts = 0;
  318. if (!s) {
  319. return false;
  320. }
  321. if (!obs_source_audio_pending(s->media_source)) {
  322. ts = obs_source_get_audio_timestamp(s->media_source);
  323. if (!ts)
  324. return false;
  325. }
  326. bool success = obs_transition_audio_render(s->source, ts_out, audio,
  327. mixers, channels,
  328. sample_rate, s->mix_a,
  329. s->mix_b);
  330. if (!ts)
  331. return success;
  332. if (!*ts_out || ts < *ts_out)
  333. *ts_out = ts;
  334. struct obs_source_audio_mix child_audio;
  335. obs_source_get_audio_mix(s->media_source, &child_audio);
  336. for (size_t mix = 0; mix < MAX_AUDIO_MIXES; mix++) {
  337. if ((mixers & (1 << mix)) == 0)
  338. continue;
  339. for (size_t ch = 0; ch < channels; ch++) {
  340. register float *out = audio->output[mix].data[ch];
  341. register float *in = child_audio.output[mix].data[ch];
  342. register float *end = in + AUDIO_OUTPUT_FRAMES;
  343. while (in < end)
  344. *(out++) += *(in++);
  345. }
  346. }
  347. return true;
  348. }
  349. static void stinger_transition_start(void *data)
  350. {
  351. struct stinger_info *s = data;
  352. if (s->media_source) {
  353. calldata_t cd = {0};
  354. proc_handler_t *ph =
  355. obs_source_get_proc_handler(s->media_source);
  356. proc_handler_t *matte_ph =
  357. s->matte_source
  358. ? obs_source_get_proc_handler(s->matte_source)
  359. : NULL;
  360. if (s->transitioning) {
  361. proc_handler_call(ph, "restart", &cd);
  362. if (matte_ph) {
  363. proc_handler_call(matte_ph, "restart", &cd);
  364. }
  365. return;
  366. }
  367. proc_handler_call(ph, "get_duration", &cd);
  368. proc_handler_call(ph, "get_nb_frames", &cd);
  369. s->duration_ns =
  370. (uint64_t)calldata_int(&cd, "duration") + 250000000ULL;
  371. s->duration_frames = (uint64_t)calldata_int(&cd, "num_frames");
  372. if (s->transition_point_is_frame)
  373. s->transition_point =
  374. (float)((long double)s->transition_point_frame /
  375. (long double)s->duration_frames);
  376. else
  377. s->transition_point =
  378. (float)((long double)s->transition_point_ns /
  379. (long double)s->duration_ns);
  380. if (s->transition_point > 0.999f)
  381. s->transition_point = 0.999f;
  382. else if (s->transition_point < 0.001f)
  383. s->transition_point = 0.001f;
  384. s->transition_a_mul = (1.0f / s->transition_point);
  385. s->transition_b_mul = (1.0f / (1.0f - s->transition_point));
  386. if (s->track_matte_enabled && s->matte_source) {
  387. proc_handler_call(matte_ph, "get_duration", &cd);
  388. uint64_t tm_duration_ns =
  389. (uint64_t)calldata_int(&cd, "duration");
  390. s->duration_ns = ((tm_duration_ns > s->duration_ns)
  391. ? (tm_duration_ns)
  392. : (s->duration_ns));
  393. obs_source_add_active_child(s->source, s->matte_source);
  394. }
  395. obs_transition_enable_fixed(
  396. s->source, true, (uint32_t)(s->duration_ns / 1000000));
  397. calldata_free(&cd);
  398. obs_source_add_active_child(s->source, s->media_source);
  399. }
  400. s->transitioning = true;
  401. }
  402. static void stinger_transition_stop(void *data)
  403. {
  404. struct stinger_info *s = data;
  405. if (s->media_source)
  406. obs_source_remove_active_child(s->source, s->media_source);
  407. if (s->matte_source)
  408. obs_source_remove_active_child(s->source, s->matte_source);
  409. s->transitioning = false;
  410. }
  411. static void stinger_enum_active_sources(void *data,
  412. obs_source_enum_proc_t enum_callback,
  413. void *param)
  414. {
  415. struct stinger_info *s = data;
  416. if (s->media_source && s->transitioning)
  417. enum_callback(s->source, s->media_source, param);
  418. if (s->matte_source && s->transitioning)
  419. enum_callback(s->source, s->matte_source, param);
  420. }
  421. static void stinger_enum_all_sources(void *data,
  422. obs_source_enum_proc_t enum_callback,
  423. void *param)
  424. {
  425. struct stinger_info *s = data;
  426. if (s->media_source)
  427. enum_callback(s->source, s->media_source, param);
  428. if (s->matte_source)
  429. enum_callback(s->source, s->matte_source, param);
  430. }
  431. #define FILE_FILTER \
  432. "Video Files (*.mp4 *.ts *.mov *.wmv *.flv *.mkv *.avi *.gif *.webm);;"
  433. static bool transition_point_type_modified(obs_properties_t *ppts,
  434. obs_property_t *p, obs_data_t *s)
  435. {
  436. int64_t type = obs_data_get_int(s, "tp_type");
  437. obs_property_t *prop_transition_point =
  438. obs_properties_get(ppts, "transition_point");
  439. if (type == TIMING_TIME) {
  440. obs_property_set_description(
  441. prop_transition_point,
  442. obs_module_text("TransitionPoint"));
  443. } else {
  444. obs_property_set_description(
  445. prop_transition_point,
  446. obs_module_text("TransitionPointFrame"));
  447. }
  448. bool uses_ms_prefix = (type == TIMING_TIME);
  449. obs_property_int_set_suffix(p, (uses_ms_prefix ? " ms" : ""));
  450. return true;
  451. }
  452. static bool track_matte_layout_modified(obs_properties_t *ppts,
  453. obs_property_t *p, obs_data_t *s)
  454. {
  455. int matte_layout = (int)obs_data_get_int(s, "track_matte_layout");
  456. obs_property_t *prop_matte_path =
  457. obs_properties_get(ppts, "track_matte_path");
  458. bool uses_separate_file = (matte_layout == MATTE_LAYOUT_SEPARATE_FILE);
  459. obs_property_set_visible(prop_matte_path, uses_separate_file);
  460. UNUSED_PARAMETER(p);
  461. return true;
  462. }
  463. static bool track_matte_enabled_modified(obs_properties_t *ppts,
  464. obs_property_t *p, obs_data_t *s)
  465. {
  466. bool track_matte_enabled = obs_data_get_bool(s, "track_matte_enabled");
  467. obs_property_t *prop_tp_type = obs_properties_get(ppts, "tp_type");
  468. if (track_matte_enabled) {
  469. obs_property_set_description(
  470. prop_tp_type,
  471. obs_module_text("AudioTransitionPointType"));
  472. } else {
  473. obs_property_set_description(
  474. prop_tp_type, obs_module_text("TransitionPointType"));
  475. }
  476. UNUSED_PARAMETER(p);
  477. return true;
  478. }
  479. static obs_properties_t *stinger_properties(void *data)
  480. {
  481. obs_properties_t *ppts = obs_properties_create();
  482. obs_properties_set_flags(ppts, OBS_PROPERTIES_DEFER_UPDATE);
  483. // main stinger settings
  484. obs_properties_add_path(ppts, "path", obs_module_text("VideoFile"),
  485. OBS_PATH_FILE, FILE_FILTER, NULL);
  486. obs_property_t *p = obs_properties_add_list(
  487. ppts, "tp_type", obs_module_text("TransitionPointType"),
  488. OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
  489. obs_properties_add_bool(ppts, "hw_decode",
  490. obs_module_text("HardwareDecode"));
  491. obs_property_list_add_int(p, obs_module_text("TransitionPointTypeTime"),
  492. TIMING_TIME);
  493. obs_property_list_add_int(
  494. p, obs_module_text("TransitionPointTypeFrame"), TIMING_FRAME);
  495. obs_property_set_modified_callback(p, transition_point_type_modified);
  496. obs_properties_add_int(ppts, "transition_point",
  497. obs_module_text("TransitionPoint"), 0, 120000,
  498. 1);
  499. // track matte properties
  500. {
  501. obs_properties_t *track_matte_group = obs_properties_create();
  502. p = obs_properties_add_list(track_matte_group,
  503. "track_matte_layout",
  504. obs_module_text("TrackMatteLayout"),
  505. OBS_COMBO_TYPE_LIST,
  506. OBS_COMBO_FORMAT_INT);
  507. obs_property_list_add_int(
  508. p, obs_module_text("TrackMatteLayoutHorizontal"),
  509. MATTE_LAYOUT_HORIZONTAL);
  510. obs_property_list_add_int(
  511. p, obs_module_text("TrackMatteLayoutVertical"),
  512. MATTE_LAYOUT_VERTICAL);
  513. /* TODO: Requires way to synchronize or combine two media files
  514. * together */
  515. #if 0
  516. obs_property_list_add_int(
  517. p, obs_module_text("TrackMatteLayoutSeparateFile"),
  518. MATTE_LAYOUT_SEPARATE_FILE);
  519. #endif
  520. obs_property_set_modified_callback(p,
  521. track_matte_layout_modified);
  522. obs_properties_add_path(track_matte_group, "track_matte_path",
  523. obs_module_text("TrackMatteVideoFile"),
  524. OBS_PATH_FILE, FILE_FILTER, NULL);
  525. obs_properties_add_bool(track_matte_group, "invert_matte",
  526. obs_module_text("InvertTrackMatte"));
  527. p = obs_properties_add_group(
  528. ppts, "track_matte_enabled",
  529. obs_module_text("TrackMatteEnabled"),
  530. OBS_GROUP_CHECKABLE, track_matte_group);
  531. obs_property_set_modified_callback(
  532. p, track_matte_enabled_modified);
  533. }
  534. // audio output settings
  535. obs_property_t *monitor_list = obs_properties_add_list(
  536. ppts, "audio_monitoring", obs_module_text("AudioMonitoring"),
  537. OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
  538. obs_property_list_add_int(monitor_list,
  539. obs_module_text("AudioMonitoring.None"),
  540. OBS_MONITORING_TYPE_NONE);
  541. obs_property_list_add_int(
  542. monitor_list, obs_module_text("AudioMonitoring.MonitorOnly"),
  543. OBS_MONITORING_TYPE_MONITOR_ONLY);
  544. obs_property_list_add_int(monitor_list,
  545. obs_module_text("AudioMonitoring.Both"),
  546. OBS_MONITORING_TYPE_MONITOR_AND_OUTPUT);
  547. // audio fade settings
  548. obs_property_t *audio_fade_style = obs_properties_add_list(
  549. ppts, "audio_fade_style", obs_module_text("AudioFadeStyle"),
  550. OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
  551. obs_property_list_add_int(
  552. audio_fade_style,
  553. obs_module_text("AudioFadeStyle.FadeOutFadeIn"),
  554. FADE_STYLE_FADE_OUT_FADE_IN);
  555. obs_property_list_add_int(audio_fade_style,
  556. obs_module_text("AudioFadeStyle.CrossFade"),
  557. FADE_STYLE_CROSS_FADE);
  558. UNUSED_PARAMETER(data);
  559. return ppts;
  560. }
  561. struct obs_source_info stinger_transition = {
  562. .id = "obs_stinger_transition",
  563. .type = OBS_SOURCE_TYPE_TRANSITION,
  564. .get_name = stinger_get_name,
  565. .create = stinger_create,
  566. .destroy = stinger_destroy,
  567. .update = stinger_update,
  568. .get_defaults = stinger_defaults,
  569. .video_render = stinger_video_render,
  570. .video_tick = stinger_video_tick,
  571. .audio_render = stinger_audio_render,
  572. .get_properties = stinger_properties,
  573. .enum_active_sources = stinger_enum_active_sources,
  574. .enum_all_sources = stinger_enum_all_sources,
  575. .transition_start = stinger_transition_start,
  576. .transition_stop = stinger_transition_stop,
  577. };