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

932 Commits

Author SHA1 Message Date
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
jp9000
3510e69121 libobs: Account for filters in source dimensions
The obs_source_get_width and obs_source_get_height functions need to
account for filters that may change their width/height such as a crop
filter or something similar.

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

One could use an obs_view, but I felt like it was unnecessary because
using an obs_view just to display a single source feels somewhat
superfluous.
2015-03-02 12:23:25 -08:00
jp9000
ab520cab25 libobs: Hide sources when an obs_view is destroyed
This fixes a bug where sources would not decrement their showing
references when an obs_view is destroyed.
2015-03-02 12:23:25 -08:00
jp9000
eed1a51d3a libobs: Free main view separately from std. views
The main view does not need to worry about hiding/deactivation of
sources when it's being freed here, when the obs context is shutting
down in this section of obs, all the sources are being freed, thus
there's no need to worry about deactivating/hiding sources.
2015-03-02 12:23:25 -08:00
Socapex
753959170b libobs: Fix bug (last scene item potentially lost) 2015-03-01 17:43:31 -08:00
jp9000
0c63afccf5 libobs: Update to 0.8.3 2015-02-20 21:56:03 -08:00
Palana
d085d6e4a1 libobs: Allow duplicate sources per scene
Previously having a source multiple times in a single scene would cause
the recursion check to trigger. Example scenes.json:

{
    "current_scene": "Scene",
    "sources": [
        {
            "flags": 0,
            "id": "scene",
            "mixers": 0,
            "name": "Scene",
            "settings": {
                "items": [
                    {
                        "align": 5,
                        "bounds": {
                            "x": 0.0,
                            "y": 0.0
                        },
                        "bounds_align": 0,
                        "bounds_type": 0,
                        "name": "Text (FreeType 2)",
                        "pos": {
                            "x": 0.0,
                            "y": 0.0
                        },
                        "rot": 0.0,
                        "scale": {
                            "x": 1.0,
                            "y": 1.0
                        },
                        "visible": true
                    },
                    {
                        "align": 5,
                        "bounds": {
                            "x": 0.0,
                            "y": 0.0
                        },
                        "bounds_align": 0,
                        "bounds_type": 0,
                        "name": "Text (FreeType 2)",
                        "pos": {
                            "x": 0.0,
                            "y": 98.0
                        },
                        "rot": 0.0,
                        "scale": {
                            "x": 1.0,
                            "y": 1.0
                        },
                        "visible": true
                    }
                ]
            },
            "sync": 0,
            "volume": 1.0
        },
        {
            "flags": 0,
            "id": "text_ft2_source",
            "mixers": 0,
            "name": "Text (FreeType 2)",
            "settings": {},
            "sync": 0,
            "volume": 1.0
        }
    ]
}
2015-02-17 13:41:49 +01:00
Palana
9dca07db30 libobs: Handle obs_scene_add failure
Previously a NULL item would cause a crash when reading transform info.
The crash can be reproduced by e.g. editing scenes.json so that two
scenes contain each other. Example scenes.json:

{
    "current_scene": "Scene",
    "sources": [
        {
            "flags": 0,
            "id": "scene",
            "mixers": 0,
            "name": "Scene",
            "settings": {
                "items": [
                    {
                        "align": 5,
                        "bounds": {
                            "x": 1440.0,
                            "y": 900.0
                        },
                        "bounds_align": 0,
                        "bounds_type": 2,
                        "name": "Scene 2",
                        "pos": {
                            "x": 0.0,
                            "y": 0.0
                        },
                        "rot": 0.0,
                        "scale": {
                            "x": 1.0,
                            "y": 1.0
                        },
                        "visible": true
                    }
                ]
            },
            "sync": 0,
            "volume": 1.0
        },
        {
            "flags": 0,
            "id": "scene",
            "mixers": 0,
            "name": "Scene 2",
            "settings": {
                "items": [
                    {
                        "align": 5,
                        "bounds": {
                            "x": 1.0,
                            "y": 1.0
                        },
                        "bounds_align": 0,
                        "bounds_type": 0,
                        "name": "Scene",
                        "pos": {
                            "x": 854.0,
                            "y": -520.0
                        },
                        "rot": 0.0,
                        "scale": {
                            "x": 1.75,
                            "y": 1.7562724351882935
                        },
                        "visible": true
                    }
                ]
            },
            "sync": 0,
            "volume": 1.0
        }
    ]
}
2015-02-17 13:41:49 +01:00
jp9000
ba3cac938a libobs: Update to version 0.8.2 2015-02-11 13:10:53 -08:00
jp9000
ffc7b3c666 libobs: Fix multi. video encoder sync issues
When using multiple video encoders together with a single audio encoder,
the audio wouldn't be in sync.

The reason why this occurred is because the dts_usec variable of the
encoder packet (which is based on system time) would always be reset to
a value based upon the dts (which is not guaranteed to be based on
system time) in the apply_interleaved_packet_offset function.  This
would then in turn cause it to miscalculate the starting audio/video
offsets, which are required to calculate sync.

