Commit graph

533 commits

Author SHA1 Message Date
jp9000 d64542e10b Revert "libobs: Allow source to fully control source flags (for now)"
This reverts commit d85224bb9b.

Would cause other flags to stop saving.  Buffering needs to be split off
from the source flags.
2017-05-13 23:30:36 -07:00
jp9000 e7f754df97 libobs: Use tex.Load for reverse NV12/I420 funcs
Eventually, most things should be replaced with Load where applicable
(though in some cases sub-pixel sampling is desired).

This commit also fixes a bug where NV12 async sources wouldn't render
correctly.
2017-05-06 01:24:45 -07:00
Shaolin e006d961a4 audio-monitoring: Add ability to monitor Outputs
(Note: This commits also modifies the linux-pulseaudio, mac-capture, and
win-wasapi plugins)

Do not prevent the targeted output device from being monitored if the
selected monitor output device is a different one.

Closes jp9000/obs-studio#872
2017-04-05 18:58:08 -07:00
jp9000 0941a9c13d libobs: Add ability to preload async frames
Prevents any delay when starting up certain async video sources.
Additionally prevents old frames from being presented as well.
2017-03-28 09:39:47 -07:00
jp9000 d85224bb9b libobs: Allow source to fully control source flags (for now)
This change prevents source flags from being incorrectly overwritten and
set to 0.  Eventually flags need to be separated from source settings
and this should be reverted, but for now this solves an issue where
buffering would be enabled on async video sources regardless of whether
the user disabled it or not on the source.
2017-03-28 09:19:01 -07:00
cg2121 1ef7a48e9c libobs: Add obs_source_copy_filters function
Allows copying filters from one source to another.

Closes jp9000/obs-studio#860
2017-03-25 04:23:22 -07:00
Richard Stanway 8b640fae24
Fix various null pointer issues detected by Coverity 2017-02-25 16:45:45 +01:00
jp9000 d2934eca7e libobs: Implement audio monitoring
Adds functions to turn on audio monitoring to allow the user to hear
playback of an audio source over the user's speaker.  It can be set to
turn off monitoring and only output to stream, or it can be set to
output only to monitoring, or it can be set to both.

On windows, audio monitoring uses WASAPI.  Windows also is capable of
syncing the audio to the video according to when the video frame itself
was played.

On mac, it uses AudioQueue.

On linux, it's not currently implemented and won't do anything (to be
implemented).
2017-02-06 11:44:02 -08:00
jp9000 74f9c389cb libobs: Use original audio structure for audio signal
Ensures audio has the source-local timestamp when used with audio
monitoring.
2017-02-06 11:44:01 -08:00
jp9000 f728f5b9ec libobs: Mark parameter as constant if not modifying 2017-02-06 11:44:00 -08:00
jp9000 d60d222d71 libobs: Mark last video ts even when buffering off
Ensures that the system always has a record of when the last video frame
was played.
2017-02-06 11:43:59 -08:00
jp9000 69ec87b9a5 libobs: Enumerate full tree when adding active child
Fixes a bug that would allow possible infinite recursion within a source
tree.  To fix this, inactive sources must be enumerated as well in order
to prevent infinite recursion.
2017-01-16 09:53:16 -08:00
jp9000 2877f1d553 libobs: Add func to enum active and inactive child tree 2017-01-16 09:53:08 -08:00
jp9000 521c40460e libobs: Fix bug drawing RGB/BGR async sources
Commit 53955301a2 introduced a async source texture copy bug due to
creating a new case in a switch without adding a break to the one above
it, causing it to execute both cases by mistake.
2016-12-21 20:11:31 -08:00
jp9000 f10e2c6740 libobs: Increase maximum audio tracks to 6 2016-12-21 17:13:19 -08:00
jp9000 53955301a2 libobs: Fix line size issue when copying Y800 data 2016-12-17 22:53:52 -08:00
jp9000 919aecfd62 libobs: Fix format not being set for new source frames
With the previous Y800 fix a bug was introduced where the format for the
destination frame wouldn't be set if it wasn't Y800, causing a crash.
2016-12-17 21:56:10 -08:00
jp9000 85269fb5b2 libobs: Convert Y800 to RGBX manually
Because D3D11 specifically does not support an L8 texture format (you
have to use a shader swizzle), manually convert Y800 signals to RGBX
instead.  This also fixes a bug where Y800 signals will render red.

Closes jp9000/obs-studio#718
2016-12-17 19:58:01 -08:00
Jim 9982581a4f libobs: Ensure async source sizes are always reset
If an async source is cropped on one side, then when the program is
restarted and the source is loaded from file, the async source will
start out with a width/height of zero.  This will cause the async source
to not be drawn if cropping or scale filtering is added to the scene
item, because it has to be rendered to a texture first.  However, the
source cannot reset its size until it's drawn, so it leaves it in
perpetual state of having a 0x0 size.

This fixes that problem by ensuring that the async source size is always
reset even when not being rendered.

Close jp9000/obs-studio#686
2016-11-10 00:13:06 -08:00
Christoph Hohmann a276b9023b libobs: Duplicate filters of a scene when it is is duplicated
When a scene is duplicated the filters on the scene were not copied to
the new scene. This causes that a temporary copy of a scene renders
differently in the program than in the preview when using studio mode.
2016-11-05 19:51:06 +01:00
jp9000 526d390adb libobs: Reduce unnecessary logging (info -> debug)
(Note: This commit also modifies coreaudio-encoder, win-capture, and
win-mf modules)

This reduces logging to the user's log file.  Most of the things
specified are not useful for examining log files, and make reading log
files more painful.

The things that are useful to log should be up to the front-end to
implement.  The core and core plugins should have minimal mandatory
logging.
2016-08-05 18:59:32 -07:00
jp9000 a9caa99c5b libobs: Fix source active/show incrementing/decrementing
The active_refs and show_refs variable would only increment/decrement
their children if their values were 1 and 0, which means that in the
case of scenes within scenes, sub-sources of scenes within scenes would
end up having the wrong ref values.
2016-07-02 14:13:17 -07:00
jp9000 643823505c libobs: Fix obs_source_duplicate on scenes
Scenes have special duplication handling, so make it internally call
obs_scene_duplicate instead.
2016-07-01 15:20:27 -07:00
jp9000 5cc59256e7 libobs: Fix 'set but unused' warnings 2016-06-22 14:10:43 -07:00
jp9000 b5df4537a9 libobs: Fix null pointer dereference w/ null private sources 2016-06-11 12:27:05 -07:00
jp9000 fb1ff173f9 libobs: Fix crash with 4:2:0 async source resolutions
When using GPU conversion for 4:2:0 frames on async video sources, it
would create a texture bigger than necessary and try to copy too much
data from the frame, resulting in a crash.
2016-06-06 23:46:56 -07:00
jp9000 cb9ce7547d libobs: Fix bug activating/showing transitions in a tree
When a transition is a sub-source of another source, it would not call
the transition's active source enum function, meaning that any sources
the transition had would not increment their active/showing refs (it
would only be called when activating the transition directly before).
That would result in negative/invalid active/showing refs on its
sub-sources, causing them to become permanently active/inactive and/or
permanently showing/hidden.
2016-05-26 08:13:21 -07:00
jp9000 2741624fbe libobs: Log when a filter is added/removed from a source 2016-05-04 20:29:26 -07:00
jp9000 ff99ba7818 libobs: Allow filter processing function to return false
(Note: this commit also modifies the obs-filters and test-input modules)

Changes the obs_source_process_filter_begin return type so that it
returns true/false to indicate that filter processing should or should
not continue (for example if the filter is bypassed or if there's some
other sort of issue that causes the filtering to fail)
2016-04-22 10:18:12 -07:00
Richard Stanway bc231eda75
libobs: Fix a race condition when initializing audio sources
The source shouldn't be inserted into obs->data.first_audio_source until it's
fully initialized, or other threads will access source->control and
dereference an uninitialized pointer.
2016-04-13 18:39:24 +02:00
Richard Stanway a73b09c74e
libobs: Remove various dead code found by static analysis
Detected by Coverity Scan (CID 92178, 92171)
2016-04-13 02:43:11 +02:00
jp9000 2274b57926 libobs: Mark filters as private (band-aid fix)
This patch fixes a specific crash where if the user named a filter the
same name as an input source that already existed in the system, scene
item loading code could find the filter with the same name instead of
the source, and mistakenly use it as the scene item's source directly.
This would cause a crash when trying to render that filter as a regular
source.

Marking filters as private is a temporary and simple workaround to the
solution.  Filters are currently not meant to be found via the main
enumeration/search functions, which is a design flaw (lack of
consistency).  In future major API revisions of libobs, filters should
be reworked to act as sources, with the sources they filter as
sub-sources ideally.

Additionally, the concept of "private context objects" and "primary
lists of context objects" in the back-end should probably also be
removed, allowing the font-end (or optional separate API layers) to
control all primary lists of obs context objects.  These minor issues
that occur ultimately stem from API design flaws which need to be
corrected.
2016-04-09 18:12:50 -07:00
jp9000 f23974ab64 libobs: Fix possible crash with filters
This crash happened when a filter was mistakenly used as a regular
source due to an unrelated bug in filter code and scene loading code.
The filter and the source it belongs to both had the same names, and the
source loading code found the filter and mistakenly used it as the
source instead of the actual source with the same name.
2016-04-09 18:12:49 -07:00
jpk c3629eacb5 libobs: Add Y800 color format support
(Note: Also modified the obs-ffmpeg plugin module)

Allows the ability for frame data to pass 8-bit grayscale images (Y800
color format).

Closes jp9000/obs-studio#515
2016-03-24 03:33:35 -07:00
jp9000 07c644c581 libobs: Add deinterlacing API functions
Adds deinterlacing API functions.  Both standard and 2x variants are
supported.  Deinterlacing is set via obs_source_set_deinterlace_mode and
obs_source_set_deinterlace_field_order.

This was implemented in to the core itself because deinterlacing should
happen before effect filters are processed, but after async filters are
processed.  If this were added as a filter, there is the possibility
that a different filter is processed before deinterlacing, which could
mess with the result.  It was also a bit easier to implement this way
due to the fact that that deinterlacing may need to have access to the
previous async frame.

Effects were split in to separate files to reduce load time (especially
for yadif shaders which take a significant amount of time to compile).
2016-03-21 21:22:32 -07:00
jp9000 11d9a8f3e4 libobs: Rename async_convert_texrender to async_texrender 2016-03-21 21:22:31 -07:00
jp9000 9a86a10f91 libobs: Update async textures via function parameters
Instead of just updating the async texture variables directly in the
source, allow the ability to pass the async texture variables via
function parameters to allow the ability to parse more than one frame to
more than one texture.

This code is primarily intended to be used to upload/convert the
"previous" async frame for the deinterlacer (if necessary).
2016-03-21 21:22:31 -07:00
jp9000 12cdaec1a7 libobs: Move frame-related functions to obs-internal.h
Allows access in other source files (particularly the deinterlacer)
2016-03-21 21:22:30 -07:00
John Bradley 310f390e1e libobs: Allow filters to specify technique 2016-03-21 21:22:27 -07:00
jp9000 9e15e3d8fd libobs: Remove need for DrawMatrix technique in effects
(Note: This commit also modifies obs-filters and text-freetype2)

