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

1122 Commits

Author SHA1 Message Date
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
jp9000
6bf2be407b libobs/util: Add config_remove_value function 2015-07-03 09:57:51 -07:00
jp9000
526b9e6bc1 libobs: Do not add audio hotkeys for filters 2015-07-03 09:21:43 -07:00
jp9000
4ed1ee7009 libobs: Check for removals in obs_enum_sources
Checks for removals while enumerating, which allows one to be able to
remove a source in the enumeration.
2015-07-02 17:18:43 -07:00
jp9000
5bcaa7b590 libobs/util: Do not add empty config file values
This allows config file values to defer to their defaults instead of
being null.
2015-07-02 17:18:43 -07:00
jp9000
625ecda3dc libobs/util: Add ConfigFile::Swap function
Allows swapping the internal data of two ConfigFile objects.
2015-07-02 17:18:34 -07:00
jp9000
09b78b12de libobs/util: Add os_copyfile function
Adds a function to copy a file.  On unix-based systems, manually copies
the data with fopen/fread/fwrite/fclose.
2015-07-02 17:18:27 -07:00
jp9000
216baaf799 libobs/util: Add os_rmdir function
Adds a function to remove a directory.
2015-07-02 17:18:23 -07:00
jp9000
50f4793c99 libobs/util: Add os_rename function
Allows moving/renaming of files.
2015-07-02 17:18:15 -07:00
Palana
41689fe746 libobs: Add obs_scene_reorder_items 2015-06-28 04:10:10 +02:00
Palana
ef9090e0a3 libobs: Add obs_scene_atomic_update 2015-06-28 04:10:10 +02:00
jp9000
546b189f05 libobs: Use audio-math.h for decibel conversion 2015-06-26 03:40:28 -07:00
jp9000
c82da7da93 libobs/media-io: Add common audio math functions
This adds functions specific to audio math, which at the moment is just
converting to and from decibel and multiple.
2015-06-26 03:40:27 -07:00
jp9000
d9c7290891 libobs: Do not try to render audio-only sources 2015-06-25 15:55:27 -07:00
jp9000
71e4f3091b libobs: Add OBS_OUTPUT_UNSUPPORTED error code
This allows an output to specify that the format or track count is
unsupported.
2015-06-21 22:34:47 -07:00
jp9000
657985da94 libobs: Allow obs-encoder callback self-removal
Allows obs-encoder callbacks to remove themselves while in a callback.
2015-06-21 22:34:46 -07:00
jp9000
693962a468 libobs: Allow audio-io callback self-removal
Allows audio-io callbacks to remove themselves while in a callback.
2015-06-21 22:34:45 -07:00
jp9000
6587b18d59 libobs: Add return code to process pipe destroy 2015-06-21 22:34:44 -07:00
jp9000
43956388b2 libobs: Fix bug with process piping
The size parameter is the size of the elements, not the size of the
data.  The size parameter should be 1, and the elements should be the
number of bytes.

The reason why I'm making this change is because the fread/fwrite would
fail when the parameters were swapped.
2015-06-21 22:34:43 -07:00
Palana
0037d7c011 libobs: Ignore OSX keyboard layout notifications w/o layout change
These notifications can happen with e.g. the Japanese Kotoeri layout
when switching between active windows
2015-06-06 21:08:17 +02:00
Palana
2097224061 libobs: Move OSX keyboard layout logging
In the (unlikely) event of multiple concurrent calls to
input_method_changed it was possible that the log messages would appear
out of order with respect to which layout would actually be active
after the last log message
2015-06-06 21:08:09 +02: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
51dd204c6f libobs: Save clamped video time
The "clamped" video time is the system time per video frame that is
closest to the current system time, but always divisible by the frame
interval.  For example, if the last frame system timestamp was 1600 and
the new frame is 2500, but the frame interval is 800, then the
"clamped" video time is 2400.