So instead of calling that function unnecessarily, separate the check
for whether audio/video has been received in to a new function, and only
start applying the interleaved offsets after audio and video have
actually started up and the starting offsets have been calculated.
2015-02-10 22:10:41 -08:00
jp9000
a05ed355f5 libobs: Fix 64bit -> 32bit conversion warnings 2015-02-10 19:31:25 -08:00
jp9000
4eacb5f3e9 libobs: Add API to apply service encoder settings
Instead of having services automatically apply encoder settings on
initialization (whether the output wants to or not), instead make it
something that must be explicitly called by the developer.  There are
cases where the developer may not wish to apply the service-specific
settings, or may wish to override them for whatever reason.
2015-02-10 19:23:36 -08:00
jp9000
fe849ec482 libobs: Update to 0.8.1 2015-02-09 19:32:40 -08:00
jp9000
268f8daf2e libobs: Update version to 0.8.0 2015-02-09 16:25:59 -08:00
jp9000
e26dec916e libobs: Use windows wide <-> UTF8 conversion
If on windows, use the windows UTF conversion functions due to the fact
that the existing utf code is meant for 32bit wide characters, while the
windows conversion functions will properly handle 16bit wide characters.
2015-02-09 03:49:16 -08:00
jp9000
0c30dca526 libobs: Update to latest version of ComPtr.hpp 2015-02-09 03:49:15 -08:00
jp9000
5dfecab15c Fix windows printf format warnings (from mingw) 2015-02-09 03:49:14 -08:00
jp9000
0c1d121ff2 Remove various unused variables
Unused variables detected by mingw
2015-02-09 03:49:13 -08:00
martell
a83e74dc1c Disable SEH for mingw-w64
The SEH implementation is not quite working properly in mingw-w64, so
disable it for the time being.
2015-02-09 03:47:27 -08:00
martell
f9fa9c289f libobs: fix warning when logging the win version
The OSVERSIONINFOW structure contains DWORD variables, so to keep mingw
happy this should be printed with %ld
2015-02-09 03:41:49 -08:00
martell
9dd542f4fb libobs: fix warning when logging the cpu speed
Speed is a DWORD and should be printed as %ld.  This will keep mingw
happy and warning free
2015-02-09 03:41:49 -08:00
martell
ef37b9b888 libobs: fix windows version log warning
OSVERSIONINFOW uses SIZE_T so cast to unsigned long instead.
2015-02-09 03:41:48 -08:00
martell
23d39ea5a8 libobs: threading-windows mingw-w64 support
Enable support for mingw-w64 in threading-windows.c
2015-02-09 03:41:44 -08:00
martell
079d15d518 libobs: mingw-w64 threading-posix
Enable support for mingw-w64 in threading-posix.c
2015-02-09 03:41:43 -08:00
martell
47c86b6cbe libobs: avoid using to w32-pthreads for mingw-w64
mingw-w64 provides its own pthreads library.

also change some link libs as mingw-w64 libraries are not postfixed .lib
2015-02-09 03:41:37 -08:00
jp9000
99c674e41f libobs: Add UI-independent plugin search paths
Adds an additional search path for UI-independent and
installation-independent plugins for windows/mac.

Windows:
%appdata%/obs-plugins/

Mac:
~/Library/Application Support/obs-plugins/

Plugin directory format is [module]/bin and [module]/data.

On windows, for 32bit binaries:
[module]/bin/32bit

and 64bit binaries:
[module]/bin/64bit
2015-02-08 00:55:26 -08:00
jp9000
7e3efa86e5 libobs: Don't search '.' and '..' dirs for modules
On windows doing os_glob will also include '.' and '..', exclude these
when searching for modules.
2015-02-08 00:54:07 -08:00
jp9000
b72e68afe7 (API Change) Fix obs_service_gettype func name
Before:                After:
obs_service_gettype    obs_service_get_type

It seems there was an API function that was missed when we were doing
our big API consistency update.  Unsquishes obs_service_gettype to
obs_service_get_type.
2015-02-07 08:19:34 -08:00
jp9000
cb8acd59ce libobs: Export obs_properties_apply_settings
I didn't think it would ever need to be exported, but this function is
actually useful for applying settings to properties (to call all of
their update callbacks based upon the settings) without necessarily
having to have an object associated with it.
2015-02-04 16:51:59 -08:00
jp9000
bd76f16564 libobs: Add functions to get an encoder's type
'obs_encoder_get_type' to get the type of an existing encoder, and
'obs_get_encoder_type' to get the type via its identifier
2015-02-04 16:51:58 -08:00
jp9000
0e398c89be libobs: Add obs_get_encoder_codec function
This allows the ability to get the codec of an encoder via its
identifier string
2015-02-04 16:51:58 -08:00
jp9000
c0c24ab234 libobs: Add obs_encoder_set_name function 2015-02-04 16:51:55 -08:00
jp9000
84e1f47ced (API Change) Add support for multiple audio mixers
API changed:
--------------------------

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

obs_encoder_t *obs_output_get_audio_encoder(
		const obs_output_t *output);

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

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

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

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

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

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

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

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

Sources:

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

Audio Encoders:

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

Outputs:

Outputs that use encoders can now support multiple audio tracks at once
if they have the OBS_OUTPUT_MULTI_TRACK capability flag set.  This is
mostly only useful for certain types of RTMP transmissions, though may
be useful for file formats that support multiple audio tracks as well
later on.
2015-02-04 16:51:29 -08:00
jp9000
e4fdd61c74 libobs: Clarify comment on obs_source_set_flags
The comment says "these are different", but doesn't state why.
Actually, I should really rename the output flags so they're not flags,
but instead just "caps", because that's really all that they are.
2015-02-04 15:40:22 -08:00
jp9000
24eaf77963 libobs: Fix typo, 'audio' instead of 'video'
For some extremely inexplicable reason, I somehow managed to use 'video'
for the audio data instead of 'audio'.
2015-02-04 15:40:21 -08:00
jp9000
fec29532de libobs: Removed unused parameter and variable 2015-02-04 15:40:21 -08:00
jp9000
af8d5db4ad libobs: Add obs_data_clear to clear settings
This function is intended to clear all settings outside of
default/autoselect values.
2015-01-24 22:09:24 -08:00
jp9000
b042e20e24 libobs: Fix obs_data_apply
obs_data_apply is used to apply the changes of a source object in to a
destination object.  Problem with this however is that if sub-objects
are in use, it currently just copies the pointer of the sub-object,
meaning that the source and destination will both share the same
sub-object via reference.  If anything modifies that sub-object data,
it'll modify it for both objects, which was not intended.

Instead of copying the object pointer, create a new copy and then
recursively repeat the process to ensure the data is always completely
separate.
2015-01-24 21:03:04 -08:00
jp9000
82320a9ca7 (API Change) Make os_get_config_path safer to use
Changed:
  char *os_get_config_path(const char *name);

To:
  int os_get_config_path(char *dst, size_t size, const char *name);

Also added:
  char *os_get_config_path_ptr(const char *name);

