Commit graph

45 commits

Author SHA1 Message Date
derrod 94d158c425 libobs: Add functions to serialize JSON with default values 2024-05-25 17:29:28 -07:00
Norihiro Kamae 40562ff47e libobs: Expose obs_data_set_autoselect_array 2023-11-10 02:10:43 -06:00
Lain 106c7aa61f Update copyrights/names 2023-05-20 01:31:18 -07:00
derrod 4b062a7147 libobs: Add functions for getting/saving pretty JSON 2023-03-10 23:55:42 +01:00
jp9000 74c2379eba libobs: Add obs_data_get_last_json()
Helper function to return the last generated json string for this
object.
2021-04-23 12:38:50 -07:00
Ford Smith 31e5d2e5e3 libobs: Implement obs_data_get_defaults
Implements obs_data_get_defaults and updates the documentation. This is
supposed to allow someone to access all the defaults of an object.
Should help in cases where the full data is needed, and not just the
currently set.
2021-03-22 15:44:56 -04:00
jp9000 f53df7da64 clang-format: Apply formatting
Code submissions have continually suffered from formatting
inconsistencies that constantly have to be addressed.  Using
clang-format simplifies this by making code formatting more consistent,
and allows automation of the code formatting so that maintainers can
focus more on the code itself instead of code formatting.
2019-06-23 23:49:10 -07:00
jp9000 2329c6f6ea libobs: Add obs_data_array_push_back_array
Allows easily/safely appending all the values of one data array to
another.
2018-07-15 17:09:02 -07:00
jp9000 f60952fe09 libobs: Add obs_data_item_get_name function
Allows getting the name of a data sub-item.
2016-06-28 02:52:15 -07:00
Palana 0b3fcb8b6e libobs: Add obs_data wrappers for media_frames_per_second 2015-11-14 15:37:59 +01:00
jp9000 e479d4d0dc libobs: Add obs_data funcs for safe file handling
obs_data_create_from_json_file_safe: Attempts to create an obs_data
object from a file, and if that fails and a backup file exists, deletes
the old file and tries to open it again.

obs_data_save_json_safe: Saves json data to a temporary file first,
optionally backs up the target file if the file exists and backup_ext is
valid (otherwise deletes it), and then renames the temporary file to the
target file.  This helps reduce the chance of json corruption on save.
2015-08-21 18:22:24 -07:00
jp9000 40988f7e1d libobs: Add obs_data_save_json function
We keep having to repeat code for saving the json data to a file, so add
a helper function to help clean up some of that code.
2015-08-21 17:47:13 -07:00
jp9000 d53cef47ac libobs: Add obs_data_create_from_json_file func
Just a little helper function that allows you to create an obs_data_t
object from a json file (rather than having to manually open it each
time and then call obs_data_create_from_json on the file data)
2015-08-16 06:43:43 -07:00
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 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 7608f77e8b (API Change) Rename autoselect/default functions
For the sake of consistency, renamed these two functions to include
_value at the end so they are consistent.

Renamed:                         To:
-------------------------------------------------------
obs_data_has_default             obs_data_has_default_value
obs_data_has_autoselect          obs_data_has_autoselect_value
obs_data_item_has_default        obs_data_item_has_default_value
obs_data_item_has_autoselect     obs_data_item_has_autoselect_value
2014-08-09 14:36: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
Palana c2bb95250b Add obs-data autoselect functions
These are meant to reflect auto-detection configuration changes that
should not be written to the config, for example, frame rate changes
for a camera where the (user-/config-file-)configured frame rate isn't
available but a similar frame rate can be automatically chosen
2014-06-22 01:32:09 +02:00
Palana 7f172eb1b4 Change semantics of obs-data default values
Default values are now permanently stored in the obs_data_items and
can be accessed via the new get_default functions

