libobs: Implement pausing of outputs

This implements pausing of outputs.  To accomplish this, raw audio/video
data is halted to the encoders or raw output.  Pausing is as precisely
timed as possible according to the timing of the obs_output_pause call,
and audio data will be spliced down to the exact audio sample in
accordance to that timing at the start/end marks.

Outputs that support this (outputs used for recording) can set the
OBS_OUTPUT_CAN_PAUSE capability flag.
This commit is contained in:
jp9000
2019-07-07 12:27:13 -07:00
parent 3b581a3727
commit 153fa6337f
7 changed files with 374 additions and 25 deletions

View File

@@ -66,6 +66,14 @@ Output Definition Structure (obs_output_info)
When this capability flag is used, specifies that this output
supports multiple encoded audio tracks simultaneously.
- **OBS_OUTPUT_CAN_PAUSE** - Output supports pausing.
When this capability flag is used, the output supports pausing.
When an output is paused, raw or encoded audio/video data will be
halted when paused down to the exact point to the closest video
frame. Audio data will be correctly truncated down to the exact
audio sample according to that video frame timing.
.. member:: const char *(*obs_output_info.get_name)(void *type_data)
Get the translated name of the output type.
@@ -170,13 +178,9 @@ Output Definition Structure (obs_output_info)
:return: The properties of the output
.. member:: void (*obs_output_info.pause)(void *data)
.. member:: void (*obs_output_info.unused1)(void *data)
Pauses the output (if the output supports pausing).
(Author's note: This is currently unimplemented)
(Optional)
This callback is no longer used.
.. member:: uint64_t (*obs_output_info.get_total_bytes)(void *data)
@@ -257,6 +261,14 @@ Output Signals
| OBS_OUTPUT_NO_SPACE - Ran out of disk space
| OBS_OUTPUT_ENCODE_ERROR - Encoder error
**pause** (ptr output)
Called when the output has been paused.
**unpause** (ptr output)
Called when the output has been unpaused.
**starting** (ptr output)
Called when the output is starting.
@@ -444,11 +456,18 @@ General Output Functions
---------------------
.. function:: void obs_output_pause(obs_output_t *output)
.. function:: bool obs_output_pause(obs_output_t *output, bool pause)
Pause an output (if supported by the output).
(Author's Note: Not yet implemented)
:return: *true* if the output was paused successfuly, *false*
otherwise
---------------------
.. function:: bool obs_output_paused(const obs_output_t *output)
:return: *true* if the output is paused, *false* otherwise
---------------------
@@ -808,6 +827,14 @@ Functions used by outputs
| OBS_OUTPUT_UNSUPPORTED - The settings, video/audio format, or codecs are unsupported by this output
| OBS_OUTPUT_NO_SPACE - Ran out of disk space
---------------------
.. function:: uint64_t obs_output_get_pause_offset(obs_output_t *output)
Returns the current pause offset of the output. Used with raw
outputs to calculate system timestamps when using calculated
timestamps (see FFmpeg output for an example).
.. ---------------------------------------------------------------------------
.. _libobs/obs-output.h: https://github.com/jp9000/obs-studio/blob/master/libobs/obs-output.h