This clamped value is useful to get the relative system time without any
jitter.
2015-06-04 18:04:23 -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
jp9000
a752b32b83 libobs: Add editable list property
Add an editable list property, primarily used for adding files to a
playlist for example.
2015-06-02 17:01:38 -07:00
jp9000
899557699f libobs: Add OBS_UNIX_STRUCTURE config variable
This obsconfig.h variable will be true or false depending on whether the
project is configured with the cmake UNIX_STRUCTURE variable or not.
2015-06-01 16:42:27 -07:00
Palana
4ee5c8e0f3 libobs: Fix crash on encoder initialization failure
Found via clang static analysis
2015-06-01 01:37:36 +02:00
Palana
c680b3e115 libobs/calldata: Fix unaligned loads/stores
Found via UBSan, actual errors (addresses not pruned for illustrative purposes):

"runtime error: store to misaligned address 0x7f9a9178e84c for type
'size_t' (aka 'unsigned long'), which requires 8 byte alignment"

"runtime error: load of misaligned address 0x7f9a9140f2cf for type
'size_t' (aka 'unsigned long'), which requires 8 byte alignment"
2015-05-31 04:45:54 +02:00
jp9000
dcf7ac9587 libobs: Update version to 0.10.1 2015-05-18 15:11:52 -07:00
jp9000
3a5d7b1168 libobs: Fix mouse button hotkeys on linux
The screen index returned from XDefaultScreen is 0-based, and we were
decrementing it before the check to see if it had reached 0 rather than
after, so in the default_screen function it would always end up getting
either the wrong screen or no screen.

When xcb_query_pointer and xcb_query_pointer_reply was called with no
valid screen, it would fail with an error, thus making it so that the
mouse buttons could not be properly captured as hotkeys.
2015-05-16 20:10:49 -07:00
Palana
f9eeb049fa libobs: (Re-)Move (duplicate) graphics mutex init
This probably fixes the crash from "libobs: Check effect mutex exists
before destroying it" (c2c47b1169)
2015-05-16 22:16:43 +02:00
Palana
f981b58b43 Revert "libobs: Check effect mutex exists before destroying it"
This reverts commit c2c47b1169.
2015-05-16 22:10:15 +02:00
Richard Stanway
c2c47b1169 libobs: Check effect mutex exists before destroying it
Fixes a crash if graphics system didn't finish intializing.
2015-05-16 18:44:25 +02:00
jp9000
782a5daa18 Update to 0.10.0 2015-05-12 15:37:40 -07:00
Palana
e044fcfaaa libobs: Fix saving/loading of push-to-mute settings 2015-05-12 21:36:46 +02:00
Palana
23a2228142 libobs: Add scene item hotkeys 2015-05-11 20:45:25 +02: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
jp9000
d0cae31a48 libobs: Add linux hotkey implementation 2015-05-11 20:45:25 +02:00
jp9000
3fc63f83f1 libobs: Add windows hotkey implementation 2015-05-11 20:45:25 +02:00
Palana
f37e72205a libobs: Add OSX hotkey implementation 2015-05-11 20:45:24 +02:00
Palana
5ad553d06d libobs: Add global hotkey support 2015-05-11 20:45:24 +02:00
Palana
4daa5c7aa7 media-io: Fix check before passing pointer to av_freep
Found by clang-3.7 (trunk 236075) via -Wpointer-bool-conversion:

