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

172 Commits

Author SHA1 Message Date
jp9000
f0164f9d28 libobs: Do not signal reorder while scene mutex locked
Prevents a potential race condition with the scene mutex.
2018-06-03 15:04:39 -07:00
jp9000
ff52d34027 libobs: Defer and refactor scene item transform update
Defers updating the scene item transform to the graphics thread to
reduce the number of transform update calls.
2018-06-03 15:04:39 -07:00
jp9000
7a2337c1f2 libobs: Refactor item signaling (add func to signal parent) 2018-06-03 15:04:39 -07:00
jp9000
a1012c3f2c libobs: Do not draw item texture if source size 0 2018-06-03 15:04:39 -07:00
jp9000
b3dfd7ef80 libobs: Fix bug where cropped items would recalc transform
Fixes a bug where items that had cropping would recalculate transform
every frame.  obs_scene_item::last_width and obs_scene_item::last_height
would be set to the cropped sizes rather than the source's actual size.
2018-06-03 15:04:38 -07:00
jp9000
df88140e6a libobs: Zero scene data instead of setting members manually 2018-06-03 15:04:38 -07:00
jp9000
10fc206f98 libobs: Refactor obs_scene_add to allow adding internally
Allows using obs_scene_add_internal to add without sending signals.
2018-06-03 07:24:59 -07:00
jp9000
a79992eae9 libobs: Fix audio issue with scene items
When a scene is added as a scene item with the same audio sources that
are already in the current scene, it would cause the current scene to no
longer output audio due to audio.

To replicate the issue, you would create two separate audio device
captures in scene 1, use add existing in scene 2 and add one of those
audio sources, then go back to scene 1, add scene 2 as a source, then
make scene 1 invisible.
2018-01-09 18:13:32 -08:00
SuslikV
c706742097 libobs: Fix scene filter duplication
Scene filters were not being copied when a scene was duplicated with
obs_scene_duplicate.

Closes jp9000/obs-studio#1104
2018-01-04 20:36:11 -08:00
jp9000
e70b226e7e libobs: Duplicate private scene/source settings
Ensures that private settings data is also duplicated when a scene or a
source is duplicated.
2017-11-30 05:05:06 -08:00
jp9000
2ef00ecec4 libobs: Add private settings to scene items/sources
Allows setting and sharing of user data for sources and scene items.
2017-09-13 21:17:44 -07:00
SuslikV
650495331d libobs: Add default hotkey id to duplicated item
Fixes https://obsproject.com/mantis/view.php?id=508

The toggle_visibility set only by init_hotkeys() call, but used each
time in obs_sceneitem_destroy() call.  Because zero hotkey_pair_id is
valid - we need to set item property other than zero here.

Closes jp9000/obs-studio#1000
2017-08-11 08:41:22 -07:00
Dmitry Odintsov
2a53d03d5f libobs: Fix item copying during scene duplication
When item in the old scene had only Scale Filter, texture renderer
was not created for an item in the new scene. However if the item also
had Crop set, the texture renderer was created.

Now after copying the data, texture renderer is created for the item in
the new scene when needed.

Closes jp9000/obs-studio#969
2017-07-21 08:48:05 -07:00
Michael Fabian Dirks
f8b14bdb46 libobs: Ensure scene items don't have pre-multiplied alpha
Scene items would incorrectly have pre-multiplied alpha when they were
scaled with different scale filtering, when they were cropped, or when
the item itself was a scene.  This happens because the scene renders the
items to a texture in those cases, and when they are rendered to a
texture the blend function would be the default srcalpha/invsrcalpha
blend function, which would cause alpha to become pre-multiplied in the
texture's result rather than straight alpha.

This changes the behavior to directly copy the color/alpha to the
texture using the one/zero blend function instead, which makes the
resulting texture straight alpha.  (Note that you do not want to turn
off the blend mode for the same result because certain sources can have
custom drawing that may rely on blending being available)

Related Issue: https://obsproject.com/mantis/view.php?id=954

Closes jp9000/obs-studio#966
2017-07-21 08:30:14 -07:00
cg2121
fce078d997 UI, libobs: Add ability to lock individual scene items
Adds a lock checkbox to allow the user to lock a specific scene item.