This simplifies writing of effects.  DrawMatrix is no longer necessary
because there are no sources that require drawing with a color matrix
other than async sources, and async sources are automatically processed
and don't defer their initial render stage to filters.
2016-03-21 21:22:26 -07:00
jp9000 d069302b2e libobs: Add function to get obs object type 2016-02-27 02:49:03 -08:00
jp9000 a64f7dd649 libobs: Fix an issue that would cause audio stuttering
Under certain circumstances, the timing_adjust variable would cause line
1161 to continually trigger over and over again.  The "loop detection"
code incorrectly made it so that any timestamp that was just simply
below the expected value would be seen as a jump.  After that, the
timing_adjust variable would be set for the frame again, and then the
audio would see it as a jump again after that, and those two things
would continue endlessly.  This would cause stuttering particularly with
certain devices (particularly elgato/lgp/hdpvr) where the audio/video
data are decoded and sent at varying/different/unpredictable times.

To fix this issue, it should not detect values below as jumps, but
instead should only do it for values that exceed the MAX_TS_VAR (maximum
timestamp variance) value.
2016-02-21 11:04:34 -08:00
jp9000 fa8ae473cf libobs: Fix bug where source audio could stop outputting
If obs_source::audio_ts is set to 0 (such as by discard_if_stopped in
obs-audio.c), but the push_back variable in the source_output_audio_data
function in obs-source.c was being set to true (meaning it's within the
seamless audio smoothing threshold), it would cause it to never reset
the obs_source::audio_ts value, and thus all audio data from the source
would become perpetually ignored by the audio subsystem until there was
finally some sort of timestamp jump that caused it to call
source_output_audio_place, and thus reset obs_source::audio_ts.

obs_source::audio_ts is only reset in source_output_audio_place, not in
source_output_audio_push_back, so the most simple solution is to just
call source_output_audio_push_back is obs_source::audio_ts is 0.
2016-02-04 01:36:13 -08:00
jp9000 b86fdae4a8 libobs: Don't clear audio on ts jump (seamless loops)
There's technically no need to clear the audio data here, nor is there
any need to try to trick the timestamp in to a different position.  It
can simple just reset the audio timing.

Prevents a possible case where audio data might be deleted when it's not
necessary to delete any.
2016-02-03 11:29:09 -08:00
jp9000 d2f2783b44 libobs: Always reset last audio buf size when it changes
This variable is used to detect whether audio has stopped -- if audio
stops, it detects that no new data is coming in, and resets the audio
position so that it eliminates the chance of causing the audio buffering
to go haywire if audio starts up again.  However, this variable was not
being reset every time the value changes, which it should.
2016-01-31 14:08:37 -08:00
jp9000 971728a1a7 libobs: Fix variable being access outside of a mutex
audio_input_buf should never be accessed outside of audio_buf_mutex.
2016-01-31 00:54:55 -08:00
jp9000 d43d59ca8a libobs: Remove seamless audio loop handling
The seamless audio looping code would erroneously trigger for things
that weren't loops, causing the audio data to continually push back and
ignore timestamps, thus going out of sync.

There does need to be loop handling code, but due to the fact that other
things may need to trigger this code, it's best just to clear the audio
data and start from a fresh sync point.  Unfortunately for the case of
loops, this means the window in which audio data loops and video frames
loop need to be muted.
2016-01-31 00:54:54 -08:00
jp9000 eae1328a4f libobs: Always return audio as pending if not an audio source
This is an additional method/helper that prevents composite sources from
treating non-audio sources as audio sources.
2016-01-31 00:54:53 -08:00
jp9000 6f98bd9fed libobs: Use calldata with stack for simple signals
Makes signals use stack memory rather than allocate memory each time.
Most likely a completely insignificant and pointless optimization.
2016-01-26 11:49:56 -08:00
jp9000 ce0a189228 libobs: Fix audio issues with async video/audio looping
This fixes an age-old issue where audio samples could be lost or audio
could temporarily go out of sync in the case of looping videos.  When
audio/video data is looping, there's a window between when the audio
data resets its timestamp value and when the video data resets its
timestamp value.  This method simply pushes back the audio data while in
that window and does not modify sync, and when it detects that its out
of the loop window it simply forces a resync of the audio data in the
circular buffer.

