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

116 Commits

Author SHA1 Message Date
jp9000
a2953d1161 libobs: Fix bug where outputs would not set stopped event
When an output fails to connect and it's already been prematurely
stopped, the event to mark the output as stopped would not be signaled,
causing obs_output_destroy to lock up indefinitely while waiting for the
event to be signaled.
2017-05-20 13:11:59 -07:00
jp9000
87f14a1254 libobs: Always call stop callback
Rather than have the back-end try to determine whether the output can or
cannot stop, allow the stop callback to continue in the plugin either
way and let the plugin itself make that determination.

This fixes a bug where the back-end wouldn't have data active while
connecting, therefore the stop callback wouldn't be called, and once
connected it wouldn't know that it was supposed to stop.  In other words
trying to call obs_output_stop on an output that was in a state of
connecting would do nothing and the output would never stop.
2017-05-20 12:31:57 -07:00
Richard Stanway
50f8a066b9
libobs: Add support for output error messages 2017-05-15 12:04:11 +02:00
jp9000
5c773d6807 libobs: Add obs_output_reconnecting func
Returns whether the output is currently in a state of reconnecting or
not.
2017-05-13 01:21:18 -07:00
jp9000
668763550c libobs: Add function to allow getting output connect time 2017-05-06 11:29:31 -07:00
jp9000
829ec5be2d libobs: Fix skipped frames reporting
When frames are skipped the skipped frame count would increment, but the
total frame count would not increment, causing the percentage
calculation to fail.

Additionally, the skipped frames log reporting has been moved to
media-io/video-io.c instead of each output.
2017-05-06 11:29:25 -07:00
Ryan Foster
be98cee2a0 Fix various typos across multiple modules 2017-04-25 22:39:42 -04:00
jp9000
d8500b47ea libobs: Add ability to get output congestion
From 0.0 (not congested) to 1.0 (completely congested/dropping).
2017-01-24 15:31:44 -08:00
jp9000
5cbd34df92 libobs: Eliminate an unnecessary allocation with captions 2016-12-24 03:45:19 -08:00
jp9000
cd7bc32388 libobs: Fix caption encoder packet reallocation
Captions do something unusual with encoder packets: they reallocate them
due to appending extra h.264 data.  Due to the way allocations are
handled with core encoder packets (they now store a reference in their
data), instead of modifying the encoder data directly, create a new
encoder packet instead and release the old packet.
2016-12-24 03:01:49 -08:00
jp9000
04ae015a60 libobs: Add ability to insert captions into frames
Uses the libcaption library to allow insertion of caption data directly
in to H.264 frame data.
2016-12-23 10:37:09 -08:00
jp9000
7d6e6eee79 libobs: Use reference counting for encoder packets
Prevents reallocation of encoded packet data.

Deprecates:
obs_duplicate_encoder_packet
obs_free_encoder_packet

Replaces those functions with:
obs_encoder_packet_ref
obs_encoder_packet_release
2016-12-08 03:27:39 -08:00
jp9000
ec4317dd2b libobs: Fix bug where outputs cannot initialize hotkeys
When an output's context data is being created, it cannot register any
hotkeys because the output has not initialized its reference counting
capability.  This is due to the fact that when a hotkey is registered,
it creates a weak reference to the source/output/service/encoder.

The solution to this is to make sure the output's reference counter data
is created before calling the create callback.
2016-12-08 03:27:35 -08:00
jp9000
bc3944301f libobs: Allow forced stop even when already stopping
Allow outputs to force a stop even when already in the process of
stopping.  If for example a stream is heavily congested and taking a
very long time to stop, this allows frontends to give the users the
option to forcibly stop the stream to make it stop as quickly as
possible.
2016-09-09 17:39:18 -07:00
jp9000
e284ffd896 libobs: Limit reconnect retry interval to 15 mins max
The retry interval seconds could grow exponentially large.  Limit it to
a maximum of 15 minutes between retry intervals.
2016-08-06 20:10:18 -07:00
jp9000
526d390adb libobs: Reduce unnecessary logging (info -> debug)
(Note: This commit also modifies coreaudio-encoder, win-capture, and
win-mf modules)

This reduces logging to the user's log file.  Most of the things
specified are not useful for examining log files, and make reading log
files more painful.