Closes jp9000/obs-studio#949
2017-06-27 10:27:57 -07:00
jp9000
2c74fc36e2 libobs: Add scene item IDs
Adds a method of uniquely identifying scene items, as well as finding
those scene items via that unique ID.
2017-05-15 00:18:18 -07:00
jp9000
a5828610bb libobs: Fix bug where scenes would not properly mix audio 2017-02-26 08:20:54 -08:00
Richard Stanway
8b640fae24
Fix various null pointer issues detected by Coverity 2017-02-25 16:45:45 +01:00
jp9000
b1707b18b2 libobs: Add callback for enumerating all scene children
Prevents infinite recursion when adding children to a scene.
2017-01-16 09:55:15 -08:00
jp9000
3f976bec8b libobs: Fix scale filtering bug when duplicating scenes
When duplicating scenes, scene item scale filtering options would not be
preserved.
2017-01-15 09:15:44 -08:00
jp9000
e71137534c libobs: Process all scene audio actions if no audio playing
When there are audio sources in a scene and they've all stopped playing
their audio (audio is pending), all scene item audio actions (volume
changes, toggling visibility) will perpetually buffer and no longer be
processed until audio plays again.

So instead of that, if all audio sources have stopped playing in the
scene, just process all pending scene item audio actions immediately to
prevent them from never being processed while waiting for a scene item
to start playing audio.
2016-12-22 00:31:11 -08:00
jp9000
5fb9dcbaa7 libobs: Fix possible null pointer dereference 2016-07-09 07:41:13 -07:00
jp9000
4d61fa9a4c libobs: Use item texture if scene item is scene
Allows rendering scenes as scene items without off-screen sub-source of
the scene popping out on the sides.
2016-07-01 15:21:12 -07:00
jp9000
364cb9fb03 libobs: Use strings instead of enums when saving scale data
Saves the scene item scale filters as strings instead of enums.  It's
important to save data in a form that won't break if an API enum
changes.
2016-06-29 08:19:23 -07:00
jp9000
d49833830c libobs: Add ability to use scale filters on scene items
Allows the ability to use scale filters such as point, bicubic, lanczos
on specific scene items, disabled by default.  When using one of the
latter two options, if the item's scale is under half of the source's
original size, it uses the bilinear low resolution downscale shader
instead.
2016-06-29 08:00:54 -07:00
jp9000
acd8b612ee libobs: Reset projection transform when cropping
The crop texture would not always render correctly because the
projection matrix had not been set.
2016-03-31 11:01:29 -07:00
jp9000
eb1ee87f38 libobs: Add functions to crop individual scene items
Renders the scene item to a texture if crop is enabled; otherwise
renders directly.
2016-03-30 18:59:36 -07:00
jp9000
0d7a969ebf libobs: Add functions to defer scene item update
Allows the ability to defer updating the item transform until all
functions have been executed.
2016-03-30 18:35:59 -07:00
jp9000
f3df14374f libobs: Fix obs_scene_duplicate excluding rotatation 2016-02-04 10:10:53 -08:00
jp9000
6f98bd9fed libobs: Use calldata with stack for simple signals
Makes signals use stack memory rather than allocate memory each time.
Most likely a completely insignificant and pointless optimization.
2016-01-26 11:49:56 -08:00
jp9000
91ebb5c5e0 libobs: Add comment warning about scene mutex lock ordering
A comment that serves as a reminder to anyone who might need to edit the
scene code.  If the graphics mutex must be locked, it must be locked
first before entering the scene mutexes, or outside of the scene
mutexes.
2016-01-26 11:49:55 -08:00
jp9000
a61933dd8e (API Change) libobs: Add 'type' to obs_scene_duplicate
(Note: This commit also modifies the UI)

Allows the ability to duplicate sources fully copied, and/or have the
scene and its duplicates be private sources
2016-01-26 11:49:52 -08:00
jp9000
6824910f5d libobs: Add obs_scene_create_private function
Creates a scene marked as a private source
2016-01-26 11:49:52 -08:00
jp9000
234cb5802f libobs: Release scene items outside of scene mutexes
Prevents a mutual lock with the scene mutex and graphics mutex.  In
libobs/obs-video.c, the graphics mutex could be locked first, then the
scene mutexes second, while in the UI thread, the scene mutexes could be
locked first, then when a scene item is being destroyed, a source could
be destroyed, and sometimes sources would lock the graphics mutex
second.