warning: address of array 'rs->output_buffer' will always evaluate
to 'true'
2015-05-11 20:42:53 +02:00
jp9000
c1e8d28548 libobs: Use exponential backoff for reconnecting
Implements exponential backoff for consecutive reconnects, which is
useful to prevent too many connections from trying to reconnect back to
a service at once over a short period of time in the case of potential
service downtime.  Exponential backoff causes each subsequent reconnect
attempt to double its timeout duration.
2015-05-10 16:07:22 -07:00
jp9000
691d3b4a73 libobs: Add timeout_sec param to reconnect signal
This optionally allows the front-end to know what the current timeout
value in seconds is set to for the reconnection without having to call
an extra API function to find that out.
2015-05-10 16:05:26 -07:00
Jim
b620bb13b5 Merge pull request #425 from fryshorts/bsd-cpu-model
libobs: Implement logging cpu model on bsd
2015-05-07 12:30:23 -07:00
Palana
0f2310a8bc libobs: Extend levels_updated signal with muted flag 2015-05-07 02:08:08 +02:00
Palana
4d40c5c853 libobs: Extend audio_data signal with muted flag 2015-05-07 02:08:08 +02:00
Palana
71abed387f (API Change) libobs: Make obs_service refcounted 2015-05-07 02:08:05 +02:00
Palana
ba0b8eb0e1 (API Change) libobs: Make obs_encoder refcounted 2015-05-07 02:07:56 +02:00
Palana
f094bf199d (API Change) libobs: Make obs_output refcounted 2015-05-07 02:06:40 +02:00
Palana
a563fbc05b libobs: Add weak reference type for obs_source 2015-05-07 01:57:14 +02:00
Palana
99deb0821f libobs: Add refcounting helpers 2015-05-07 01:57:14 +02:00
Palana
a907d74903 util: Add os_atomic_compare_swap_long 2015-05-07 01:57:14 +02:00
jp9000
bf1ca59965 util: Add dstr functions to make upper/lower 2015-05-07 01:57:14 +02:00
Palana
ae19eec2c6 util: Improve handling of config values with linebreaks 2015-05-07 01:55:12 +02:00
fryshorts
e3901b2072 Revert "libobs: Fix missing getline on FreeBSD"
This is no longer needed since getline is only used in linux specific
functions now.
2015-05-06 21:39:17 +02:00
fryshorts
bc38bf641b libobs: Only log distribution info on linux
Add ifdefs to only log the distribution information on linux since this
is a platform specific implementation.
2015-05-06 21:39:17 +02:00
fryshorts
ceb1b218f1 libobs: Implement logging processor model on bsd
Implement the log_processor_info function on bsd and add ifdefs to only
build the implementation specific to the platform.
Also add an ifdef around the call to that function to make sure it will
only be called on platforms where it is actually implemented.
2015-05-06 21:39:17 +02:00
fryshorts
f5568ff586 libobs: Split up processor logging on nix
Split the function logging the processor information on nix into two
parts. The part logging the number of logical cores is portable and
works on all systems that support POSIX.1 while the other part is
specific to linux.
2015-05-06 21:15:24 +02:00
Jim
ee284a56ac Merge pull request #424 from fryshorts/bsd-build-fixes
BSD build fixes
2015-05-05 04:46:16 -07:00
fryshorts
7a33f27c72 libobs: Link against compat sysinfo on FreeBSD
Link against the compatibility library that provides sysinfo on FreeBSD.
2015-05-04 22:37:17 +02:00
Kris Moore
9c483aae10 libobs: Add support for FreeBSD to gs_window
Enable the X11 specific members in the gs_window struct when on FreeBSD.
2015-05-04 21:08:17 +02:00
fryshorts
d998c16724 libobs: Remove unused include
Remove unused include as it is not available on FreeBSD and was
therefore causing a build error.
2015-05-04 21:08:17 +02:00
Kris Moore
5803d921ae libobs: Fix thread naming on FreeBSD
Add the relevant header file needed on FreeBSD and utilize yet another
ifdef to call pthread_set_name_np as the function name differs from
those on the other platforms.
2015-05-04 21:08:17 +02:00
Kris Moore
013e97ff54 libobs: Fix missing getline on FreeBSD
Add definition on FreeBSD to enable getline in stdio, as it is not
(yet ?) available by default. According to the manpage getline was a
GNU extension but was standardized in POSIX.1-2008.
2015-05-04 21:05:55 +02:00
GoaLitiuM
2ab4c430e0 libobs: Define snprintf only for Visual Studios prior VS2015
This change is purely cosmetic one. _snprintf is still defined in 2015,
but Microsoft may change this in the future.
2015-05-04 19:33:55 +03: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
Palana
17ff1d94e6 util: Calculate buffer size for dstr_vprintf (C99) 2015-04-23 23:49:06 +02:00
jp9000
a736b01276 libobs: Log video format 2015-04-18 00:03:22 -07:00
jp9000
1b53215b99 libobs: Add function to get video format name 2015-04-18 00:03:21 -07:00
jp9000
4d002f588b (API Change) Remove encoder callback boilerplate
API Changed (in struct obs_encoder_info):
----------------------------------------
bool (*get_audio_info)(void *data, struct audio_convert_info *info);
bool (*get_video_info)(void *data, struct video_scale_info *info);