Also default values are no longer serialized to JSON to ease transition
to new default values
2014-06-22 01:32:09 +02:00
jp9000 89df81e72d libobs: Add helper functions for math data 2014-06-14 23:57:00 -07:00
jp9000 7114f65d18 Fix a few warnings 2014-04-28 00:15:26 -07:00
jp9000 21b67d007b Add helper functions to obs_data and fix bug
Add math helpers to the obs_data functions for vec2/3/4 and quat, and
fix a bug where it wouldn't load arrays from json
2014-04-26 23:45:41 -07:00
jp9000 291d9961cd obs-data: Internally store as int or double
If integers are used, then store as integers.  If doubles are used, then
store as doubles.  This way precision issues are prevented.
2014-03-16 20:38:13 -07:00
jp9000 7fcec77351 For *_update, apply settings instead of replacing
Make it so obs_data settings input in to *_update are applied to the
existing settings rather than fully replace the existing settings.  That
way you can update with only certain specific settings, leaving other
settings untouched.  Of course if you're already using the original
settings pointer in the first place then you've already done that, so
it'll just ignore it because you've already applied them.
2014-02-21 21:05:21 -07:00
Palana a2cd42abf0 Remove external ref count visibilty from obs_data_* as well 2014-02-03 05:39:25 +01:00
jp9000 9116be8d9c Improve safety for settings usage
- Add 'set_default' functions to obs-data.*.  These functions ensure
  that a paramter exists and that the parameter is of a specific type.
  If not, it will create or overwrite the value with the default setting
  instead.

  These functions are meant to be explicitly called before using any of
  the 'get' functions.  The reason why it was designed this way is to
  encourage defaults to be set in a single place/function.

  For example, ideal usage is to create one function for your data,
  "set_my_defaults(obs_data_t data)", set all the default values within
  that function, and then call that function on create/update, that way
  all defaults are centralized to a single place.

- Ensure that data passed to sources/encoders/outputs/etc is always
  valid, and not a null value.

- While I'm remembering, fix a few defaults of the main program config
  file data.
2014-01-28 18:41:24 -07:00
jp9000 c6300d0956 Add a couple more setting data safety measures
Prevent null dereferencing if data is null, instead just make the
functions return and ignore the get/set requests.
2014-01-28 15:45:30 -07:00
jp9000 6c44291693 Implement settings interface for plugins
Add a fairly easy to use settings interface that can be passed to
plugins, and replaced the old character string system that was being
used before.  The new data interface allows for an easier method of
getting/altering settings for plugins, and is built to be serializable
to/from JSON.

Also, removed another wxFormBuilder file that was no longer in use.
2014-01-27 23:14:58 -07:00
jp9000 563613db8f Rename obs-data.h to obs-internal.h
Renaming obs-data.h to avoid confusion about its usage
2014-01-26 18:48:14 -07:00
jp9000 4cba9d336a Fix render issues with main preview widget
- I seem to have fixed ths issues with the main preview widget.  It
   seems you just need to set the right window attributes to stop it from
   breaking.  Though when opengl is enabled, there appears to be a weird
   background glitch in the Qt stuff -- I'm not entirely sure what's
   going on.  Bug in Qt?

   Also fixed the layout issues, and the widget now properly resizes and
   centers in to its parent widget.

 - Prevent the render loop from accessing data if the data isn't valid.
   Because obs->data is freed before the graphics stuff, it can cause
   the graphics to keep trying to query the obs->data.displays_mutex
   after it had already been destroyed.
2014-01-23 17:00:42 -07:00
jp9000 8d63845dd4 Use macros to improve safety loading callbacks
Just a minor fix mostly because I noticed that I kept accidentally
forgetting to add checks to the code properly.  This is one of those
cases where macros come in useful, as macros can automate the process
and help prevent these mistakes from happening by accident.
2014-01-17 06:24:34 -07:00
jp9000 29b7d3621c Add preliminary output/encoder interface
- First, I redid the output interface for libobs.  I feel like it's
  going in a pretty good direction in terms of design.

  Right now, the design is so that outputs and encoders are separate.
  One or more outputs can connect to a specific encoder to receive its
  data, or the output can connect directly to raw data from libobs
  output itself, if the output doesn't want to use a designated encoder.
  Data is received via callbacks set when you connect to the encoder or
  raw output.  Multiple outputs can receive the data from a single
  encoder context if need be (such as for streaming to multiple channels
  at once, and/or recording with the same data).

  When an encoder is first connected to, it will connect to raw output,
  and start encoding.  Additional connections will receive that same
  data being encoded as well after that.  When the last encoder has
  disconnected, it will stop encoding.  If for some reason the encoder
  needs to stop, it will use the callback with NULL to signal that
  encoding has stopped.  Some of these things may be subject to change
  in the future, though it feels pretty good with this design so far.
  Will have to see how well it works out in practice versus theory.

