Commit Graph

1282 Commits (f8fd87bbf613cec2eea8863819e744ecbb429490)

Author SHA1 Message Date
jp9000 da2f9f732e libobs: Do not require get_width/height for filters/transitions 2016-01-26 11:49:43 -08:00
jp9000 03df6b2ceb libobs: Warn/ignore if transitions use get_width/get_height
These functions aren't used with transition sources, and will be
ignored.
2016-01-26 11:49:43 -08:00
jp9000 c28cfa556b libobs: Mark transitions as video/custom draw 2016-01-26 11:49:42 -08:00
jp9000 2a4ac3dc21 libobs: Improve module register warnings
Fixes some typos and specifies the function that's being called
2016-01-26 11:49:42 -08:00
jp9000 234cb5802f libobs: Release scene items outside of scene mutexes
Prevents a mutual lock with the scene mutex and graphics mutex.  In
libobs/obs-video.c, the graphics mutex could be locked first, then the
scene mutexes second, while in the UI thread, the scene mutexes could be
locked first, then when a scene item is being destroyed, a source could
be destroyed, and sometimes sources would lock the graphics mutex
second.

A possible additional solution is to defer source destroys to the video
thread.
2016-01-26 11:49:41 -08:00
jp9000 ed10b1ab57 libobs: Allow add_alignment to be used by other source files 2016-01-26 11:49:40 -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 6f053b89bd libobs: Mark transition sources as composite
Transition sources are always considered composite sources, as they have
child sources.
2016-01-26 11:49:39 -08:00
jp9000 84251055fa libobs: Add function to enumerate all source types 2016-01-26 11:49:38 -08:00
jp9000 e68331e988 libobs: Add source type OBS_SOURCE_TYPE_SCENE
Helps identify a scene without having to compare its type name to
"scene".
2016-01-26 11:49:38 -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 20db7649aa libobs/media-io: Reset audio array for each input
The audio data would get overwritten and become invalid if there was
more than one input
2016-01-26 11:49:36 -08:00
jp9000 3c68196c5c libobs: Buffer scene item visibility actions
This buffers scene item visibility actions so that if
obs_sceneitem_set_visible to true or false, that it will ensure that the
action is mapped to the exact sample point time in which
obs_sceneitem_set_visible is called.  Mapping to the exact sample point
isn't necessary, but it's a nice thing to have.
2016-01-26 11:49:36 -08:00
jp9000 247a42c2a1 libobs: Make scenes mix audio of sub-sources
Mark scenes as composite sources and use audio_render to mix and output
the audio of their sub-sources.
2016-01-26 11:49:35 -08:00
jp9000 40d6f986e6 libobs: Split scene mutex to improve performance
Splits the scene mutex in to an audio/video mutex to allow video/audio
thread to use the same data at the same time without locking on each
other.
2016-01-26 11:49:34 -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 ee1842d1f5 libobs/media-io: Remove audio lines (skip)
(Note: This commit breaks libobs compilation.  Skip if bisecting)

Uses a callback and allows the caller to mix audio.  Additionally,
allows the callback to return audio later, allowing it to buffer as much
as it needs.
2016-01-26 11:49:28 -08:00
jp9000 726163aa29 libobs: Report lost frame count due to rendering lag
This has been missing for a bit too long, and should make it
easier/faster to diagnose issues users might be having.
2016-01-25 17:29:09 -08:00
jp9000 23f4d17d41 libobs/media-io: Fix bug (skipped frames including lagged frames)
The skipped frame count (dropped frames due to encoding being
overloaded) would erroneously include lagged frames (dropped frames due
to render stalls).  This will make diagnosing actual issues a user might
be having a bit easier.
2016-01-25 17:29:09 -08:00
jp9000 65eb3c0815 libobs: Fix potential output audio/video sync bug
Problem:

When an output is started with encoders that have already been started
by another output, and it starts in between the window in between where
the first audio packets start coming in and where the first video packet
comes in, the output would get audio packets with timestamps potentially
much later than the first video frame when the first video frame finally
comes in.  The audio/video encoders will almost always have a differing
delay.

Solution:

Detect that starting window, and if within that starting window, wait
for a new keyframe from video instead of trying to sync up video.

Additional Notes:

In these cases where an output starts with already-active encoders, this
patch also reduces the potential sync offset between the first video
frame and the first audio frame.  Before, it would sync the first video
frame with the first audio frames right after that, but now it syncs
with the closest audio frame in the interleaved array, which halves the
potential sync difference between the first video frame and the first
audio frame of already-active encoders.  (So now the potential sync
difference is roughly 11.6 milliseconds at 44.1khz audio, where it was
23.2 before)
2016-01-25 17:29:09 -08:00
jp9000 c4657da2f1 libobs: Subtract packet dts_usec with first packet offset
Ensures that the packet dts_usec vals which are generated for
syncing/interleaving use the proper offset relative to where they're
supposed to be starting from.  The negative DTS of a first video packet
could potentially have been applied twice due to this.
2016-01-25 17:29:09 -08:00
jp9000 346ddd502f libobs: Fix potential race condition
Fixes potential race conditions when two threads are trying to
initialize/start/stop the same encoders at the same time.
2016-01-25 17:29:09 -08:00
jp9000 92bbb8e8b1 libobs/callback: Allow ability to use calldata_t with stack
Allows the ability to use fixed stack memory to construct a calldata_t
structure rather than having to allocate each time.  This is fine to do
for certain signals where the calldata never goes above a specific size.
If by some chance the size is insufficient, it will output a log
message.
2016-01-25 17:29:08 -08:00
jp9000 9c5f95d823 libobs: Add function to get current video time (in nanosec)
Allows getting the timestamp for the video frame currently being
rendered.
2016-01-25 17:29:08 -08:00
jp9000 13890a46e6 libobs/graphics: Add gs_image_file_* functions (w/animated gifs)
These functions allow animated gifs and management of image files.  Uses
libnsgif to load animated gifs.
2016-01-25 17:29:08 -08:00
jp9000 9f63554e69 libobs: Add gs_create_texture_file_data function
Allows loading the file to memory first so the graphics subsystem
doesn't necessarily have to be locked when loading image files.
2016-01-23 07:17:48 -08:00
jp9000 b0ca6eaf50 libobs: Make obs_source_save and obs_source_load internal
There shouldn't be any need to call these functions manually.  These
functions are called automatically by obs_save_sources and
obs_load_sources.
2016-01-23 07:17:47 -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 bdd7577a1a libobs: Always have a transparent blank texture available
Allows transitions to be able to return a blank texture to transitions
if a transition is transitioning from/to a NULL source.
2016-01-23 07:17:46 -08:00
jp9000 46feac7f8f libobs/graphics: Allow gs_render_sprite use without texture
Allows gs_render_sprite to be used without a texture as long as cx/cy
are set.  There's no reason why it shouldn't be able to do this.
2016-01-23 07:17:45 -08:00
jp9000 38f368aa80 libobs/util: Make all atomic funcs inline and use intrinsics
Needless function calls here for what should be intrinsic calls
2016-01-23 07:17:44 -08:00
jp9000 ac63bd819c libobs: Move windows headers to WIN32 section in cmake file
These were in the APPLE section by mistake
2016-01-23 07:17:43 -08:00
jp9000 4543cd168d libobs/util: Add long load/store atomic funcs 2015-12-28 05:49:55 -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 fc057f6d88 libobs/media-io: Add funcs to convert between nanoseconds/frames
Uses 128bit integer math to prevent overflow
2015-12-22 06:18:18 -08:00
jp9000 9f9a4bc3f3 libobs/util: Add uint128 structure/functions
Allows some limited 128bit integer math functions, primarily for the
sake of performing calculations on nanosecond-based intervals of time
2015-12-22 06:18:17 -08:00
jp9000 7a81d3d6d7 libobs/util: Add circlebuf pop_back/peek_back functions 2015-12-22 06:18:16 -08:00
jp9000 c2168cf9e8 libobs/util: Don't perform calculation until data checked 2015-12-22 06:18:15 -08:00
jp9000 c6914fda45 libobs/util: Add circlebuf_push_front function 2015-12-22 06:18:14 -08:00
jp9000 5be855e852 libobs: Make scene item visibility activate/deactivate
Before if a source was set to invisible it would still be considered
active.  This changes it so that the source is deactivated when the
source is invisible to reduce needless resource usage or capturing.
2015-12-22 05:49:03 -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
Palana 684b43ccfa libobs: Move previously ineffective NULL checks 2015-12-22 05:49:02 -08:00
Palana ec86bdaa09 libobs: Add obs_save_sources_filtered (skip)
(Note: This commit breaks UI compilation.  Skip if bisecting)

