obs-data.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /******************************************************************************
  2. Copyright (C) 2013 by Hugh Bailey <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. #pragma once
  15. #include "util/darray.h"
  16. #include "util/threading.h"
  17. #include "graphics/graphics.h"
  18. #include "media-io/video-io.h"
  19. #include "media-io/audio-io.h"
  20. #include "obs.h"
  21. #include "obs-module.h"
  22. #include "obs-source.h"
  23. #include "obs-output.h"
  24. #include "obs-service.h"
  25. #include "obs-encoder.h"
  26. #define LOAD_MODULE_SUBFUNC(name, required) \
  27. do { \
  28. info->name = load_module_subfunc(module, module_name, \
  29. id, #name, required); \
  30. if (required && !info->name) \
  31. return false; \
  32. } while (false)
  33. #define NUM_TEXTURES 2
  34. struct obs_display {
  35. swapchain_t swap; /* can be NULL if just sound */
  36. obs_source_t channels[MAX_CHANNELS];
  37. /* TODO: sound output target */
  38. };
  39. /* ------------------------------------------------------------------------- */
  40. struct obs_video {
  41. graphics_t graphics;
  42. stagesurf_t copy_surfaces[NUM_TEXTURES];
  43. texture_t render_textures[NUM_TEXTURES];
  44. texture_t output_textures[NUM_TEXTURES];
  45. effect_t default_effect;
  46. bool textures_copied[NUM_TEXTURES];
  47. bool copy_mapped;
  48. int cur_texture;
  49. video_t video;
  50. pthread_t video_thread;
  51. bool thread_initialized;
  52. uint32_t base_width;
  53. uint32_t base_height;
  54. };
  55. struct obs_audio {
  56. /* TODO: audio subsystem */
  57. audio_t audio;
  58. };
  59. /* user sources, output channels, and displays */
  60. struct obs_data {
  61. /* arrays of pointers jim? you should really stop being lazy and use
  62. * linked lists. */
  63. DARRAY(struct obs_display*) displays;
  64. DARRAY(struct obs_source*) sources;
  65. DARRAY(struct obs_output*) outputs;
  66. DARRAY(struct obs_encoder*) encoders;
  67. obs_source_t channels[MAX_CHANNELS];
  68. pthread_mutex_t sources_mutex;
  69. pthread_mutex_t displays_mutex;
  70. pthread_mutex_t outputs_mutex;
  71. pthread_mutex_t encoders_mutex;
  72. volatile bool valid;
  73. };
  74. struct obs_subsystem {
  75. DARRAY(struct obs_module) modules;
  76. DARRAY(struct source_info) input_types;
  77. DARRAY(struct source_info) filter_types;
  78. DARRAY(struct source_info) transition_types;
  79. DARRAY(struct output_info) output_types;
  80. DARRAY(struct encoder_info) encoder_types;
  81. DARRAY(struct service_info) service_types;
  82. signal_handler_t signals;
  83. proc_handler_t procs;
  84. /* segmented into multiple sub-structures to keep things a bit more
  85. * clean and organized */
  86. struct obs_video video;
  87. struct obs_audio audio;
  88. struct obs_data data;
  89. };
  90. extern struct obs_subsystem *obs;
  91. extern void *obs_video_thread(void *param);