- Second, Started adding preliminary RTMP/x264 output plugin code.

  To speed things up, I might just make a direct raw->FFmpeg output to
  create a quick output plugin that we can start using for testing all
  the subsystems.
2014-01-16 22:34:51 -07:00
jp9000 62c2b1d74e Simplify media i/o interfaces
Completely revamped the entire media i/o data and handlers.  The
original idea was to have a system that would have connecting media
inputs and outputs, but at a certain point I realized that this was an
unnecessary complexity for what we wanted to do.  (Also, it reminded me
of directshow filters, and I HATE directshow with a passion, and
wouldn't wish it upon my greatest enemy)

Now, audio/video outputs are connected to directly, with better callback
handlers, and will eventually have the ability to automatically handle
conversions such as 4:4:4 to 4:2:0 when connecting to an input that uses
them.  Doing this will allow the video/audio i/o handlers to also
prevent duplicate conversion, as well as make it easier/simple to use.

My true goal for this is to make output and encoder plugins as simple to
create as possible.  I want to be able to be able to create an output
plugin with almost no real hassle of having to worry about image
conversions, media inputs/outputs, etc.  A plugin developer shouldn't
have to handle that sort of stuff when he/she doesn't really need to.

Plugins will be able to simply create a callback via obs_video() and/or
obs_audio(), and they will automatically receive the audio/video data in
the formats requested via a simple callback, without needing to do
almost anything else at all.
2014-01-14 01:58:47 -07:00
jp9000 6edcd456fe implement signal/procedure handling into libobs and individual sources 2013-12-26 23:10:15 -07:00
jp9000 9218627892 add obs_source functions to allow name manipulation and lookup based upon name, and a few other functions related to getting/setting source information 2013-12-20 19:35:12 -07:00
jp9000 ff47b3a2dc added functions to get current audio/video output information 2013-12-06 06:38:19 -07:00
jp9000 8298fa4dc7 With the permission of my fellow contributors, I'm switching obs-studio back to GPL v2+ to prevent issues between this project and the original OBS project, and for personal reasons to avoid legal ambiguity (not political reasons, I admittedly would prefer GPL v3+) 2013-12-02 22:24:38 -07:00
jp9000 58810f9806 changed gs_draw_sprite to allow custom sizes, added output textures to the core, and adjusted the test code to accommodate the changes 2013-11-26 22:26:14 -07:00
jp9000 f1decd08f4 adjusted the way source removal is handled to make it a bit more safe 2013-11-20 18:36:46 -07:00
jp9000 409b011a8e cleaned up main internal data structure design, changed to reference counting for sources to ensure safe destruction of source objects from all parts of the system, added some service-related stuff for testing 2013-11-20 15:00:16 -07:00
jp9000 a43e291577 fill in the texture_setimage function, fill in a few other functions, and change certain names to be a little more consistent 2013-10-25 10:25:28 -07:00
jp9000 ae3cecf09f make data access in the threads a bit more safe (note: probably will need some more safety measures later on) 2013-10-18 20:25:13 -07:00
jp9000 9570f0b8d7 change names, fix some bugs, minor GL/D3D fixes, update tests, fix effect files, output a little more debug information 2013-10-14 12:37:52 -07:00
Peter SZTANOJEV 0301b24ace modernize header guards to #pragma once 2013-10-14 13:21:15 +02:00
jp9000 f255ae1922 first commit 2013-09-30 19:37:13 -07:00