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

311 Commits

Author SHA1 Message Date
jp9000
413641a11f Log when any libobs objects are created/destroyed 2014-07-13 05:01:02 -07:00
jp9000
a27f2fbb3a Fix potentially uninitialized variable warnings 2014-07-12 11:59:46 -07:00
jp9000
dc27cb2051 Add signal for renaming sources 2014-06-30 00:05:35 -07:00
jp9000
7b12133af3 Use uint8_t* instead of void* for texture data
NOTE: In texture_setimage, I had to move variables to the top of the
scope because microsoft's C compiler will give the legacy C90 error of:
'illegal use of this type as an expression'.

To sum it up, microsoft's C compiler is still utter garbage.
2014-06-28 10:12:57 -07:00
jp9000
dbb9124bf6 Remove 'effect' param from effect param funcs
Similar to the shader functions, the effect parameter functions take
the effect as a parameter.  However, the effect parameter is pretty
pointless, because the effect parameter.. parameter stores the effect
pointer interally.
2014-06-25 22:24:27 -07:00
jp9000
0b4a259e56 Remove 'locale' parameter from all callbacks
The locale parameter was a mistake, because it puts extra needless
burden upon the module developer to have to handle this variable for
each and every single callback function.  The parameter is being removed
in favor of a single centralized module callback function that
specifically updates locale information for a module only when needed.
2014-06-25 12:36:26 -07:00
jp9000
20a61ace77 libobs: Account for volume with audio levels 2014-06-06 08:56:37 -07:00
Jim
4eb6267372 Merge pull request #90 from antihax/master
Added simple volume meter for reference of input levels.
2014-06-03 05:15:18 -07:00
jp9000
5cd64ce7f2 libobs: Add level/magnitude/peak volume levels
This replaces the older code which simply queried the max volume level
value for any given audio.

I'm still not 100% sure on if this is how I want to approach the
problem, particularly, whether this should be done in obs_source or in
audio_line, but it can always be moved later if needed.

This uses the calculations by the awesome Bill Hamilton that OBS1 used
for its volume levels.  It calculates the current max (level),
magnitude, and current peak.  This data then can be used to create
awesome volume meter controls later on.

NOTE: Will probably need optimization, does one float at a time right
now.

Also, change some of the naming conventions.  I actually need to change
a lot of the naming conventions in general so that all words are
separated by underscores.  Kind of a bad practice there on my part.
2014-06-03 04:48:20 -07:00
Palana
7d0a1502bd Fix typo in conversion technique name (there is no UYUV, only UYVY) 2014-06-02 16:44:37 +02:00
jp9000
1343d6bdee libobs: Allow deferred source udpate on create
This allows sources to optionally defer update on creation in order to
prevent updates from being called from threads other than the video
thread.
2014-05-30 03:24:15 -07:00
jp9000
75d25b4e5b libobs: Init source info before calling 'create'
When a source's private data is being created by a module, it wasn't
able to call most source functions because most functions rely on the
obs_source_info part of the context to be set.  This fixes that issue.

It was strange that this wasn't already the case because the other
context types already did the same thing.
2014-05-30 02:35:24 -07:00
jp9000
9595a78e8a libobs: Add planar 4:2:0 async texture support
This uses the reverse planar YUV 4:2:0 conversion shader to output a YUV
texture without having to convert it via CPU.  Again, this will reduce
video upload bandwidth usage to 37.5% of the original rate.  I suspect
this will be particularly useful for when an FFmpeg or libav input
plugin for playing videos is made.

NOTE: There's an issue with certain texture sizes right now I haven't
been able to identify, if the full size of texture data divided by the
base texture width is an uneven number, the V chroma plane seems like it
can potentially shift, though I only had this happen with 160x90
resolution C920.  Almost all resolutions tend to be even.  Needs further
testing with more devices that support planar YUV 4:2:0 output.
2014-05-30 02:23:36 -07:00
Danni
90d9a5204f Updated per comments pull #90. 2014-05-24 16:24:48 -07:00
Danni
bc542a3e75 Added simple volume meter for reference of input levels. 2014-05-20 09:26:18 -05:00
jp9000
2ab48dd590 obs-source.c: Fix a few potential concerns
First, if the private data of the source fails to be created, then do
not destroy the source.  If the source is destroyed, all the user's data
associated with that source is lost, which could end up being a
potential problem.  Instead, let it linger as a 'dead' source until the
user chooses to fix the problem (though this should never really happen,
the source module functions should be programmed to handle this
scenario)

