0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 13:08:50 +02:00
Commit Graph

268 Commits

Author SHA1 Message Date
jp9000
14c95ac421 Add functions to enumerate source children/tree 2014-02-20 17:44:42 -07:00
jp9000
d6ec5438a8 Add source audio sync offset setting 2014-02-20 16:16:25 -07:00
jp9000
579f026c5b Add more volume options
Added a "master" volume for the entire audio subsystem.

Also, added a "presentation" volume for both the master volume and for
each invidiaul source.  The presentation volume is used to control
things like transitioning volumes, preventing sources from outputting
any audio when they're inactive, as well as some other uses in the
future.
2014-02-20 15:56:51 -07:00
jp9000
27b851c06e Properly clamp audio timing and remove warnings
If audio was under, it originally did a full reset of the audio timing.
However, resetting the audio timing when this happens is kind of a bad
thing.  It's better just to clamp the value to the expected timestamp to
ensure seamless audio output.

Also, implement audio timestamp smoothing to ensure audio tries to be as
seamless as possible.
2014-02-18 14:38:51 -07:00
jp9000
f2d4de3c03 Implement automatic video scaling (if requested)
Add a scaler interface (defaults to swscale), and if a separate output
wants to use a different scale or format than the default output format,
allow a scaler instance to be created automatically for that output,
which will then receive the new scaled output.
2014-02-18 13:37:56 -07:00
jp9000
971faf09d5 Fix inttypes.h usage
...I neglected to put a '%' character before using the PRI* macros.
2014-02-14 16:05:52 -07:00
jp9000
8b8217f68e Fix a some more linux/GCC specific warnings 2014-02-14 15:56:01 -07:00
jp9000
966b943d5b Remove majority of warnings
There were a *lot* of warnings, managed to remove most of them.

Also, put warning flags before C_FLAGS and CXX_FLAGS, rather than after,
as -Wall -Wextra was overwriting flags that came before it.
2014-02-14 15:13:36 -07:00
jp9000
8e81d8be56 Revamp API and start using doxygen
The API used to be designed in such a way to where it would expect
exports for each individual source/output/encoder/etc.  You would export
functions for each and it would automatically load those functions based
on a specific naming scheme from the module.

The idea behind this was that I wanted to limit the usage of structures
in the API so only functions could be used.  It was an interesting idea
in theory, but this idea turned out to be flawed in a number of ways:

 1.) Requiring exports to create sources/outputs/encoders/etc meant that
     you could not create them by any other means, which meant that
     things like faruton's .net plugin would become difficult.

 2.) Export function declarations could not be checked, therefore if you
     created a function with the wrong parameters and parameter types,
     the compiler wouldn't know how to check for that.

 3.) Required overly complex load functions in libobs just to handle it.
     It makes much more sense to just have a load function that you call
     manually.  Complexity is the bane of all good programs.

 4.) It required that you have functions of specific names, which looked
     and felt somewhat unsightly.

So, to fix these issues, I replaced it with a more commonly used API
scheme, seen commonly in places like kernels and typical C libraries
with abstraction.  You simply create a structure that contains the
callback definitions, and you pass it to a function to register that
definition (such as obs_register_source), which you call in the
obs_module_load of the module.

It will also automatically check the structure size and ensure that it
only loads the required values if the structure happened to add new
values in an API change.

The "main" source file for each module must include obs-module.h, and
must use OBS_DECLARE_MODULE() within that source file.