This ensures that minimal audio data is lost in the loop process, and
minimizes the likelihood of any sort of sync issues associated with
looping.
2016-01-26 11:49:54 -08:00
jp9000 41fa9c1bdb libobs: Don't include sync offsets in TS smoothing
Apply user sync offset *after* timestamp smoothing, not before.
Prevents small or gradual sync offsets from not being properly applied.
2016-01-26 11:49:54 -08:00
jp9000 1089564b57 libobs: Apply resampler offset to system audio TS
Instead of applying the resampler offset right away (to each audio
packet), apply the resampler offset when the timestamps are converted to
system timestamps.  This fixes an issue where if audio timestamps reset
to 0 (for whatever reason), the offset would cause the timestamp to go
in to the negative.
2016-01-26 11:49:53 -08:00
jp9000 9661ba8142 libobs: Add obs_source_duplicate function
Allows full duplication of sources (with exception of sources that are
marked with the OBS_SOURCE_DO_NOT_DUPLICATE output capability flag)
2016-01-26 11:49:51 -08:00
jp9000 56dc605497 libobs: Add obs_is_source_configurable function
Mostly only used for transitions with the intention of automatically
creating transitions which don't require configuration, returns whether
the source has any properties or not (whether it's configurable)
2016-01-26 11:49:49 -08:00
jp9000 3371ff59c9 libobs: Add *_create_private functions
Allows creation of private/unlisted sources/outputs/services/encoders
2016-01-26 11:49:48 -08:00
jp9000 bccd3b0b0a libobs: Allow "private" contexts
The intention of this is to allow sources/outputs/etc to be created
without being visible to the UI or save/load functions.
2016-01-26 11:49:47 -08:00
jp9000 669da7ba36 libobs: Do not use signals with audio capture/controls
(Note: This commit also modifies UI)

Instead of using signals, use designated callback lists for audio
capture and audio control helpers.  Signals aren't suitable here due to
the fact that signals aren't meant for things that happen every frame or
things that happen every time audio/video is received.  Also prevents
audio from being allocated every time these functions are called due to
the calldata structure.
2016-01-26 11:49:47 -08:00
jp9000 6839ff7686 libobs: Implement transition sources
Transition sources are implemented by registering a source type as
OBS_SOURCE_TYPE_TRANSITION.  They're automatically marked as video
composite sources, and video_render/audio_render callbacks must be set
when registering the source.  get_width and get_height callbacks are
unused for these types of sources, as transitions automatically handle
width/height behind the scenes with the transition settings.

In the video_render callback, the helper function
obs_transition_video_render is used to assist in automatically
processing and rendering the audio.  A render callback is passed to the
function, which in turn passes to/from textures that are automatically
rendered in the back-end.

Similarly, in the audio_render callback, the helper function
obs_transition_audio_render is used to assist in automatically
processing and rendering the audio.  Two mix callbacks are used to
handle how the source/destination sources are mixed together.  To ensure
the best possible quality, audio processing is per-sample.

Transitions can be set to automatically resize, or they can be set to
have a fixed size.  Sources within transitions can be made to scale to
the transition size (with or without aspect ratio), or to not scale
unless they're bigger than the transition.  They can have a specific
alignment within the transition, or they just default to top-left.
These features are implemented for the purpose of extending transitions
to also act as "switch" sources later, where you can switch to/from two
different sources using the transition animation.

Planned (but not yet implemented and lower priority) features:

- "Switch" transitions which allow the ability to switch back and forth
  between two sources with a transitioning animation without discarding
  the references

- Easing options to allow the option to transition with a bezier or
  custom curve

- Manual transitioning to allow the front-end/user to manually control
  the transition offset
2016-01-26 11:49:45 -08:00
jp9000 5098f68db0 libobs: Move obs_source_dosignal to obs-internal.h
Allows using it in multiple source files
2016-01-26 11:49:40 -08:00
jp9000 b0104fcee0 (API Change) libobs: Remove source_type param from functions
(Note: test and UI are also modified by this commit)

API Changed (removed "enum obs_source_type type" parameter):
-------------------------
obs_source_get_display_name
obs_source_create
obs_get_source_output_flags
obs_get_source_defaults
obs_get_source_properties

Removes the "type" parameter from these functions.  The "type" parameter
really doesn't serve much of a purpose being a parameter in any of these
cases, the type is just to indicate what it's used for.
2016-01-26 11:49:37 -08:00
jp9000 c1dd156db8 libobs: Implement new audio subsystem
The new audio subsystem fixes two issues:

- First Primary issue it fixes is the ability for parent sources to
  intercept the audio of child sources, and do custom processing on
  them.  The main reason for this was the ability to do custom
  cross-fading in transitions, but it's also useful for things such as
  side-chain effects, applying audio effects to entire scenes, applying
  scene-specific audio filters on sub-sources, and other such
  possibilities.

- The secondary issue that needed fixing was audio buffering.
  Previously, audio buffering was always a fixed buffer size, so it
  would always have exactly a certain number of milliseconds of audio
  buffering (and thus output delay).  Instead, it now dynamically
  increases audio buffering only as necessary, minimizing output delay,
  and removing the need for users to have to worry about an audio
  buffering setting.

The new design makes it so that audio from the leaves of the scene graph
flow to the root nodes, and can be intercepted by parent sources.  Each
audio source handles its own buffering, and each audio tick a specific
number of audio frames are popped from the front of the circular buffer
on each audio source.  Composite sources (such as scenes) can access the
audio for child sources and do custom processing or mixing on that
audio.  Composite sources use the audio_render callback of sources to do
synchronous or deferred audio processing per audio tick.  Things like
scenes now mix audio from their sub-sources.
2016-01-26 11:49:34 -08:00
jp9000 ddfd89a673 libobs: Implement composite sources (skip)
(Note: This commit breaks libobs compilation.  Skip if bisecting)

Adds a "composite" source type which is used for sources that composite
one or more sub-sources.  The audio_render callback is called for
composite sources to allow those types of sources to do custom
processing of the audio of its sub-sources.
2016-01-26 11:49:33 -08:00
jp9000 a5c9350be5 libobs: Remove "presentation volume" and "base volume" (skip)
(Note: This commit breaks libobs compilation.  Skip if bisecting)

These variables are considered obsolete and will no longer be needed.
2016-01-26 11:49:32 -08:00
jp9000 73ec5906b7 libobs: Add function that checks whether source is muted (skip)
(Note: This commit breaks libobs compilation.  Skip if bisecting)
2016-01-26 11:49:32 -08:00
jp9000 27438a5156 libobs/media-io: Remove 'volume' from audio_data (skip)
(Note: This commit breaks libobs compilation.  Skip if bisecting)

This variable is somewhat redundant.  Volume is already known/accessible
to front-ends.
2016-01-26 11:49:31 -08:00
jp9000 bc0b85cb79 libobs: Store circular audio buffer on source itself (skip)
(Note: This commit breaks libobs compilation.  Skip if bisecting)

Removes audio lines and stores the circular buffer for the audio on the
source itself.
2016-01-26 11:49:30 -08:00
jp9000 f73bbe6746 libobs: Store source audio mixers in obs_source (skip)
(Note: This commit breaks libobs compilation.  Skip if bisecting)

The mixers that a source was assigned to were originally stored in the
audio line.  This will store it in the sources themselves instead.
2016-01-26 11:49:29 -08:00
jp9000 ed8998e403 libobs: Do recursive height/width calls on non-filters
Originally this was programmed to call the recursive height/width
functions if the source type was an input with the intention of not
calling it on filters, but instead of doing that just program it to do
just that: only call the recursive height/width functions if it's not a
filter.
2016-01-23 07:17:47 -08:00
jp9000 8f7d8d05b2 libobs: Add sample_rate param to conv_frames_to_time
Prevents from having to query the base audio subsystem for the sample
rate each time the function is called
2015-12-22 06:18:21 -08:00
jp9000 96d9bf794c libobs: Store linked list of audio sources
Useful for going traversing the list of audio sources (particularly for
the new audio subsystem)
2015-12-22 06:18:20 -08:00
jp9000 a702d88c25 libobs: Don't track active transitions
This was originally used for calculating audio volume if transitions
were active, but transitions won't work that way so tracking the active
transitions is no longer needed.
2015-12-22 06:18:19 -08:00
jp9000 c8f4fbe42b (API Change) libobs: Rename funcs relating to active child sources
Renames:
----------------------------------------
obs_source_add_child
obs_source_remove_child
obs_source_enum_sources
obs_source_enum_tree
obs_source_info::enum_sources

To:
----------------------------------------
obs_source_add_active_child
obs_source_remove_active_child
obs_source_enum_active_sources
obs_source_enum_active_tree
obs_source_info::enum_active_sources

These functions/callbacks had misleading names: they originally implied
any child sources, when they actually meant active child sources that
are being used to render video or audio.  It's important that the
function names represent their actual purpose.
2015-12-22 05:49:02 -08:00
jp9000 70fec7ae8e (API Change) libobs: Remove "User sources list" (skip)
(Note: This commit breaks UI compilation.  Skip if bisecting)

API Removed:
------------------------
obs_add_source

API Changed:
------------------------
obs_source_remove: Now just marks/signals a source for removal

The concept of "user sources" is flawed: it was something that the
front-end was forced to deal with if it wanted to automate source
saving/loading, and often it had to code around it.  That's not how
saving/loading should work, a front-end should be allowed to manage
lists of sources in the way it explicitly chooses, and it should be able
to choose which sources it wants to save/load.
2015-12-22 05:48:43 -08:00
jp9000 59f0ba0c8a libobs: Add load/save signals for sources
These signals are meant to replace the add/remove signals.
2015-12-22 05:36:22 -08:00
jp9000 11922265de libobs: Keep reference to source when rendering 2015-12-15 01:11:11 -08:00
jp9000 332359d286 libobs: If filter size invalid, skip filter
This shouldn't happen anymore because crop was fixed, but if a filter
returns 0x0 size and is invalid it shouldn't stop the filter chain.
Instead, it should just be skipped.
2015-11-20 14:07:15 -08:00
jp9000 fea4f75157 libobs: Update async video texture before effect filters
When an async video source is about to be rendered, the async texture
should be updated before any effect filtering occurs, rather than right
when it's about to render.

Fixes a few bugs:

- If the async texture hadn't drawn for its first time, and the source
  has an effect filter, it would never end up rendering the first
  frame due to the fact that it would fail on obs-source.c:2434 for the
  first filter, causing it to never actually render the source, and thus
  never get to a point in which it could call set_async_texture_size to
  establish the async texture width/height for the first time.

- Any time the async texture size changed, it would only update the
  async texture size at the end of the filter loop, which means that the
  first frame after a size change would use the old size for the filters
  rather than update to the new size right away.
2015-10-22 17:46:54 -07:00
jp9000 db7aebb940 libobs: Allow null pointer with obs_source_release_frame
A null pointer to a release/destroy function should be considered legal,
and simply do nothing.
2015-10-22 17:45:58 -07:00
jp9000 485a006215 libobs: Check source textures before destroying
Check to make sure the texrenders and textures on a source are valid
before destroying.
2015-10-21 07:46:40 -07:00
jp9000 f07ce8501f libobs: Add null debug messages for base obs funcs 2015-10-21 06:30:32 -07:00
jp9000 c27ff7903d libobs: Display debug msg in data_valid if null
Uses obs_source_valid in data_valid which will ensure a debug message is
displayed if null.
2015-10-21 06:28:03 -07:00
jp9000 8686451d5d libobs: Rename source_valid to data_valid
To prevent confusion with the new obs_source_valid function which
displays a warning, rename the "source_valid" function to "data_valid"
to emphasize that it's checking for the validity of the internal data as
well as the source itself.
2015-10-21 06:27:44 -07:00
jp9000 6ad8df8adb (API Change) libobs: Use single func for base effects
API removed:
--------------------
gs_effect_t *obs_get_default_effect(void);
gs_effect_t *obs_get_default_rect_effect(void);
gs_effect_t *obs_get_opaque_effect(void);
gs_effect_t *obs_get_solid_effect(void);
gs_effect_t *obs_get_bicubic_effect(void);
gs_effect_t *obs_get_lanczos_effect(void);
gs_effect_t *obs_get_bilinear_lowres_effect(void);

API added:
--------------------
gs_effect_t *obs_get_base_effect(enum obs_base_effect effect);

Summary:
--------------------
Combines multiple near-identical functions into a single function with
an enum parameter.
2015-10-19 00:52:45 -07:00
Richard Stanway 4b9d0256c8 libobs: Add missing mutex unlocks to some filter functions
Detected by Coverity Scan (CID 12831, 12830)
2015-10-12 23:21:45 +02:00
jp9000 6285a47726 (API Change) libobs: Pass type data to get_name callbacks
API changed from:
obs_source_info::get_name(void)
obs_output_info::get_name(void)
obs_encoder_info::get_name(void)
obs_service_info::get_name(void)

API changed to:
obs_source_info::get_name(void *type_data)
obs_output_info::get_name(void *type_data)
obs_encoder_info::get_name(void *type_data)
obs_service_info::get_name(void *type_data)

This allows the type data to be used when getting the name of the
object (useful for plugin wrappers primarily).

NOTE: Though a parameter was added, this is backward-compatible with
older plugins due to calling convention.  The new parameter will simply
be ignored by older plugins, and the stack (if used) will be cleaned up
by the caller.
2015-09-16 09:21:12 -07:00
jp9000 0ed913a136 libobs: Add functions to get private type data
The private type data is the type_data variable that's provided when
object types are registered by plugins.
2015-09-16 09:17:14 -07:00
kc5nra 3b2b7f2f37 libobs: Remove flag check when resetting timestamp
Removes obsolete check when resetting a timestamp as some sources
can register for Audio/Video async yet only output audio frames.
2015-08-02 15:54:10 -05:00
jp9000 91bfb53ed5 libobs: Fix audio filters killing video on source
When an audio filter is applied to a video source that also has
accompanying audio, it would cause the video from the source to stop
rendering.

The original code this was from was to prevent audio-only sources from
rendering video, but I neglected to make sure that this would not apply
to filters, and thus when an audio filter is on a source with video, the
code would kill the video.
2015-07-09 02:05:09 -07:00
jp9000 526b9e6bc1 libobs: Do not add audio hotkeys for filters 2015-07-03 09:21:43 -07:00
jp9000 d9c7290891 libobs: Do not try to render audio-only sources 2015-06-25 15:55:27 -07:00
jp9000 76870d1764 libobs: Increase async jitter compensation
Due to the fact that async timestamps themselves can be susceptible to
minor jitter from certain types of inputs, increase the allowable jitter
compensation value to ensure that the rendered frame timing from async
video sources is always as close as possible to the compositor.

When the framerate of the source is the same as the framerate as the
compositor, this (combined with the fact that clamped video timing now
being used with async video frames) helps ensure that buffered async
video sources will sync up their rendering to the compositor as
accurately as possible despite jitter from the source's timestamps.

If there is no jitter in the source's timestamps then it'll always sync
up perfectly with the compositor, thanks to clamped video timing.
2015-06-04 18:05:59 -07:00
jp9000 35a35badeb libobs: Use clamped video time for async timing
When playing back buffered async frames, this reduces the probability
that new frames will be missed/skipped due to jitter in the system
timestamps.

If a buffered async source is playing at the same framerate as the
compositor and there is no jitter in the async source's timestamps, then
the async source will play back perfectly in sync with the compositor
thanks to this change, ensuring that there's no skipped or missed frames
in video playback.
2015-06-04 18:05:51 -07:00
jp9000 7f7901b930 libobs: Reset frame cache if it gets too big
When buffering is enabled for an async video source, sometimes minor
drift in timestamps or unexpected delays to frames can cause frames to
slowly buffer more and more in memory, in some cases eventually causing
the system to run out of memory.

The circumstances in which this can happen seems to depend on both the
computer and the devices in use.  So far, the only known circumstances
in which this happens are with heavily buffered devices, such as
hauppauge, where decoding can sometimes take too long and cause
continual frame playback delay, and thus continual buffering until
memory runs out.  I've never been able to replicate it on any of my
machines however, even after hours of testing.

This patch is a precautionary measure that puts a hard limit on the
number of async frames that can be currently queued to prevent any case
where memory might continually build for whatever reason.  If it goes
over the limit, it clears the cache to reset the buffering.

I had a user with this problem test this patch with success and positive
feedback, and the intervals between buffering resets were long to where
it wasn't even noticeable while streaming/recording.

Ideally when decoding frames (such as from those devices), frame
dropping should be used to ensure playback doesn't incur extra delay,
although this sort of hard limit on the frame cache should still be
implemented regardless just as a safety precaution.  For DirectShow
encoded devices I should just switch to faruton's libff for decoding and
enable the frame dropping options.  It would probably explain why no
one's ever reported it for the media source, and pretty much only from
DirectShow device usage.
2015-06-04 17:39:03 -07:00
Palana 7b3b083889 libobs: Add audio source hotkeys 2015-05-11 20:45:25 +02:00
Palana 1d39c3e9b6 (API Change) libobs: Add hotkey data to *_create functions 2015-05-11 20:45:25 +02:00
Palana 5ad553d06d libobs: Add global hotkey support 2015-05-11 20:45:24 +02:00
Palana 4d40c5c853 libobs: Extend audio_data signal with muted flag 2015-05-07 02:08:08 +02:00
Palana a563fbc05b libobs: Add weak reference type for obs_source 2015-05-07 01:57:14 +02:00
jp9000 9d82760405 libobs: Warn if source released after shutdown
Instead of letting this area of code crash, check to see if the core is
still active or not, and safely warn and ignore the release if so.
2015-04-30 05:14:38 -07:00
jp9000 908a165d62 Add planar YUV 4:4:4 format support
Adds the ability to natively output with planar YUV 4:4:4.
2015-04-17 20:16:40 -07:00
jp9000 cf28a8af22 libobs: Init source mutexes before calling create
Fixes a crash that could happen if any of the mutexes are used in the
create callback, or before the obs_source_init function is called.

I'm not sure how this function order slipped because it seems fairly
obvious that these mutexes should be created before the create callback.

Had this crash happen to me when creating a WASAPI output source, the
create callback of the WASAPI source creates a thread which outputs
audio, and that thread managed to call obs_source_output_audio before
the obs_source_init function was called, which in turn caused it to try
to use a null mutex.
2015-04-15 16:13:37 -07:00
jp9000 ab65df74e0 libobs: Increment new frame ref when first copying
When caching a new frame, keep a reference to the frame while copying to
ensure that the frame is not potentially destroyed for whatever reason
while that data is being copied.
2015-04-10 19:28:41 -07:00
jp9000 dde1a73132 libobs: Fix async texture data race
The obs_source::async_reset_texture variable can cause a data race
between threads to occur because it could be set to true in one thread
then changed back to false in another thread.  This could cause the
async texture to not update its size when it's supposed to, which can
cause a crash or corruption when copying data from a frame of a
differing size.

The solution to this is to:

- Delete the async_reset_texture variable, and make the
  set_async_texture_size function change the texture size if the
  async_width, async_height, or async_format variables differ from the
  frame's width/height/format.  Those variables are then only ever set
  in the libobs graphics thread.

- Make the cache_video function use separate variables from other
  functions to detect a change in size (due to the fact that the texture
  size should only be resized in the libobs graphics thread).  These
  variables are async_cache_width, async_cache_height, and
  async_cache_format, which are only be set in the thread that calls
  obs_source_output_video.

How to replicate the data race:

- On OSX, use window capture on a textedit window, then continually
  resize the textedit window.
2015-04-10 19:16:18 -07:00
jp9000 85a490c5e8 libobs: Remove out-of-context comment
This comment was originally for an older version of the code; I'm
guessing I forgot to remove it along with the code that it originally
belonged with.
2015-04-10 19:15:06 -07:00
jp9000 095159c23a libobs: Fix bug with filter bypassing
Due to a bad 'if' expression, when a filter that is not last in the
chain is disabled or being bypassed, it ends up still calling the
filter's video processing function unintentionally.

This fix makes sure that it only calls the appropriate render functions
if the next filter target is the source, otherwise it will just call
obs_source_video_render to process the next filter in the chain.

How to replicate the bug:
1. Create two crop filters on the same source
2. Give each crop filter a different distinct value
3. Disable both crop filters
4. The image would still be cropped
2015-04-10 07:27:26 -07:00
jp9000 95f5a3c260 libobs: Clear current async frame if cache freed
If the cache is freed the current async frame will of course become
invalid, so make sure it's set to null if the cache is freed.
2015-03-27 10:03:47 -07:00
jp9000 3a90be39dd libobs: Deallocate lingering unused cache frames
This fixes an issue where cache frames would not free at all after
having been allocated with no upper limit on the cached frame size.  If
cached frames go unused for a specific period of time, they are
deallocated and removed from the cache.

This is preferable to having an upper cache limit due to the potential
for async delay filtering.
2015-03-27 00:07:16 -07:00
jp9000 f03e66fc99 Revert "libobs: Fix memory leak (Enforce cache limit)"
This reverts commit 4459ed3e2c.
2015-03-26 23:40:36 -07:00
jp9000 4459ed3e2c libobs: Fix memory leak (Enforce cache limit)
Under certain circumstances the cache could be prone to growing too
large unintentionally.  Setting a hard maximum limit should prevent
memory from growing if we suddenly get a lot of frames.
2015-03-26 22:59:48 -07:00
jp9000 6e22ac41b8 libobs: Swap async source frames in tick
Async frames are only swapping when rendering, or when not visible.
This is a flawed design due to the fact that there are certain
circumstances where the source is neither visible nor currently
rendering.

This is what caused a memory leak when scene items were marked as
invisible, because if a source has an async child source and decides not
to render that source for whatever reason, the child source would not
process the async frames at all, and the cache would just grow.

To fix this, simply moving the async frame cycle to tick fixes the issue
due to the fact that tick is always called regardless of circumstance.
2015-03-26 22:59:48 -07:00
jp9000 621158f8e1 libobs: Fix warning
Removed this variable some time back, but didn't test on GCC (which
throws this warning), so I never knew about it until recently.
2015-03-25 14:14:40 -07:00
jp9000 74d886c2f8 libobs: Reorder filters based upon their type
If a filter is an async filter move above/below other async filters,
and similarly for effect filters move above/below other effect filters.
2015-03-25 10:03:20 -07:00
jp9000 2b4fdb19ad libobs: Filter async video before rendering
Filtering the video before it's output to the texture means that it
happens after all the processing on the timestamps and such of the video
data.  This way, the video filter does not have to worry about what's
currently buffered, and it won't affect timing.
2015-03-25 10:03:19 -07:00
jp9000 c16f1a7430 libobs: Add obs_get_source_output_flags function
Gets the output flags by its source type.
2015-03-25 10:03:17 -07:00
jp9000 1a70ae0105 libobs: Add missing function definition
obs_get_source_defaults was missing the definition for the function.
2015-03-25 10:03:17 -07:00
jp9000 f109be3010 libobs: Fix potential bug destroying filters
When OBS is shutting down, if for some reason the filter is destroyed
before the parent source is destroyed, it would try to remove itself
from the source, but it would decrement the reference and try to destroy
itself again while already in the process of destroying itself.