A possible additional solution is to defer source destroys to the video
thread.
2016-01-26 11:49:41 -08:00
jp9000
ed10b1ab57 libobs: Allow add_alignment to be used by other source files 2016-01-26 11:49:40 -08:00
jp9000
e68331e988 libobs: Add source type OBS_SOURCE_TYPE_SCENE
Helps identify a scene without having to compare its type name to
"scene".
2016-01-26 11:49:38 -08:00
jp9000
b0104fcee0 (API Change) libobs: Remove source_type param from functions
(Note: test and UI are also modified by this commit)

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

Removes the "type" parameter from these functions.  The "type" parameter
really doesn't serve much of a purpose being a parameter in any of these
cases, the type is just to indicate what it's used for.
2016-01-26 11:49:37 -08:00
jp9000
3c68196c5c libobs: Buffer scene item visibility actions
This buffers scene item visibility actions so that if
obs_sceneitem_set_visible to true or false, that it will ensure that the
action is mapped to the exact sample point time in which
obs_sceneitem_set_visible is called.  Mapping to the exact sample point
isn't necessary, but it's a nice thing to have.
2016-01-26 11:49:36 -08:00
jp9000
247a42c2a1 libobs: Make scenes mix audio of sub-sources
Mark scenes as composite sources and use audio_render to mix and output
the audio of their sub-sources.
2016-01-26 11:49:35 -08:00
jp9000
40d6f986e6 libobs: Split scene mutex to improve performance
Splits the scene mutex in to an audio/video mutex to allow video/audio
thread to use the same data at the same time without locking on each
other.
2016-01-26 11:49:34 -08:00
jp9000
5be855e852 libobs: Make scene item visibility activate/deactivate
Before if a source was set to invisible it would still be considered
active.  This changes it so that the source is deactivated when the
source is invisible to reduce needless resource usage or capturing.
2015-12-22 05:49:03 -08:00
jp9000
c8f4fbe42b (API Change) libobs: Rename funcs relating to active child sources
Renames:
----------------------------------------
obs_source_add_child
obs_source_remove_child
obs_source_enum_sources
obs_source_enum_tree
obs_source_info::enum_sources

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

These functions/callbacks had misleading names: they originally implied
any child sources, when they actually meant active child sources that
are being used to render video or audio.  It's important that the
function names represent their actual purpose.
2015-12-22 05:49:02 -08:00
jp9000
19969a27d5 libobs: Remove TODO (not used) 2015-12-15 01:11:08 -08:00
jp9000
6285a47726 (API Change) libobs: Pass type data to get_name callbacks
API changed from:
obs_source_info::get_name(void)
obs_output_info::get_name(void)
obs_encoder_info::get_name(void)
obs_service_info::get_name(void)

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

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

NOTE: Though a parameter was added, this is backward-compatible with
older plugins due to calling convention.  The new parameter will simply
be ignored by older plugins, and the stack (if used) will be cleaned up
by the caller.
2015-09-16 09:21:12 -07:00
jp9000
ba718e94b5 libobs: Add function to duplicate scenes 2015-08-28 15:01: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
Palana
23a2228142 libobs: Add scene item 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
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
0d8ae565f2 libobs: Add API to hide/show scene items 2015-03-25 10:03:16 -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
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
Socapex
753959170b libobs: Fix bug (last scene item potentially lost) 2015-03-01 17:43:31 -08: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
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
41fad2d1a4 (API Change) Use const params where applicable
This Fixes a minor flaw with the API where data had to always be mutable
to be usable by the API.

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

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

This does not break ABI though, which is pretty nice.
2014-09-25 21:48:11 -07:00
jp9000
5780f3f177 (API Change) Improve graphics API consistency
Summary:
- Prefix all graphics subsystem names with gs_ or GS_
- Unsquish funciton names (for example _setfloat to _set_float)
- Changed create functions to be more consistent with the rest of the
  API elsewhere.  For exmaple, instead of
  gs_create_texture/gs_texture_destroy, it's now
  gs_texture_create/gs_texture_destroy
- Renamed gs_stencil_op enum to gs_stencil_op_type

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

