README 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. What is OBS?
  2. This project is a rewrite of what was formerly known as "Open Broadcaster
  3. Software", software originally designed for recording and streaming live
  4. video content, efficiently.
  5. What's the goal of rewriting OBS?
  6. - Make it multiplatform. Use multiplatform libraries/functions/classes where
  7. possible to allow this. Multi-platform support was one of the primary
  8. reasons for the rewrite. This also means using a UI toolkit will be
  9. necessary for user interface. It also means allowing the use of OpenGL as
  10. well as Direct3D.
  11. - Separate the application from the core, allowing custom application of
  12. the core if desired, and easier extending of the user interface.
  13. - Simplify complex systems to not only make it easier to use, but easier to
  14. maintain.
  15. - Write a better core API, and design the entire system to be modular.
  16. - Now that we have much more experience, improve the overall design of all
  17. the subsystems/API, and minimize/eliminate design flaws. Make it so we can
  18. do all the things we've had trouble with before, such as custom outputs,
  19. multiple outputs at once, better handling of inputs, custom services.
  20. - Make a better/cleaner code base, use better coding standards, use standard
  21. libraries where possible (not just STL and C standard library, but also
  22. things like ffmpeg as well), and improve maintainability of the project as a
  23. whole.
  24. - Implement a new API-independent shader/effect system allowing better and
  25. easier shaders usage and customization without having to duplicate shader
  26. code.
  27. - Better device support. Again, I didn't know what I was getting into when
  28. I originally started writing code for devices. It evolved into a totally
  29. convoluted mess. I would have improved the existing device plugin code, but
  30. it was just all so fundamentally bad and flawed that it would have been
  31. detrimental to progression to continue working on it rather than rewrite it.
  32. What was wrong with the original OBS?
  33. The original OBS was rewritten not because it was bad, at least in terms of
  34. optimization. Optimization and graphics are things I love. However, there
  35. were some serious problems with the code and design that were deep and
  36. fundamental, which prevented myself and other developers from being able to
  37. improve/extend the application or add new features very easily.
  38. First, the design flaws:
  39. - The original OBS was completely and hopelessly hard-coded for windows,
  40. and only windows. It was just totally impossible to use it on other
  41. systems.
  42. - All the sub-systems were written before I really knew what I was getting
  43. into. When I started the project, I didn't really fully comprehend the
  44. scope of what I would need or how to properly design the project. My
  45. design and plans for the application were just to write something that
  46. would "stream games and a webcam, with things like overlays and such."
  47. This turned out fine for most casual gamers and streamers (and very
  48. successful), but left anyone wanting to do anything more advanced left
  49. massively wanting.
  50. - Subsystems and core functionalities intermingled in such a way that it
  51. was a nightmare to get proper custom functionality out of it. Things
  52. like QSV had to be meshed in with the main encoding loop, and it just
  53. made things a nightmare to deal with. Custom outputs were nigh
  54. impossible.
  55. - The API was poorly designed because most of it came after I originally
  56. wrote the application, it was more of an afterthought, and plugin API
  57. would routinely break for plugin developers due to changing C++
  58. interfaces (one of the reasons the core is now C).
  59. - API was intermeshed with the main executable. The OBSApi DLL was
  60. nothing more than basically this mutant growth upon OBS.exe that allowed
  61. plugin developers to barely write plugins, but all the important API
  62. code was actually stored in the executable. Navigation was a total mess.
  63. - The graphics subsystem, while not bad, was incomplete, and though far
  64. easier to use than bare D3D, wasn't ideal, and was hard-coded for D3D
  65. specifically.
  66. - The devices and audio code was poor, I had no idea what I was getting into
  67. when I started writing them in. I did not realize beforehand all the
  68. device-specific quirks that each device/system could have. Some devices
  69. had bad timing and quirks that I never aniticipated while writing them.
  70. I struggled with devices, and my original design for the audio subsystem
  71. for example morphed over and over into an abomination that, though works,
  72. is basically this giant duct-taped zombie monster.
  73. - Shaders were difficult to customize because they had to be duplicated if
  74. you wanted slightly different functionality that required more than just
  75. changing shader constants.
  76. - Oriantation of sources was fixed, and required special code for each
  77. source to do any custom modification of rotation/position/scale/etc.
  78. This is one of those fundamental flaws that I look back on and regret, as
  79. it was a stupid idea from the beginning. I originally thought I could
  80. get more accurate source position/sizes, but it just turned out to be
  81. totally bad. Should have been matrices from the beginning just like with
  82. a regular 3D engine.
  83. Second, the coding flaws:
  84. - The coding style was inconsistent.
  85. - C++98, C-Style C++, there was no exception usage, no STL. C++ used
  86. poorly.
  87. - Not Invented Here Syndrome everywhere. Custom string functions/classes,
  88. custom templates, custom everything everywhere. To be fair, it was all
  89. hand-me-down code from the early 2000s that I had become used to, but
  90. that was no excuse -- C-standard libraries and the STL should have been
  91. used from the beginning over anything else. That doesn't mean to say
  92. that using custom stuff is always bad, but doing it to the extent I did
  93. definitely was. Made it horrible to maintain as well, required extra
  94. knowledge for plugin developers and anyone messing with the code.
  95. - Giant monolithic classes everywhere, the main OBS class was paricularly
  96. bad in this regard. This meant navigation was a nightmare, and no one
  97. really knew where to go or where to add/change things.
  98. - Giant monolithic functions everywhere. This was particularly bad
  99. because it meant that functions became harder to debug and harder to
  100. keep track of what was going on in any particular function at any given
  101. time. These large functions, though not inefficient, were delicate and
  102. easily breakable. (See OBS::MainCaptureLoop for a nightmarish example,
  103. or the listbox subclass window procedure in WindowStuff.cpp)
  104. - Very large file sizes with everything clumped up into single files (for
  105. another particularly nightmarish example, see WindowStuff.cpp)
  106. - Bad formatting. Code could go beyond 200 columns in some cases, making
  107. it very unpleasant to read with many editors. Spaces instead of tabs,
  108. K&R mixed with allman (which was admittedly my fault).
  109. New (actual) coding guidelines
  110. - For the C code (especially in the core), guidelines are pretty strict K&R,
  111. kernel style. See the linux kernel "CodingStyle" document for more
  112. information. That particular coding style guideline is for more than just
  113. style, it actually helps produce a better overall code base.
  114. - For C++ code, I still use CamelCase instead of all_lowercase just because
  115. I prefer it that way, it feels right with C++ for some reason. It also
  116. helps make it distinguishable from C code.
  117. - I've started using 8-column tabs for almost everything -- I really
  118. personally like it over 4-column tabs. I feel that 8-column tabs are very
  119. helpful in preventing large amounts of indentation. A self-imposed
  120. limitation, if you will. I also use actual tabs now, instead of spaces.
  121. Also, I feel that the K&R style looks much better/cleaner when viewed with
  122. 8-column tabs.
  123. - Preferred maximum columns: 80. I've also been doing this because in
  124. combination with 8-column tabs, it further prevents large/bad functions
  125. with high indentation. Another self-imposed limitation. Also, it makes
  126. for much cleaner viewing in certain editors that wrap (like vim).