So, the solution was simply to make sure that if it's removing itself
from the source that it doesn't decrement its own reference.
2015-03-25 10:03:15 -07:00
jp9000 18afe82304 libobs: Skip filter if internal data not present
If the filter's binary was recently removed, the data will be invalid,
so make sure that it properly handles that situation by skipping the
filter.
2015-03-25 10:03:14 -07:00
jp9000 e31fea66be libobs: Add API to mute/unmute sources 2015-03-25 10:03:13 -07:00
jp9000 f04ef236ac libobs: Add ability to disable sources/filters 2015-03-25 10:03:13 -07:00
jp9000 98a6c8f0d0 libobs: Always enumerate filter list in reverse
The "last" filter that's rendered is technically at filter index 0, so
enumeration needs to be from the last index in the list to the first
index in the list.
2015-03-25 10:03:12 -07:00
jp9000 64943f3fc6 libobs: Lock mutex when changing filter order
Refactors the function a bit to ensure that the filter mutex is locked
when changing the filter order.
2015-03-25 10:03:11 -07:00
jp9000 dedc454caf libobs: Add "reorder_filters" source signal
Signals when the filter order has been changed for a source.
2015-03-25 10:03:10 -07:00
jp9000 4aa8f2d14b libobs: Fix bug when changing filter order
The 'idx' variable is the incorrect variable to be using here, the
variable that was supposed to be used was 'i'.
2015-03-25 10:03:09 -07:00
jp9000 86a0f370c3 libobs: Insert new filters at index 0
Technically, the "last" filter rendered is the filter at index 0, so
inserting a new filter at that point makes the most sense.
2015-03-25 10:03:08 -07:00
jp9000 c0cc81d20f libobs: Turn blending off for filter renders
When rendering a filter to a texture, the target is empty and unused, so
there's no reason for blending to be on when rendering the filter to a
render target.
2015-03-25 10:03:07 -07:00
jp9000 44e484ad34 (API Change) Fix filter rendering design flaw
obs_source_process_filter tried to do everything in a single function,
but the problem is that effect parameters would not properly be
accounted for due to the way it internally draws, therefore it was
necessary to split the functions in to two, you first call
obs_source_process_filter_begin, then you set your effect parameters,
then you finally call obs_source_process_filter_end.  This ensures that
when the filter is drawn, that the effect parameters are set.
2015-03-25 10:03:06 -07:00
jp9000 44f103de9c libobs: Fix rendering at end of the filter chain
When the filter chain finally reaches the source and the last filter in
the chain is set to not render directly (meaning it has to render to
texture), it would not render the source with any effect due to the fact
that it expects a filter to be present.
2015-03-25 10:03:05 -07:00
jp9000 7878fda442 libobs: Add filter_remove callback for sources
Adds a source callback function that is used when a filter is removed
from a source.  This ensures that any data that might be associated with
that source can be cleaned up if necessary.
2015-03-25 10:03:04 -07:00
jp9000 cd7d045ff3 libobs: Make filter mutex recursive 2015-03-25 10:03:03 -07:00
jp9000 c2775eaa3d libobs: Add obs_source_skip_video_filter function
This allows a filter to skip its step and move on to the next target in
the chain without affecting performance.
2015-03-25 10:03:02 -07:00
jp9000 f4af2fcadc libobs: Always clear render target filter
This fixes a bug where the previous contents of a filter's render target
texture might become visible if using alpha.
2015-03-25 10:03:01 -07:00
jp9000 dfde8d4a63 libobs: Use 'can_bypass' func for filter bypassing
There are a few more conditions which need to be checked to ensure
whether we can actually bypass or not; in this particular case we are
using the YUV texture shaders, plus the image can also be flipped, so we
can't really use the bypass optimization in those situations.
2015-03-25 10:03:00 -07:00
jp9000 b9eef3c4f2 libobs: Add API to get base source dimensions
These functions are primarily for use with filters, filters need to be
able to get the width/height of a target source without it necessarily
getting the post-filtered dimensions.
2015-03-25 10:02:59 -07:00
jp9000 506e30da10 libobs: Do not clear frame cache if 0,0 dimension
Previously I had it set so that it would set the async_width and
async_height variables to 0,0 if a null frame occurs, but the problem
with this is that it was inadvertently cause the frame cache to clear
when it starts receiving textures again because it detects it as a size
change.

So instead of changing async_width and async_height to 0 when a null
frame occurs, change it so that if the source is set to an inactive
state, make obs_source_get_width/_get_height return 0 for their
dimensions instead.
2015-03-25 10:02:58 -07:00
jp9000 26206f6af4 libobs: Use reference counting with source frames
When a frame is processed by a filter, it comes directly from the
source's video frame cache.  However, if a filter is using or processing
those frames for whatever reason, there would be no guarantee that the
frames would persist during processing, and frames could eventually be
deallocated unexpected, for example when the resolution or format
changes.

So the solution is to implement simple reference counting for the frames
so that the frames will exist until they have been released by any
source or filter that's using them.
2015-03-25 10:02:57 -07:00
jp9000 ebee67097a libobs: Prevent video cache clear on first frame
Fix a bug where when a source first starts up its async cache, it
unintentionally resets its cache, which means that the first few frames
would be lost.
2015-03-22 19:18:19 -07:00
jp9000 13046145f7 libobs: Fix filter dimension issue
The wrong function was being used to recurse through the filter chain in
obs_source_process_filter, obs_source_get_[width/height] would get the
post-effect dimensions rather than the pre-effect dimensions.
2015-03-22 18:38:40 -07:00
jp9000 95e63992cb libobs: Fix filter rendering bug
The parameters order was wrong; sort of a rare thing to see, but it can
happen, especially when it's a function that's not used very often.
2015-03-22 18:28:12 -07:00
jp9000 0f31880c3c libobs: Fix bug (source resampler not resetting)
If the audio data had the same format/samplerate as the obs audio
subsystem, it would fail to simply destroy the resampler and set it to
NULL, and then any audio data going through would use the resampler that
was being used before that, causing audio to become garbage.