Previous names:             New names:
-----------------------------------------------------------
obs_audio                   obs_get_audio
obs_video                   obs_get_video
obs_signalhandler           obs_get_signal_handler
obs_prochandler             obs_get_proc_handler
obs_source_signalhandler    obs_source_get_signal_handler
obs_source_prochandler      obs_source_get_proc_handler
obs_output_signalhandler    obs_output_get_signal_handler
obs_output_prochandler      obs_output_get_proc_handler
obs_service_signalhandler   obs_service_get_signal_handler
obs_service_prochandler     obs_service_get_proc_handler
2014-08-08 11:04:46 -07:00
jp9000
73baaa59e9 (API Change) Unsquish libobs (base) names
Previous names:             New names:
-----------------------------------------------------------
obs_view_setsource          obs_view_set_source
obs_view_getsource          obs_view_get_source
obs_source_getdisplayname   obs_source_get_display_name
obs_source_getwidth         obs_source_get_width
obs_source_getheight        obs_source_get_height
obs_filter_getparent        obs_filter_get_parent
obs_filter_gettarget        obs_filter_get_target
obs_source_filter_setorder  obs_source_filter_set_order
obs_source_getsettings      obs_source_get_settings
obs_source_getname          obs_source_get_name
obs_source_setname          obs_source_set_name
obs_source_setvolume        obs_source_set_volume
obs_source_getvolume        obs_source_get_volume
obs_scene_getsource         obs_scene_get_source
obs_scene_fromsource        obs_scene_from_source
obs_scene_findsource        obs_scene_find_source
obs_output_getdisplayname   obs_output_get_display_name
obs_output_getname          obs_output_get_name
obs_encoder_getname         obs_encoder_get_name
obs_service_getdisplayname  obs_service_get_display_name
obs_service_getname         obs_service_get_name
2014-08-08 11:04:46 -07:00
jp9000
b007c6b139 (API Change) Un-squish obs_sceneitem_*
Renamed:                         To:
-----------------------------------------------------------
obs_sceneitem_getscene           obs_sceneitem_get_scene
obs_sceneitem_getsource          obs_sceneitem_get_source
obs_sceneitem_setpos             obs_sceneitem_set_pos
obs_sceneitem_setrot             obs_sceneitem_set_rot
obs_sceneitem_setscale           obs_sceneitem_set_scale
obs_sceneitem_setalignment       obs_sceneitem_set_alignment
obs_sceneitem_setorder           obs_sceneitem_set_order
obs_sceneitem_getpos             obs_sceneitem_get_pos
obs_sceneitem_getrot             obs_sceneitem_get_rot
obs_sceneitem_getscale           obs_sceneitem_get_scale
obs_sceneitem_getalignment       obs_sceneitem_get_alignment
2014-08-08 11:04:45 -07:00
jp9000
d2b4f82637 (API Change) Rename order_movement
Prefix with obs_ for the sake of consistency

Renamed enums:
- order_movement (now obs_order_movement)

Affected functions:
- obs_source_filter_setorder
- obs_sceneitem_setorder
2014-08-08 11:04:43 -07:00
jp9000
24bd82a09c (API Change) Rename obs_sceneitem_info structure
Change obs_sceneitem_info structure to obs_transform_info - this
structure will not just be used with scene items in the future.
2014-08-08 11:04:42 -07:00
jp9000
3af33e11b7 Fix 'potentially uninitialized' warning on var 2014-06-27 21:37:40 -07:00
jp9000
0b4a259e56 Remove 'locale' parameter from all callbacks
The locale parameter was a mistake, because it puts extra needless
burden upon the module developer to have to handle this variable for
each and every single callback function.  The parameter is being removed
in favor of a single centralized module callback function that
specifically updates locale information for a module only when needed.
2014-06-25 12:36:26 -07:00
jp9000
ed5b4f590c Fix a number of warnings
Structures with anonymous unions would a warning when you do a brace
assignment on them.

Also fixed some unused parameters and removed some unused variables.
2014-06-16 17:55:48 -07:00
jp9000
452e0695f4 UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating).  I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.

I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.

There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.

If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply).  If
bounds are active, it will modify the bounding box only instead.

How a source scales when a bounding box is active depends on the type of
bounds being used.  You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.

