obs-output.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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/c99defs.h"
  16. #include "util/dstr.h"
  17. /*
  18. * ===========================================
  19. * Outputs
  20. * ===========================================
  21. *
  22. * An output takes raw audio and/or video and processes and/or outputs it
  23. * to a destination, whether that destination be a file, network, or other.
  24. *
  25. * A module with outputs needs to export these functions:
  26. * + enum_outputs
  27. *
  28. * Each individual output is then exported by it's name. For example, an
  29. * output named "myoutput" would have the following exports:
  30. * + myoutput_getname
  31. * + myoutput_create
  32. * + myoutput_destroy
  33. * + myoutput_start
  34. * + myoutput_stop
  35. * + myoutput_encoders
  36. *
  37. * [and optionally]
  38. * + myoutput_config
  39. * + myoutput_pause
  40. *
  41. * ===========================================
  42. * Primary Exports
  43. * ===========================================
  44. * const char *enum_outputs(size_t idx);
  45. * idx: index of the output.
  46. * Return value: Output identifier name. NULL when no more available.
  47. *
  48. * ===========================================
  49. * Output Exports
  50. * ===========================================
  51. * const char *[name]_getname(const char *locale);
  52. * Returns the full translated name of the output type (seen by the user).
  53. *
  54. * ---------------------------------------------------------
  55. * void *[name]_create(const char *settings, obs_output_t output);
  56. * Creates an output.
  57. *
  58. * settings: Settings of the output.
  59. * output: pointer to main output
  60. * Return value: Internal output pointer, or NULL if failed.
  61. *
  62. * ---------------------------------------------------------
  63. * void [name]_destroy(void *data);
  64. * Destroys the output.
  65. *
  66. * ---------------------------------------------------------
  67. * void [name]_update(void *data, const char *settings)
  68. * Updates the output's settings
  69. *
  70. * settings: New settings of the output
  71. *
  72. * ---------------------------------------------------------
  73. * bool [name]_start(void *data)
  74. * Starts output
  75. *
  76. * Return value: true if successful
  77. *
  78. * ---------------------------------------------------------
  79. * void [name]_stop(void *data)
  80. * Stops output
  81. *
  82. * ---------------------------------------------------------
  83. * bool [name]_active(void *data)
  84. * Returns whether currently active or not
  85. *
  86. * ---------------------------------------------------------
  87. * uint32_t [name]_encoders(void *data)
  88. * Returns 0 or a combination of the following values:
  89. * + OUTPUT_VIDEO_ENCODER: requires a video encoder
  90. * + OUTPUT_AUDIO_ENCODER: requires an audio encoder
  91. *
  92. * ===========================================
  93. * Optional Output Exports
  94. * ===========================================
  95. * bool [name]_setencoder(void *data, obs_encoder_t encoder,
  96. * enum obs_encoder_type type)
  97. * Sets the encoder for this output.
  98. *
  99. * encoder: Encoder context
  100. * type: Type of encoder (ENCODER_VIDEO or ENCODER_AUDIO)
  101. *
  102. * Returns true if successful and compatible
  103. *
  104. * ---------------------------------------------------------
  105. * obs_encoder_t [name]_getencoder(void *data, enum obs_encoder_type type)
  106. * Gets the encoder for this output
  107. *
  108. * type: Type of encoder
  109. *
  110. * Returns the encoder, or NULL if none.
  111. *
  112. * ---------------------------------------------------------
  113. * void [name]_config(void *data, void *parent);
  114. * Called to configure the output.
  115. *
  116. * parent: Parent window pointer
  117. *
  118. * ---------------------------------------------------------
  119. * void [name]_pause(void *data)
  120. * Pauses output. Typically only usable for local recordings.
  121. */
  122. struct obs_output;
  123. struct output_info {
  124. const char *id;
  125. const char *(*getname)(const char *locale);
  126. void *(*create)(const char *settings, struct obs_output *output);
  127. void (*destroy)(void *data);
  128. bool (*start)(void *data);
  129. void (*stop)(void *data);
  130. bool (*active)(void *data);
  131. /* optional */
  132. void (*update)(void *data, const char *settings);
  133. void (*pause)(void *data);
  134. };
  135. struct obs_output {
  136. char *name;
  137. void *data;
  138. struct output_info callbacks;
  139. struct dstr settings;
  140. };
  141. extern bool load_output_info(void *module, const char *module_name,
  142. const char *output_name, struct output_info *info);