I don't like this function returning an allocation by default.
Similarly to what was done with the wide character conversion functions,
this function now operates on an array argument, and if you really want
to just get a pointer for convenience, you use the *_ptr version of the
function that clearly indicates that it's returning an allocation.
2015-01-15 23:44:38 -08:00
jp9000
d54b3cc8c0 libobs: Update to 0.7.3 2015-01-14 23:05:37 -08:00
jp9000
1cb02d5879 libobs: Add function to enumerate video adapters
The gs_enum_adapters function is an optional implementation to allow
enumeration of available graphics adapters that can be used with the
program.  The ID associated with the adapter can be an index or a hash
depending on the implementation.
2015-01-14 21:28:01 -08:00
jp9000
05fc9c5b78 libobs: Fix calculation copying aligned textures
Direct3D textures are usually aligned to a specific pitch, so their
internal width is often not equal to the expected output width; this
means that if we want to use it on our texture output, that we must
de-align the texture while copying the texture data.

However, I unintentionally messed up the calculation at some point with
RGBA textures, so the variable size I was supposed to be using was
supposed to be multiplied by 4 (for RGBA), while I was still expecting
single channel data.  So, if the texture width was something like 1332,
the source (directx) texture line size would be somewhere at or above
5328 (because it's RGBA), then destination is at 1332 (YUV luma plane),
and it would unintentionally treat 3996 (or 5328 - 1332) bytes as the
unused alignment data.  So this fixes that miscalculation.
2015-01-14 14:57:27 -08:00
Jim
6d2226bde8 Merge pull request #326 from azatoth/plugin_lib
use multiarch compatible plugin lib path
2015-01-10 23:50:25 -08:00
jp9000
4ae68b3511 libobs: Whoops, use a 2 here instead of a 3
This file is GPL 2, not GPL 3.
2015-01-10 18:39:57 -08:00
Palana
1a53c8ca66 Rename parameters to avoid GLSL keyword conflicts
Refer to https://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.clean.pdf
for a list of current (reserved) keywords.

In the future the shader compiler in libobs-opengl should probably take
care of avoiding those name conflicts (bonus points for transparently
remapping the names of effect parameters)
2015-01-08 01:42:22 +01:00
jp9000
2ce2298d56 libobs: Update to 0.7.2 2015-01-06 16:48:06 -08:00
Carl Fürstenberg
1ba39b08ca use multiarch compatible plugin lib path
use OBS_PLUGIN_DESTINATION instead of hardcoded path for module_bin
2015-01-07 00:15:35 +01:00
jp9000
12d149bd3a libobs: Fix cache overflowing (memory leak)
Fixes a bug where all frames in the cache would get marked as 'in use',
this causing it to continually allocate new frames continually.
2015-01-06 14:29:40 -08:00
jp9000
5d30f268a0 libobs: Return NULL on ending property list string
Instead of returning a valid string value when there are no more strings
available in the list, return NULL to indicate failure.  An empty string
should really be allowed to be a valid value for the list.
2015-01-06 01:27:16 -08:00
jp9000
b120f7cc80 libobs: Fix sync bug in new frame handling code
The return value of os_sleepto_ns is true if it waited to the specified
time, and false if the current time is past the specified time.  So it
basically returns true if it successfully waited.

I just didn't check the return value properly here, so it ended up just
setting the count of frames to 1 if overshot, ultimately causing sync
issues.
2015-01-05 14:07:22 -08:00
jp9000
c7b3ff6323 libobs: Update to version 0.7.1 2015-01-05 07:07:45 -08:00
jp9000
c3e498d25f libobs: Add frame caching for async video sources
The temporary unoptimized code we were using before just completely
allocated a new copy of each frame every single time a new async frame
was output by the source plugin.  This just creates a cache of frames as
needed for the current format/width/height to minimize the allocation
and deallocation.  If new frames come in that are of a different
format/width/height, it'll just clear the cache.  This is a fairly
important optimization.
2015-01-05 02:10:33 -08:00
jp9000
ae39e5bb77 libobs: Rename some variables for consistency
all the async video related stuff usually started with async_*, and
there were two that didn't.  So I just renamed them so they have the
same naming convention
2015-01-05 02:10:32 -08:00
jp9000
8b065fd068 libobs: Allow disabling of async video texture
If an async video source stops video for whatever reason, it would get
stuck on the last frame that was played.  This was particularly awkward
when I wanted to give the user the ability to deactivate a source such
as a webcam because it would get stuck on the last frame.
2015-01-03 20:47:29 -08:00
jp9000
32ca251bb0 libobs: Add obs_property_set_description
This allows us to change the visible UI name of a property after it's
been created (particularly for a case where I want to change an
'Activate' button to 'Deactivate')
2015-01-03 20:46:18 -08:00
jp9000
e3068ed985 libobs: Add win32 crash handler
A slightly refactored version of R1CH's crash handler, allows crash
handling for windows which provides stack traces of all threads and a
list of all loaded modules.  Also shows the processor, windows version,
and current libobs version.
2015-01-03 02:37:21 -08:00
jp9000
f93b2fe794 Set various thread names
Helps identify which threads are which when debugging
2015-01-03 02:37:20 -08:00
jp9000
144fb925ff libobs: Add ability to set thread names 2015-01-03 02:37:20 -08:00
jp9000
92c154017b libobs: Use def. colorspace when scaling encoder
When the encoder is set to scale to a different resolution than the obs
output resolution, make sure it uses the current video colorspace and
range by default.
2015-01-03 02:37:19 -08:00
jp9000
a87fe6d783 libobs: Add wstrstri function
Performs a case-insensitive search for a wide-character string within
another wide-character string.
2015-01-03 02:37:16 -08:00
jp9000
9a91bbc16c libobs: Make astrstri a bit more C-compliant
I actually kind of hate how strstr returns a non-const even though it
takes a const parameter, but I can understand why they made it that way.
They really should have split it in to two functions though, one const
and one non-const or something.  But alas, ultimately for a C programmer
who knows what they're doing it isn't a huge deal.
2015-01-03 02:37:16 -08:00
jp9000
f2287c8a28 libobs: Add obs_source_set_default_flags
This allows sources to set default flags on creation without interfering
with user set flags
2015-01-03 02:37:15 -08:00
jp9000
eac55edca0 libobs: Add obs_source_showing function
This allows the ability to see whether the source is being displayed
somewhere (though not necessarily active in the main output)
2015-01-03 02:37:15 -08:00
jp9000
fd8f8cfda8 libobs: Fix potential null pointer dereference 2015-01-03 02:37:14 -08:00
jp9000
e14050bbe1 libobs: Fix crash if missing plugin for a source
I forgot that the info variable may be intentionally NULL if a source's
plugin in missing.
2015-01-03 02:37:14 -08:00
jp9000
44b8c24f34 libobs: Add output duplicator support
This adds support for the windows 8+ output duplicator feature which
allows the efficient capturing of a specific monitor connected to the
currently used device.
2015-01-03 02:37:13 -08:00
jp9000
11106c2fce libobs: Redesign/optimize frame encoding handling
Previously, the design for the interaction between the encoder thread
and the graphics thread was that the encoder thread would signal to the
graphics thread when to start drawing each frame.  The original idea
behind this was to prevent mutually cascading stalls of encoding or
graphics rendering (i.e., if rendering took too long, then encoding
would have to catch up, then rendering would have to catch up again, and
so on, cascading upon each other).  The ultimate goal was to prevent
encoding from impacting graphics and vise versa.

However, eventually it was realized that there were some fundamental
flaws with this design.

1. Stray frame duplication.  You could not guarantee that a frame would
   render on time, so sometimes frames would unintentionally be lost if
   there was any sort of minor hiccup or if the thread took too long to
   be scheduled I'm guessing.

2. Frame timing in the rendering thread was less accurate.  The only
   place where frame timing was accurate was in the encoder thread, and
   the graphics thread was at the whim of thread scheduling.  On higher
   end computers it was typically fine, but it was just generally not
   guaranteed that a frame would be rendered when it was supposed to be
   rendered.

So the solution (originally proposed by r1ch and paibox) is to instead
keep the encoding and graphics threads separate as usual, but instead of
the encoder thread controlling the graphics thread, the graphics thread
now controls the encoder thread.  The encoder thread keeps a limited
cache of frames, then the graphics thread copies frames in to the cache
and increments a semaphore to schedule the encoder thread to encode that
data.

In the cache, each frame has an encode counter.  If the frame cache is
full (e.g., the encoder taking too long to return frames), it will not
cache a new frame, but instead will just increment the counter on the
last frame in the cache to schedule that frame to encode again, ensuring
that frames are on time and reducing CPU usage by lowering video
complexity.  If the graphics thread takes too long to render a frame,
then it will add that frame with the count value set to the total amount
of frames that were missed (actual legitimately duplicated frames).

Because the cache gives many frames of breathing room for the encoder to
encode frames, this design helps improve results especially when using
encoding presets that have higher complexity and CPU usage, minimizing
the risk of needlessly skipped or duplicated frames.

I also managed to sneak in what should be a bit of an optimization to
reduce copying of frame data, though how much of an optimization it
ultimately ends up being is debatable.

So to sum it up, this commit increases accuracy of frame timing,
completely removes stray frame duplication, gives better results for
higher complexity encoding presets, and potentially optimizes the frame
pipeline a tiny bit.
2014-12-31 04:03:47 -08:00
jp9000
11dd7912ce libobs: Fix bug with frame output handling
The boolean variables which stored whether frames have been
rendered/downloaded/converted/etc were not being reset when video
restarted, causing frames to not be sent in the correct order whenever
video was reset.  This could lead to minor desync of video/audio.
2014-12-31 04:03:46 -08:00
jp9000
244280335b libobs: Fix potential crash on output stop
In certain circumstances where the output was stopping, and where data
took a long enough time to send (such as when using an encoding preset
that causes high CPU usage), the output would sometimes still send data
even after it was stopped, typically causing the output to crash.
2014-12-31 04:03:45 -08:00
jp9000
8e1549820b libobs/media-io: Add frame copying function 2014-12-31 04:03:45 -08:00
jp9000
5d0551eb27 libobs/media-io: Add #pragma once to video-frame.h 2014-12-31 04:03:44 -08:00
jp9000
caa6251054 libobs: Fix force mono channel count
I unintentionally made it use obs_source::sample_info instead of using
the actual target channel count, which is designated by the OBS output
sampler info.  obs_source::sample_info is actually used to indicate the
currently set sampler information for incoming samples.  So if a source
is outputting 5.1 channel 48khz audio, and OBS is running at stereo
44.1khz, then the obs_source::sample_info value would be set to
5.1/48khz, not the other way around.  It indicates what the source
itself is running at, not what OBS is running at.

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

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

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

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

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

This also adds a new callback to the obs_source_info structure for
transition sources, get_transition_volume, which is called to get the
transitioning volume of a sub-source.
2014-12-28 01:51:43 -08:00
jp9000
10f8988667 libobs: Keep transition reference counter
The reason to keep a reference counter for transitions is due to an
optimization I'm planning on when calculating transition volumes.  I'm
planning on walking the source tree to be able to calculate the current
base volume of a source, but *only* if there are transitions active,
because the only time that the volume can be anything other than 1.0
or 0.0 is when there are active transitions, which may change the base
volume of a source.
2014-12-28 01:04:29 -08:00
jp9000
6eab6ceff5 (API Change) libobs: Add _FLAG to source flags
Changes OBS_SOURCE_UNBUFFERED to OBS_SOURCE_FLAG_UNBUFFERED to make
naming a bit better for source flags.
2014-12-28 01:04:28 -08:00
jp9000
fb09db432f libobs: Save/load source audio sync and flags
When a source is being saved, include the audio sync as well as the
flags.
2014-12-28 01:04:28 -08:00
jp9000
48210d41a6 libobs: Do not set presentation volume on children
When the presentation volume is set for a source, it's set for all of
its children and their children.  The original intention for doing this
was to be able to use it for transitioning, but honestly it's just bad
design, and I feel there are better ways to handle transitioning volume.
2014-12-28 01:04:27 -08:00
jp9000
fb6f8721e2 libobs: Add 'audio_sync' source signal
Adds a signal is called when the sync offset has changed for a source.
2014-12-28 01:04:27 -08:00
jp9000
e29a1fd367 libobs: Prevent infinite source recursion
Changed the design from using obs_source::enum_refs to just simply
preventing infinite source recursion in general, rather than allowing it
through the enum_refs variable.  obs_source_add_child has been changed
so that it now returns a boolean, and if the function fails, it means
that the child cannot be added due to that potential recursion.
2014-12-28 01:04:26 -08:00
jp9000
1ed4c2a920 libobs: Remove unused audio level source vars
These variables are no longer used by sources anymore, as they were
removed in favor of the new source audio control handlers.
2014-12-28 01:04:26 -08:00
jp9000
c72284f387 libobs: Fix a few warnings
Two integers are needlessly converted to floating points for what should
be an integer operation.  One of those floats is then used for another
integer operation later, where the original integer value should have
been used.  So essentially there was an int -> float -> int conversion
going on, which could lead to potential loss of data due to floating
point precision.

There were also some general 64bit -> 32bit conversion warnings.
2014-12-28 01:03:10 -08:00
jp9000
5875434afa libobs: Implement obs_source_active
..Apparently I left this function unimplemented.  This function just
returns whether a source is currently active or not.
2014-12-24 15:55:38 -08:00
jp9000
78c2129f31 libobs: Fix export declaration name
obs_encoder_getdisplayname declaration was not changed to match the
definition (obs_encoder_get_display_name) when the API consistency
update occurred.
2014-12-24 15:55:37 -08:00
Jim
9f3ab85d2b Merge pull request #311 from fryshorts/audio-analyzer-move
libobs: Move audio level calculations
2014-12-21 11:56:02 -08:00
jp9000
1a95004fe8 libobs: Fix bug when SEI not present
If an encoder did not possess any SEI data, it would never send data at
all because the sent_first_packet wasn't set despite the first packet
being sent.
2014-12-21 10:14:23 -08:00
jp9000
9f97b02c32 libobs: Add function to determine AVC keyframes
Added obs_avc_keyframe that returns whether an avc packet is a keyframe
or not.  This function is particularly useful for when writing custom
encoder plugins.
2014-12-21 10:14:22 -08:00
jp9000
f8e56a4e1e libobs: Expose NAL enums in obs-avc.h
I encountered some cases where I needed to use these enumerations
outside of the file, so this allows other modules to use AVC
enumerations without having to redefine them each time.  Especially
useful for custom encoder modules.
2014-12-21 10:14:21 -08:00
jp9000
923916ecce libobs: Use extern "C" on export headers if C++
I neglected to surround some files with extern "C", so if something
written with C++ used the files it would cause function exports to not
be mangled by it correctly.
2014-12-21 10:14:21 -08:00
jp9000
c52406c178 libobs/media-io: Fix recursive lock in video
In certain cases the video thread could end up trying to lock itself
recursively.  This just allows the mutexes to safely be locked
recursively.
2014-12-21 10:14:19 -08:00
jp9000
817a724dea libobs: Add NV12_Reverse shader 2014-12-21 10:14:18 -08:00
jp9000
488cd84f6f libobs: Set version to 0.7.0 2014-12-15 01:55:18 -08:00
jp9000
c88220552f (API Change) libobs: Add bicubic/lanczos scaling
This adds bicubic and lanczos scaling capability to libobs to improve
scaling quality and sharpness when the output resolution has to be
scaled relative to the base resolution.  Bilinear is also available,
although bilinear has rather poor quality and causes scaling to appear
blurry.

If the output resolution is close to the base resolution, then bilinear
is used instead as an optimization, as there's no need to use these
shaders if scaling is not in use.

The Bicubic and Lanczos effects are also exposed via exported function
to allow the ability to use those shaders in plugin modules if desired.

The API change adds a variable 'scale_type' to the obs_video_info
structure that allows the user interface to choose what type of scaling
filter should be used.
2014-12-15 01:55:12 -08:00
fryshorts
73883e6fa8 libobs: Remove volume level signal from obs_source
Remove the calculation of volume levels and the corresponding signal
from obs_source since this is now handled in the volume meter.
Code that is interested in the volume levels can either use the
volmeter provided from obs_audio_controls or use the audio_data signal
to gain access to the raw audio data.
2014-12-14 18:39:54 +01:00
fryshorts
c0e6324278 libobs: Signal own levels in volmeter
Signal updated volume levels when they become available in the volume
meter. The frequency of the updates can be adjusted by setting a
different update interval.
2014-12-14 18:39:54 +01:00
fryshorts
94445ddba2 libobs: Remove audio levels handler from volmeter
Remove the the signal handler for the volume_level signal of audio
sources from the volume meter in anticipation of using the levels
calculated in the volume meter itself.
2014-12-14 18:39:54 +01:00
fryshorts
6e0c1533fc libobs: Add level calculations to volmeter
Use the new audio_data signal from sources to calculate the volume
levels in the volume meter.
2014-12-14 18:39:54 +01:00
fryshorts
63399bbfd8 libobs: Add peak hold property to volmeter
Add a property to the volume meter that specifies the time for which
peak value should be held until it is reset.
2014-12-14 18:39:54 +01:00
fryshorts
e0ce484b81 libobs: Add update interval property to volmeter
Add a property to the volume meter that specifies the length of the
interval in which the audio data should be sampled before the
audio_levels signal is emitted.
2014-12-14 18:39:28 +01:00
fryshorts
984dd53389 libobs: Add data signal to audio sources
This adds a new signal to (audio) sources which is emitted whenever new
audio data is received from the source. This enables other code that is
interested in the raw audio data to directly access it when it becomes
available.
2014-12-13 14:10:45 +01:00
jp9000
b07862286a (API Change) Add colorspace info to obs_video_info
This was an important change because we were originally using an
hard-coded 709/partial range color matrix for the output, which was
causing problems for people wanting to use different formats or color
spaces.  This will now automatically generate the color matrix depending
on the format, color space, and range, or use an identity matrix if the
video format is RGB instead of YUV.
2014-12-11 19:51:30 -08:00
jp9000
59c4731aa6 libobs/media-io: Add colorspace to video info
This is useful for keeping track of what the current colorspace/range is
if a YUV format is being used.
2014-12-11 19:47:51 -08:00
jp9000
a69524a271 libobs: Add obs_property_list_insert_* functions
These functions allow you to insert items at a specific index in a list
instead of being forced to always append to the end.
2014-12-09 14:21:02 -08:00
jp9000
ca8a9fb5a7 libobs: Fix conversion shader D3D display bug
Just for a quick background: D3D's fmod intrinsic is very imprecise.
Naturally floating points aren't precise at all, and when the numbers
you're dealing with become very large, it can often be off by 0.1 or
more.

However, apparently 0.1 isn't enough of an offset to ensure a proper
value when using the fmod intrinsic and then flooring the value.  0.2
seems to fix the issue and make the image display properly.
2014-12-09 14:21:01 -08:00
jp9000
87ac9c91bc libobs: Add flush to video pipeline
On certain GPUs, if you don't flush and the window is minimized it can
endlessly accumulate memory due to what I'm assuming are driver design
flaws (though I can't know for sure).  The flush seems to prevent this
from happening, at least from my tests.  It would be nice if this
weren't necessary.
2014-12-07 23:15:13 -08:00
Jim
fe6622c653 Merge pull request #306 from fryshorts/volume-meter-improvements
Volume meter improvements
2014-12-07 22:51:21 -08:00
fryshorts
014a333807 obs/libobs: Use new volume meter api
This replaces the old code for the audio meter that was using
calculations in two different places with the new audio meter api.
The source signal will now emit simple levels instead of dB values,
in order to avoid dB conversion and calculation in the source.
The GUI on the other hand now expects simple position values from
the volume meter api with no knowledge about dB calculus either.
That way all code that handles those conversions is in one place,
with the option to easily add new mappings that can be used
everywhere.
2014-12-04 21:58:35 +01:00
fryshorts
1b034569f0 libobs: Add Logarithmic fader type
This adds the conversion function used by the old obs based on a
logarithmic scale.
2014-12-04 21:58:35 +01:00
fryshorts
119d77e176 libobs: Add IEC 60-268-18 compliant fader type
This adds a new fader type that implements a position/dB mapping
as specified in IEC 60-268-18.
2014-12-04 21:58:34 +01:00
fryshorts
46686ec556 libobs: Add volume meter object
This adds a volume meter object to libobs that can be used by the GUI
or plugins to convert the raw audio level data from sources to values
that can easily be used to display the audio data.
The volume meter object will use the same mapping functions as the
fader object to map dB levels to a scale.
2014-12-04 21:58:34 +01:00
Nicolas F
486b1082d2 libobs: Use FFmpeg for image loading by default 2014-12-04 15:38:58 +01:00
jp9000
346bcd7e48 libobs: Fix microsoft compiler issue
In older versions of visual studio 2013 microsoft's WORTHLESS C compiler
has a bug where it will, almost at random, not be able to handle having
variables declared in the middle of a function and give the warning:
"illegal use of this type as an expression".  It was fixed in recent
VS2013 updates, but I'm not about to force everyone to update to it.
2014-11-27 11:05:36 -08:00
jp9000
c8dfce886b libobs: Fix warnings assigning values to vec3
Because a vec3 structure can contain a __m128 variable and not the
expected three floats x, y, and z, you must use vec3_set when
setting a value for a vec3 structure to ensure that it uses the proper
intrinsics internally if necessary.
2014-11-27 00:07:49 -08:00
jp9000
8922f2503f libobs: Fix double -> float conversion warning 2014-11-27 00:07:49 -08:00
jp9000
e3e79dcdc5 libobs: Fix windows warnings with C library macro
The macro INFINITY apparently will trigger a warning with microsoft's
compiler despite being a C standard library macro.
2014-11-27 00:07:48 -08:00
jp9000
225f597379 libobs: Add process piping functions
This adds functions for piping a command line program's stdin or stdout.
Note however that this is unidirectional only.

This will be especially useful later on when implementing MP4 output,
because MP4 output has to be piped to prevent unexpected program
termination from corrupting the file.
2014-11-27 00:07:48 -08:00
fryshorts
8dcbd77bf2 libobs: Add audio control functions
This adds a new library of audio control functions mainly for the use in
GUIS. For now it includes an implementation of a software fader that can
be attached to sources in order to easily control the volume.
The fader can translate between fader-position, volume in dB and
multiplier with a configurable mapping function.
Currently only a cubic mapping (mul = fader_pos ^ 3) is included, but
different mappings can easily be added.

Due to libobs saving/restoring the source volume from the multiplier,
the volume levels for existing source will stay the same, and live
changing of the mapping will work without changing the source volume.
2014-11-26 20:07:26 +01:00
jp9000
e994d6d498 graphics: Add gs_effect_loop helper function
This function greatly simplifies the use of effects by making it so you
can call this function in a simple loop.  This reduces boilerplate and
makes drawing with effects much easier.  The gs_effect_loop function
will now automatically handle all the functions required to do drawing.

---------------------
Before:

gs_technique_t *technique = gs_effect_get_technique("technique");

size_t passes = gs_technique_begin(technique);
for (size_t pass = 0; pass < passes; pass++) {
	gs_technique_begin_pass(technique, pass);

	[draw]

	gs_technique_end_pass(technique);
}
gs_technique_end(technique);

---------------------
After:

while (gs_effect_loop(effect, "technique")) {
	[draw]
}
2014-11-19 19:46:27 -08:00
jp9000
cdf36cf8ba Add helper functions for drawing sources
If you look at the previous commits, you'll see I had added
obs_source_draw before.  For custom drawn sources in particular, each
time obs_source_draw was called, it would restart the effect and its
passes for each draw call, which was not optimal.  It should really use
the effect functions for that.  I'll have to add a function to simplify
effect usage.

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

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

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

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

Overall, these feel much more clean to use than the previous iteration.
2014-11-19 19:08:39 -08:00
jp9000
ed2d9936a5 Revert "Add obs_source_draw helper function"
This reverts commit ab5a76901b.
2014-11-19 18:04:38 -08:00
jp9000
8b4120bf7a libobs: Add function to get cur. effect technique 2014-11-19 18:04:38 -08:00
Jim
b3312a7657 Merge pull request #300 from fryshorts/audio-perf
libobs: Replace fmaxf with inline comparison.
2014-11-17 10:27:38 -08:00
jp9000
5888085a8e Allow hex numbers to be used in config data
This allows the 0x* format of hexadecimal integers to be used as config
integers.
2014-11-17 06:47:48 -08:00
jp9000
397dda78f8 Add config_open_string function
This allows opening ini config data from a string.  Before, it was only
possible to load config from a file.
2014-11-17 06:47:48 -08:00
jp9000
ab5a76901b Add obs_source_draw helper function
This function simplifies drawing textures for sources in order to help
reduce boilerplate code.  If a source is a custom drawn source, it will
automatically set up the effect to draw the sprite.  If it's not a
custom drawn source, it will simply draw the sprite as per normal.  If
the source uses a specific color matrix, it will also handle that as
well.
2014-11-17 06:47:47 -08:00
fryshorts
ab0c2cf431 libobs: Replace fmaxf with inline comparison.
This replaces the call to fmaxf with the equivalent inline comparison
which is a bit faster (at least on linux).
2014-11-16 22:07:37 +01:00
Christoph Hohmann
278aa141e3 Fix creating textures from image data with flipping
When the image data is copied into a texture with flipping set to true
each row has to be copied into the (height - row - 1)th row instead of
the row with the same number. Otherwise it will just create an unflipped
copy.
2014-11-15 13:03:04 +01:00
jp9000
391dc0f267 Update to 0.6.4 2014-11-03 14:18:30 -08:00
jp9000
b4c797bc1d Fix asset crash interleaving with active encoders
Apparently the audio isn't guaranteed to start up past the first video
frame, so it would trigger that assert (which I'm glad I put in).  I
didn't originally have this happen when I was testing because my audio
buffering was not at the default value and didn't trigger it to occur.
A blunder on my part, and once again a fine example of how you should
never make assumptions about possible code path.
2014-11-03 14:13:14 -08:00
jp9000
37ffc7b448 Update to 0.6.3 2014-11-02 16:03:51 -08:00
Jim
ed51fd0efd Merge pull request #287 from fryshorts/doxygen
Add Doxygen configuration for creating api documentation
2014-10-29 20:41:05 -07:00
Palana
29e61cc68e Fix OBSRef move assignment not releasing the previous reference 2014-10-29 16:17:07 +01:00
Palana
e16b57b076 Add missing copy/move operations for OBSObj 2014-10-29 16:06:17 +01:00
Palana
572401fd80 Add missing copy/move operations for OBSSignal 2014-10-29 16:05:23 +01:00
Palana
60cc91f9c9 Fix typo in signal handler creation check 2014-10-29 16:05:23 +01:00
jp9000
015bc80edb Add optional source flags
This moves the 'flags' variable from the obs_source_frame structure to
the obs_source structure, and allows user flags to be set for a specific
source.  Having it set on the obs_source_frame structure didn't make
much sense.

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

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

The obs_source_frame should not need to take flags to do this.  This
shouldn't be a setting associated with the frame, but rather a setting
associated with the source itself.  This was the wrong approach to
solving this particular problem.
2014-10-23 10:15:26 -07:00
jp9000
73599b8df6 Fix a major sync bug
This bug would happen if audio packets started being received before
video packets.  It would erroneously cause audio packets to be
completely thrown away, and in certain cases would cause audio and video
to start way out of sync.

My original intention was "don't accept audio until video has started",
but instead mistakenly had the effect of "don't start audio until a
video packet has been received".  This was originally was intended as a
way to handle outputs hooking in to active encoders and compensating
their existing timestamp information.

However, this made me realize that there was a major flaw in the design
for handling this, so I basically rewrote the entire thing.

Now, it does the following steps when inserting packets:

- Insert packets in to the interleaved packet array

- When both audio/video packets are received, prune packets up until the
  point in which both audio/video start at the same time

- Resort the interleaved packet array

I have tested this code extensively and it appears to be working well,
regardless of whether or not the encoders were already active with
another output.
2014-10-22 20:32:50 -07:00
jp9000
661d53067a util: Fix bug with darray_erase_range
Did not multiply the element size for the memory move operation.
2014-10-22 20:32:50 -07:00
jp9000
a07ebf44e6 media-io: Fix repeating video timestamps
In video-io.c, video frames could skip, but what would happen is the
frame's timestamp would repeat for the next frame, giving the next frame
a non-monotonic timestamp, and then jump.  This could mess up syncing
slightly when the frame is finally given to an outputs.
2014-10-22 20:32:49 -07:00
jp9000
e4629978e8 Fix a bug where audio would not restart (outputs)
Apparently I unintentionally typed received_video = false twice instead
of one for video and one for audio.

This fixes a bug where audio would not start up again on an output that
had recently started and then stopped.
2014-10-22 20:32:49 -07:00
jp9000
0f2e4f8e0c Fix bug removing output from its previous encoders
When the output sets a new audio/video encoder, it was not properly
removing itself from the previous audio/video encoders it was associated
with.  It was erroneously removing itself from the encoder parameter
instead.
2014-10-22 20:32:48 -07:00
jp9000
d14dbbc540 Add timestamp circlebuf for video input/output
At the start of each render loop, it would get the timestamp, and then
it would then assign that timestamp to whatever frame was downloaded.
However, the frame that was downloaded was usually occurred a number of
frames ago, so it would assign the wrong timestamp value to that frame.

This fixes that issue by storing the timestamps in a circular buffer.
2014-10-22 20:32:48 -07:00
jp9000
381afe0493 Detect audio time values within OS time thresh.
If audio timestamps are within the operating system timing threshold,
always use those values directly as a timestamp, and do not apply the
regular jump checks and timing adjustments that normally occur.

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

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

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

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

This is partly a convenience feature, and partly a necessity for certain
plugins (such as the linux v4l plugin) where timestamp information for
the video frames can sometimes be unreliable.
2014-10-22 20:32:47 -07:00
jp9000
2c3f9c47d1 Fix a typo ('timetamp') 2014-10-22 20:32:46 -07:00
jp9000
f6d635e586 Change default audio smoothing threshold to 50ms
70 milliseconds is a bit too high for the default audio timestamp
smoothing threshold.  The full range of error thus becomes 140
milliseconds, which is a bit more than necessary to worry about.  For
the time being, I feel it may be worth it to try 50 milliseconds.
2014-10-22 20:32:46 -07:00
fryshorts
a2472592d4 Some documentation improvements to obs-encoder.h 2014-10-19 15:00:07 +02:00
fryshorts
b4a5832ec7 Some documentation improvements to obs-service.h 2014-10-19 15:00:07 +02:00
fryshorts
87586d1cf5 Some documentation improvements in obs-source.h 2014-10-19 15:00:07 +02:00
fryshorts
2eadd445d2 Some documentation improvements in obs-module.h 2014-10-19 15:00:07 +02:00
fryshorts
5524711e54 Some documentation improvements in obs-properties.h
Create a stub for the documentation page.
2014-10-19 15:00:07 +02:00
fryshorts
f0db683d0b Some documentation improvements in obs.h
A stub for the main documentation page was created.
2014-10-19 15:00:07 +02:00
jp9000
54b1d7532b Update to version 0.6.2 2014-10-18 14:13:32 -07:00
Palana
8b93ba1c53 Disable blending for colorspace conversion and subsampling only
This should fix blending issues on stream/recording that weren't visible
in the preview
2014-10-14 17:40:48 +02:00
jp9000
76d538611a Initialize default_rect_effect only with OpenGL
Instead of limiting this to an apple-specific define, just limit it to
OpenGL -- because this particular effect file cannot be used with
Direct3D.
2014-10-14 06:47:25 -07:00
jp9000
69fc9fb7fc Free graphics subsystem if graphics fails to load
The graphics subsystem was not being freed here, for example if a
required effect failed to compile it would still successfully have the
graphics subsystem sans required effect.  The graphics subsystem should
be completely shut down if required libobs effects fail to compile.
2014-10-14 01:44:59 -07:00
jp9000
9eab73ea85 Do not init default_rect effect if not on mac 2014-10-14 01:44:20 -07:00
jp9000
caa32cb6d1 Add support for shared textures to graphics API 2014-10-13 21:56:42 -07:00
jp9000
2e2b4a5e90 Log dropped frame count
This was sorely needed for debugging stream issues.
2014-10-12 19:22:04 -07:00
Palana
4247a7b81e Add media remuxer to media-io 2014-10-12 06:27:33 +02:00
jp9000
964ee75ea0 Update to version 0.6.0 2014-10-11 20:29:17 -07:00
fryshorts
5894054521 Fix small bug in timestamp smoothing for audio sources
Due to a small error in the timestamp smoothing code the timestamp of
audio packages that were too early was always set to the next expected
timestamp, even if the difference was bigger than the smoothing threshold.

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

This should reduce corruption problems with for example the pulseaudio
plugin, which resends data under certain conditions.
2014-10-09 22:25:29 +02:00
jp9000
e78c54e8e5 libobs/media-io: Add more audio debug output 2014-10-06 18:49:53 -04:00
Jim
5af4000110 Merge pull request #274 from reboot/fix_crash_on_video_init_error
Fix crash in obs_get_video_info when video_output_get_info returns NULL
2014-10-05 14:18:04 -07:00
Christoph Hohmann
1abda41c20 Fix crash in obs_get_video_info when video_output_get_info returns NULL 2014-10-05 22:33:53 +02:00
Christoph Hohmann
3e74e96649 Fix calculation of physical memory on linux systems
As stated in the sysinfo manpage the totalram field in the sysinfo
structure is in mem_unit sizes since Linux 2.3.23. To get the actual
memory in the system the totalram value has to be multiplied with the
mem_unit size.
2014-10-05 13:01:19 -07:00
Palana
2edac33c58 libobs/util: Write 0 character when converting empty strings
Fixes log_windows_version logging garbage for build when running with
debug heap enabled (assuming osvi.szCSDVersion is an empty string)
2014-10-04 21:48:08 +02:00
Palana
0f15cc143e Add obs_get_default_rect_effect
This provides a default effect for users of GL_TEXTURE_RECTANGLE/textures
that return true for gs_texture_is_rect
2014-10-03 20:18:01 +02:00
Palana
b99c378e33 Add 'update_properties' signal and obs_source_update_properties call
obs_source_update_properties should be called by sources when property
values change, e.g. a capture device source would use this when it
detects a new capture device (in case its properties contain a list of
available capture devices or similar)
2014-10-01 15:39:57 +02:00
Palana
94a93abb2b (API Change) Pass data to get_properties when possible 2014-10-01 15:39:57 +02:00
Palana
74c4932184 Sort obs_data_items by name
This allows for easier comparison between two obs_data_t and it will make

const char *json1 = obs_data_get_json(data);
obs_data_t *data_ = obs_data_create_from_json(json1);
const char *json2 = obs_data_get_json(data_);

produce the same string in json1 and json2
2014-10-01 15:32:49 +02:00
BtbN
8841ea8a6f cmake: Export plugin data destination 2014-09-27 09:41:32 -07:00
BtbN
599febcb54 cmake: Replace FFMpeg modules with single module
Now using components instead of one find_package call per module
2014-09-27 09:41:13 -07:00
BtbN
9dd341a3ed cmake: Properly check for Threading support 2014-09-26 22:52:30 -07:00
jp9000
41fad2d1a4 (API Change) Use const params where applicable
This Fixes a minor flaw with the API where data had to always be mutable
to be usable by the API.

Functions that do not modify the fundamental underlying data of a
structure should be marked as constant, both for safety and to signify
that the parameter is input only and will not be modified by the
function using it.
2014-09-26 17:23:07 -07:00
jp9000
05ac1aea2c Do not modify gs_init_data parameter in gs_create 2014-09-26 16:31:20 -07:00
jp9000
05f89f48ea Ensure num_backbuffers > 0 in gs_swapchain_create 2014-09-26 16:31:20 -07:00
GoaLitiuM
10f5d7f3aa Fixed NULL pointer dereferencing in linked lists 2014-09-27 01:35:36 +03:00
jp9000
c9df41c1e2 (API Change) Remove pointers from all typedefs
Typedef pointers are unsafe.  If you do:
typedef struct bla *bla_t;
then you cannot use it as a constant, such as: const bla_t, because
that constant will be to the pointer itself rather than to the
underlying data.  I admit this was a fundamental mistake that must
be corrected.

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

This does not break ABI though, which is pretty nice.
2014-09-25 21:48:11 -07:00
jp9000
732d24caa1 Remove unused variables 2014-09-19 18:46:25 -07:00