Like in OBS1, objects will snap to the edges unless the control key is
pressed.  However, this will now happen even if the object is rotated or
oriented in any strange way.  Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 20:33:13 -07:00
jp9000
b23f8cc6e1 Scenes: Implement more item positioning features
There are a ridiculous number of features related to scaling and
positioning due to requests by a number of people who complained that
they hated the way that OBS1 would always resize their sources when the
source's base size changed.  There were also people who wanted more
control for how the resizing was handled, or the ability to completely
prevent resizing entirely if desired.  So I made it so that you can
optionally use a 'bounds' system, which allows you to specify different
styles of controlling resizing.

If disabled, the source will always automatically resize and only the
base scale is applied.  If enabled, you have a variety of different ways
to limit/control how it can resize within the bounds, or make it so it
can't resize at all.  You can also control alignment within that
bounding box, so you can make it so that a source always aligns to a
side or corner of the box.

I also added an alignment value which changes how the source is oriented
relative to the position of the scene item.  For example, setting
bottom-right alignment will make it so that the position of the item is
the bottom right corner of the source.  When the source resizies, it
will resize leftward and upward in that case, which solves the problem
of how a source resizes relative to a desired position.
2014-06-15 20:33:13 -07:00
jp9000
999d8ee916 Add ability to move source up/down/etc 2014-05-15 17:40:53 -07:00
jp9000
7114f65d18 Fix a few warnings 2014-04-28 00:15:26 -07:00
jp9000
65455c27be Add preliminary saving/loading of scene/sources
This saves scenes/sources from json on exit, and properly loads it back
up when starting up the program again, as well as the currently active
scene.

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

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

I also had to adjust the obs_scene code so that it's a regular input
source type now, and I also modified it so that it doesn't have some
strange custom creation code anymore.  The obs_scene_create function is
now simply just a wrapper for obs_source_create.  You could even create
a scene with obs_source_create manually as well.
2014-04-26 23:47:50 -07:00
jp9000
4a6d19f206 libobs: Add services API, reduce repeated code
Add API for streaming services.  The services API simplifies the
creation of custom service features and user interface.

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

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

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

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

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

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

I also switched to using linked lists for the global object lists,
rather than using an array of pointers (you could say it was..
pointless.)  ..Anyway, the linked list info is also stored in the shared
context data structure.
2014-04-19 20:38:53 -07:00
Palana
3990c18aac Add NULL checks and assertions to fix clang static analysis problems
Also remove an unused variable from obs-encoder.c (via clang static
analysis)
2014-04-14 23:02:53 +02:00
jp9000
154e0c59e1 Use atomic functions where appropriate
Also, rename atomic functions to be consistent with the rest of the
platform/threading functions, and move atomic functions to threading*
files rather than platform* files
2014-03-16 18:26:46 -07:00
jp9000
5288467aeb Ensure names are valid
Ensure that a source has a valid name.  Duplicates aren't a big deal
internally, but sources without a name are probably something that
should be avoided.  Made is so that if a source is programmatically
created without a name, it's assigned an index based name.

In the main basic-mode window, made it check to make sure the name was
valid as well.
2014-03-10 13:39:51 -07:00
jp9000
9c6da6f52d Split output/input audio capture sources
- Split input and output audio captures so that they're different
   sources.  This allows easier handling and enumeration of audio
   devices without having to do some sort of string processing.

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

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

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

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

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

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

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

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

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

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

LOG_WARNING should be used in places where it's not entirely unexpected,
is recoverable, and doesn't really affect the user/application.
2014-02-28 20:02:29 -07:00
jp9000
268e4e7811 Add more checks for NULL pointers 2014-02-23 22:39:33 -07:00
jp9000
096cce9a86 Rename scene signals
the signals for scenes could have potentially conflicted with default
source signals.  "remove" should be used for source removal, for
example.  Changed the scene signals to "item-add" and "item-remove" for
its items.
2014-02-23 18:58:01 -07:00
jp9000
be81276f03 Implement volume handling
- Remove obs_source::type because it became redundant now that the
   type is always stored in the obs_source::info variable.

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

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

   * obs_transition_begin_frame
   * obs_source_set_transition_vol
   * obs_transition_end_frame

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

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

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

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

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

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

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

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

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

Also, fixed the main window so it properly selects a source when the
current active scene has been changed.
2014-02-20 22:04:14 -07:00
jp9000
14c95ac421 Add functions to enumerate source children/tree 2014-02-20 17:44:42 -07:00
jp9000
966b943d5b Remove majority of warnings
There were a *lot* of warnings, managed to remove most of them.