Also, started writing some doxygen documentation in to the main library
headers.  Will add more detailed documentation as I go.
2014-02-12 08:04:50 -07:00
jp9000
b067440f73 Use bzalloc instead of bmalloc then memset
Reduces needless code repetition and still allows for proper memory
alignment.  Cleans up the code a bit.
2014-02-09 12:34:07 -07:00
jp9000
6c92cf5841 Implement output, improve video/audio subsystems
- Fill in the rest of the FFmpeg test output code for testing so it
   actually properly outputs data.

 - Improve the main video subsystem to be a bit more optimal and
   automatically output I420 or NV12 if needed.

 - Fix audio subsystem insertation and byte calculation.  Now it will
   seamlessly insert new audio data in to the audio stream based upon
   its timestamp value.  (Be extremely cautious when using floating
   point calculations for important things like this, and always round
   your values and check your values)

 - Use 32 byte alignment in case of future optimizations and export a
   function to get the current alignment.

 - Make os_sleepto_ns return true if slept, false if the time has
   already been passed before the call.

 - Fix sinewave output so that it actually properly calculates a middle
   C sinewave.

 - Change the use of row_bytes to linesize (also makes it a bit more
   consistent with FFmpeg's naming as well)
2014-02-09 05:51:06 -07:00
jp9000
3d6d43225f Add planar audio support, improve test output
- Add planar audio support.  FFmpeg and libav use planar audio for many
  encoders, so it was somewhat necessary to add support in libobs
  itself.

- Improve/adjust FFmpeg test output plugin.  The exports were somewhat
  messed up (making me rethink how exports should be done).  Not yet
  functional; it handles video properly, but it still does not handle
  audio properly.

- Improve planar video code.  The planar video code was not properly
  accounting for row sizes for each plane.  Specifying row sizes for
  each plane has now been added.  This will also make it more compatible
  with FFmpeg/libav.

- Fixed a bug where callbacks wouldn't create properly in audio-io and
  video-io code.

- Implement 'blogva' function to allow for va_list usage with libobs
  logging.
2014-02-07 03:03:54 -07:00
jp9000
89cfbdc033 Improve naming scheme of libobs core structures 2014-02-05 21:03:06 -07:00
jp9000
ab4ab95790 Implement output scaling/conversion/downloading
- Implement texture scaling/conversion/downloading for the main view so
  we can finally start getting data to output.

  Also, redesign how it works a bit, it will now properly wait one full
  frame for each step in the process:  rendering the main texture,
  scaling the main texture to an output texture, staging/downloading the
  ouput texture, and then outputting that staged data.  This way, the
  GPU will have more than enough time to fully complete each step.

- Fix a bug with OpenGL plugin's texture staging function.  Was using
  glBindBuffer instead of what should have been used:  glBindTexture.

- Change the naming scheme of the variables in default.effect.  It's now
  named with the idea of just "color matrix" in mind instead of "yuv
  matrix", and instead of DrawRGBToYUV, it's now just DrawMatrix.
2014-02-05 20:36:21 -07:00
Palana
ac23df500a Remove external ref count visibility
The returned ref count was never used and the returned value doesn't
actually confer any meaning in a multithreaded environment
2014-02-03 02:34:06 +01:00
jp9000
37ed83acec Use QMetaObject::invokeMethod in libobs callbacks
Doing this ensures Qt thread safety when adding/removing sources and
scenes, because it will defer the function call to the main thread.
2014-02-02 17:03:55 -07:00
jp9000
6e1dd92f0c Improve thread safety in UI code
- Implemented better C++ classes for handling scenes/sources/items in
  obs.hpp, allowing them to automatically increment and decrement the
  references of each, as well as assign them to QVariants.

- Because QVariants are now using the C++ classes, remove the pointer
  QVariant wrapper.

- Use the new C++ classes with the QVariant user data of list box items,
  both for the sake of thread safety and to ensure that the data
  referenced is not freed until removed.  NOTE: still might need some
  testing.

- Implemented a source-remove signal from libobs, and start using that
  signal instead of the source-destroy signal for signalling item
  removal.
2014-02-02 14:26:23 -07:00
jp9000
458325fc6f Add property list callbacks
- Add property list callbacks to sources/outputs/encoders so that if
  necessary user interface can be automatically generated or perhaps a
  property list widget can be used for them.

- Change some of the property API names.  obs_property_list_t felt a bit
  awkward when actually using it, so I just renamed it to
  obs_properties_t.

- Removed the getdata/setdata nad getparam/setparam functions from
  sources/services, they will be superseded by the dynamic procedure
  call API.
2014-02-01 22:46:13 -07:00
jp9000
a12656bd91 Add module UI export capability
Add the ability to be able to call and use toolkit-specific or
program-specific user interface in modules.

User interface code can be either bundled with the module, or 'split'
out in to separate libraries (recommended).

There are three reasons why splitting is recommended:

  1.) It allows plugins to be able to create custom user interface for
      each toolkit if desired.

  2.) Often, UI will be programmed in one language (the language of the
      toolkit), and core logic may be programmed in another.  This
      allows plugins to keep the languages separated if necessary.

  3.) It prevents direct linkage of UI toolkits libraries with core
      module logic.

Splitting is not required, though is recommended if you want your plugin
to be more flexible with other user interface toolkits or programs.