Secondly, rename new_frame_ready to ready_async_frame, and fix a
potential memory leak with it.
2014-05-04 16:20:11 -07:00
Palana
4682cfb61b Fix an issue with async (video) source destruction
obs_source_output_video can cause cached frames to be freed twice if
called with a partially destroyed source, among other undesirable
effects; freeing the source private data right after the destroy signal
has been processed ensures proper behavior
2014-05-04 21:02:01 +02:00
jp9000
52746c2523 Add (temporary terrible) volume controls
- Add volume control

   These volume controls are basically nothing more than sliders.  They
   look terrible and hopefully will be as temporary as they are
   terrible.

 - Allow saving of specific non-user sources via obs_load_source and
   obs_save_source functions.

 - Save data of desktop/mic audio sources (sync data, volume data, etc),
   and load the data on startup.

 - Make it so that a scene is created by default if first time using the
   application.  On certain operating systems where supported, a default
   capture will be created.  Desktop capture on mac, particularly.  Not
   sure what to do about windows because monitor capture on windows 7 is
   completely terrible and is bad to start users off with.
2014-05-03 22:54:38 -07:00
jp9000
0b5ba66b33 async vid.: Fix potential endless buffering issue
If a source with async video wasn't currently active, it would endlessly
buffer the video data, which would cause memory to grow endlessly until
available memory was extinguished.

This really needs to be replaced with a proper caching mechanism at some
point.
2014-04-28 20:38:15 -07:00
Palana
14f3e79260 Add async texrender to cleanup 2014-04-28 21:54:13 +02:00
jp9000
65455c27be Add preliminary saving/loading of scene/sources
This saves scenes/sources from json on exit, and properly loads it back
up when starting up the program again, as well as the currently active
scene.

I had to add a 'load' and 'save' callback to the source interface
structure because I realizes that certain sources (such as scenes)
operate different with their saved data; scenes for example would have
to keep track of their settings information constantly, and that was
somewhat unacceptable to make it functional.

The optional 'load' callback will be called only after having loaded
setttings specifically from file/imported data, and the 'save' function
will be called only specifically when data actually needs to be saved.

I also had to adjust the obs_scene code so that it's a regular input
source type now, and I also modified it so that it doesn't have some
strange custom creation code anymore.  The obs_scene_create function is
now simply just a wrapper for obs_source_create.  You could even create
a scene with obs_source_create manually as well.
2014-04-26 23:47:50 -07:00
Palana
52b9f5fe52 Fix defaults for DrawMatrix 2014-04-24 22:33:02 +02:00
Palana
12cc06b560 Add GPU based frame decompression for async video sources 2014-04-24 22:03:32 +02:00
Palana
065379bffa Add limited range rendering for rendering YUV non-full range sources 2014-04-24 21:45:54 +02:00
jp9000
4a6d19f206 libobs: Add services API, reduce repeated code
Add API for streaming services.  The services API simplifies the
creation of custom service features and user interface.

Custom streaming services later on will be able to do things such as:

 - Be able to use service-specific APIs via modules, allowing a more
   direct means of communicating with the service and requesting or
   setting service-specific information

 - Get URL/stream key via other means of authentication such as OAuth,
   or be able to build custom URLs for services that require that sort
   of thing.

 - Query information (such as viewer count, chat, follower
   notifications, and other information)

 - Set channel information (such as current game, current channel title,
   activating commercials)

Also, I reduce some repeated code that was used for all libobs objects.
This includes the name of the object, the private data, settings, as
well as the signal and procedure handlers.