Adds a means of saving specific sources that the front-end chooses,
rather than being forced to use the now-removed "user list".
2015-12-22 05:48:59 -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 d1f225e2e8 libobs/callback: Set default return values to 0/NULL
These functions created stack variables but never actually initialized
them.  If the calldata variable is invalid, the return values will be
the uninitialized stack value.
2015-12-15 01:11:10 -08:00
jp9000 091706920f libobs/util: Use malloc/free for temp darray allocations 2015-12-15 01:11:09 -08:00
jp9000 69ab209fdd libobs/util: Use correct dereferenced size with da_swap 2015-12-15 01:11:09 -08:00
jp9000 19969a27d5 libobs: Remove TODO (not used) 2015-12-15 01:11:08 -08:00
jp9000 e23a20874b libobs/util: Rename da_swap_item to da_swap
The name was inconsistent with the darray_swap function that it's a
macro for.
2015-12-15 01:11:07 -08:00
jp9000 2c8887b582 libobs: Update to version 0.12.4 2015-12-11 17:03:08 -08:00
jp9000 bb1b705cd3 libobs: Put obs_get_default_rect_effect back in temporarily
This function was removed even though the browser plugin was using this
function on mac, so this is being put back in temporarily while the
browser plugin is modified to remove this function.
2015-12-11 16:47:22 -08:00
jp9000 4e55cf1125 libobs/util: Add function deprecation defines 2015-12-11 16:45:31 -08:00
jp9000 725a36bc0f libobs: Update version to 0.12.3 2015-12-04 04:23:31 -08:00
jp9000 c32407d1df libobs/media-io: Increase TS smooth threshold to 70ms
With certain devices (AVerMedia C985 and LGP), audio timestamps are
bad, and a 50ms threshold of audio data "smoothing" (making consecutive
audio packets seamless with one another) isn't enough to handle bad
consecutive timestamp values.  After testing, 70ms sufficiently solves
the issue.
2015-11-28 16:42:32 -08:00
Palana 1cd98ae008 libobs/util: Fix config value line break unescaping
Given a config file with some value "foo=\\n" querying the value of foo
would return {'\\', '\n', 0}, instead of {'\\', 'n', 0}
2015-11-27 15:48:30 +01:00
jp9000 5548e62162 libobs: Update to version 0.12.2 2015-11-20 14:44:17 -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 d1cbb2742e libobs/util: Use SIGTRAP for os_breakpoint
SIGTRAP is the correct value to use to specify a breakpoint.
2015-11-18 18:59:54 -08:00
jp9000 9e17f41caf libobs/util: Don't perform memalign trick of pointer null 2015-11-18 18:46:21 -08:00
jp9000 52d5a9b0b4 libobs/util: Breakpoint crash on "out of memory"
This forces proper crash handling to generate a stack trace.
2015-11-18 12:42:15 -08:00
jp9000 fa5c477826 libobs/util: Add os_breakpoint function 2015-11-18 12:42:15 -08:00
jp9000 c629bbe50f libobs: Always write crashing thread first 2015-11-18 12:42:14 -08:00
jp9000 598ae383bc libobs/util: Add atomic bool load functions 2015-11-18 12:42:14 -08:00
jp9000 14bfa07168 libobs: Fix unsigned expression warning
Fixes warning introduced by d7848f3cb7 that pops up in GCC:

warning: comparison of unsigned expression < 0 is always false
[-Wtype-limits]

The proper solution was to use the 64bit integer values with the clamp,
and then convert to a 32bit unsigned integer.
2015-11-16 08:22:55 -08:00
jp9000 717e2b6e66 libobs: Update version to 0.12.1 2015-11-15 09:49:24 -08:00
jp9000 d7848f3cb7 libobs: Fix "possible loss of data" warning
Fixes the following warning of MSVC:

warning C4244: '=' : conversion from '__int64' to 'uint32_t', possible
loss of data
2015-11-15 09:49:23 -08:00
Palana ad5aec99ff libobs: Fix obs_data crash
Accessing objects inside obs_datas after obs_data_clear was called on the
parent obs_data causes a NULL dereference.

Reproduce with:
	obs_data_t *data = obs_data_create();
	obs_data_set_obj(data, "foo", NULL);
	obs_data_clear(data);
	obs_data_get_obj(data, "foo");
