Implement encoder usage with outputs
- Make it so that encoders can be assigned to outputs. If an encoder is destroyed, it will automatically remove itself from that output. I specifically didn't want to do reference counting because it leaves too much potential for unchecked references and it just felt like it would be more trouble than it's worth. - Add a 'flags' value to the output definition structure. This lets the output specify if it uses video/audio, and whether the output is meant to be used with OBS encoders or not. - Remove boilerplate code for outputs. This makes it easier to program outputs. The boilerplate code involved before was mostly just involving connecting to the audio/video data streams directly in each output plugin. Instead of doing that, simply add plugin callback functions for receiving video/audio (either encoded or non-encoded, whichever it's set to use), and then call obs_output_begin_data_capture and obs_output_end_data_capture to automatically handle setting up connections to raw or encoded video/audio streams for the plugin. - Remove 'active' function from output callbacks, as it's no longer really needed now that the libobs output context automatically knows when the output is active or not. - Make it so that an encoder cannot be destroyed until all data connections to the encoder have been removed. - Change the 'start' and 'stop' functions in the encoder interface to just an 'initialize' callback, which initializes the encoder. - Make it so that the encoder must be initialized first before the data stream can be started. The reason why initialization was separated from starting the encoder stream was because we need to be able to check that the settings used with the encoder *can* be used first. This problem was especially annoying if you had both video/audio encoding. Before, you'd have to check the return value from obs_encoder_start, and if that second encoder fails, then you basically had to stop the first encoder again, making for unnecessary boilerplate code whenever starting up two encoders.
This commit is contained in:
@@ -118,13 +118,14 @@ struct obs_encoder_info {
|
||||
void (*destroy)(void *data);
|
||||
|
||||
/**
|
||||
* Starts the encoder
|
||||
* Initializes the encoder with the specified settings
|
||||
*
|
||||
* @param data Data associated with this encoder context
|
||||
* @param settings Settings for the encoder
|
||||
* @return true if successful, false otherwise
|
||||
* @return true if the encoder settings are valid and the
|
||||
* encoder is ready to be used, false otherwise
|
||||
*/
|
||||
bool (*start)(void *data, obs_data_t settings);
|
||||
bool (*initialize)(void *data, obs_data_t settings);
|
||||
|
||||
/**
|
||||
* Encodes frame(s), and outputs encoded packets as they become
|
||||
@@ -151,13 +152,6 @@ struct obs_encoder_info {
|
||||
*/
|
||||
void (*defaults)(obs_data_t settings);
|
||||
|
||||
/**
|
||||
* Stops the encoder
|
||||
*
|
||||
* @param data Data associated with this encoder context
|
||||
*/
|
||||
void (*stop)(void *data);
|
||||
|
||||
/**
|
||||
* Gets the property information of this encoder
|
||||
*
|
||||
|
Reference in New Issue
Block a user