The things that are useful to log should be up to the front-end to
implement.  The core and core plugins should have minimal mandatory
logging.
2016-08-05 18:59:32 -07:00
jp9000
41277f6cac libobs: Fix 'may be uninitialized' warning 2016-06-22 14:10:43 -07:00
jp9000
b738f496b5 libobs: Forcibly stop output if stopped during reconnect
This fixes an design flaw where a delayed output would schedule a
stop even while in the process of reconnecting instead of just shutting
down right away.
2016-06-22 14:10:40 -07:00
jp9000
e13dd53376 libobs: Fix output shutdown order
When obs_output_actual_stop is called on shutdown, it should wait for
the output to fully stop before doing anything, and then it should wait
for the data capture to end.  The service should not be removed until
after the output has stopped, otherwise it could result in a possible
memory leak on stop.  Packets should be freed last.
2016-06-22 14:10:40 -07:00
jp9000
d7db0b8b01 (API Change) libobs: Fix output data cutoff on stop
(Note: This commit also modifies obs-ffmpeg and obs-outputs)

API Changed:
obs_output_info::void (*stop)(void *data);

To:
obs_output_info::void (*stop)(void *data, uint64_t ts);

This fixes the long-time design flaw where obs_output_stop and the
output 'stop' callback would just shut down the output without
considering the timing of when obs_output_stop was used, discarding any
possible buffering and causing the output to get cut off at an
unexpected timing.

The 'stop' callback of obs_output_info now takes a timestamp with the
expectation that the output will use that timestamp to stop output data
in accordance to that timing.  obs_output_stop now records the timestamp
at the time that the function is called and calls the 'stop' callback
with that timestamp.  If needed, obs_output_force_stop will still stop
the output immediately without buffering.
2016-06-22 14:10:39 -07:00
jp9000
29e849e355 libobs: Move output/encoder shutdown to independent thread
obs_output_end_data_capture could cause a hard lock due to mutex lock
ordering, depending on what thread it was called in.
2016-06-22 03:08:44 -07:00
jp9000
7018c6039d libobs: Do not allow output stop calls more than once 2016-06-22 03:08:43 -07:00
jp9000
ceb675f6df libobs: Use atomics for certain output boolean variables 2016-06-22 03:08:32 -07:00
jp9000
82a7d795db libobs: Always prune excessive starting audio packets
On outputs that use already-active video/audio encoder, the audio
pruning to sync up audio packets with video packets doesn't always get
called (for example if the video pruning function was called).  Always
prune excess starting audio packets.
2016-04-20 20:13:49 -07:00
jp9000
84ad6b563e libobs: Improve output packet pruning debug message
Specifies whether packets were pruned or not
2016-04-20 20:13:48 -07:00
jp9000
cbd13063c6 libobs: Fix another sync issue with encoder sharing
If audio buffering is very high, the audio packets built up in the
interleaved buffer would be significantly before the first video packet,
causing the offset between the starting video/audio packet pairs to be
significantly off, leading to desync.

This issue was not spotted until recently because it only happens when
streaming/recording with same encoders while audio buffering is very
high.
2016-04-18 14:02:57 -07:00
jp9000
d069302b2e libobs: Add function to get obs object type 2016-02-27 02:49:03 -08:00
jp9000
a7067906f3 libobs: Try to pair video with one multi-track encoders
When starting a multi-track output, attempt to pair the video encoder
with one of the audio encoders to ensure that the video and audio
encoders start as close together in time as possible.  This ensures the
best possible audio/video syncing point when using multi-track audio
output.
2016-01-31 00:55:00 -08:00
jp9000
b0d88f7c1f libobs: Start audio tracks before starting video tracks
When using multi-track audio, encoders cannot be paired like they can
when only using a single audio track with video, so it has to choose the
best point in the interleaved buffer as the "starting point", and if the
encoders start up at different times, it has to prune that data and wait
to start the output on the next video keyframe.  When the audio encoders
started up, there was the case where the encoders would take some time
to load, and it would cause the pruning code to wait for the next
keyframe to ensure startup syncing.

Starting the audio encoders before starting the video encoder should
reduce the possibility of that happening in a multi-track scenario.
2016-01-31 00:54:59 -08:00
jp9000
be717dbb2c libobs: Consider multi-track audio when pruning packets
In a multi-track scenario it was not taking in to consideration the
possibility of secondary audio tracks, which could have caused desync on
some of the audio tracks.
2016-01-31 00:54:58 -08:00
jp9000
ec7faee32c libobs: Add find_first_packet_type_idx
Gets the index of the first interleaved packet of a given/type and audio
index
2016-01-31 00:54:57 -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
bccd3b0b0a libobs: Allow "private" contexts
The intention of this is to allow sources/outputs/etc to be created
without being visible to the UI or save/load functions.
2016-01-26 11:49:47 -08:00
jp9000
726163aa29 libobs: Report lost frame count due to rendering lag
This has been missing for a bit too long, and should make it
easier/faster to diagnose issues users might be having.
2016-01-25 17:29:09 -08:00
jp9000
65eb3c0815 libobs: Fix potential output audio/video sync bug
Problem:

When an output is started with encoders that have already been started
by another output, and it starts in between the window in between where
the first audio packets start coming in and where the first video packet
comes in, the output would get audio packets with timestamps potentially
much later than the first video frame when the first video frame finally
comes in.  The audio/video encoders will almost always have a differing
delay.

Solution:

Detect that starting window, and if within that starting window, wait
for a new keyframe from video instead of trying to sync up video.

Additional Notes:

In these cases where an output starts with already-active encoders, this
patch also reduces the potential sync offset between the first video
frame and the first audio frame.  Before, it would sync the first video
frame with the first audio frames right after that, but now it syncs
with the closest audio frame in the interleaved array, which halves the
potential sync difference between the first video frame and the first
audio frame of already-active encoders.  (So now the potential sync
difference is roughly 11.6 milliseconds at 44.1khz audio, where it was
23.2 before)
2016-01-25 17:29:09 -08:00
jp9000
346ddd502f libobs: Fix potential race condition
Fixes potential race conditions when two threads are trying to
initialize/start/stop the same encoders at the same time.
2016-01-25 17:29:09 -08:00
jp9000
03d6eab49d libobs: Rename obs_output_canpause
Renames obs_output_canpause to obs_output_can_pause
2015-10-21 07:46:42 -07:00
jp9000
63f7daa61c libobs: Add API to get object ids 2015-10-21 07:46:41 -07:00
jp9000
f07ce8501f libobs: Add null debug messages for base obs funcs 2015-10-21 06:30:32 -07: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
0ed913a136 libobs: Add functions to get private type data
The private type data is the type_data variable that's provided when
object types are registered by plugins.
2015-09-16 09:17:14 -07:00
jp9000
af310fb556 libobs: Allow object creation if id not found
Allows objects to be created regardless of whether the actual id exists
or not.  This is a precaution that preserves objects/settings if for
some reason the id was removed for whatever reason (plugin removed, or
hardware encoder that disappeared).  This was already added for sources,
but really needs to be added for other libobs objects as well: outputs,
encoders, services.
2015-09-13 11:55:06 -07:00
jp9000
5096b3c697 libobs: Set reconnect to false on user cancel
This fixes the issue when an output cancels reconnecting, reconnect is
left at true, causing obs_output_active to always return true even
though reconnecting has actually been canceled.
2015-09-11 08:20:18 -07:00
jp9000
0538865553 libobs: Add encoded output delay support
This feature allows a user to delay an output (as long as the output
itself supports it).  Needless to say this intended for live streams,
where users may want to delay their streams to prevent stream sniping,
cheating, and other such things.

The design this time was a bit more elaborate, but still simple in
design:  the user can now schedule stops/starts without having to wait
for the stream itself to stop before being able to take any action.
Optionally, they can also forcibly stop stream (and delay) in case
something happens which they might not want to be streamed.

Additionally, a new option was added to preserve stream cutoff point on
disconnections/reconnections, so that if you get disconnected while
streaming, when it reconnects, it will reconnect right at the point
where it left off.  This will probably be quite useful for a number of
applications in addition to regular delay, such as setting the delay to
1 second and then using this feature to minimize, for example, a
critical stream such as a tournament stream from getting any of its
stream data cut off.  However, using this feature will of course cause
the stream data to buffer and increase delay (and memory usage) while
it's in the process of reconnecting.
2015-09-10 12:13:37 -07:00
jp9000
582ecdab0f libobs: Add activate/deactivate output signals
Indicates when an output is considered active/inactive.
2015-09-10 12:12:42 -07:00
jp9000
c7ad09fc0b libobs: Move encoded_callback_t to obs-internal.h
Allows it to be used in multiple source files.
2015-09-06 15:29:17 -07:00
Palana
1d39c3e9b6 (API Change) libobs: Add hotkey data to *_create functions 2015-05-11 20:45:25 +02:00
Palana
5ad553d06d libobs: Add global hotkey support 2015-05-11 20:45:24 +02:00
jp9000
c1e8d28548 libobs: Use exponential backoff for reconnecting
Implements exponential backoff for consecutive reconnects, which is
useful to prevent too many connections from trying to reconnect back to
a service at once over a short period of time in the case of potential
service downtime.  Exponential backoff causes each subsequent reconnect
attempt to double its timeout duration.
2015-05-10 16:07:22 -07:00
jp9000
691d3b4a73 libobs: Add timeout_sec param to reconnect signal
This optionally allows the front-end to know what the current timeout
value in seconds is set to for the reconnection without having to call
an extra API function to find that out.
2015-05-10 16:05:26 -07:00