To:
----------------------------------------
void (*get_audio_info)(void *data, struct audio_convert_info *info);
void (*get_video_info)(void *data, struct video_scale_info *info);

The encoder video/audio information callbacks no longer need to manually
query the libobs video/audio information, that information is now passed
via the parameter, which the callbacks can modify.

The refactor that reduces boilerplate in the encoder video/audio
information callbacks also removes the need for their return values, so
change the return types to void.
2015-04-17 20:17:43 -07:00
jp9000
5c91d93d87 libobs: Refactor video/audio encoder conversion
I realized that the get_video_info and get_audio_info encoder callbacks
always have to manually query the libobs audio/video information.

This fixes that problem by passing the libobs video/audio information in
the structures passed to those callbacks so they don't have to query it
each time, reducing needless boilerplate code for encoders.
2015-04-17 20:17:43 -07:00
jp9000
1ee277ed33 libobs: Add preferred video format encoder funcs
Allows the ability to hint at encoders what format should be used.

This is particularly useful if libobs is currently operating in planar
4:4:4, but you want to force an encoder used for streaming to convert to
NV12 to prevent streaming issues.
2015-04-17 20:17:42 -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
822d1ec3fc libobs: Add packed yuv to planar 4:4:4 conversion 2015-04-16 22:51:31 -07:00
jp9000
0f346561ff libobs: Refactor pack_lum to pack_shift
Allows the ability to specify the bytes to shift as a parameter.  Useful
for planar 4:4:4 conversion.
2015-04-16 22:48:54 -07:00
jp9000
7bc8dc3471 libobs: Add Planar444 conversion to effect 2015-04-16 22:43:46 -07:00
jp9000
a32f8a5d19 libobs: Fix RGB output
RGB output wasn't occurring due to the fact that the frame simply wasn't
being copied.
2015-04-15 18:41:09 -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
6e572d849f libobs: Don't use 'output' as a keyword in shader
The bilinear lowres scale effect was using 'output' for a variable,
which is apparently a reserved keyword in GLSL on macs.  This slipped
by me due to the fact that this didn't occur with OpenGL on my windows
machine.
2015-04-10 09:58:04 -07:00
jp9000
ea8327ce5b libobs: Always free effect if not cached
Fix an issue where effects that fail to compile will not properly free
their data if they cannot not be parsed or compiled.
2015-04-10 09:48:55 -07:00
jp9000
4e54c89f9c libobs: Fix full range min/max output
The minimum and maximum color range values were not being set by the
video_format_get_parameters function when full range was in use; I
assume it's because the expected min/max values of full range is
{0.0, 0.0, 0.0} and {1.0, 1.0, 1.0}, so I'm just making it so that it
sets those values if using full range.

Way to replicate the issue (windows):
1.) Create a win-dshow device capture source
2.) Select a device and set it to a YUV color format to enable YUV color
conversion
3.) Select "Full Range" in the color range property.
4.) Restart OBS, the device will then start up, but will display green
due to the fact that the min/max range values were never set, and are
left at their default value of 0.
2015-04-10 07:27:26 -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
13fd6ff064 libobs: Use bilinear low res scale effect
The normal scaling methods cannot sample enough pixels to create an
accurate output image when the output size is under half the base size,
so use the bilinear low resolution scaling effect in that case instead
to ensure a more accurate low resolution image.
2015-04-10 07:27:25 -07:00
jp9000
65517ea4cf libobs: Add low resolution bilinear scale effect
This effect preserves detail of images that are scaled below half size
by using sampling 9 pixels.
2015-04-10 07:27:24 -07:00
jp9000
b18e957d81 libobs: Add missing function definitions
Add missing function definitions for the lanczos and bicubic effects
2015-04-10 07:27:23 -07:00
jp9000
27a0749d8d libobs: Add func to set display background color
This function sets the background color for a display
2015-04-10 07:27:23 -07:00
jp9000
1a9c512f38 libobs: Add functions to disable main preview
If you don't need to see what's displayed, then this is particularly
useful for two reasons:
1. It reduces the number of draw/present calls
2. It can prevent issues with certain hardware setups where rendering on
   a monitor hooked up to a separate card can experience slowdowns