This bug only started appearing when I recently changed the libobs
internal audio subsystem format to non-interleaved floating point, which
is a common format, and thus caused this bug to actually occur more
often.
2015-03-13 01:03:01 -07:00
jp9000 4fdd8fb570 libobs: Don't ignore starting audio if async
I when a source has both async audio/video capability, it would ignore
audio until the video has started.  There's really no need to do this,
when the video starts it'll just fix up the timing automatically.

This should fix the case where things like the media source would not be
able to play audio-only files.
2015-03-12 22:27:36 -07:00
jp9000 9832a760b8 (API Change) Always use planar float audio output
Core API functions changed:
-----------------------------
EXPORT bool obs_reset_audio(struct audio_output_info *aoi);
EXPORT bool obs_get_audio_info(struct audio_output_info *aoi);

To:
-----------------------------
EXPORT bool obs_reset_audio(const struct obs_audio_info *oai);
EXPORT bool obs_get_audio_info(struct obs_audio_info *oai);

Core structure added:
-----------------------------
struct obs_audio_info {
	uint32_t            samples_per_sec;
	enum speaker_layout speakers;
	uint64_t            buffer_ms;
};

Non-interleaved (planar) floating point output is standard with audio
filtering, so to prevent audio filters from having to worry about
different audio format implementations and for the sake consistency
between user interfaces, make it so that audio is always set to
non-interleaved floating point output.
2015-03-12 22:22:02 -07:00
Palana 89b7230652 libobs: Fix async plane offset calculation
Frames allocated via video_frame_init from media-io/video-frame.c have
their planes aligned which the original offset calculation didn't take
into account, resulting in some planes being drawn incorrectly.

Example media file to reproduce via the ffmpeg (media) source:
http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_surround-fix.avi
2015-03-10 18:20:49 +01:00
jp9000 50a36f45cd libobs: Add obs_source_get_filter_by_name function 2015-03-06 09:13:56 -08:00
jp9000 9f82085243 libobs: Add obs_source_enum_filters function
Enumerates filters that are currently present on a source.
2015-03-06 09:12:00 -08:00
jp9000 0b5a5c16a9 libobs: Fix bug rendering async video with filters
This code was originally meant to skip some checks as an optimization,
but it did not account for async video sources and would call
obs_source_default_render (which is only for synchronous video sources),
this fixes the issue by just calling obs_source_video_render.
2015-03-06 09:09:57 -08:00
jp9000 502f4005f1 libobs: Fix race condition when adding a filter
The source would sometimes be rendered before the code to add it to the
filter chain was executed, therefore it would cause a crash.
2015-03-06 09:09:57 -08:00
jp9000 b1ba8561ff libobs: Keep references to filters when on sources
When a filter is added to a source, it does not currently keep a
reference when it's associated that that source, this fixes that
problem.
2015-03-06 09:09:56 -08:00
jp9000 3510e69121 libobs: Account for filters in source dimensions
The obs_source_get_width and obs_source_get_height functions need to
account for filters that may change their width/height such as a crop
filter or something similar.

As a side effect of this commit, because these functions need to lock
the filter mutex, these functions can no longer be used with a
const-qualified obs_source_t pointer.
2015-03-06 09:09:56 -08:00
jp9000 46341725c2 libobs: Remove inline from function
This function is somewhat big and is a function called conditionally,
therefore having it be inline is somewhat of a waste if it's not always
being called.
2015-03-06 09:09:56 -08:00
jp9000 818a57c33f libobs: Fix graphics memory leak
Graphics data has to be freed inside of an active graphics context,
otherwise the resources will not be freed; in the future, we should
probably make sure that the graphics subsystem automatically
asserts/warns about this scenario.
2015-03-06 09:09:56 -08:00
jp9000 8e5a0970b1 libobs: Fix releasing filters on source destroy
I was iterating through the obs_source::filters array to remove filters,
but every time I removed a filter, it would remove itself from the
array, therefore it would end up skipping items in the array, therefore
leaving filters unreleased.  This just removes the first filter until
all filters have been removed.
2015-03-06 09:09:56 -08:00
jp9000 95a5e8009f libobs: Add filter add/remove signals
Adds "filter_remove" and "filter_add" signals that signal when a filter
is added or removed
2015-03-06 09:09:55 -08:00
jp9000 8323799113 libobs: Use video thread for show/active callbacks
For the show/hide and activate/deactivate callbacks, schedule these
callbacks to only be called from within the video thread rather than in
a separate thread.  This ensures that any potential graphics activity
that occurs within them is kept in the same thread.
2015-03-02 18:53:25 -08:00
jp9000 7055775c7c libobs: Add functions to show/hide sources
obs_source_inc_showing and obs_source_dec_showing are used to indicate
that a source is showing or no longer being shown in a particular area
of the program outside from the main render view.

One could use an obs_view, but I felt like it was unnecessary because
using an obs_view just to display a single source feels somewhat
superfluous.
2015-03-02 12:23:25 -08:00
Palana d085d6e4a1 libobs: Allow duplicate sources per scene
Previously having a source multiple times in a single scene would cause
the recursion check to trigger. Example scenes.json:

{
    "current_scene": "Scene",
    "sources": [
        {
            "flags": 0,
            "id": "scene",
            "mixers": 0,
            "name": "Scene",
            "settings": {
                "items": [
                    {
                        "align": 5,
                        "bounds": {
                            "x": 0.0,
                            "y": 0.0
                        },
                        "bounds_align": 0,
                        "bounds_type": 0,
                        "name": "Text (FreeType 2)",
                        "pos": {
                            "x": 0.0,
                            "y": 0.0
                        },
                        "rot": 0.0,
                        "scale": {
                            "x": 1.0,
                            "y": 1.0
                        },
                        "visible": true
                    },
                    {
                        "align": 5,
                        "bounds": {
                            "x": 0.0,
                            "y": 0.0
                        },
                        "bounds_align": 0,
                        "bounds_type": 0,
                        "name": "Text (FreeType 2)",
                        "pos": {
                            "x": 0.0,
                            "y": 98.0
                        },
                        "rot": 0.0,
                        "scale": {
                            "x": 1.0,
                            "y": 1.0
                        },
                        "visible": true
                    }
                ]
            },
            "sync": 0,
            "volume": 1.0
        },
        {
            "flags": 0,
            "id": "text_ft2_source",
            "mixers": 0,
            "name": "Text (FreeType 2)",
            "settings": {},
            "sync": 0,
            "volume": 1.0
        }
    ]
}
2015-02-17 13:41:49 +01:00
jp9000 84e1f47ced (API Change) Add support for multiple audio mixers
API changed:
--------------------------

void obs_output_set_audio_encoder(
		obs_output_t *output,
		obs_encoder_t *encoder);

obs_encoder_t *obs_output_get_audio_encoder(
		const obs_output_t *output);

obs_encoder_t *obs_audio_encoder_create(
		const char *id,
		const char *name,
		obs_data_t *settings);

Changed to:
--------------------------

/* 'idx' specifies the track index of the output */
void obs_output_set_audio_encoder(
		obs_output_t *output,
		obs_encoder_t *encoder,
		size_t idx);

/* 'idx' specifies the track index of the output */
obs_encoder_t *obs_output_get_audio_encoder(
		const obs_output_t *output,
		size_t idx);

/* 'mixer_idx' specifies the mixer index to capture audio from */
obs_encoder_t *obs_audio_encoder_create(
		const char *id,
		const char *name,
		obs_data_t *settings,
		size_t mixer_idx);

Overview
--------------------------
This feature allows multiple audio mixers to be used at a time.  This
capability was able to be added with surprisingly very little extra
overhead.  Audio will not be mixed unless it's assigned to a specific
mixer, and mixers will not mix unless they have an active mix
connection.

Mostly this will be useful for being able to separate out specific audio
for recording versus streaming, but will also be useful for certain
streaming services that support multiple audio streams via RTMP.

I didn't want to use a variable amount of mixers due to the desire to
reduce heap allocations, so currently I set the limit to 4 simultaneous
mixers; this number can be increased later if needed, but honestly I
feel like it's just the right number to use.

Sources:

Sources can now specify which audio mixers their audio is mixed to; this
can be a single mixer or multiple mixers at a time.  The
obs_source_set_audio_mixers function sets the audio mixer which an audio
source applies to.  For example, 0xF would mean that the source applies
to all four mixers.

Audio Encoders:

Audio encoders now must specify which specific audio mixer they use when
they encode audio data.

Outputs:

Outputs that use encoders can now support multiple audio tracks at once
if they have the OBS_OUTPUT_MULTI_TRACK capability flag set.  This is
mostly only useful for certain types of RTMP transmissions, though may
be useful for file formats that support multiple audio tracks as well
later on.
2015-02-04 16:51:29 -08:00
jp9000 12d149bd3a libobs: Fix cache overflowing (memory leak)
Fixes a bug where all frames in the cache would get marked as 'in use',
this causing it to continually allocate new frames continually.
2015-01-06 14:29:40 -08:00
jp9000 c3e498d25f libobs: Add frame caching for async video sources
The temporary unoptimized code we were using before just completely
allocated a new copy of each frame every single time a new async frame
was output by the source plugin.  This just creates a cache of frames as
needed for the current format/width/height to minimize the allocation
and deallocation.  If new frames come in that are of a different
format/width/height, it'll just clear the cache.  This is a fairly
important optimization.
2015-01-05 02:10:33 -08:00
jp9000 ae39e5bb77 libobs: Rename some variables for consistency
all the async video related stuff usually started with async_*, and
there were two that didn't.  So I just renamed them so they have the
same naming convention
2015-01-05 02:10:32 -08:00
jp9000 8b065fd068 libobs: Allow disabling of async video texture
If an async video source stops video for whatever reason, it would get
stuck on the last frame that was played.  This was particularly awkward
when I wanted to give the user the ability to deactivate a source such
as a webcam because it would get stuck on the last frame.
2015-01-03 20:47:29 -08:00
jp9000 f2287c8a28 libobs: Add obs_source_set_default_flags
This allows sources to set default flags on creation without interfering
with user set flags
2015-01-03 02:37:15 -08:00
jp9000 eac55edca0 libobs: Add obs_source_showing function
This allows the ability to see whether the source is being displayed
somewhere (though not necessarily active in the main output)
2015-01-03 02:37:15 -08:00
jp9000 fd8f8cfda8 libobs: Fix potential null pointer dereference 2015-01-03 02:37:14 -08:00
jp9000 e14050bbe1 libobs: Fix crash if missing plugin for a source
I forgot that the info variable may be intentionally NULL if a source's
plugin in missing.
2015-01-03 02:37:14 -08:00
jp9000 caa6251054 libobs: Fix force mono channel count
I unintentionally made it use obs_source::sample_info instead of using
the actual target channel count, which is designated by the OBS output
sampler info.  obs_source::sample_info is actually used to indicate the
currently set sampler information for incoming samples.  So if a source
is outputting 5.1 channel 48khz audio, and OBS is running at stereo
44.1khz, then the obs_source::sample_info value would be set to
5.1/48khz, not the other way around.  It indicates what the source
itself is running at, not what OBS is running at.