I also switched to using linked lists for the global object lists,
rather than using an array of pointers (you could say it was..
pointless.)  ..Anyway, the linked list info is also stored in the shared
context data structure.
2014-04-19 20:38:53 -07:00
jp9000
2451b80ef6 Fix drawing bug with async video sources
Before, async video sources would flicker because they were only being
drawn when they were updated.  So when updated, they'd draw that frame,
then it would stop drawing it until it updated again.  This fixes that
issue and they should now draw properly.

Also, fix a few other minor bugs and issues relating to async video,
and make it so that non-async video filters can be properly applied to
them.

For the purposes of testing, change the 'test-random' source to an async
video source that updates every quarter of a second with a new random
face.

Also fix a bug where non-async video sources wouldn't have filter
effects applied properly.
2014-04-13 02:22:28 -07:00
jp9000
92522d1886 Implement RTMP module (still needs drop code)
- Implement the RTMP output module.  This time around, we just use a
   simple FLV muxer, then just write to the stream with RTMP_Write.
   Easy and effective.

 - Fix the FLV muxer, the muxer now outputs proper FLV packets.

 - Output API:
   * When using encoders, automatically interleave encoded packets
     before sending it to the output.

   * Pair encoders and have them automatically wait for the other to
     start to ensure sync.

   * Change 'obs_output_signal_start_fail' to 'obs_output_signal_stop'
     because it was a bit confusing, and doing this makes a lot more
     sense for outputs that need to stop suddenly (disconnections/etc).

 - Encoder API:
   * Remove some unnecessary encoder functions from the actual API and
     make them internal.  Most of the encoder functions are handled
     automatically by outputs anyway, so there's no real need to expose
     them and end up inadvertently confusing plugin writers.

   * Have audio encoders wait for the video encoder to get a frame, then
     start at the exact data point that the first video frame starts to
     ensure the most accrate sync of video/audio possible.

   * Add a required 'frame_size' callback for audio encoders that
     returns the expected number of frames desired to encode with.  This
     way, the libobs encoder API can handle the circular buffering
     internally automatically for the encoder modules, so encoder
     writers don't have to do it themselves.

 - Fix a few bugs in the serializer interface.  It was passing the wrong
   variable for the data in a few cases.

 - If a source has video, make obs_source_update defer the actual update
   callback until the tick function is called to prevent threading
   issues.
2014-04-07 22:00:10 -07:00
jp9000
1bca7e0a3e Improve properties API
Improve the properties API so that it can actually respond somewhat to
user input.  Maybe later this might be further improved or replaced with
something script-based.

When creating a property, you can now add a callback to that property
that notifies when the property has been changed in the user interface.
Return true if you want the properties to be refreshed, or false if not.
Though now that I think about it I doubt there would ever be a case
where you would have this callback and *not* refresh the properties.

Regardless, this allows functions to change the values of properties or
settings, or enable/disable/hide other property controls from view
dynamically.
2014-04-04 00:30:37 -07:00
jp9000
d9251f9e87 Add source properties window (very preliminary)
- Add a properties window for sources so that you can now actually edit
   the settings for sources.  Also, display the source by itself in the
   window (Note: not working on mac, and possibly not working on linux).

   When changing the settings for a source, it will call
   obs_source_update on that source when you have modified any values
   automatically.

 - Add a properties 'widget', eventually I want to turn this in to a
   regular nice properties view like you'd see in the designer, but
   right now it just uses a form layout in a QScrollArea with regular
   controls to display the properties.  It's clunky but works for the
   time being.

 - Make it so that swap chains and the main graphics subsystem will
   automatically use at least one backbuffer if none was specified

 - Fix bug where displays weren't added to the main display array

 - Make it so that you can get the properties of a source via the actual
   pointer of a source/encoder/output in addition to being able to look
   up properties via identifier.

 - When registering source types, check for required functions (wasn't
   doing it before).  getheight/getwidth should not be optional if it's
   a video source as well.

 - Add an RAII OBSObj wrapper to obs.hpp for non-reference-counted
   libobs pointers

 - Add an RAII OBSSignal wrapper to obs.hpp for libobs signals to
   automatically disconnect them on destruction

 - Move the "scale and center" calculation in window-basic-main.cpp to
   its own function and in its own source file

 - Add an 'update' callback to WASAPI audio sources