2015-04-10 07:27:22 -07:00
jp9000
ebfe477caf libobs: Add ability to disable displays
Sometimes it can be useful to turn off rendering to the display in order
to reduce the number of draw calls and present calls.
2015-04-10 07:27:21 -07:00
jp9000
54535753ee Revert "libobs: Add UI-independent plugin search paths"
This reverts commit 99c674e41f.

These commits were originally added to allow multiple user interfaces to
use the same plugins, but I soon realized that multiple user interfaces
can use multiple libobs versions, so each user interface should have its
own set of plugins to manage.  Some user interfaces may not wish to use
certain plugins anyway, so this fixes that issue as well.
2015-04-03 19:54:36 -07:00
jp9000
ec0048e05e Revert "Merge pull request #410 from bazukas/nix-modules"
This reverts commit 92d800cc18, reversing
changes made to 35a4acede0.

These commits were originally added to allow multiple user interfaces to
use the same plugins, but I soon realized that multiple user interfaces
can use multiple libobs versions, so each user interface should have its
own set of plugins to manage.  Some user interfaces may not wish to use
certain plugins anyway, so this fixes that issue as well.
2015-04-03 19:54:03 -07:00
Azat Khasanshin
6b066e9bc6 Add $HOME/.obs-plugins as default module search dir on Linux 2015-04-03 19:20:05 +03:00
jp9000
99060e5bf2 Update to 0.9.1 2015-03-27 12:24:54 -07:00
jp9000
c7e1878390 libobs: Use default blend state with scenes
Instead of manually setting the blend state to the desired values, use
gs_reset_blend_state to ensure we have the default blend state (which
for color is a typical srcalpha/invsrcalpha alpha blending operation,
then the alpha channels are added together).

This fixes an issue where filtered scenes would look strange due to the
fact that alpha was not being blended properly.
2015-03-27 11:22:58 -07:00
jp9000
be52fa26f9 Add gs_blend_function_separate
This allows the ability to separate the blend states of color and alpha.

The default blend state has also changed so that alpha is always added
together to ensure that the destination image always gets an alpha value
that is actually usable after the operation (for render targets).

Old default state:
  color source: GS_BLEND_SRCALPHA, color dest: GS_BLEND_INVSRCALPHA
  alpha source: GS_BLEND_SRCALPHA, alpha dest: GS_BLEND_INVSRCALPHA

New default state:
  color source: GS_BLEND_SRCALPHA, color dest: GS_BLEND_INVSRCALPHA
  alpha source: GS_BLEND_ONE,      alpha dest: GS_BLEND_ONE