I suppose the variable needs a better name because even I used it
incorrectly despite actually having been the one who wrote it.
2014-12-28 03:51:06 -08:00
jp9000 ce6a1146cc libobs: Remove inline on a function
The copy_audio_data function really shouldn't be inlined because it's
being called twice.  It's somewhat unnecessary, I think I left it inline
by accident.
2014-12-28 01:51:55 -08:00
jp9000 63c43b649d libobs: Add flag to force source audio to mono
This flag is actually useful under a number of circumstances, and has
been requested a number of times.
2014-12-28 01:51:55 -08:00
jp9000 c431ac6aa5 libobs: Refactor source volume transition design
This changes the way source volume handles transitioning between being
active and inactive states.

The previous way that transitioning handled volume was that it set the
presentation volume of the source and all of its sub-sources to 0.0 if
the source was inactive, and 1.0 if active.  Transition sources would
then also set the presentation volume for sub-sources to whatever their
transitioning volume was.  However, the problem with this is that the
design didn't take in to account if the source or its sub-sources were
active anywhere else, so because of that it would break if that ever
happened, and I didn't realize that when I was designing it.

So instead, this completely overhauls the design of handling
transitioning volume.  Each frame, it'll go through all sources and
check whether they're active or inactive and set the base volume
accordingly.  If transitions are currently active, it will actually walk
the active source tree and check whether the source is in a
transitioning state somewhere.

 - If the source is a sub-source of a transition, and it's not active
   outside of the transition, then the transition will control the
   volume of the source.

 - If the source is a sub-source of a transition, but it's also active
   outside of the transition, it'll defer to whichever is louder.

This also adds a new callback to the obs_source_info structure for
transition sources, get_transition_volume, which is called to get the
transitioning volume of a sub-source.
2014-12-28 01:51:43 -08:00
jp9000 10f8988667 libobs: Keep transition reference counter
The reason to keep a reference counter for transitions is due to an
optimization I'm planning on when calculating transition volumes.  I'm
planning on walking the source tree to be able to calculate the current
base volume of a source, but *only* if there are transitions active,
because the only time that the volume can be anything other than 1.0
or 0.0 is when there are active transitions, which may change the base
volume of a source.
2014-12-28 01:04:29 -08:00
jp9000 6eab6ceff5 (API Change) libobs: Add _FLAG to source flags
Changes OBS_SOURCE_UNBUFFERED to OBS_SOURCE_FLAG_UNBUFFERED to make
naming a bit better for source flags.
2014-12-28 01:04:28 -08:00
jp9000 48210d41a6 libobs: Do not set presentation volume on children
When the presentation volume is set for a source, it's set for all of
its children and their children.  The original intention for doing this
was to be able to use it for transitioning, but honestly it's just bad
design, and I feel there are better ways to handle transitioning volume.
2014-12-28 01:04:27 -08:00
jp9000 fb6f8721e2 libobs: Add 'audio_sync' source signal
Adds a signal is called when the sync offset has changed for a source.
2014-12-28 01:04:27 -08:00
jp9000 e29a1fd367 libobs: Prevent infinite source recursion
Changed the design from using obs_source::enum_refs to just simply
preventing infinite source recursion in general, rather than allowing it
through the enum_refs variable.  obs_source_add_child has been changed
so that it now returns a boolean, and if the function fails, it means
that the child cannot be added due to that potential recursion.
2014-12-28 01:04:26 -08:00
jp9000 5875434afa libobs: Implement obs_source_active
..Apparently I left this function unimplemented.  This function just
returns whether a source is currently active or not.
2014-12-24 15:55:38 -08:00
Jim 9f3ab85d2b Merge pull request #311 from fryshorts/audio-analyzer-move
libobs: Move audio level calculations
2014-12-21 11:56:02 -08:00
jp9000 817a724dea libobs: Add NV12_Reverse shader 2014-12-21 10:14:18 -08:00
fryshorts 73883e6fa8 libobs: Remove volume level signal from obs_source
Remove the calculation of volume levels and the corresponding signal
from obs_source since this is now handled in the volume meter.
Code that is interested in the volume levels can either use the
volmeter provided from obs_audio_controls or use the audio_data signal
to gain access to the raw audio data.
2014-12-14 18:39:54 +01:00
fryshorts 984dd53389 libobs: Add data signal to audio sources
This adds a new signal to (audio) sources which is emitted whenever new
audio data is received from the source. This enables other code that is
interested in the raw audio data to directly access it when it becomes
available.
2014-12-13 14:10:45 +01:00
fryshorts 014a333807 obs/libobs: Use new volume meter api
This replaces the old code for the audio meter that was using
calculations in two different places with the new audio meter api.
The source signal will now emit simple levels instead of dB values,
in order to avoid dB conversion and calculation in the source.
The GUI on the other hand now expects simple position values from
the volume meter api with no knowledge about dB calculus either.
That way all code that handles those conversions is in one place,
with the option to easily add new mappings that can be used
everywhere.
2014-12-04 21:58:35 +01:00
jp9000 c8dfce886b libobs: Fix warnings assigning values to vec3
Because a vec3 structure can contain a __m128 variable and not the
expected three floats x, y, and z, you must use vec3_set when
setting a value for a vec3 structure to ensure that it uses the proper
intrinsics internally if necessary.
2014-11-27 00:07:49 -08:00
jp9000 cdf36cf8ba Add helper functions for drawing sources
If you look at the previous commits, you'll see I had added
obs_source_draw before.  For custom drawn sources in particular, each
time obs_source_draw was called, it would restart the effect and its
passes for each draw call, which was not optimal.  It should really use
the effect functions for that.  I'll have to add a function to simplify
effect usage.

I also realized that including the color matrix parameters in
obs_source_draw made the function kind of messy to use; instead,
separating the color matrix stuff out to
obs_source_draw_set_color_matrix feels a lot more clean.

On top of that, having the ability to set the position would be nice to
have as well, rather than having to mess with the matrix stuff each
time, so I also added that for the sake of convenience.

obs_source_draw will draw a texture sprite, optionally of a specific
size and/or at a specific position, as well as optionally inverted.  The
texture used will be set to the 'image' parameter of whatever effect is
currently active.

obs_source_draw_set_color_matrix will set the color matrix value if the
drawing requires color matrices.  It will set the 'color_matrix',
'color_range_min', and 'color_range_max' parameters of whatever effect
is currently active.

Overall, these feel much more clean to use than the previous iteration.
2014-11-19 19:08:39 -08:00
jp9000 ed2d9936a5 Revert "Add obs_source_draw helper function"
This reverts commit ab5a76901b.
2014-11-19 18:04:38 -08:00
Jim b3312a7657 Merge pull request #300 from fryshorts/audio-perf
libobs: Replace fmaxf with inline comparison.
2014-11-17 10:27:38 -08:00
jp9000 ab5a76901b Add obs_source_draw helper function
This function simplifies drawing textures for sources in order to help
reduce boilerplate code.  If a source is a custom drawn source, it will
automatically set up the effect to draw the sprite.  If it's not a
custom drawn source, it will simply draw the sprite as per normal.  If
the source uses a specific color matrix, it will also handle that as
well.
2014-11-17 06:47:47 -08:00
fryshorts ab0c2cf431 libobs: Replace fmaxf with inline comparison.
This replaces the call to fmaxf with the equivalent inline comparison
which is a bit faster (at least on linux).
2014-11-16 22:07:37 +01:00
jp9000 015bc80edb Add optional source flags
This moves the 'flags' variable from the obs_source_frame structure to
the obs_source structure, and allows user flags to be set for a specific
source.  Having it set on the obs_source_frame structure didn't make
much sense.

OBS_SOURCE_UNBUFFERED makes it so that the source does not buffer its
async video output in order to try to play it on time.  In other words,
frames are played as soon as possible after being received.

Useful when you want a source to play back as quickly as possible
(webcams, certain types of capture devices)
2014-10-23 11:38:51 -07:00
jp9000 db81c59b5e Revert "Add flag to obs_source_frame for unbuffered video"
This reverts commit c3f4b0f018.

The obs_source_frame should not need to take flags to do this.  This
shouldn't be a setting associated with the frame, but rather a setting
associated with the source itself.  This was the wrong approach to
solving this particular problem.
2014-10-23 10:15:26 -07:00
jp9000 381afe0493 Detect audio time values within OS time thresh.
If audio timestamps are within the operating system timing threshold,
always use those values directly as a timestamp, and do not apply the
regular jump checks and timing adjustments that normally occur.

This potentially fixes an issue with plugins that use OS timestamps
directly as timestamp values for their audio samples, and bypasses the
timing conversions to system time for the audio line and uses it
directly as the timestamp value.  It prevents those calculations from
potentially affecting the audio timestamp value when OS timestamps are
used.

For example, if the first set of audio samples from the audio source
came in delayed, while the subsequent samples were not delayed, those
first samples could have potentially inadvertently triggered the timing
adjustments, which would affect all subsequent audio samples.
2014-10-22 20:32:48 -07:00
jp9000 1c40ce6332 Use MAX_TS_VAR for timestamp jump detection
This combines the 'direct' timestamp variance threshold with the maximum
timestamp jump threshold (or rather just removes the max timestamp jump
threshold and uses the timestamp variance threshold for both timestamp
jumps and detecting timestamps).

The reason why this was done was because a timestamp jump could occur at
a higher threshold than the threshold used for detecting OS timestamps
within a certain threshold.  If timestamps got between those two
thresholds it kind of became a weird situation where timestamps could be
sort of 'stuck' back or forward in time more than intended.  Better to
be consistent and use the same threshold for both values.
2014-10-22 20:32:47 -07:00
jp9000 c3f4b0f018 Add flag to obs_source_frame for unbuffered video
Add 'flags' member variable to obs_source_frame structure.

The OBS_VIDEO_UNBUFFERED flags causes the video to play back as soon as
it's received (in the next frame playback), causing it to disregard the
timestamp value for the sake of video playback (however, note that the
video timestamp is still used for audio synchronization if audio is
present on the source as well).

This is partly a convenience feature, and partly a necessity for certain
plugins (such as the linux v4l plugin) where timestamp information for
the video frames can sometimes be unreliable.
2014-10-22 20:32:47 -07:00
jp9000 2c3f9c47d1 Fix a typo ('timetamp') 2014-10-22 20:32:46 -07:00
fryshorts 5894054521 Fix small bug in timestamp smoothing for audio sources
Due to a small error in the timestamp smoothing code the timestamp of
audio packages that were too early was always set to the next expected
timestamp, even if the difference was bigger than the smoothing threshold.