Will implement a generic properties lookup next, which will be used for
automatic UI handling so that plugin UI isn't necessarily required.
2014-02-01 00:49:50 -07:00
jp9000
9116be8d9c Improve safety for settings usage
- Add 'set_default' functions to obs-data.*.  These functions ensure
  that a paramter exists and that the parameter is of a specific type.
  If not, it will create or overwrite the value with the default setting
  instead.

  These functions are meant to be explicitly called before using any of
  the 'get' functions.  The reason why it was designed this way is to
  encourage defaults to be set in a single place/function.

  For example, ideal usage is to create one function for your data,
  "set_my_defaults(obs_data_t data)", set all the default values within
  that function, and then call that function on create/update, that way
  all defaults are centralized to a single place.

- Ensure that data passed to sources/encoders/outputs/etc is always
  valid, and not a null value.

- While I'm remembering, fix a few defaults of the main program config
  file data.
2014-01-28 18:41:24 -07:00
jp9000
c6300d0956 Add a couple more setting data safety measures
Prevent null dereferencing if data is null, instead just make the
functions return and ignore the get/set requests.
2014-01-28 15:45:30 -07:00
jp9000
6c44291693 Implement settings interface for plugins
Add a fairly easy to use settings interface that can be passed to
plugins, and replaced the old character string system that was being
used before.  The new data interface allows for an easier method of
getting/altering settings for plugins, and is built to be serializable
to/from JSON.

Also, removed another wxFormBuilder file that was no longer in use.
2014-01-27 23:14:58 -07:00
jp9000
de288ac541 Rename obs_data structure to obs_program_data
I'm doing this because I might create another data structure called
obs_data for a different purpose.  That and obs_program_data feels a bit
less vague for what it does.
2014-01-27 09:07:13 -07:00
jp9000
563613db8f Rename obs-data.h to obs-internal.h
Renaming obs-data.h to avoid confusion about its usage
2014-01-26 18:48:14 -07:00
jp9000
fc8851e9f4 Add preliminary ffmpeg plugin (still testing)
- Added some code for FFmpeg output that I'm still playing around with.
  Right now I'm just trying to get it to output to file and try to
  understand the FFmpeg/libav APIs.  Hopefully in the future this plugin
  can be used for any sort of output to FFmpeg.

- Fixed a cast warning in audio-io.c with size_t -> uint32_t

- Renamed the 'video_info' and 'audio_info' structures to
  'video_conver_info' and 'audio_convert_info' to better represent their
  actual purpose, and to avoid confusion with 'audio_output_info' and
  'video_output_info' structures.

- Removed a few macros from obs-def.h that were at one point going to be
  used but no longer going to be used (at least for now)
