mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-14 23:34:08 +00:00
libobs: Add 'initialize' callback to services
The 'initialize' callback is used before the encoders/output start up so it can adjust encoder settings to required values if needed. Also added the function 'obs_encoder_active' that returns true or false depending on whether that encoder is active or not.
This commit is contained in:
parent
85ee5d591b
commit
9b23914c37
|
@ -41,7 +41,7 @@
|
|||
*
|
||||
* Reset to zero each major or minor version
|
||||
*/
|
||||
#define LIBOBS_API_PATCH_VER 0
|
||||
#define LIBOBS_API_PATCH_VER 1
|
||||
|
||||
#define LIBOBS_API_VER ((LIBOBS_API_MAJOR_VER << 24) | \
|
||||
(LIBOBS_API_MINOR_VER << 16) | \
|
||||
|
|
|
@ -438,6 +438,11 @@ audio_t obs_encoder_audio(obs_encoder_t encoder)
|
|||
encoder->media : NULL;
|
||||
}
|
||||
|
||||
bool obs_encoder_active(obs_encoder_t encoder)
|
||||
{
|
||||
return encoder ? encoder->active : false;
|
||||
}
|
||||
|
||||
static inline bool get_sei(struct obs_encoder *encoder,
|
||||
uint8_t **sei, size_t *size)
|
||||
{
|
||||
|
|
|
@ -446,5 +446,7 @@ struct obs_service {
|
|||
struct obs_output *output;
|
||||
};
|
||||
|
||||
void obs_service_activate(struct obs_service *service);
|
||||
void obs_service_deactivate(struct obs_service *service, bool remove);
|
||||
extern void obs_service_activate(struct obs_service *service);
|
||||
extern void obs_service_deactivate(struct obs_service *service, bool remove);
|
||||
extern bool obs_service_initialize(struct obs_service *service,
|
||||
struct obs_output *output);
|
||||
|
|
|
@ -577,6 +577,8 @@ bool obs_output_initialize_encoders(obs_output_t output, uint32_t flags)
|
|||
|
||||
if (!encoded)
|
||||
return false;
|
||||
if (has_service && !obs_service_initialize(output->service, output))
|
||||
return false;
|
||||
if (has_video && !obs_encoder_initialize(output->video_encoder))
|
||||
return false;
|
||||
if (has_audio && !obs_encoder_initialize(output->audio_encoder))
|
||||
|
|
|
@ -222,3 +222,14 @@ void obs_service_deactivate(struct obs_service *service, bool remove)
|
|||
else if (remove)
|
||||
service->output = NULL;
|
||||
}
|
||||
|
||||
bool obs_service_initialize(struct obs_service *service,
|
||||
struct obs_output *output)
|
||||
{
|
||||
if (!service || !output)
|
||||
return false;
|
||||
|
||||
if (service->info.initialize)
|
||||
return service->info.initialize(service->context.data, output);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,17 @@ struct obs_service_info {
|
|||
|
||||
obs_properties_t (*properties)(const char *locale);
|
||||
|
||||
/**
|
||||
* Called when getting ready to start up an output, before the encoders
|
||||
* and output are initialized
|
||||
*
|
||||
* @param data Internal service data
|
||||
* @param output Output context
|
||||
* @eturn true to allow the output to start up,
|
||||
* false to prevent output from starting up
|
||||
*/
|
||||
bool (*initialize)(void *data, obs_output_t output);
|
||||
|
||||
const char *(*get_url)(void *data);
|
||||
const char *(*get_key)(void *data);
|
||||
|
||||
|
|
|
@ -959,6 +959,9 @@ EXPORT video_t obs_encoder_video(obs_encoder_t encoder);
|
|||
*/
|
||||
EXPORT audio_t obs_encoder_audio(obs_encoder_t encoder);
|
||||
|
||||
/** Returns true if encoder is active, false otherwise */
|
||||
EXPORT bool obs_encoder_active(obs_encoder_t encoder);
|
||||
|
||||
/** Duplicates an encoder packet */
|
||||
EXPORT void obs_duplicate_encoder_packet(struct encoder_packet *dst,
|
||||
const struct encoder_packet *src);
|
||||
|
|
Loading…
Reference in a new issue