This would cause obs to simply append all audio data to the buffer even if
the real timestamp was way smaller than the next that was expected.

This should reduce corruption problems with for example the pulseaudio
plugin, which resends data under certain conditions.
2014-10-09 22:25:29 +02:00
Palana b99c378e33 Add 'update_properties' signal and obs_source_update_properties call
obs_source_update_properties should be called by sources when property
values change, e.g. a capture device source would use this when it
detects a new capture device (in case its properties contain a list of
available capture devices or similar)
2014-10-01 15:39:57 +02:00
Palana 94a93abb2b (API Change) Pass data to get_properties when possible 2014-10-01 15:39:57 +02:00
jp9000 41fad2d1a4 (API Change) Use const params where applicable
This Fixes a minor flaw with the API where data had to always be mutable
to be usable by the API.

Functions that do not modify the fundamental underlying data of a
structure should be marked as constant, both for safety and to signify
that the parameter is input only and will not be modified by the
function using it.
2014-09-26 17:23:07 -07:00
jp9000 c9df41c1e2 (API Change) Remove pointers from all typedefs
Typedef pointers are unsafe.  If you do:
typedef struct bla *bla_t;
then you cannot use it as a constant, such as: const bla_t, because
that constant will be to the pointer itself rather than to the
underlying data.  I admit this was a fundamental mistake that must
be corrected.

All typedefs that were pointer types will now have their pointers
removed from the type itself, and the pointers will be used when they
are actually used as variables/parameters/returns instead.

This does not break ABI though, which is pretty nice.
2014-09-25 21:48:11 -07:00
jp9000 732d24caa1 Remove unused variables 2014-09-19 18:46:25 -07:00
kc5nra 26cf4688c2 Add interaction support to libobs 2014-09-15 17:19:37 -05:00
jp9000 11b0fe122c Improve async source render timing
This helps ensure that an asynchronous video source is played as close
to its framerate as possible, reduces the risk of duplication as
much as possible, and helps to ensure that playback is as smooth as
possible.
2014-09-12 20:36:31 -07:00
jp9000 52e08249f1 Only render async frames to texture once per frame
This prevents multiple needless calls to obs_source_get_frame and other
functions.  If the texture has already been processed, then just render
it as-is in any subsequent calls to obs_source_video_render.
2014-09-12 20:36:31 -07:00
jp9000 5defc67991 Remove audio/video sync reference counter
This is actually unnecessary now that there's a hard limit on the
maximum offset in which audio can be inserted.

This also assumes too much about the audio; it assumes audio is always
on, where as with some devices (such as the elgato) audio is not on
until the stream starts, and when the video has already incremented the
counter.
2014-09-04 14:01:46 -07:00
jp9000 355d5dab6e Move timestamp smooth threshold to media-io 2014-08-30 11:51:37 -07:00
jp9000 47570f4153 Fix bug with source audio
If the audio didn't start at the 0 timestamp, it would misinterpret it
as a timestamp jump because obs_source::next_audio_ts_min is set to 0 on
creation.  Timestamp starting values should be allowed to start at any
arbitrary value.
2014-08-28 18:34:36 -07:00
jp9000 5780f3f177 (API Change) Improve graphics API consistency
Summary:
- Prefix all graphics subsystem names with gs_ or GS_
- Unsquish funciton names (for example _setfloat to _set_float)
- Changed create functions to be more consistent with the rest of the
  API elsewhere.  For exmaple, instead of
  gs_create_texture/gs_texture_destroy, it's now
  gs_texture_create/gs_texture_destroy
- Renamed gs_stencil_op enum to gs_stencil_op_type

From:                            To:
-----------------------------------------------------------
tvertarray                       gs_tvertarray
vb_data                          gs_vb_data
vbdata_create                    gs_vbdata_create
vbdata_destroy                   gs_vbdata_destroy
shader_param                     gs_shader_param
gs_effect                        gs_effect
effect_technique                 gs_effect_technique
effect_pass                      gs_effect_pass
effect_param                     gs_effect_param
texture_t                        gs_texture_t
stagesurf_t                      gs_stagesurf_t
zstencil_t                       gs_zstencil_t
vertbuffer_t                     gs_vertbuffer_t
indexbuffer_t                    gs_indexbuffer_t
samplerstate_t                   gs_samplerstate_t
swapchain_t                      gs_swapchain_t
texrender_t                      gs_texrender_t
shader_t                         gs_shader_t
sparam_t                         gs_sparam_t
effect_t                         gs_effect_t
technique_t                      gs_technique_t
eparam_t                         gs_eparam_t
device_t                         gs_device_t
graphics_t                       graphics_t
shader_param_type                gs_shader_param_type
SHADER_PARAM_UNKNOWN             GS_SHADER_PARAM_UNKNOWN
SHADER_PARAM_BOOL                GS_SHADER_PARAM_BOOL
SHADER_PARAM_FLOAT               GS_SHADER_PARAM_FLOAT
SHADER_PARAM_INT                 GS_SHADER_PARAM_INT
SHADER_PARAM_STRING              GS_SHADER_PARAM_STRING
SHADER_PARAM_VEC2                GS_SHADER_PARAM_VEC2
SHADER_PARAM_VEC3                GS_SHADER_PARAM_VEC3
SHADER_PARAM_VEC4                GS_SHADER_PARAM_VEC4
SHADER_PARAM_MATRIX4X4           GS_SHADER_PARAM_MATRIX4X4
SHADER_PARAM_TEXTURE             GS_SHADER_PARAM_TEXTURE
shader_param_info                gs_shader_param_info
shader_type                      gs_shader_type
SHADER_VERTEX                    GS_SHADER_VERTEX
SHADER_PIXEL                     GS_SHADER_PIXEL
shader_destroy                   gs_shader_destroy
shader_numparams                 gs_shader_get_num_params
shader_getparambyidx             gs_shader_get_param_by_idx
shader_getparambyname            gs_shader_get_param_by_name
shader_getviewprojmatrix         gs_shader_get_viewproj_matrix
shader_getworldmatrix            gs_shader_get_world_matrix
shader_getparaminfo              gs_shader_get_param_info
shader_setbool                   gs_shader_set_bool
shader_setfloat                  gs_shader_set_float
shader_setint                    gs_shader_set_int
shader_setmatrix3                gs_shader_setmatrix3
shader_setmatrix4                gs_shader_set_matrix4
shader_setvec2                   gs_shader_set_vec2
shader_setvec3                   gs_shader_set_vec3
shader_setvec4                   gs_shader_set_vec4
shader_settexture                gs_shader_set_texture
shader_setval                    gs_shader_set_val
shader_setdefault                gs_shader_set_default
effect_property_type             gs_effect_property_type
EFFECT_NONE                      GS_EFFECT_NONE
EFFECT_BOOL                      GS_EFFECT_BOOL
EFFECT_FLOAT                     GS_EFFECT_FLOAT
EFFECT_COLOR                     GS_EFFECT_COLOR
EFFECT_TEXTURE                   GS_EFFECT_TEXTURE
effect_param_info                gs_effect_param_info
effect_destroy                   gs_effect_destroy
effect_gettechnique              gs_effect_get_technique
technique_begin                  gs_technique_begin
technique_end                    gs_technique_end
technique_beginpass              gs_technique_begin_pass
technique_beginpassbyname        gs_technique_begin_pass_by_name
technique_endpass                gs_technique_end_pass
effect_numparams                 gs_effect_get_num_params
effect_getparambyidx             gs_effect_get_param_by_idx
effect_getparambyname            gs_effect_get_param_by_name
effect_updateparams              gs_effect_update_params
effect_getviewprojmatrix         gs_effect_get_viewproj_matrix
effect_getworldmatrix            gs_effect_get_world_matrix
effect_getparaminfo              gs_effect_get_param_info
effect_setbool                   gs_effect_set_bool
effect_setfloat                  gs_effect_set_float
effect_setint                    gs_effect_set_int
effect_setmatrix4                gs_effect_set_matrix4
effect_setvec2                   gs_effect_set_vec2
effect_setvec3                   gs_effect_set_vec3
effect_setvec4                   gs_effect_set_vec4
effect_settexture                gs_effect_set_texture
effect_setval                    gs_effect_set_val
effect_setdefault                gs_effect_set_default
texrender_create                 gs_texrender_create
texrender_destroy                gs_texrender_destroy
texrender_begin                  gs_texrender_begin
texrender_end                    gs_texrender_end
texrender_reset                  gs_texrender_reset
texrender_gettexture             gs_texrender_get_texture
GS_BUILDMIPMAPS                  GS_BUILD_MIPMAPS
GS_RENDERTARGET                  GS_RENDER_TARGET
gs_device_name                   gs_get_device_name
gs_device_type                   gs_get_device_type
gs_entercontext                  gs_enter_context
gs_leavecontext                  gs_leave_context
gs_getcontext                    gs_get_context
gs_renderstart                   gs_render_start
gs_renderstop                    gs_render_stop
gs_rendersave                    gs_render_save
gs_getinput                      gs_get_input
gs_geteffect                     gs_get_effect
gs_create_effect_from_file       gs_effect_create_from_file
gs_create_effect                 gs_effect_create
gs_create_vertexshader_from_file gs_vertexshader_create_from_file
gs_create_pixelshader_from_file  gs_pixelshader_create_from_file
gs_create_texture_from_file      gs_texture_create_from_file
gs_resetviewport                 gs_reset_viewport
gs_set2dmode                     gs_set_2d_mode
gs_set3dmode                     gs_set_3d_mode
gs_create_swapchain              gs_swapchain_create
gs_getsize                       gs_get_size
gs_getwidth                      gs_get_width
gs_getheight                     gs_get_height
gs_create_texture                gs_texture_create
gs_create_cubetexture            gs_cubetexture_create
gs_create_volumetexture          gs_voltexture_create
gs_create_zstencil               gs_zstencil_create
gs_create_stagesurface           gs_stagesurface_create
gs_create_samplerstate           gs_samplerstate_create
gs_create_vertexshader           gs_vertexshader_create
gs_create_pixelshader            gs_pixelshader_create
gs_create_vertexbuffer           gs_vertexbuffer_create
gs_create_indexbuffer            gs_indexbuffer_create
gs_gettexturetype                gs_get_texture_type
gs_load_defaultsamplerstate      gs_load_default_samplerstate
gs_getvertexshader               gs_get_vertex_shader
gs_getpixelshader                gs_get_pixel_shader
gs_getrendertarget               gs_get_render_target
gs_getzstenciltarget             gs_get_zstencil_target
gs_setrendertarget               gs_set_render_target
gs_setcuberendertarget           gs_set_cube_render_target
gs_beginscene                    gs_begin_scene
gs_draw                          gs_draw
gs_endscene                      gs_end_scene
gs_setcullmode                   gs_set_cull_mode
gs_getcullmode                   gs_get_cull_mode
gs_enable_depthtest              gs_enable_depth_test
gs_enable_stenciltest            gs_enable_stencil_test
gs_enable_stencilwrite           gs_enable_stencil_write
gs_blendfunction                 gs_blend_function
gs_depthfunction                 gs_depth_function
gs_stencilfunction               gs_stencil_function
gs_stencilop                     gs_stencil_op
gs_setviewport                   gs_set_viewport
gs_getviewport                   gs_get_viewport
gs_setscissorrect                gs_set_scissor_rect
gs_create_texture_from_iosurface gs_texture_create_from_iosurface
gs_create_gdi_texture            gs_texture_create_gdi
gs_is_compressed_format          gs_is_compressed_format
gs_num_total_levels              gs_get_total_levels
texture_setimage                 gs_texture_set_image
cubetexture_setimage             gs_cubetexture_set_image
swapchain_destroy                gs_swapchain_destroy
texture_destroy                  gs_texture_destroy
texture_getwidth                 gs_texture_get_width
texture_getheight                gs_texture_get_height
texture_getcolorformat           gs_texture_get_color_format
texture_map                      gs_texture_map
texture_unmap                    gs_texture_unmap
texture_isrect                   gs_texture_is_rect
texture_getobj                   gs_texture_get_obj
cubetexture_destroy              gs_cubetexture_destroy
cubetexture_getsize              gs_cubetexture_get_size
cubetexture_getcolorformat       gs_cubetexture_get_color_format
volumetexture_destroy            gs_voltexture_destroy
volumetexture_getwidth           gs_voltexture_get_width
volumetexture_getheight          gs_voltexture_get_height
volumetexture_getdepth           gs_voltexture_getdepth
volumetexture_getcolorformat     gs_voltexture_get_color_format
stagesurface_destroy             gs_stagesurface_destroy
stagesurface_getwidth            gs_stagesurface_get_width
stagesurface_getheight           gs_stagesurface_get_height
stagesurface_getcolorformat      gs_stagesurface_get_color_format
stagesurface_map                 gs_stagesurface_map
stagesurface_unmap               gs_stagesurface_unmap
zstencil_destroy                 gs_zstencil_destroy
samplerstate_destroy             gs_samplerstate_destroy
vertexbuffer_destroy             gs_vertexbuffer_destroy
vertexbuffer_flush               gs_vertexbuffer_flush
vertexbuffer_getdata             gs_vertexbuffer_get_data
indexbuffer_destroy              gs_indexbuffer_destroy
indexbuffer_flush                gs_indexbuffer_flush
indexbuffer_getdata              gs_indexbuffer_get_data
indexbuffer_numindices           gs_indexbuffer_get_num_indices
indexbuffer_gettype              gs_indexbuffer_get_type
texture_rebind_iosurface         gs_texture_rebind_iosurface
texture_get_dc                   gs_texture_get_dc
texture_release_dc               gs_texture_release_dc
2014-08-09 11:57:38 -07:00
jp9000 50ec8b0d55 (API Change) libobs/callback: Unsquish names
Renamed:                  To:
-------------------------------------------------
calldata_getdata          calldata_get_data
calldata_getint           calldata_get_int
calldata_getfloat         calldata_get_float
calldata_getbool          calldata_get_bool
calldata_getptr           calldata_get_ptr
calldata_getstring        calldata_get_string
calldata_setdata          calldata_set_data
calldata_setint           calldata_set_int
calldata_setfloat         calldata_set_float
calldata_setbool          calldata_set_bool
calldata_setptr           calldata_set_ptr
calldata_setstring        calldata_set_string
2014-08-09 11:57:38 -07:00
jp9000 42a0925ce1 (API Change) media-io: Improve naming consistency
Renamed:                        To:
-----------------------------------------------------------
audio_output_blocksize          audio_output_get_block_size
audio_output_planes             audio_output_get_planes
audio_output_channels           audio_output_get_channels
audio_output_samplerate         audio_output_get_sample_rate
audio_output_getinfo            audio_output_get_info
audio_output_createline         audio_output_create_line
video_output_getinfo            video_output_get_info
video_gettime                   video_output_get_time
video_getframetime              video_output_get_frame_time
video_output_width              video_output_get_width
video_output_height             video_output_get_height
video_output_framerate          video_output_get_frame_rate
video_output_num_skipped_frames video_output_get_skipped_frames
video_output_total_frames       video_output_get_total_frames
2014-08-09 11:57:37 -07:00
jp9000 2d606dd8d8 (API Change) Use 'get' convention: API callbacks
Renamed:                       To:
-------------------------------------------------------
obs_source_info::defaults       obs_source_info::get_defaults
obs_source_info::properties     obs_source_info::get_properties
obs_output_info::defaults       obs_output_info::get_defaults
obs_output_info::properties     obs_output_info::get_properties
obs_output_info::total_bytes    obs_output_info::get_total_bytes
obs_output_info::dropped_frames obs_output_info::get_dropped_frames
obs_encoder_info::defaults      obs_encoder_info::get_defaults
obs_encoder_info::properties    obs_encoder_info::get_properties
obs_encoder_info::extra_data    obs_encoder_info::get_extra_data
obs_encoder_info::sei_data      obs_encoder_info::get_sei_data
obs_encoder_info::audio_info    obs_encoder_info::get_audio_info
obs_encoder_info::video_info    obs_encoder_info::get_video_fino
obs_service_info::defaults      obs_service_info::get_defaults
obs_service_info::properties    obs_service_info::get_properties
2014-08-09 11:57:30 -07:00
jp9000 c83d05117f (API Change) Unsquish libobs API callback names
Renamed:                    To:
-------------------------------------------------------
obs_source_info::getname    obs_source_info::get_name
obs_source_info::getwidth   obs_source_info::get_width
obs_source_info::getheight  obs_source_info::get_height
obs_output_info::getname    obs_output_info::get_name
obs_encoder_info::getname   obs_encoder_info::get_name
obs_service_info::getname   obs_service_info::get_name
2014-08-08 11:04:46 -07:00
jp9000 a3682fc8fb (API Change) Use 'get' convention in libobs (base)
Instead of having functions like obs_signal_handler() that can fail to
properly specify their actual intent in the name (does it signal a
handler, or does it return a signal handler?), always prefix functions
that are meant to get information with 'get' to make its functionality
more explicit.