2014-01-19 03:16:41 -07:00
jp9000
8d63845dd4 Use macros to improve safety loading callbacks
Just a minor fix mostly because I noticed that I kept accidentally
forgetting to add checks to the code properly.  This is one of those
cases where macros come in useful, as macros can automate the process
and help prevent these mistakes from happening by accident.
2014-01-17 06:24:34 -07:00
jp9000
62c2b1d74e Simplify media i/o interfaces
Completely revamped the entire media i/o data and handlers.  The
original idea was to have a system that would have connecting media
inputs and outputs, but at a certain point I realized that this was an
unnecessary complexity for what we wanted to do.  (Also, it reminded me
of directshow filters, and I HATE directshow with a passion, and
wouldn't wish it upon my greatest enemy)

Now, audio/video outputs are connected to directly, with better callback
handlers, and will eventually have the ability to automatically handle
conversions such as 4:4:4 to 4:2:0 when connecting to an input that uses
them.  Doing this will allow the video/audio i/o handlers to also
prevent duplicate conversion, as well as make it easier/simple to use.

My true goal for this is to make output and encoder plugins as simple to
create as possible.  I want to be able to be able to create an output
plugin with almost no real hassle of having to worry about image
conversions, media inputs/outputs, etc.  A plugin developer shouldn't
have to handle that sort of stuff when he/she doesn't really need to.

Plugins will be able to simply create a callback via obs_video() and/or
obs_audio(), and they will automatically receive the audio/video data in
the formats requested via a simple callback, without needing to do
almost anything else at all.
2014-01-14 01:58:47 -07:00
jp9000
02a101d1e8 Fix one minor bug with new timing code
When the first async video frame is used it would not set audio timing,
moved that code into obs_source_getframe.  Also, might consider renaming
obs_source_getframe.  "Query frame" instead perhaps?  Will sleep on it,
might not even bother.
2014-01-12 03:24:01 -07:00
jp9000
9f1a3c3112 Add preliminary handling of timestamp invalidation
- Add preliminary (yet to be tested) handling of timestamp invalidation
  issues that can happen with specific devices, where timestamps can
  reset or go backward/forward in time with no rhyme or reason.  Spent
  the entire day just trying to figure out the best way to handle this.

  If both audio and video are present, it will increment a reference
  counter if video timestamps invalidate, and decrement the reference
  counter when the audio timestamps invalidate.  When the reference
  counter is not 0, it will not send audio as the audio will have
  invalid timing.  What this does is it ensures audio data will never go
  out of bounds in relation to the video, and waits for both audio and
  video timestamps to "jump" together before resuming audio.

- Moved async video frame timing adjustment code into
  obs_source_getframe instead so it's automatically handled whenever
  called.

- Removed the 'audio wait buffer' as it was an unnecessary complexity
  that could have had problems in the future.  Instead, audio will not
  be added until video starts for sources that have both async
  audio/video.  Audio could have buffered for too long of a time anyway,
  who knows what devices are going to do.

- Fixed a minor conversion warning in audio-io.c
2014-01-12 02:40:51 -07:00
jp9000
2a89306420 Detect audio timestamp jumps and reset timing
- Often, timestamps will go "back" in time with certain..  terrible
   devices that no one should use.  When this occurs, timing is now
   reset so that the new audio comes in directly after the old audio
   seamlessly.
2014-01-10 12:45:53 -07:00
jp9000
faa7f4d20e Properly position position mixed audio data
- Audio data was just being popped to the "front" of the mix buffer, so
   instead it now properly pops into the correct position in the mix
   buffer (proper mixing still needs to be implemented)
2014-01-10 11:55:54 -07:00
jp9000
f827ba38ef Added a sinewave audio test source
- Added a test audio sinewave test source that should just play a sine
   wave of the middle C note.  Using unsigned 8 bit mono to test
   ffmpeg's audio resampler, seems to work pretty good.

 - Fixed a boolean trap in threading.h for the event_init function, it
   now uses enum event_type, which can be EVENT_TYPE_MANUAL or
   EVENT_TYPE_AUTO, to specify whether the event is automatically reset
   or not.

 - Changed display names of test sources to something a little less
   vague.

 - Removed te whole "if timestamp is 0 just use current system time"
   when outputting source audio, if you want to use system time you
   should just use system time yourself.  Using 0 as some sort of
   "indicator" like that just makes things confusing, and prevents you
   from legitimately using 0 as a timestamp for your audio data.
2014-01-09 22:10:04 -07:00
jp9000
6b8e84844a Add preliminary audio processing
- Mixing still isn't implemented, but the audio system should be able
   to start up, and mix at least once audio line for the time being.
   Will have to write some test audio sources to verify things are
   working properly, and build the rest of the output functionality.
2014-01-09 19:08:20 -07:00
jp9000
3838abe1f4 Implement volumes for sources
- Added a volume variable to the obs_source structure and implemented
   functions for manipulating source volume.

 - Added a volume variable to the audio_data structure so that the
   volume will be applied when mixing.
2014-01-07 11:03:15 -07:00
jp9000
a2a8a5f148 Added add/remove signals to scenes
Scenes will now signal via their source when an item has been added
or removed from them.

  "add" - Item added to the scene.
  Parameters:  "scene": Scene that the item was added to.
               "item":  Item that was added.

  "remove" - Item removed from the scene.
  Parameters:  "scene": Scene that the item was removed from.
               "item":  Item that was removed.
2014-01-04 13:47:48 -07:00
jp9000
f3e3aeae74 make sure to include function declarations from calldata.h 2013-12-30 10:09:20 -07:00
jp9000
d99c345595 fix bad enum for get_source_info in obs_source.c 2013-12-30 09:04:05 -07:00
jp9000
c129cc37cb update API and implement preliminary ability to add sources to scenes 2013-12-30 06:56:39 -07:00
jp9000
cec94b042e implement scene adding callbacks, make a few API tweaks 2013-12-28 05:33:16 -07:00
jp9000
bbd8178dab fixed a typo in a function call 2013-12-27 15:23:42 -07:00
jp9000
261b9d7056 fix a few bugs with callback system, add some test signals 2013-12-27 05:08:58 -07:00
jp9000
6edcd456fe implement signal/procedure handling into libobs and individual sources 2013-12-26 23:10:15 -07:00
jp9000
922eb7b8e8 make direct filter rendering optional (can be useful for certain cases) 2013-12-22 02:03:40 -07:00
jp9000
bd47d9fe74 clear up a minor inconsistency in default effect naming 2013-12-22 01:33:11 -07:00
jp9000
19c4ee995e add major optimization to filter processing, and as a nice side effect, make it easier to create new filters and sources 2013-12-22 01:30:18 -07:00
jp9000
9218627892 add obs_source functions to allow name manipulation and lookup based upon name, and a few other functions related to getting/setting source information 2013-12-20 19:35:12 -07:00
jp9000
95a7da2d4c add names to sources, use 'id' for the internal source identifier names rather than 'name' 2013-12-20 17:23:19 -07:00
jp9000
f41bb4b7e9 add support for texture_rect texture type in shaders, add new form, clear up a few things in the API 2013-12-20 11:58:09 -07:00
jp9000
5d3f3e0d1b make text lookup use a simple linked lists rather than an unnecessary array of pointers 2013-12-07 11:23:49 -07:00
jp9000
8298fa4dc7 With the permission of my fellow contributors, I'm switching obs-studio back to GPL v2+ to prevent issues between this project and the original OBS project, and for personal reasons to avoid legal ambiguity (not political reasons, I admittedly would prefer GPL v3+) 2013-12-02 22:24:38 -07:00
jp9000
58810f9806 changed gs_draw_sprite to allow custom sizes, added output textures to the core, and adjusted the test code to accommodate the changes 2013-11-26 22:26:14 -07:00
jp9000
93dd3cec50 made the getframe function a bit more safe and modified a few names for clarity 2013-11-22 16:18:31 -07:00
jp9000
71890e0365 removed now-redundant callback enum_children from sources 2013-11-20 21:52:20 -07:00
jp9000
f1decd08f4 adjusted the way source removal is handled to make it a bit more safe 2013-11-20 18:36:46 -07:00
jp9000
409b011a8e cleaned up main internal data structure design, changed to reference counting for sources to ensure safe destruction of source objects from all parts of the system, added some service-related stuff for testing 2013-11-20 15:00:16 -07:00
jp9000
146e9a7dbd added support for jansson, added new output files, made some adjustments to the API, fixed a UI subclass issue 2013-11-13 06:24:20 -07:00
Palana
85dd2ad073 fixed log output 2013-11-02 02:16:18 +01:00
jp9000
a6a6118c04 finish up most of the source audio stuff and rename some variables/structs/enum to be a bit more consistent 2013-10-31 10:28:47 -07:00
jp9000
3adfaf7f9f not sure how a backslash slipped into an include, but it's gone now 2013-10-29 23:54:43 -07:00
jp9000
d2ba08e46b add frame flipping code 2013-10-26 15:05:51 -07:00
jp9000
7dada3bef4 fill out the rest of the source video frame functions, added nv12 decompression function, and cleaned up the design of the source video frame stuff 2013-10-26 14:32:06 -07:00
jp9000
a43e291577 fill in the texture_setimage function, fill in a few other functions, and change certain names to be a little more consistent 2013-10-25 10:25:28 -07:00
jp9000
ac2c08927f added intial async audio/video code, fixed a few bugs, improved thread safety, and made a few other minor adjustments 2013-10-24 00:57:55 -07:00
jp9000
ae3cecf09f make data access in the threads a bit more safe (note: probably will need some more safety measures later on) 2013-10-18 20:25:13 -07:00
jp9000
18834c6a45 some static analysis cleanup 2013-10-17 17:21:42 -07:00
jp9000
dfa2dc6eab fix up the rest of the GL code, add glew to project, add makefiles for opengl, fix makefiles so that it can be built with gcc, update project files to automatically output to the build directory 2013-10-16 23:31:18 -07:00
jp9000
9570f0b8d7 change names, fix some bugs, minor GL/D3D fixes, update tests, fix effect files, output a little more debug information 2013-10-14 12:37:52 -07:00
jp9000
f255ae1922 first commit 2013-09-30 19:37:13 -07:00