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

647 Commits

Author SHA1 Message Date
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