Previous names:             New names:
-----------------------------------------------------------
obs_audio                   obs_get_audio
obs_video                   obs_get_video
obs_signalhandler           obs_get_signal_handler
obs_prochandler             obs_get_proc_handler
obs_source_signalhandler    obs_source_get_signal_handler
obs_source_prochandler      obs_source_get_proc_handler
obs_output_signalhandler    obs_output_get_signal_handler
obs_output_prochandler      obs_output_get_proc_handler
obs_service_signalhandler   obs_service_get_signal_handler
obs_service_prochandler     obs_service_get_proc_handler
2014-08-08 11:04:46 -07:00
jp9000 73baaa59e9 (API Change) Unsquish libobs (base) names
Previous names:             New names:
-----------------------------------------------------------
obs_view_setsource          obs_view_set_source
obs_view_getsource          obs_view_get_source
obs_source_getdisplayname   obs_source_get_display_name
obs_source_getwidth         obs_source_get_width
obs_source_getheight        obs_source_get_height
obs_filter_getparent        obs_filter_get_parent
obs_filter_gettarget        obs_filter_get_target
obs_source_filter_setorder  obs_source_filter_set_order
obs_source_getsettings      obs_source_get_settings
obs_source_getname          obs_source_get_name
obs_source_setname          obs_source_set_name
obs_source_setvolume        obs_source_set_volume
obs_source_getvolume        obs_source_get_volume
obs_scene_getsource         obs_scene_get_source
obs_scene_fromsource        obs_scene_from_source
obs_scene_findsource        obs_scene_find_source
obs_output_getdisplayname   obs_output_get_display_name
obs_output_getname          obs_output_get_name
obs_encoder_getname         obs_encoder_get_name
obs_service_getdisplayname  obs_service_get_display_name
obs_service_getname         obs_service_get_name
2014-08-08 11:04:46 -07:00
jp9000 e42af67128 (API Change) Split obs_source_gettype
Changed:
- obs_source_gettype
To:
- enum obs_source_type obs_source_get_type(obs_source_t source);
- const char *obs_source_get_id(obs_source_t source);

This function was inconsistent for a number of reasons.  First, it
returns both the ID and the type of source (input/transition/filter),
which is inconsistent with the name of "get type".  Secondly, the
'squishy' naming convention which has just turned out to be bad
practice and causes inconsistencies.  So it's now replaced with two
functions that just return the type and the ID.
2014-08-08 11:04:44 -07:00
jp9000 0961af6e66 (API Change) Rename source_audio structure
Rename source_audio to obs_source_audio to make it more consistent with
the rest of the API
2014-08-08 11:04:44 -07:00
jp9000 45eec06891 (API Change) Rename filtered_audio structure
Reanmed filtered_audio to obs_audio_data, to improve the naming and
prefix with obs_ for the sake with consistency with the rest of the API
2014-08-08 11:04:44 -07:00
jp9000 4d1272e6e2 (API Change) Rename allow_direct_render enum
For the sake of consistency, changed allow_direct_render to
obs_allow_direct_render
2014-08-08 11:04:43 -07:00
jp9000 d2b4f82637 (API Change) Rename order_movement
Prefix with obs_ for the sake of consistency

Renamed enums:
- order_movement (now obs_order_movement)

Affected functions:
- obs_source_filter_setorder
- obs_sceneitem_setorder
2014-08-08 11:04:43 -07:00
jp9000 4122a5b9b5 (API Change) Rename 'source_frame' + related
For the sake of naming consistency with the rest of obs.h, prefix this
structure and associated functions with obs_.

Renamed structures:
- struct source_frame (now obs_source_frame)

Renamed functions:
- source_frame_init (now obs_source_frame_init)
- source_frame_free (now obs_source_frame_free)
- source_frame_create (now obs_source_frame_create)
- source_frame_destroy (now obs_source_frame_destroy)

Affected functions:
- obs_source_output_video
- obs_source_get_frame
- obs_source_release_frame
2014-08-08 11:04:42 -07:00
jp9000 7b402245dc (API Change) Rename obs_source_get(/release)frame
Renamed functions:
- obs_source_getframe (rename to obs_source_get_frame)
- obs_source_releaseframe (rename to obs_source_release_frame)

For the sake of consistency and helping to get rid of the "squishy
function name" issue
2014-08-08 11:04:42 -07:00
Palana 1abde3d476 Preserve source data for sources with unknown source ids 2014-07-29 20:06:36 +02:00
Palana e123c9c062 Clarify source creation error message 2014-07-29 17:11:49 +02:00
jp9000 53aa0a60d5 Check for duplicate sources/outputs/encoders/etc
With the recent change to module handling by BtbN, I felt that having
this information might be useful in case someone is actually using make
install to set up their libraries.
2014-07-28 16:15:09 -07:00
HomeWorld 6b284d9e58 Fix audio meters so that volume is applied linearly. 2014-07-14 21:12:53 +03:00
HomeWorld 336c3821fc Corrected a math mistake in obs_source.c calc_volume_levels. 2014-07-14 19:24:04 +03:00
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