Also, put warning flags before C_FLAGS and CXX_FLAGS, rather than after,
as -Wall -Wextra was overwriting flags that came before it.
2014-02-14 15:13:36 -07:00
jp9000
8e81d8be56 Revamp API and start using doxygen
The API used to be designed in such a way to where it would expect
exports for each individual source/output/encoder/etc.  You would export
functions for each and it would automatically load those functions based
on a specific naming scheme from the module.

The idea behind this was that I wanted to limit the usage of structures
in the API so only functions could be used.  It was an interesting idea
in theory, but this idea turned out to be flawed in a number of ways:

 1.) Requiring exports to create sources/outputs/encoders/etc meant that
     you could not create them by any other means, which meant that
     things like faruton's .net plugin would become difficult.

 2.) Export function declarations could not be checked, therefore if you
     created a function with the wrong parameters and parameter types,
     the compiler wouldn't know how to check for that.

 3.) Required overly complex load functions in libobs just to handle it.
     It makes much more sense to just have a load function that you call
     manually.  Complexity is the bane of all good programs.

 4.) It required that you have functions of specific names, which looked
     and felt somewhat unsightly.

So, to fix these issues, I replaced it with a more commonly used API
scheme, seen commonly in places like kernels and typical C libraries
with abstraction.  You simply create a structure that contains the
callback definitions, and you pass it to a function to register that
definition (such as obs_register_source), which you call in the
obs_module_load of the module.

It will also automatically check the structure size and ensure that it
only loads the required values if the structure happened to add new
values in an API change.

The "main" source file for each module must include obs-module.h, and
must use OBS_DECLARE_MODULE() within that source file.

Also, started writing some doxygen documentation in to the main library
headers.  Will add more detailed documentation as I go.
2014-02-12 08:04:50 -07:00
jp9000
b067440f73 Use bzalloc instead of bmalloc then memset
Reduces needless code repetition and still allows for proper memory
alignment.  Cleans up the code a bit.
2014-02-09 12:34:07 -07:00
Palana
ac23df500a Remove external ref count visibility
The returned ref count was never used and the returned value doesn't
actually confer any meaning in a multithreaded environment
2014-02-03 02:34:06 +01:00
jp9000
37ed83acec Use QMetaObject::invokeMethod in libobs callbacks
Doing this ensures Qt thread safety when adding/removing sources and
scenes, because it will defer the function call to the main thread.
2014-02-02 17:03:55 -07:00
jp9000
6e1dd92f0c Improve thread safety in UI code
- Implemented better C++ classes for handling scenes/sources/items in
  obs.hpp, allowing them to automatically increment and decrement the
  references of each, as well as assign them to QVariants.

- Because QVariants are now using the C++ classes, remove the pointer
  QVariant wrapper.

- Use the new C++ classes with the QVariant user data of list box items,
  both for the sake of thread safety and to ensure that the data
  referenced is not freed until removed.  NOTE: still might need some
  testing.

- Implemented a source-remove signal from libobs, and start using that
  signal instead of the source-destroy signal for signalling item
  removal.
2014-02-02 14:26:23 -07:00
jp9000
74032922bc Fix another bug (don't commit without compiling)
Also don't code in anger
2014-01-30 12:42:20 -07:00
jp9000
73d4e1331c And cover the one in scene_destroy 2014-01-30 12:41:11 -07:00
jp9000
7b37dc6cbb Oh and while we're at it I suppose another fix 2014-01-30 12:39:26 -07:00
jp9000
f26cb706c2 Clean up the previous commit a bit
The was_removed variable was rather unnecessary
2014-01-30 12:35:21 -07:00
jp9000
f2e1ce533c Use mutex instead of variable for RC check 2014-01-30 12:29:13 -07:00
jp9000
103ef75310 Improve thread safety for scene items
Scene items previously were removed by calling obs_sceneitem_destroy,
but this proved to be a potential race condition where two different
threads could try to destroy the same scene item at the same time.

Instead of doing that, reference counting is now used on scene items,
and an explicit obs_sceneitem_remove function is used instead for item
removal, which sets a 'removed' variable to ensure it can only be called
exactly one time.
2014-01-30 01:31:52 -07:00