2014-03-23 01:07:54 -07:00
jp9000
154e0c59e1 Use atomic functions where appropriate
Also, rename atomic functions to be consistent with the rest of the
platform/threading functions, and move atomic functions to threading*
files rather than platform* files
2014-03-16 18:26:46 -07:00
jp9000
3ed647b8a0 Set defaults automatically
Automatically query defaults for sources/outputs/encoders and set them
before calling create
2014-03-16 17:42:37 -07:00
jp9000
5288467aeb Ensure names are valid
Ensure that a source has a valid name.  Duplicates aren't a big deal
internally, but sources without a name are probably something that
should be avoided.  Made is so that if a source is programmatically
created without a name, it's assigned an index based name.

In the main basic-mode window, made it check to make sure the name was
valid as well.
2014-03-10 13:39:51 -07:00
jp9000
7d48dbb1dc Add a way to get default settings
- Implement a means of obtaining default settings for an
   input/output/encoder.  obs_source_defaults for example will return
   the default settings for a particular source type.

 - Because C++ doesn't have designated initializers, use functions in
   the WASAPI plugin to register the sources instead.
2014-03-07 06:55:21 -07:00
jp9000
9c6da6f52d Split output/input audio capture sources
- Split input and output audio captures so that they're different
   sources.  This allows easier handling and enumeration of audio
   devices without having to do some sort of string processing.

   This way the user interface code can handle this a bit more easily,
   and so that it doesn't confuse users either.  This should be done for
   all audio capture sources for all operating systems.  You don't have
   to duplicate any code, you just need to create input/output wrapper
   functions to designate the audio as input or output before creation.

 - Make it detect soundflower and wavtap devices as mac "output" devices
   (even though they're actually input) for the mac output capture, and
   make it so that users can select a default output capture and
   automatically use soundflower or wavtap.

   I'm not entirely happy about having to do this, but because mac is
   designed this way, this is really the only way to handle it that
   makes it easier for users and UI code to deal with.

   Note that soundflower and wavtap are still also designated as input
   devices, so will still show up in input device enumeration.

 - Remove pragma messages because they were kind polluting the other
   compiler messages and just getting in the way.  In the future we can
   just do a grep for TODO to find them.

 - Redo list property again, this time using a safer internal array,
   rather than requiring sketchy array inputs.  Having functions handle
   everything behind the scenes is much safer.

 - Remove the reference counter debug log code, as it was included
   unintentionally in a commit.
2014-03-03 02:56:54 -07:00
jp9000
e9342143a7 Simplify and extend callback/signalling system
- Signals and dynamic callbacks now require declarations to be made
  before being used.  What this does is allows us to get information
  about the functions dynamically which can be relayed to the user and
  plugins for future extended usage (this should have big implications
  later for scripting in particular, hopefully).

- Reduced the number of types calldata uses from "everything I could
  think of" to simply integer, float, bool, pointer/object, string.
  Integer data is now stored as long long.  Floats are now stored as
  doubles (check em).

- Use a more consistent naming scheme for lexer error/warning macros.

- Fixed a rather nasty bug where switching to an existing scene would
  cause it to increment sourceSceneRefs, which would mean that it would
  never end up never properly removing the source when the user clicks
  removed (stayed in limbo, obs_source_remove never got called)
2014-03-01 05:54:55 -07:00
jp9000
771eac6015 Be more consistent about log levels
LOG_ERROR should be used in places where though recoverable (or at least
something that can be handled safely), was unexpected, and may affect
the user/application.

LOG_WARNING should be used in places where it's not entirely unexpected,
is recoverable, and doesn't really affect the user/application.
2014-02-28 20:02:29 -07:00
jp9000
268e4e7811 Add more checks for NULL pointers 2014-02-23 22:39:33 -07:00
jp9000
60e6316a5e Separate source activation for main/aux views
Split off activate to activate and show callbacks, and split off
deactivate to deactivate and hide callbacks.  Sources didn't previously
have a means to know whether it was actually being displayed in the main
view or just happened to be visible somewhere.  Now, for things like
transition sources, they have a means of knowing when they have actually
been "activated" so they can initiate their sequence.

A source is now only considered "active" when it's being displayed by
the main view.  When a source is shown in the main view, the activate
callback/signal is triggered.  When it's no longer being displayed by
the main view, deactivate callback/signal is triggered.

When a source is just generally visible to see by any view, the show
callback/signal is triggered.  If it's no longer visible by any views,
then the hide callback/signal is triggered.

Presentation volume will now only be active when a source is active in
the main view rather than also in auxilary views.

Also fix a potential bug where parents wouldn't properly increment or
decrement all the activation references of a child source when a child
was added or removed.
2014-02-23 17:46:00 -07:00
jp9000
0ff0d32731 Fix video reset and apply new video settings
This allows the changing of bideo settings without having to completely
reset all graphics data.  Will recreate internal output/conversion
buffers and such and reset the main preview.
2014-02-22 20:14:19 -07:00
jp9000
7fcec77351 For *_update, apply settings instead of replacing
Make it so obs_data settings input in to *_update are applied to the
existing settings rather than fully replace the existing settings.  That
way you can update with only certain specific settings, leaving other
settings untouched.  Of course if you're already using the original
settings pointer in the first place then you've already done that, so
it'll just ignore it because you've already applied them.
2014-02-21 21:05:21 -07:00
jp9000
be81276f03 Implement volume handling
- Remove obs_source::type because it became redundant now that the
   type is always stored in the obs_source::info variable.

 - Apply presentation volumes of 1.0 and 0.0 to sources when they
   activate/deactivate, respectively.  It also applies that presentation
   volume to all sub-sources, with exception of transition sources.
   Transition sources must apply presentation volume manually to their
   sub-sources with the new transition functions below.

 - Add a "transition_volume" variable to obs_source structure, and add
   three functions for handling volume for transitions:

   * obs_transition_begin_frame
   * obs_source_set_transition_vol
   * obs_transition_end_frame

   Because the to/from targets of a transition source might both contain
   some of the same sources, handling the transitioning of volumes for
   that specific situation becomes an issue.

   So for transitions, instead of modifying the presentation volumes
   directly for both sets of sources, we do this:

   - First, call obs_transition_begin_frame at the beginning of each
     transition frame, which will reset transition volumes for all
     sub-sources to 0.  Presentation volumes remain unchanged.

   - Call obs_source_set_transition_vol on each sub-source, which will
     then add the volume to the transition volume for each source in
     that source's tree.  Presentation volumes still remain unchanged.

   - Then you call obs_trandition_end_frame when complete, which will
     then finally set the presentation volumes to the transition
     volumes.

   For example, let's say that there's one source that's within both the
   "transitioning from" sources and "transition to" sources.  It would
   add both the fade in and fade out volumes to that source, and then
   when the frame is complete, it would set the presentation volume to
   the sum of those two values, rather than set the presentation volume
   for that same source twice which would cause weird volume jittering
   and also set the wrong values.
2014-02-21 19:41:38 -07:00
jp9000
bdcabc6170 Add volume signals 2014-02-21 17:51:16 -07:00
jp9000
d4f1eacc1f Implement source activation/deactivation
Now sources will be properly activated and deactivated when they are in
use or not in use.

Had to figure out a way to handle child sources, and children of
children, just ended up implementing simple functions that parents use
to signal adding/removal to help with hierarchial activation and
deactivation of child sources.

To prevent the source activate/deactivate callbacks from being called
more than once, added an activation reference counter.  The first
increment will call the activate callback, and the last decrement will
call the deactivate callback.

Added "source-activate" and "source-deactivate" signals to the main obs
signal handler, and "activate" and "deactivate" to individual source
signal handlers.

Also, fixed the main window so it properly selects a source when the
current active scene has been changed.
2014-02-20 22:04:14 -07:00
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