2015-11-14 15:57:21 +01:00
Palana 1b078f57d8 libobs: Add frame rate property 2015-11-14 15:37:59 +01:00
Palana 0b3fcb8b6e libobs: Add obs_data wrappers for media_frames_per_second 2015-11-14 15:37:59 +01:00
Palana 95487c3eec libobs/media-io: Add frame rate helpers 2015-11-14 15:37:47 +01:00
jp9000 1e1f442a61 libobs/util: Remove unnecessary allocations (win32)
Removes unnecessary allocations for the os_event_* and os_sem_*
thread functions
2015-11-11 16:52:48 -08:00
Richard Stanway 94b5bc222b libobs: Rename create_proccess to create_process 2015-11-06 18:25:53 +01:00
Richard Stanway 3671153a4f libobs: Don't use SPI_SETSCREENSAVEACTIVE on Windows
SetThreadExecutionState with ES_DISPLAY_REQUIRED has the same effect of preventing the screensaver from activating. Using SPI_SETSCREENSAVEACTIVE leaves the screensaver disabled system-wide if OBS crashes before it can re-enable it.
2015-11-05 03:58:26 +01:00
jp9000 a914bb24fa libobs/util: Add atomic functions for bool values 2015-11-03 15:03:39 -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 83630fa14a libobs/graphics: Safely fail gs_texrender_begin with 0,0 size
Passing 0,0 texture size should be considered legal, and safely return
false to indicate that rendering can't begin.  Also there's no need to
try to use the current swap chain's width/height if either of the sizes
are 0, there's no need try try to "force" success here anymore.
2015-10-22 17:42:44 -07:00
jp9000 0be0eedc81 libobs/graphics: Allow NULL *_destroy parameters
Passing null pointer values to the destroy functions should be
considered legal and simply ignored.
2015-10-22 17:37:59 -07:00
jp9000 ccfd57d100 libobs/graphics: Rename inconsistent function names
Renames functions:
gs_shader_setmatrix3 -> gs_shader_set_matrix3
gs_voltexture_getdepth -> gs_voltexture_get_depth
2015-10-21 07:46:43 -07:00
jp9000 03d6eab49d libobs: Rename obs_output_canpause
Renames obs_output_canpause to obs_output_can_pause
2015-10-21 07:46:42 -07:00
jp9000 63f7daa61c libobs: Add API to get object ids 2015-10-21 07:46:41 -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 d242004bee libobs/graphics: Add null/context warnings
Adds warnings for graphics functions to ensure that graphics functions
are called within an active graphics context, and add warnings if
required pointer parameters are null.
2015-10-21 07:46:39 -07:00
jp9000 f07ce8501f libobs: Add null debug messages for base obs funcs 2015-10-21 06:30:32 -07:00
jp9000 d3f9cdb8c8 libobs: Use LOG_DEBUG for null pointer checks 2015-10-21 06:30:31 -07:00
jp9000 6861eaabaf libobs: Use macros for obs validity checks 2015-10-21 06:30:30 -07:00
jp9000 92258d6bae libobs: Clarify obs_object_invalid message 2015-10-21 06:30:29 -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
adray e354a433c7 libobs/util: Add function to get free space
Meant as a part of solving mantis issue 105 ("Disk space usage monitor
when recording").

From pull request: jp9000/obs-studio#374
Relevant mantis issue: https://obsproject.com/mantis/view.php?id=105
2015-10-15 01:43:23 -07:00
adray 3e6db990fc libobs/util: Add function to get file size
From pull request: jp9000/obs-studio#374
2015-10-15 01:41:37 -07:00
jp9000 d542663478 libobs/util: Add os_get_abs_path(_ptr) functions
These functions resolve the absolute path from a relative path.
2015-10-15 01:35:18 -07:00
jp9000 1bcbaf8e75 libobs: Use byte sequence for non-breaking spaces
Use explicit UTF-8 byte sequence for the "no-break space" character.

Prevents issues with certain editors, and fixes the following compiler
warning on Visual C++:

warning C4819: The file contains a character that cannot be represented
in the current code page (X). Save the file in Unicode format to prevent
data loss
2015-10-15 01:31:07 -07:00
Richard Stanway 90a45a0ca0 libobs: Don't call signal handlers that got removed
It's possible for one signal handler to disconnect another during signal_handler_signal, which could result in crashes when the disconnected signal handler is called with a potentially freed data pointer due to other cleanup.
2015-10-13 01:08:51 +02: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
Palana 74e4c33756 libobs: Use IOKit error code when polling hotkeys (OSX)
In case a system authentication prompt is open the actual error code
(via err_get_code) is kIOReturnExclusiveAccess on OSX 10.9; I'm not
100% sure if this makes the "if (!value)" part of the code obsolete,
but that code path shouldn't be triggered under most circumstances
anyway

Fixes https://obsproject.com/mantis/view.php?id=346
2015-10-07 11:06:40 +02:00
jp9000 a468777614 libobs: Always use CRLF for crash text
When the crash text is generated, it's generated with LF line endings
only.  Pasting the crash text in to notepad will result in garbled text
on windows (due to the fact that notepad still to this day has not been
programmed to understand anything other than CRLF).  Instead of using
LF, just use CRLF.
2015-10-05 13:07:16 -07:00
jp9000 3c0a309ac5 libobs: Move SymRefreshModuleList to crash handler
There's no need to refresh the actual module list for the crash handler
until a crash has occurred.  Reduces startup time for this function call
from 400ms to 40ms.
2015-10-05 13:04:31 -07:00
jp9000 b038ed8d1d libobs: Profile win32 symbol update call 2015-10-04 21:16:30 -07:00
jp9000 7a15068d96 libobs: Only update symbols after plugins loaded
Reloading symbols after each plugin is causing the load times to
increase a fair bit on some computers, so do it after all plugins are
loaded instead.
2015-10-04 21:16:29 -07:00
jp9000 8a0a28bf27 libobs/util: Add get_dll_ver function (windows)
Used to get the version of a dynamic link library on windows.
2015-10-04 21:16:28 -07:00
jp9000 48550b9691 libobs/util: Add function to calculate CRC32 2015-10-04 21:16:27 -07:00
jp9000 05748195a8 libobs/util: Save filename in config_create
Fixes a bug where config_save could not save the file due to the fact
that it did not store the path of the file as it was supposed to.
2015-10-04 21:16:26 -07:00
jp9000 b3d6d9e49d libobs: Add file serializers 2015-10-04 21:16:25 -07:00
jp9000 8c1fb99e99 libobs/util: Use int64_t as return for serializer
Intended as a means of expressing an error occurred (-1) when performing
a seek or getting a position.
2015-10-04 21:16:24 -07:00
jp9000 af11984314 libobs/util: Call SymInitialize before other Sym*
On the first call to update the symbol paths, pass the path string to
the SymInitializeW function first if it hasn't been called yet.  If it
has been called, then defer to SymSetSearchPathW and then
SymRefreshModuleList.  This is meant to reduce a needless extra call to
the latter two functions on the first use of the function.
2015-10-04 21:16:23 -07:00
jp9000 9630c3032c libobs: Update version to 0.12.0 2015-09-22 20:49:04 -07:00
jp9000 088debdef4 libobs: Call CoInitializeEx in libobs
Due to the fact that certain modules may need COM on startup, initialize
COM by default in libobs.
2015-09-22 11:30:38 -07:00
jp9000 f3986afcb4 libobs: Add pdb paths for all plugin dirs (win32)
Use SymSetSearchPath to include plugin directories in pdb search paths.
This is important for generating proper crash data and crash logs on
windows.
2015-09-21 18:53:04 -07:00
jp9000 57edd5fb32 libobs: Make minor adjustment to module logging 2015-09-21 18:49:24 -07:00
jp9000 0a228d0740 libobs/util: Use gzopen* instead of gzdopen
Using gzdopen will not work properly if the C standard library used to
get the descriptor is not the same library as the one that was compiled
with zlib.  When this is the case, it causes zlib to fail to write a
file, and would report a C standard library error.  Use gzopen and
gzopen_w instead to ensure that the file is opened and closed by zlib
itself, ensuring that zlib and the libobs do not have to share the C
standard library between each other.
2015-09-21 00:01:19 -07:00
jp9000 c52b954b8e libobs: Add output stop error for "no space left" 2015-09-18 22:04:23 -07:00
jp9000 fb32b85f4c libobs: Shut down encoder if valid but not active
It's not impossible that this sort of thing could happen, although
unlikely.
2015-09-17 14:47:51 -07: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
jp9000 7920668e56 libobs: Add private data to definition structures
This is useful for allowing the ability to have private data associated
with the object type definition structures.  This private data can be
useful for things like plugin wrappers for other languages, or providing
dynamically generated object types.
2015-09-16 09:17:13 -07:00
jp9000 fa7286f84c libobs: Shut down encoder when not in use
This prevents encoders (hardware encoders in particular) from being
continually active when all outputs disconnect from an encoder.  This is
mostly just a temporary measure; the encoding interface may need a bit
of a redesign.  It will also definitely needs to be able to flush at
some point.  Currently when an output is stopped, the pending data is
discarded, which needs to be fixed.
2015-09-13 16:03:01 -07:00
jp9000 af310fb556 libobs: Allow object creation if id not found
Allows objects to be created regardless of whether the actual id exists
or not.  This is a precaution that preserves objects/settings if for
some reason the id was removed for whatever reason (plugin removed, or
hardware encoder that disappeared).  This was already added for sources,
but really needs to be added for other libobs objects as well: outputs,
encoders, services.
2015-09-13 11:55:06 -07:00
jp9000 a746c8cdd1 libobs: Remove potential NULL pointer dereference 2015-09-13 11:53:33 -07:00
jp9000 df14671d2f libobs: Fix cmake bug (make sure variable exists)
If the FFMPEG_AVCODEC_LIBRARIES variable does not exist, it will
generate a cmake error, so check to make sure the variable exists before
executing this code.
2015-09-13 11:29:28 -07:00
jp9000 d78d0072a0 libobs/util: Add functions to inhibit sleep
These fucntions prevent the computer from going to sleep, hibernating,
or starting up a screen saver.

On linux, it will also attempt to use DBus to prevent gnome/kde/etc
sleep, but it's not necessarily required in order to compile the
library.  Otherwise, it will simply call "xdg-screensaver reset" once
every 30 seconds to reset the screensaver timer.
2015-09-12 22:08:05 -07:00
jp9000 5096b3c697 libobs: Set reconnect to false on user cancel
This fixes the issue when an output cancels reconnecting, reconnect is
left at true, causing obs_output_active to always return true even
though reconnecting has actually been canceled.
2015-09-11 08:20:18 -07:00
jp9000 0538865553 libobs: Add encoded output delay support
This feature allows a user to delay an output (as long as the output
itself supports it).  Needless to say this intended for live streams,
where users may want to delay their streams to prevent stream sniping,
cheating, and other such things.

The design this time was a bit more elaborate, but still simple in
design:  the user can now schedule stops/starts without having to wait
for the stream itself to stop before being able to take any action.
Optionally, they can also forcibly stop stream (and delay) in case
something happens which they might not want to be streamed.

Additionally, a new option was added to preserve stream cutoff point on
disconnections/reconnections, so that if you get disconnected while
streaming, when it reconnects, it will reconnect right at the point
where it left off.  This will probably be quite useful for a number of
applications in addition to regular delay, such as setting the delay to
1 second and then using this feature to minimize, for example, a
critical stream such as a tournament stream from getting any of its
stream data cut off.  However, using this feature will of course cause
the stream data to buffer and increase delay (and memory usage) while
it's in the process of reconnecting.
2015-09-10 12:13:37 -07:00
jp9000 582ecdab0f libobs: Add activate/deactivate output signals
Indicates when an output is considered active/inactive.
2015-09-10 12:12:42 -07:00
Palana b2714fa353 libobs/util: Restore original code point
This was broken in cd222f8ce0 which had a
horrible commit message that makes replicating the issue impossible if
there weren't others who reported similar visual studio issues when
using a Japanese locale
2015-09-08 11:36:19 +02:00
jp9000 c7ad09fc0b libobs: Move encoded_callback_t to obs-internal.h
Allows it to be used in multiple source files.
2015-09-06 15:29:17 -07:00
jp9000 ed8a06bf65 libobs: Add validity checks for obs objects
These functions are intended to log a warning when an obs function is
called with a null object.
2015-09-06 15:26:47 -07:00
jp9000 46101b6d5b libobs: Fix various string format warnings
GCC 5.1+ seems to be more aggressive about spotting potentially
non-matching printf format specifiers.
2015-08-30 23:41:09 -07:00
jp9000 ba718e94b5 libobs: Add function to duplicate scenes 2015-08-28 15:01:15 -07:00
jp9000 3620dbb59f libobs: Fix warning
Should have used size_t here instead of int.
2015-08-28 15:00:22 -07:00
jp9000 ff6cf508e5 libobs/media-io: Improve audio data logging
This improves logging for when audio data insertion is way out of bounds
or is getting cut off in the front due to a bad negative sync offset.

Instead of throwing out a log message for every time this happens with
each piece of data, it now states when the out of bounds or cutoff has
started and stopped only.
2015-08-27 16:33:07 -07:00
jp9000 263037102b libobs/media-io: Fix potential crash inserting audio
This fixes a case where an insertion of audio data would pass
valid_timestamp_range yet the insert position would cause a negative
integer position and thus an unsigned integer overflow.
2015-08-27 16:33:06 -07:00
jp9000 e479d4d0dc libobs: Add obs_data funcs for safe file handling
obs_data_create_from_json_file_safe: Attempts to create an obs_data
object from a file, and if that fails and a backup file exists, deletes
the old file and tries to open it again.

obs_data_save_json_safe: Saves json data to a temporary file first,
optionally backs up the target file if the file exists and backup_ext is
valid (otherwise deletes it), and then renames the temporary file to the
target file.  This helps reduce the chance of json corruption on save.
2015-08-21 18:22:24 -07:00
jp9000 40988f7e1d libobs: Add obs_data_save_json function
We keep having to repeat code for saving the json data to a file, so add
a helper function to help clean up some of that code.
2015-08-21 17:47:13 -07:00
jp9000 dd9107dbd8 libobs: Don't return valid obs_data if json fails
If obs_data_create_from_json fails on loading the json data, do not
return a valid data object; return NULL instead.
2015-08-21 17:45:03 -07:00
jp9000 f29431d8db libobs/util: Add config_save_safe function
This safely saves a configuration file, optionally with a backup.
2015-08-21 17:42:24 -07:00
jp9000 3a77ac3516 libobs/util: Add os_quick_write_utf8_file_safe
This helper function saves to a temporary file first, (optionally) backs
up the original file, then renames the temporary file to the actual file
name.  This helps reduce the chance of file corruption under various
circumstances (such as shutdown or crash while the file is being written
to disk).
2015-08-21 17:31:23 -07:00
jp9000 0d30d1229f libobs: Add API func to get module config path
Allows the ability to get a module-specific configuration file/path
2015-08-19 12:16:21 -07:00
jp9000 2bd8ab7c09 (API Change) libobs: Add global module config path
API Changed:
---------------------------
From:
- bool obs_startup(const char *locale, profiler_name_store_t *store);

To:
- bool obs_startup(const char *locale, const char *module_config_path,
		profiler_name_store_t *store);

Summary:
---------------------------
This allows plugin modules to store plugin-specific configuration data
(rather than only allowing objects to store configuration data).  This
will be useful for things like caching data, for example looking up and
storing ingests from remote (rather than storing locally), or caching
font data (so it doesn't have to build a font cache each time), among
other things.

Also adds a module-specific directory for the UI
2015-08-19 12:16:20 -07:00
jp9000 cd222f8ce0 libobs/util: Fix character encoding issue
Manually specifies the UTF-8 character codes used by the file rather
than relying on the compiler to determine what the codes are manually.
I was getting compile errors due to the fact that my current code page
is not at the default code page; so visual c++ tried to use my current
code page rather than UTF-8 and it would cause an error on the file.
2015-08-19 11:56:17 -07:00
jp9000 1afd32e70b libobs: Update version to 0.11.4 2015-08-16 15:04:15 -07:00
jp9000 6bd4f27fe9 libobs: Fix issue with getting the module data dir
When getting a blank module data file (indicating you want to get the
path to the module data directory itself), on certain operating systems
(windows) it will fail if you end the path with '/' or '\'.  So simply
make sure that if a blank module sub-path is used, don't try to append a
slash.
2015-08-16 13:40:37 -07:00
jp9000 d53cef47ac libobs: Add obs_data_create_from_json_file func
Just a little helper function that allows you to create an obs_data_t
object from a json file (rather than having to manually open it each
time and then call obs_data_create_from_json on the file data)
2015-08-16 06:43:43 -07:00
Palana bf2df49d71 libobs: Prevent registering (potentially) unsupported plugins
The rationale for rejecting these register calls is that these functions
may be required for the plugin to work properly, which can't be
guaranteed when libobs doesn't know about them.

This behavior may be revisited once the plugin manager is implemented,
to e.g. make it configurable (potentially per plugin) to allow loading
newer plugins in case they are known to work with the older libobs
2015-08-13 16:31:03 +02:00
Palana a26afbb9ae libobs: Prevent out of bound reads in obs_register_*
Previously adding new required functions would cause libobs to read out
of bounds in plugins not built with the new additions
2015-08-13 16:12:56 +02:00
Palana 5eb330276c libobs: Reformat required function error message 2015-08-13 15:24:41 +02:00
Palana 13b2469d61 libobs/util: Extend profiler csv export data
The id and parent_id fields should now allow better recovery of the
actual call trees, though they aren't compatible between different data
dumps in a single profiler session anymore; for that reason the new
fields name_id and parent_name_id are introduced, they hold the old id
and parent_id values respectively
2015-08-13 11:57:42 +02:00
Palana 91ea844333 libobs/util: Add compressed profiler snapshot saving 2015-08-12 15:30:30 +02:00
Palana c6140b4756 libobs/media-io: Profile audio/video_thread 2015-08-12 15:30:29 +02:00
Palana cf6b75e067 libobs: Add profiler calls 2015-08-12 15:30:29 +02:00
Palana 44b5afbd07 (API Change) libobs: Add profile_name_store_t parameter to obs_startup
Due to all the threads in libobs it wouldn't be safe to make that
parameter reconfigurable after libobs is initialized without adding
even more synchronization. On the other hand, adding a function to set
the name store before calling obs_startup would solve the problem of
passing a name store into libobs, but it can lead to more complicated
semantics for obs_get_profiler_name_store (e.g., should it always return
the current name store even if libobs isn't initialized until someone
calls set_name_store(NULL)? should obs_shutdown call
set_name_store(NULL)? Passing it as obs_startup parameter avoids
these (and hopefully other) potential misunderstandings
2015-08-12 15:30:29 +02:00
Palana d9cf5c668b libobs/util: Add profiler 2015-08-12 15:30:28 +02:00
Palana 7187c1b6d4 libobs: Move video_sleep call 2015-08-12 15:30:27 +02:00
jp9000 0685279892 libobs: Update version to 0.11.3 2015-08-07 21:28:47 -07:00
jp9000 6dfb59572f libobs: Remove windowless context #error 2015-08-05 01:07:10 -07:00
jp9000 b89ea47b96 (API Change) libobs: Remove main window funcs/vars
(Non-compiling commit: windowless-context branch)

API Changed:
---------------------
Removed functions:
- obs_add_draw_callback
- obs_remove_draw_callback
- obs_resize
- obs_preview_set_enabled
- obs_preview_enabled

Removed member variables from struct obs_video_info:
- window_width
- window_height
- window

Summary:
---------------------
Changes the core libobs API to not be dependent upon a main window/view.
If you wish to draw to a window/view, use an obs_display object to
handle it.

This allows the use of libobs without requiring a window to be present
on the system.  This is also prunes code that had to be needlessly
duplicated to handle the "main" window.
2015-08-05 01:07:09 -07:00
jp9000 cf9f21e422 (API Change) libobs/graphics: Change gs_create param
(Non-compiling commit: windowless-context branch)

Changes API from:
---------------------
EXPORT int gs_create(graphics_t **graphics, const char *module,
		const struct gs_init_data *data);

To:
---------------------
EXPORT int gs_create(graphics_t **graphics, const char *module,
		uint32_t adapter);

Summary:
---------------------
Changes the gs_create function to use an adapter parameter instead of
requiring a gs_init_data with window/color/etc information.
2015-08-05 01:07:08 -07:00
jp9000 358eb56228 libobs: Add windowless context #error
Intentionally breaks compilation when trying to compile the specific
merged commits within the windowless-context branch.  This is meant to
be used in conjunction with a merge commit so that bisecting will never
see any non-compiling commits.
2015-08-05 01:07:03 -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 0fb79a4733 libobs: Use get_win_ver (not GetVersionEx) 2015-08-01 14:51:22 -07:00
jp9000 ef332ab8b6 libobs: Add function to get the windows version
Microsoft basically deprecated GetVersion/GetVersionEx, so now you have
to query the file version of kernel32.dll in order to get the actual
windows version.  Because of the steps involved in getting the windows
version are fairly complicated, this is an exported libobs helper
function that can be used to get the windows version if needed.
(Microsoft does have its own set of helper functions for this but the
API feels a bit..  awkward, and you can't actually get the real windows
version with them)
2015-08-01 14:51:21 -07:00
jp9000 9a93e4b859 libobs: Add platform-specific headers to cmake 2015-08-01 14:51:20 -07:00
jp9000 df2242b6aa libobs: Add OBSContext class to obs.hpp
This is just a data-less class that simply calls
obs_startup/obs_shutdown automatically.
2015-07-30 18:49:06 -07:00
jp9000 378b46b7b7 libobs: Update version to 0.11.2 2015-07-27 16:08:44 -07:00
Anthony Catel ffb3ca4595 libobs: Use one copy for RGBA output when possible
A minor optimization: in copy_rgbx_frame (used when libobs is set to
output RGBA frames instead of YUV frames), if the line sizes for the
source and destination match, just use a single memcpy call for all of
the data instead of multiple memcpy calls.
2015-07-24 10:42:44 -07:00
Palana 4a22f314d6 libobs/graphics: Fix printf format warning
Added cast to unsigned and the assert because microsoft's compiler
doesn't support "%zu"

Actual warning:
libobs/graphics/effect-parser.c:1387:4: warning: format specifies type
'unsigned int' but the argument has type 'size_t' (aka 'unsigned long')
[-Wformat]
2015-07-19 06:30:35 +02:00
Palana 95e19cb7ba libobs/util: Reduce allocations in dstr_vcatf 2015-07-19 06:30:35 +02:00
Palana 14b27a4cc7 libobs/util: Add format string diagnostics for dstr_(cat|print)f 2015-07-19 06:30:34 +02:00
jp9000 c87d3b1f12 cmake: Rename FindFFMpeg to FindFFmpeg
This was sort of driving me crazy: The 'm' in FFmpeg isn't supposed to
be capitalized.
2015-07-18 16:32:26 -07:00
jp9000 c53f4f2f45 libobs: Fix bug with a win8 log message
I unintentionally stored the windows version in a 16bit format rather
than an 8bit format.
2015-07-16 15:45:20 -07:00
jp9000 d7d44a92ff libobs/util: Load win. module deps from same dir
Certain plugins/modules that are loaded on windows may be dependent on
libraries that are located in the same directory as the module in
question.  This makes is so that LoadLibrary will also search for
dependent libraries for that module in the module's directory.
2015-07-16 13:33:34 -07:00
jp9000 5c0f4546ea libobs/util: Add functions to get/set the cwd
Adds functions to get or set the current working directory.
2015-07-16 01:32:16 -07:00
jp9000 7bd5147074 libobs: Fix module search to ignore . and ..
When globbing for modules, the intent was to ignore the . and ..
directories that might also be included in the glob search.  It was
mistakenly doing a string compare on the 'path' variable which contains
the full path, rather than the 'file' variable which just contains the
found file itself, so the string compare always failed.
2015-07-16 01:32:15 -07:00
jp9000 5d33c777c2 libobs/util: Add macro to specify arch. bits 2015-07-16 01:32:13 -07:00
jp9000 8472857521 libobs: Fix warning from mingw 2015-07-11 14:26:48 -07:00
jp9000 9f96e691ae libobs: Add API to get encoder sample rate
In case the encoder has to use a different sample rate (due to the
sample rate being unsupported), we need an API function for the encoder
to get the sample rate that the encoder is actually running at.
2015-07-09 10:42:09 -07:00
jp9000 6fca7c4ccf libobs: Update version to 0.11.1 2015-07-09 09:31:12 -07: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
Palana 231dfbd975 libobs/util: Make os_sleepto_ns more accurate on windows 2015-07-09 02:42:38 +02:00
jp9000 847b3df322 libobs/util: Add os_mkdirs
Recursively creates a directory structure if one or more directories in
the path structure don't exist
2015-07-08 10:00:33 -07:00
jp9000 bf37258469 libobs/util: Allow ability to get base config path
This allows you to for example, get your base home directory or base
%appdata% directory.
2015-07-08 09:21:18 -07:00
Carl Fürstenberg ba02e065fe libobs: Add XDG config directory support
Adding XDG Base Directory Specification support for config dir

http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html

Closes jp9000/obs-studio#348
2015-07-08 09:10:53 -07:00
Carl Fürstenberg cf8c096f2e libobs: Set sane write permissions on directories
Prevent setting global writable permissions on newly created
directories.
2015-07-08 08:11:14 -07:00
jp9000 2dfed30509 libobs: Update to 0.11.0 2015-07-08 00:14:21 -07:00
lemmi 0cdc53c0f0 libobs/util: Make pthread_setname_np glibc only
Fixes an issue with certain distributions that don't use glibc
(particularly musl)

Closes jp9000/obs-studio#441
2015-07-06 19:45:22 -07:00
jp9000 20e48efbe3 libobs: Remove extra log newline from audio reset 2015-07-06 17:03:38 -07:00
jp9000 9729e7af86 libobs: Add log separators to video/audio resets 2015-07-06 17:03:37 -07:00
jp9000 0e8702b006 libobs: Log when aero is on/off on startup 2015-07-06 17:03:36 -07:00
jp9000 e5ccac0c5c libobs: Log when module file is loaded 2015-07-06 17:03:36 -07:00