2015-03-27 11:18:02 -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
75ee8ff528 libobs: Update version number to 0.9.0 2015-03-25 14:14:41 -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
b33d95999f libobs: Mark audio filters as async
Async filters and effect filters are really two different classes of
filters, so it's important that audio filters be marked as async.
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
a73816665c libobs: Simplify comment
These are basically just capabilities of a source, that and too much
text on one line.
2015-03-25 10:03:18 -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
0d8ae565f2 libobs: Add API to hide/show scene items 2015-03-25 10:03:16 -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
d44d3b1f0a libobs: Use locale-independent double conversion
Prevents issues on specific locales, especially where decimal points are
represented by commas rather than periods.
2015-03-22 19:18:07 -07:00
jp9000
4abae186ce libobs: Use alpha when rendering scenes
This is just in case a filter is applied to a scene, filters will turn
off the blending so it's necessary to set the blending.
2015-03-22 19:18:06 -07:00
jp9000
0a8e3a643c libobs: Add int/float slider properties
This optionally specifies that the int/float value should be displayed
with a slider rather than and up/down control.  UIs are not necessarily
required to implement it, it's meant to be more of a hint.
2015-03-22 19:18:06 -07:00
jp9000
9b238ef71e libobs: Add obs_get_opaque_effect function
This returns a common effect useful for rendering an image with the
alpha channel overridden to 1.0.
2015-03-22 19:18:04 -07:00
jp9000
e4305d147b libobs: Fix default negative int/float shader vals
If negative was specified it would not parse the negative sign and thus
would not interpret that number as negative, and would cause
shader/effect parsing to simply fail on the file.
2015-03-22 19:17:41 -07:00
jp9000
cdb27ac06b libobs: Add functions to push/pop blend states
This is particularly important for the filter pipeline in order to
ensure that when the last filter is reached that the original blend
state is properly reset.
2015-03-22 18:38:49 -07:00
jp9000
699201a06e libobs: Cache effects to prevent shader duplicates
Switching between shaders often can cause a performance hit, so cache
effects so that they persist until the graphics subsystem is destroyed.
2015-03-22 18:38:48 -07:00
jp9000
2fa37a1f2e libobs-opengl: Fix render targets being flipped
When render targets are used, they output to the render target inverted
due to the way that opengl works.  This fixes that issue by inverting
the projection matrix so that it renders the image upside down and
inverting the front face from counterclockwise to clockwise.
2015-03-22 18:38:45 -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
76a9c90043 libobs: Clarify filter-related comments
Certain callbacks and API functions were a bit vague on when and how
they were supposed to be used.
2015-03-22 18:28:11 -07:00
jp9000
38cb1ed39b libobs: Make filter_video callback param non-const
The frame is definitely meant to be modifiable if needed, so it
shouldn't be const.  I originally meant for these frames to be
duplicated, but with the source video cache that's both unnecessary and
would reduce performance.
2015-03-22 18:28:11 -07:00
jp9000
001bfb4a6d libobs: Use nullptr instead of NULL 2015-03-21 16:34:46 -07:00
jp9000
644ac130f8 libobs: Only allow ComQIPtr on windows
ComPtr can be used for things like the DeckLink API, but ComQIPtr has
windows-specific compiler features, so can't be used outside of windows.
2015-03-21 16:34:46 -07:00
jp9000
ef4ee1fd1a libobs: Implement flags for properties
OBS_PROPERTIES_DEFER_UPDATE: Makes it so the properties are not updated
until editing of the properties is complete.
2015-03-19 15:57:03 -05: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
b03eae57c6 (API Change) Fix "apply service settings" functions
API changed from:
------------------------
EXPORT void obs_service_apply_encoder_settings(obs_service_t *service,
		obs_encoder_t *video_encoder,
		obs_encoder_t *audio_encoder);

void obs_service_info::apply_encoder_settings(void *data
			obs_encoder_t *video_encoder,
			obs_encoder_t *audio_encoder);

To:
------------------------
EXPORT void obs_service_apply_encoder_settings(obs_service_t *service,
		obs_data_t *video_encoder_settings,
		obs_data_t *audio_encoder_settings);

void obs_service_info::apply_encoder_settings(void *data
			obs_data_t *video_encoder_settings,
			obs_data_t *audio_encoder_settings);

These changes make it so that instead of an encoder potentially being
updated more than once with different settings, that these functions
will be called for the specific settings being used, and the settings
will be updated according to what's required by the service.

This fixes that design flaw and ensures that there's no case where
obs_encoder_update is called where the settings might not have
service-specific settings applied.
2015-03-07 16:32:00 -08:00
jp9000
55bba03c85 libobs: Save/load filters on sources to save data 2015-03-06 09:14:05 -08: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