libobs: Add null debug messages for base obs funcs
This commit is contained in:
parent
d3f9cdb8c8
commit
f07ce8501f
@ -259,12 +259,14 @@ void obs_encoder_destroy(obs_encoder_t *encoder)
|
||||
|
||||
const char *obs_encoder_get_name(const obs_encoder_t *encoder)
|
||||
{
|
||||
return encoder ? encoder->context.name : NULL;
|
||||
return obs_encoder_valid(encoder, "obs_encoder_get_name") ?
|
||||
encoder->context.name : NULL;
|
||||
}
|
||||
|
||||
void obs_encoder_set_name(obs_encoder_t *encoder, const char *name)
|
||||
{
|
||||
if (!encoder) return;
|
||||
if (!obs_encoder_valid(encoder, "obs_encoder_set_name"))
|
||||
return;
|
||||
|
||||
if (name && *name && strcmp(name, encoder->context.name) != 0)
|
||||
obs_context_data_setname(&encoder->context, name);
|
||||
@ -301,7 +303,10 @@ obs_properties_t *obs_get_encoder_properties(const char *id)
|
||||
|
||||
obs_properties_t *obs_encoder_properties(const obs_encoder_t *encoder)
|
||||
{
|
||||
if (encoder && encoder->info.get_properties) {
|
||||
if (!obs_encoder_valid(encoder, "obs_encoder_properties"))
|
||||
return NULL;
|
||||
|
||||
if (encoder->info.get_properties) {
|
||||
obs_properties_t *props;
|
||||
props = encoder->info.get_properties(encoder->context.data);
|
||||
obs_properties_apply_settings(props, encoder->context.settings);
|
||||
@ -312,7 +317,8 @@ obs_properties_t *obs_encoder_properties(const obs_encoder_t *encoder)
|
||||
|
||||
void obs_encoder_update(obs_encoder_t *encoder, obs_data_t *settings)
|
||||
{
|
||||
if (!encoder) return;
|
||||
if (!obs_encoder_valid(encoder, "obs_encoder_update"))
|
||||
return;
|
||||
|
||||
obs_data_apply(encoder->context.settings, settings);
|
||||
|
||||
@ -324,7 +330,10 @@ void obs_encoder_update(obs_encoder_t *encoder, obs_data_t *settings)
|
||||
bool obs_encoder_get_extra_data(const obs_encoder_t *encoder,
|
||||
uint8_t **extra_data, size_t *size)
|
||||
{
|
||||
if (encoder && encoder->info.get_extra_data && encoder->context.data)
|
||||
if (!obs_encoder_valid(encoder, "obs_encoder_get_extra_data"))
|
||||
return false;
|
||||
|
||||
if (encoder->info.get_extra_data && encoder->context.data)
|
||||
return encoder->info.get_extra_data(encoder->context.data,
|
||||
extra_data, size);
|
||||
|
||||
@ -333,7 +342,8 @@ bool obs_encoder_get_extra_data(const obs_encoder_t *encoder,
|
||||
|
||||
obs_data_t *obs_encoder_get_settings(const obs_encoder_t *encoder)
|
||||
{
|
||||
if (!encoder) return NULL;
|
||||
if (!obs_encoder_valid(encoder, "obs_encoder_get_settings"))
|
||||
return NULL;
|
||||
|
||||
obs_data_addref(encoder->context.settings);
|
||||
return encoder->context.settings;
|
||||
@ -417,7 +427,12 @@ void obs_encoder_start(obs_encoder_t *encoder,
|
||||
struct encoder_callback cb = {false, new_packet, param};
|
||||
bool first = false;
|
||||
|
||||
if (!encoder || !new_packet || !encoder->context.data) return;
|
||||
if (!obs_encoder_valid(encoder, "obs_encoder_start"))
|
||||
return;
|
||||
if (!obs_ptr_valid(new_packet, "obs_encoder_start"))
|
||||
return;
|
||||
if (!encoder->context.data)
|
||||
return;
|
||||
|
||||
pthread_mutex_lock(&encoder->callbacks_mutex);
|
||||
|
||||
@ -442,7 +457,7 @@ void obs_encoder_stop(obs_encoder_t *encoder,
|
||||
bool last = false;
|
||||
size_t idx;
|
||||
|
||||
if (!encoder) return;
|
||||
if (!obs_encoder_valid(encoder, "obs_encoder_stop")) return;
|
||||
|
||||
pthread_mutex_lock(&encoder->callbacks_mutex);
|
||||
|
||||
@ -464,7 +479,8 @@ void obs_encoder_stop(obs_encoder_t *encoder,
|
||||
|
||||
const char *obs_encoder_get_codec(const obs_encoder_t *encoder)
|
||||
{
|
||||
return encoder ? encoder->info.codec : NULL;
|
||||
return obs_encoder_valid(encoder, "obs_encoder_get_codec") ?
|
||||
encoder->info.codec : NULL;
|
||||
}
|
||||
|
||||
const char *obs_get_encoder_codec(const char *id)
|
||||
@ -475,7 +491,8 @@ const char *obs_get_encoder_codec(const char *id)
|
||||
|
||||
enum obs_encoder_type obs_encoder_get_type(const obs_encoder_t *encoder)
|
||||
{
|
||||
return encoder ? encoder->info.type : OBS_ENCODER_AUDIO;
|
||||
return obs_encoder_valid(encoder, "obs_encoder_get_type") ?
|
||||
encoder->info.type : OBS_ENCODER_AUDIO;
|
||||
}
|
||||
|
||||
enum obs_encoder_type obs_get_encoder_type(const char *id)
|
||||
@ -487,9 +504,14 @@ enum obs_encoder_type obs_get_encoder_type(const char *id)
|
||||
void obs_encoder_set_scaled_size(obs_encoder_t *encoder, uint32_t width,
|
||||
uint32_t height)
|
||||
{
|
||||
if (!encoder || encoder->info.type != OBS_ENCODER_VIDEO)
|
||||
if (!obs_encoder_valid(encoder, "obs_encoder_set_scaled_size"))
|
||||
return;
|
||||
|
||||
if (encoder->info.type != OBS_ENCODER_VIDEO) {
|
||||
blog(LOG_WARNING, "obs_encoder_set_scaled_size: "
|
||||
"encoder '%s' is not a video encoder",
|
||||
obs_encoder_get_name(encoder));
|
||||
return;
|
||||
}
|
||||
if (encoder->active) {
|
||||
blog(LOG_WARNING, "encoder '%s': Cannot set the scaled "
|
||||
"resolution while the encoder is active",
|
||||
@ -503,8 +525,15 @@ void obs_encoder_set_scaled_size(obs_encoder_t *encoder, uint32_t width,
|
||||
|
||||
uint32_t obs_encoder_get_width(const obs_encoder_t *encoder)
|
||||
{
|
||||
if (!encoder || !encoder->media ||
|
||||
encoder->info.type != OBS_ENCODER_VIDEO)
|
||||
if (!obs_encoder_valid(encoder, "obs_encoder_get_width"))
|
||||
return 0;
|
||||
if (encoder->info.type != OBS_ENCODER_VIDEO) {
|
||||
blog(LOG_WARNING, "obs_encoder_get_width: "
|
||||
"encoder '%s' is not a video encoder",
|
||||
obs_encoder_get_name(encoder));
|
||||
return 0;
|
||||
}
|
||||
if (!encoder->media)
|
||||
return 0;
|
||||
|
||||
return encoder->scaled_width != 0 ?
|
||||
@ -514,8 +543,15 @@ uint32_t obs_encoder_get_width(const obs_encoder_t *encoder)
|
||||
|
||||
uint32_t obs_encoder_get_height(const obs_encoder_t *encoder)
|
||||
{
|
||||
if (!encoder || !encoder->media ||
|
||||
encoder->info.type != OBS_ENCODER_VIDEO)
|
||||
if (!obs_encoder_valid(encoder, "obs_encoder_get_height"))
|
||||
return 0;
|
||||
if (encoder->info.type != OBS_ENCODER_VIDEO) {
|
||||
blog(LOG_WARNING, "obs_encoder_get_height: "
|
||||
"encoder '%s' is not a video encoder",
|
||||
obs_encoder_get_name(encoder));
|
||||
return 0;
|
||||
}
|
||||
if (!encoder->media)
|
||||
return 0;
|
||||
|
||||
return encoder->scaled_width != 0 ?
|
||||
@ -525,8 +561,15 @@ uint32_t obs_encoder_get_height(const obs_encoder_t *encoder)
|
||||
|
||||
uint32_t obs_encoder_get_sample_rate(const obs_encoder_t *encoder)
|
||||
{
|
||||
if (!encoder || !encoder->media ||
|
||||
encoder->info.type != OBS_ENCODER_AUDIO)
|
||||
if (!obs_encoder_valid(encoder, "obs_encoder_get_sample_rate"))
|
||||
return 0;
|
||||
if (encoder->info.type != OBS_ENCODER_AUDIO) {
|
||||
blog(LOG_WARNING, "obs_encoder_get_sample_rate: "
|
||||
"encoder '%s' is not an audio encoder",
|
||||
obs_encoder_get_name(encoder));
|
||||
return 0;
|
||||
}
|
||||
if (!encoder->media)
|
||||
return 0;
|
||||
|
||||
return encoder->samplerate != 0 ?
|
||||
@ -538,7 +581,15 @@ void obs_encoder_set_video(obs_encoder_t *encoder, video_t *video)
|
||||
{
|
||||
const struct video_output_info *voi;
|
||||
|
||||
if (!video || !encoder || encoder->info.type != OBS_ENCODER_VIDEO)
|
||||
if (!obs_encoder_valid(encoder, "obs_encoder_set_video"))
|
||||
return;
|
||||
if (encoder->info.type != OBS_ENCODER_VIDEO) {
|
||||
blog(LOG_WARNING, "obs_encoder_set_video: "
|
||||
"encoder '%s' is not a video encoder",
|
||||
obs_encoder_get_name(encoder));
|
||||
return;
|
||||
}
|
||||
if (!video)
|
||||
return;
|
||||
|
||||
voi = video_output_get_info(video);
|
||||
@ -550,7 +601,15 @@ void obs_encoder_set_video(obs_encoder_t *encoder, video_t *video)
|
||||
|
||||
void obs_encoder_set_audio(obs_encoder_t *encoder, audio_t *audio)
|
||||
{
|
||||
if (!audio || !encoder || encoder->info.type != OBS_ENCODER_AUDIO)
|
||||
if (!obs_encoder_valid(encoder, "obs_encoder_set_audio"))
|
||||
return;
|
||||
if (encoder->info.type != OBS_ENCODER_AUDIO) {
|
||||
blog(LOG_WARNING, "obs_encoder_set_audio: "
|
||||
"encoder '%s' is not an audio encoder",
|
||||
obs_encoder_get_name(encoder));
|
||||
return;
|
||||
}
|
||||
if (!audio)
|
||||
return;
|
||||
|
||||
encoder->media = audio;
|
||||
@ -560,19 +619,36 @@ void obs_encoder_set_audio(obs_encoder_t *encoder, audio_t *audio)
|
||||
|
||||
video_t *obs_encoder_video(const obs_encoder_t *encoder)
|
||||
{
|
||||
return (encoder && encoder->info.type == OBS_ENCODER_VIDEO) ?
|
||||
encoder->media : NULL;
|
||||
if (!obs_encoder_valid(encoder, "obs_encoder_video"))
|
||||
return NULL;
|
||||
if (encoder->info.type != OBS_ENCODER_VIDEO) {
|
||||
blog(LOG_WARNING, "obs_encoder_set_video: "
|
||||
"encoder '%s' is not a video encoder",
|
||||
obs_encoder_get_name(encoder));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return encoder->media;
|
||||
}
|
||||
|
||||
audio_t *obs_encoder_audio(const obs_encoder_t *encoder)
|
||||
{
|
||||
return (encoder && encoder->info.type == OBS_ENCODER_AUDIO) ?
|
||||
encoder->media : NULL;
|
||||
if (!obs_encoder_valid(encoder, "obs_encoder_audio"))
|
||||
return NULL;
|
||||
if (encoder->info.type != OBS_ENCODER_AUDIO) {
|
||||
blog(LOG_WARNING, "obs_encoder_set_audio: "
|
||||
"encoder '%s' is not an audio encoder",
|
||||
obs_encoder_get_name(encoder));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return encoder->media;
|
||||
}
|
||||
|
||||
bool obs_encoder_active(const obs_encoder_t *encoder)
|
||||
{
|
||||
return encoder ? encoder->active : false;
|
||||
return obs_encoder_valid(encoder, "obs_encoder_active") ?
|
||||
encoder->active : false;
|
||||
}
|
||||
|
||||
static inline bool get_sei(const struct obs_encoder *encoder,
|
||||
|
@ -172,7 +172,8 @@ void obs_output_destroy(obs_output_t *output)
|
||||
|
||||
const char *obs_output_get_name(const obs_output_t *output)
|
||||
{
|
||||
return output ? output->context.name : NULL;
|
||||
return obs_output_valid(output, "obs_output_get_name") ?
|
||||
output->context.name : NULL;
|
||||
}
|
||||
|
||||
bool obs_output_actual_start(obs_output_t *output)
|
||||
@ -335,6 +336,9 @@ obs_properties_t *obs_get_output_properties(const char *id)
|
||||
|
||||
obs_properties_t *obs_output_properties(const obs_output_t *output)
|
||||
{
|
||||
if (!obs_output_valid(output, "obs_output_properties"))
|
||||
return NULL;
|
||||
|
||||
if (output && output->info.get_properties) {
|
||||
obs_properties_t *props;
|
||||
props = output->info.get_properties(output->context.data);
|
||||
@ -347,7 +351,8 @@ obs_properties_t *obs_output_properties(const obs_output_t *output)
|
||||
|
||||
void obs_output_update(obs_output_t *output, obs_data_t *settings)
|
||||
{
|
||||
if (!output) return;
|
||||
if (!obs_output_valid(output, "obs_output_update"))
|
||||
return;
|
||||
|
||||
obs_data_apply(output->context.settings, settings);
|
||||
|
||||
@ -358,7 +363,7 @@ void obs_output_update(obs_output_t *output, obs_data_t *settings)
|
||||
|
||||
obs_data_t *obs_output_get_settings(const obs_output_t *output)
|
||||
{
|
||||
if (!output)
|
||||
if (!obs_output_valid(output, "obs_output_get_settings"))
|
||||
return NULL;
|
||||
|
||||
obs_data_addref(output->context.settings);
|
||||
@ -367,28 +372,34 @@ obs_data_t *obs_output_get_settings(const obs_output_t *output)
|
||||
|
||||
bool obs_output_canpause(const obs_output_t *output)
|
||||
{
|
||||
return output ? (output->info.pause != NULL) : false;
|
||||
return obs_output_valid(output, "obs_output_canpause") ?
|
||||
(output->info.pause != NULL) : false;
|
||||
}
|
||||
|
||||
void obs_output_pause(obs_output_t *output)
|
||||
{
|
||||
if (output && output->info.pause)
|
||||
if (!obs_output_valid(output, "obs_output_pause"))
|
||||
return;
|
||||
|
||||
if (output->info.pause)
|
||||
output->info.pause(output->context.data);
|
||||
}
|
||||
|
||||
signal_handler_t *obs_output_get_signal_handler(const obs_output_t *output)
|
||||
{
|
||||
return output ? output->context.signals : NULL;
|
||||
return obs_output_valid(output, "obs_output_get_signal_handler") ?
|
||||
output->context.signals : NULL;
|
||||
}
|
||||
|
||||
proc_handler_t *obs_output_get_proc_handler(const obs_output_t *output)
|
||||
{
|
||||
return output ? output->context.procs : NULL;
|
||||
return obs_output_valid(output, "obs_output_get_proc_handler") ?
|
||||
output->context.procs : NULL;
|
||||
}
|
||||
|
||||
void obs_output_set_media(obs_output_t *output, video_t *video, audio_t *audio)
|
||||
{
|
||||
if (!output)
|
||||
if (!obs_output_valid(output, "obs_output_set_media"))
|
||||
return;
|
||||
|
||||
output->video = video;
|
||||
@ -397,17 +408,19 @@ void obs_output_set_media(obs_output_t *output, video_t *video, audio_t *audio)
|
||||
|
||||
video_t *obs_output_video(const obs_output_t *output)
|
||||
{
|
||||
return output ? output->video : NULL;
|
||||
return obs_output_valid(output, "obs_output_video") ?
|
||||
output->video : NULL;
|
||||
}
|
||||
|
||||
audio_t *obs_output_audio(const obs_output_t *output)
|
||||
{
|
||||
return output ? output->audio : NULL;
|
||||
return obs_output_valid(output, "obs_output_audio") ?
|
||||
output->audio : NULL;
|
||||
}
|
||||
|
||||
void obs_output_set_mixer(obs_output_t *output, size_t mixer_idx)
|
||||
{
|
||||
if (!output)
|
||||
if (!obs_output_valid(output, "obs_output_set_mixer"))
|
||||
return;
|
||||
|
||||
if (!output->active)
|
||||
@ -416,13 +429,15 @@ void obs_output_set_mixer(obs_output_t *output, size_t mixer_idx)
|
||||
|
||||
size_t obs_output_get_mixer(const obs_output_t *output)
|
||||
{
|
||||
return output ? output->mixer_idx : 0;
|
||||
return obs_output_valid(output, "obs_output_get_mixer") ?
|
||||
output->mixer_idx : 0;
|
||||
}
|
||||
|
||||
void obs_output_remove_encoder(struct obs_output *output,
|
||||
struct obs_encoder *encoder)
|
||||
{
|
||||
if (!output) return;
|
||||
if (!obs_output_valid(output, "obs_output_remove_encoder"))
|
||||
return;
|
||||
|
||||
if (output->video_encoder == encoder) {
|
||||
output->video_encoder = NULL;
|
||||
@ -436,9 +451,15 @@ void obs_output_remove_encoder(struct obs_output *output,
|
||||
|
||||
void obs_output_set_video_encoder(obs_output_t *output, obs_encoder_t *encoder)
|
||||
{
|
||||
if (!output) return;
|
||||
if (!obs_output_valid(output, "obs_output_set_video_encoder"))
|
||||
return;
|
||||
if (encoder && encoder->info.type != OBS_ENCODER_VIDEO) {
|
||||
blog(LOG_WARNING, "obs_output_set_video_encoder: "
|
||||
"encoder passed is not a video encoder");
|
||||
return;
|
||||
}
|
||||
|
||||
if (output->video_encoder == encoder) return;
|
||||
if (encoder && encoder->info.type != OBS_ENCODER_VIDEO) return;
|
||||
|
||||
obs_encoder_remove_output(output->video_encoder, output);
|
||||
obs_encoder_add_output(encoder, output);
|
||||
@ -453,8 +474,13 @@ void obs_output_set_video_encoder(obs_output_t *output, obs_encoder_t *encoder)
|
||||
void obs_output_set_audio_encoder(obs_output_t *output, obs_encoder_t *encoder,
|
||||
size_t idx)
|
||||
{
|
||||
if (!output) return;
|
||||
if (encoder && encoder->info.type != OBS_ENCODER_AUDIO) return;
|
||||
if (!obs_output_valid(output, "obs_output_set_audio_encoder"))
|
||||
return;
|
||||
if (encoder && encoder->info.type != OBS_ENCODER_AUDIO) {
|
||||
blog(LOG_WARNING, "obs_output_set_audio_encoder: "
|
||||
"encoder passed is not an audio encoder");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((output->info.flags & OBS_OUTPUT_MULTI_TRACK) != 0) {
|
||||
if (idx >= MAX_AUDIO_MIXES) {
|
||||
@ -475,13 +501,15 @@ void obs_output_set_audio_encoder(obs_output_t *output, obs_encoder_t *encoder,
|
||||
|
||||
obs_encoder_t *obs_output_get_video_encoder(const obs_output_t *output)
|
||||
{
|
||||
return output ? output->video_encoder : NULL;
|
||||
return obs_output_valid(output, "obs_output_get_video_encoder") ?
|
||||
output->video_encoder : NULL;
|
||||
}
|
||||
|
||||
obs_encoder_t *obs_output_get_audio_encoder(const obs_output_t *output,
|
||||
size_t idx)
|
||||
{
|
||||
if (!output) return NULL;
|
||||
if (!obs_output_valid(output, "obs_output_get_audio_encoder"))
|
||||
return NULL;
|
||||
|
||||
if ((output->info.flags & OBS_OUTPUT_MULTI_TRACK) != 0) {
|
||||
if (idx >= MAX_AUDIO_MIXES) {
|
||||
@ -498,7 +526,10 @@ obs_encoder_t *obs_output_get_audio_encoder(const obs_output_t *output,
|
||||
|
||||
void obs_output_set_service(obs_output_t *output, obs_service_t *service)
|
||||
{
|
||||
if (!output || output->active || !service || service->active) return;
|
||||
if (!obs_output_valid(output, "obs_output_set_service"))
|
||||
return;
|
||||
if (output->active || !service || service->active)
|
||||
return;
|
||||
|
||||
if (service->output)
|
||||
service->output->service = NULL;
|
||||
@ -509,13 +540,15 @@ void obs_output_set_service(obs_output_t *output, obs_service_t *service)
|
||||
|
||||
obs_service_t *obs_output_get_service(const obs_output_t *output)
|
||||
{
|
||||
return output ? output->service : NULL;
|
||||
return obs_output_valid(output, "obs_output_get_service") ?
|
||||
output->service : NULL;
|
||||
}
|
||||
|
||||
void obs_output_set_reconnect_settings(obs_output_t *output,
|
||||
int retry_count, int retry_sec)
|
||||
{
|
||||
if (!output) return;
|
||||
if (!obs_output_valid(output, "obs_output_set_reconnect_settings"))
|
||||
return;
|
||||
|
||||
output->reconnect_retry_max = retry_count;
|
||||
output->reconnect_retry_sec = retry_sec;
|
||||
@ -523,7 +556,9 @@ void obs_output_set_reconnect_settings(obs_output_t *output,
|
||||
|
||||
uint64_t obs_output_get_total_bytes(const obs_output_t *output)
|
||||
{
|
||||
if (!output || !output->info.get_total_bytes)
|
||||
if (!obs_output_valid(output, "obs_output_get_total_bytes"))
|
||||
return 0;
|
||||
if (!output->info.get_total_bytes)
|
||||
return 0;
|
||||
|
||||
if (output->delay_active && !output->delay_capturing)
|
||||
@ -534,7 +569,9 @@ uint64_t obs_output_get_total_bytes(const obs_output_t *output)
|
||||
|
||||
int obs_output_get_frames_dropped(const obs_output_t *output)
|
||||
{
|
||||
if (!output || !output->info.get_dropped_frames)
|
||||
if (!obs_output_valid(output, "obs_output_get_frames_dropped"))
|
||||
return 0;
|
||||
if (!output->info.get_dropped_frames)
|
||||
return 0;
|
||||
|
||||
return output->info.get_dropped_frames(output->context.data);
|
||||
@ -542,13 +579,16 @@ int obs_output_get_frames_dropped(const obs_output_t *output)
|
||||
|
||||
int obs_output_get_total_frames(const obs_output_t *output)
|
||||
{
|
||||
return output ? output->total_frames : 0;
|
||||
return obs_output_valid(output, "obs_output_get_total_frames") ?
|
||||
output->total_frames : 0;
|
||||
}
|
||||
|
||||
void obs_output_set_preferred_size(obs_output_t *output, uint32_t width,
|
||||
uint32_t height)
|
||||
{
|
||||
if (!output || (output->info.flags & OBS_OUTPUT_VIDEO) == 0)
|
||||
if (!obs_output_valid(output, "obs_output_set_preferred_size"))
|
||||
return;
|
||||
if ((output->info.flags & OBS_OUTPUT_VIDEO) == 0)
|
||||
return;
|
||||
|
||||
if (output->active) {
|
||||
@ -570,7 +610,9 @@ void obs_output_set_preferred_size(obs_output_t *output, uint32_t width,
|
||||
|
||||
uint32_t obs_output_get_width(const obs_output_t *output)
|
||||
{
|
||||
if (!output || (output->info.flags & OBS_OUTPUT_VIDEO) == 0)
|
||||
if (!obs_output_valid(output, "obs_output_get_width"))
|
||||
return 0;
|
||||
if ((output->info.flags & OBS_OUTPUT_VIDEO) == 0)
|
||||
return 0;
|
||||
|
||||
if (output->info.flags & OBS_OUTPUT_ENCODED)
|
||||
@ -583,7 +625,9 @@ uint32_t obs_output_get_width(const obs_output_t *output)
|
||||
|
||||
uint32_t obs_output_get_height(const obs_output_t *output)
|
||||
{
|
||||
if (!output || (output->info.flags & OBS_OUTPUT_VIDEO) == 0)
|
||||
if (!obs_output_valid(output, "obs_output_get_height"))
|
||||
return 0;
|
||||
if ((output->info.flags & OBS_OUTPUT_VIDEO) == 0)
|
||||
return 0;
|
||||
|
||||
if (output->info.flags & OBS_OUTPUT_ENCODED)
|
||||
@ -597,7 +641,10 @@ uint32_t obs_output_get_height(const obs_output_t *output)
|
||||
void obs_output_set_video_conversion(obs_output_t *output,
|
||||
const struct video_scale_info *conversion)
|
||||
{
|
||||
if (!output || !conversion) return;
|
||||
if (!obs_output_valid(output, "obs_output_set_video_conversion"))
|
||||
return;
|
||||
if (!obs_ptr_valid(conversion, "obs_output_set_video_conversion"))
|
||||
return;
|
||||
|
||||
output->video_conversion = *conversion;
|
||||
output->video_conversion_set = true;
|
||||
@ -606,7 +653,10 @@ void obs_output_set_video_conversion(obs_output_t *output,
|
||||
void obs_output_set_audio_conversion(obs_output_t *output,
|
||||
const struct audio_convert_info *conversion)
|
||||
{
|
||||
if (!output || !conversion) return;
|
||||
if (!obs_output_valid(output, "obs_output_set_audio_conversion"))
|
||||
return;
|
||||
if (!obs_ptr_valid(conversion, "obs_output_set_audio_conversion"))
|
||||
return;
|
||||
|
||||
output->audio_conversion = *conversion;
|
||||
output->audio_conversion_set = true;
|
||||
@ -1160,7 +1210,9 @@ bool obs_output_can_begin_data_capture(const obs_output_t *output,
|
||||
{
|
||||
bool encoded, has_video, has_audio, has_service;
|
||||
|
||||
if (!output) return false;
|
||||
if (!obs_output_valid(output, "obs_output_can_begin_data_capture"))
|
||||
return false;
|
||||
|
||||
if (output->delay_active) return true;
|
||||
if (output->active) return false;
|
||||
|
||||
@ -1206,7 +1258,9 @@ bool obs_output_initialize_encoders(obs_output_t *output, uint32_t flags)
|
||||
bool encoded, has_video, has_audio, has_service;
|
||||
size_t num_mixes = num_audio_mixes(output);
|
||||
|
||||
if (!output) return false;
|
||||
if (!obs_output_valid(output, "obs_output_initialize_encoders"))
|
||||
return false;
|
||||
|
||||
if (output->active) return output->delay_active;
|
||||
|
||||
convert_flags(output, flags, &encoded, &has_video, &has_audio,
|
||||
@ -1254,7 +1308,9 @@ bool obs_output_begin_data_capture(obs_output_t *output, uint32_t flags)
|
||||
{
|
||||
bool encoded, has_video, has_audio, has_service;
|
||||
|
||||
if (!output) return false;
|
||||
if (!obs_output_valid(output, "obs_output_begin_data_capture"))
|
||||
return false;
|
||||
|
||||
if (output->delay_active) return begin_delayed_capture(output);
|
||||
if (output->active) return false;
|
||||
|
||||
@ -1305,7 +1361,8 @@ void obs_output_end_data_capture(obs_output_t *output)
|
||||
bool encoded, has_video, has_audio, has_service;
|
||||
encoded_callback_t encoded_callback;
|
||||
|
||||
if (!output) return;
|
||||
if (!obs_output_valid(output, "obs_output_end_data_capture"))
|
||||
return;
|
||||
|
||||
if (output->delay_active) {
|
||||
output->delay_capturing = false;
|
||||
@ -1415,7 +1472,7 @@ static void output_reconnect(struct obs_output *output)
|
||||
|
||||
void obs_output_signal_stop(obs_output_t *output, int code)
|
||||
{
|
||||
if (!output)
|
||||
if (!obs_output_valid(output, "obs_output_signal_stop"))
|
||||
return;
|
||||
|
||||
obs_output_end_data_capture(output);
|
||||
|
@ -110,7 +110,8 @@ void obs_service_destroy(obs_service_t *service)
|
||||
|
||||
const char *obs_service_get_name(const obs_service_t *service)
|
||||
{
|
||||
return service ? service->context.name : NULL;
|
||||
return obs_service_valid(service, "obs_service_get_name") ?
|
||||
service->context.name : NULL;
|
||||
}
|
||||
|
||||
static inline obs_data_t *get_defaults(const struct obs_service_info *info)
|
||||
@ -144,7 +145,10 @@ obs_properties_t *obs_get_service_properties(const char *id)
|
||||
|
||||
obs_properties_t *obs_service_properties(const obs_service_t *service)
|
||||
{
|
||||
if (service && service->info.get_properties) {
|
||||
if (!obs_service_valid(service, "obs_service_properties"))
|
||||
return NULL;
|
||||
|
||||
if (service->info.get_properties) {
|
||||
obs_properties_t *props;
|
||||
props = service->info.get_properties(service->context.data);
|
||||
obs_properties_apply_settings(props, service->context.settings);
|
||||
@ -156,12 +160,14 @@ obs_properties_t *obs_service_properties(const obs_service_t *service)
|
||||
|
||||
const char *obs_service_get_type(const obs_service_t *service)
|
||||
{
|
||||
return service ? service->info.id : NULL;
|
||||
return obs_service_valid(service, "obs_service_get_type") ?
|
||||
service->info.id : NULL;
|
||||
}
|
||||
|
||||
void obs_service_update(obs_service_t *service, obs_data_t *settings)
|
||||
{
|
||||
if (!service) return;
|
||||
if (!obs_service_valid(service, "obs_service_update"))
|
||||
return;
|
||||
|
||||
obs_data_apply(service->context.settings, settings);
|
||||
|
||||
@ -172,7 +178,7 @@ void obs_service_update(obs_service_t *service, obs_data_t *settings)
|
||||
|
||||
obs_data_t *obs_service_get_settings(const obs_service_t *service)
|
||||
{
|
||||
if (!service)
|
||||
if (!obs_service_valid(service, "obs_service_get_settings"))
|
||||
return NULL;
|
||||
|
||||
obs_data_addref(service->context.settings);
|
||||
@ -181,41 +187,64 @@ obs_data_t *obs_service_get_settings(const obs_service_t *service)
|
||||
|
||||
signal_handler_t *obs_service_get_signal_handler(const obs_service_t *service)
|
||||
{
|
||||
return service ? service->context.signals : NULL;
|
||||
return obs_service_valid(service, "obs_service_get_signal_handler") ?
|
||||
service->context.signals : NULL;
|
||||
}
|
||||
|
||||
proc_handler_t *obs_service_get_proc_handler(const obs_service_t *service)
|
||||
{
|
||||
return service ? service->context.procs : NULL;
|
||||
return obs_service_valid(service, "obs_service_get_proc_handler") ?
|
||||
service->context.procs : NULL;
|
||||
}
|
||||
|
||||
const char *obs_service_get_url(const obs_service_t *service)
|
||||
{
|
||||
if (!service || !service->info.get_url) return NULL;
|
||||
if (!obs_service_valid(service, "obs_service_get_url"))
|
||||
return NULL;
|
||||
|
||||
if (!service->info.get_url) return NULL;
|
||||
return service->info.get_url(service->context.data);
|
||||
}
|
||||
|
||||
const char *obs_service_get_key(const obs_service_t *service)
|
||||
{
|
||||
if (!service || !service->info.get_key) return NULL;
|
||||
if (!obs_service_valid(service, "obs_service_get_key"))
|
||||
return NULL;
|
||||
|
||||
if (!service->info.get_key) return NULL;
|
||||
return service->info.get_key(service->context.data);
|
||||
}
|
||||
|
||||
const char *obs_service_get_username(const obs_service_t *service)
|
||||
{
|
||||
if (!service || !service->info.get_username) return NULL;
|
||||
if (!obs_service_valid(service, "obs_service_get_username"))
|
||||
return NULL;
|
||||
|
||||
if (!service->info.get_username) return NULL;
|
||||
return service->info.get_username(service->context.data);
|
||||
}
|
||||
|
||||
const char *obs_service_get_password(const obs_service_t *service)
|
||||
{
|
||||
if (!service || !service->info.get_password) return NULL;
|
||||
if (!obs_service_valid(service, "obs_service_get_password"))
|
||||
return NULL;
|
||||
|
||||
if (!service->info.get_password) return NULL;
|
||||
return service->info.get_password(service->context.data);
|
||||
}
|
||||
|
||||
void obs_service_activate(struct obs_service *service)
|
||||
{
|
||||
if (!service || !service->output || service->active) return;
|
||||
if (!obs_service_valid(service, "obs_service_activate"))
|
||||
return;
|
||||
if (!service->output) {
|
||||
blog(LOG_WARNING, "obs_service_deactivate: service '%s' "
|
||||
"is not assigned to an output",
|
||||
obs_service_get_name(service));
|
||||
return;
|
||||
}
|
||||
if (service->active)
|
||||
return;
|
||||
|
||||
if (service->info.activate)
|
||||
service->info.activate(service->context.data,
|
||||
@ -225,7 +254,16 @@ void obs_service_activate(struct obs_service *service)
|
||||
|
||||
void obs_service_deactivate(struct obs_service *service, bool remove)
|
||||
{
|
||||
if (!service || !service->output || !service->active) return;
|
||||
if (!obs_service_valid(service, "obs_service_deactivate"))
|
||||
return;
|
||||
if (!service->output) {
|
||||
blog(LOG_WARNING, "obs_service_deactivate: service '%s' "
|
||||
"is not assigned to an output",
|
||||
obs_service_get_name(service));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!service->active) return;
|
||||
|
||||
if (service->info.deactivate)
|
||||
service->info.deactivate(service->context.data);
|
||||
@ -240,7 +278,9 @@ void obs_service_deactivate(struct obs_service *service, bool remove)
|
||||
bool obs_service_initialize(struct obs_service *service,
|
||||
struct obs_output *output)
|
||||
{
|
||||
if (!service || !output)
|
||||
if (!obs_service_valid(service, "obs_service_initialize"))
|
||||
return false;
|
||||
if (!obs_output_valid(output, "obs_service_initialize"))
|
||||
return false;
|
||||
|
||||
if (service->info.initialize)
|
||||
@ -252,7 +292,9 @@ void obs_service_apply_encoder_settings(obs_service_t *service,
|
||||
obs_data_t *video_encoder_settings,
|
||||
obs_data_t *audio_encoder_settings)
|
||||
{
|
||||
if (!service || !service->info.apply_encoder_settings)
|
||||
if (!obs_service_valid(service, "obs_service_apply_encoder_settings"))
|
||||
return;
|
||||
if (!service->info.apply_encoder_settings)
|
||||
return;
|
||||
|
||||
if (video_encoder_settings || audio_encoder_settings)
|
||||
|
@ -312,7 +312,7 @@ void obs_source_frame_init(struct obs_source_frame *frame,
|
||||
{
|
||||
struct video_frame vid_frame;
|
||||
|
||||
if (!frame)
|
||||
if (!obs_ptr_valid(frame, "obs_source_frame_init"))
|
||||
return;
|
||||
|
||||
video_frame_init(&vid_frame, format, width, height);
|
||||
@ -339,7 +339,7 @@ void obs_source_destroy(struct obs_source *source)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (!source)
|
||||
if (!obs_source_valid(source, "obs_source_destroy"))
|
||||
return;
|
||||
|
||||
if (source->info.type == OBS_SOURCE_TYPE_TRANSITION)
|
||||
@ -479,9 +479,12 @@ void obs_source_remove(obs_source_t *source)
|
||||
size_t id;
|
||||
bool exists;
|
||||
|
||||
if (!obs_source_valid(source, "obs_source_remove"))
|
||||
return;
|
||||
|
||||
pthread_mutex_lock(&data->sources_mutex);
|
||||
|
||||
if (!source || source->removed) {
|
||||
if (source->removed) {
|
||||
pthread_mutex_unlock(&data->sources_mutex);
|
||||
return;
|
||||
}
|
||||
@ -507,7 +510,8 @@ void obs_source_remove(obs_source_t *source)
|
||||
|
||||
bool obs_source_removed(const obs_source_t *source)
|
||||
{
|
||||
return source ? source->removed : true;
|
||||
return obs_source_valid(source, "obs_source_removed") ?
|
||||
source->removed : true;
|
||||
}
|
||||
|
||||
static inline obs_data_t *get_defaults(const struct obs_source_info *info)
|
||||
@ -564,7 +568,8 @@ obs_properties_t *obs_source_properties(const obs_source_t *source)
|
||||
|
||||
uint32_t obs_source_get_output_flags(const obs_source_t *source)
|
||||
{
|
||||
return source ? source->info.output_flags : 0;
|
||||
return obs_source_valid(source, "obs_source_get_output_flags") ?
|
||||
source->info.output_flags : 0;
|
||||
}
|
||||
|
||||
uint32_t obs_get_source_output_flags(enum obs_source_type type, const char *id)
|
||||
@ -584,7 +589,8 @@ static void obs_source_deferred_update(obs_source_t *source)
|
||||
|
||||
void obs_source_update(obs_source_t *source, obs_data_t *settings)
|
||||
{
|
||||
if (!source) return;
|
||||
if (!obs_source_valid(source, "obs_source_update"))
|
||||
return;
|
||||
|
||||
if (settings)
|
||||
obs_data_apply(source->context.settings, settings);
|
||||
@ -601,7 +607,8 @@ void obs_source_update_properties(obs_source_t *source)
|
||||
{
|
||||
calldata_t calldata;
|
||||
|
||||
if (!source) return;
|
||||
if (!obs_source_valid(source, "obs_source_update_properties"))
|
||||
return;
|
||||
|
||||
calldata_init(&calldata);
|
||||
calldata_set_ptr(&calldata, "source", source);
|
||||
@ -617,7 +624,7 @@ void obs_source_send_mouse_click(obs_source_t *source,
|
||||
int32_t type, bool mouse_up,
|
||||
uint32_t click_count)
|
||||
{
|
||||
if (!source)
|
||||
if (!obs_source_valid(source, "obs_source_send_mouse_click"))
|
||||
return;
|
||||
|
||||
if (source->info.output_flags & OBS_SOURCE_INTERACTION) {
|
||||
@ -631,7 +638,7 @@ void obs_source_send_mouse_click(obs_source_t *source,
|
||||
void obs_source_send_mouse_move(obs_source_t *source,
|
||||
const struct obs_mouse_event *event, bool mouse_leave)
|
||||
{
|
||||
if (!source)
|
||||
if (!obs_source_valid(source, "obs_source_send_mouse_move"))
|
||||
return;
|
||||
|
||||
if (source->info.output_flags & OBS_SOURCE_INTERACTION) {
|
||||
@ -645,7 +652,7 @@ void obs_source_send_mouse_move(obs_source_t *source,
|
||||
void obs_source_send_mouse_wheel(obs_source_t *source,
|
||||
const struct obs_mouse_event *event, int x_delta, int y_delta)
|
||||
{
|
||||
if (!source)
|
||||
if (!obs_source_valid(source, "obs_source_send_mouse_wheel"))
|
||||
return;
|
||||
|
||||
if (source->info.output_flags & OBS_SOURCE_INTERACTION) {
|
||||
@ -658,7 +665,7 @@ void obs_source_send_mouse_wheel(obs_source_t *source,
|
||||
|
||||
void obs_source_send_focus(obs_source_t *source, bool focus)
|
||||
{
|
||||
if (!source)
|
||||
if (!obs_source_valid(source, "obs_source_send_focus"))
|
||||
return;
|
||||
|
||||
if (source->info.output_flags & OBS_SOURCE_INTERACTION) {
|
||||
@ -671,7 +678,7 @@ void obs_source_send_focus(obs_source_t *source, bool focus)
|
||||
void obs_source_send_key_click(obs_source_t *source,
|
||||
const struct obs_key_event *event, bool key_up)
|
||||
{
|
||||
if (!source)
|
||||
if (!obs_source_valid(source, "obs_source_send_key_click"))
|
||||
return;
|
||||
|
||||
if (source->info.output_flags & OBS_SOURCE_INTERACTION) {
|
||||
@ -746,7 +753,8 @@ static void hide_tree(obs_source_t *parent, obs_source_t *child, void *param)
|
||||
|
||||
void obs_source_activate(obs_source_t *source, enum view_type type)
|
||||
{
|
||||
if (!source) return;
|
||||
if (!obs_source_valid(source, "obs_source_activate"))
|
||||
return;
|
||||
|
||||
if (os_atomic_inc_long(&source->show_refs) == 1) {
|
||||
obs_source_enum_tree(source, show_tree, NULL);
|
||||
@ -761,7 +769,8 @@ void obs_source_activate(obs_source_t *source, enum view_type type)
|
||||
|
||||
void obs_source_deactivate(obs_source_t *source, enum view_type type)
|
||||
{
|
||||
if (!source) return;
|
||||
if (!obs_source_valid(source, "obs_source_deactivate"))
|
||||
return;
|
||||
|
||||
if (os_atomic_dec_long(&source->show_refs) == 0) {
|
||||
obs_source_enum_tree(source, hide_tree, NULL);
|
||||
@ -783,7 +792,8 @@ void obs_source_video_tick(obs_source_t *source, float seconds)
|
||||
{
|
||||
bool now_showing, now_active;
|
||||
|
||||
if (!source) return;
|
||||
if (!obs_source_valid(source, "obs_source_video_tick"))
|
||||
return;
|
||||
|
||||
if ((source->info.output_flags & OBS_SOURCE_ASYNC) != 0) {
|
||||
uint64_t sys_time = obs->video.video_time;
|
||||
@ -1398,7 +1408,8 @@ static bool ready_async_frame(obs_source_t *source, uint64_t sys_time);
|
||||
|
||||
void obs_source_video_render(obs_source_t *source)
|
||||
{
|
||||
if (!source) return;
|
||||
if (!obs_source_valid(source, "obs_source_video_render"))
|
||||
return;
|
||||
|
||||
if (source->info.type != OBS_SOURCE_TYPE_FILTER &&
|
||||
(source->info.output_flags & OBS_SOURCE_VIDEO) == 0)
|
||||
@ -1519,19 +1530,23 @@ uint32_t obs_source_get_base_height(obs_source_t *source)
|
||||
|
||||
obs_source_t *obs_filter_get_parent(const obs_source_t *filter)
|
||||
{
|
||||
return filter ? filter->filter_parent : NULL;
|
||||
return obs_ptr_valid(filter, "obs_filter_get_parent") ?
|
||||
filter->filter_parent : NULL;
|
||||
}
|
||||
|
||||
obs_source_t *obs_filter_get_target(const obs_source_t *filter)
|
||||
{
|
||||
return filter ? filter->filter_target : NULL;
|
||||
return obs_ptr_valid(filter, "obs_filter_get_target") ?
|
||||
filter->filter_target : NULL;
|
||||
}
|
||||
|
||||
void obs_source_filter_add(obs_source_t *source, obs_source_t *filter)
|
||||
{
|
||||
struct calldata cd = {0};
|
||||
|
||||
if (!source || !filter)
|
||||
if (!obs_source_valid(source, "obs_source_filter_add"))
|
||||
return;
|
||||
if (!obs_ptr_valid(filter, "obs_source_filter_add"))
|
||||
return;
|
||||
|
||||
pthread_mutex_lock(&source->filter_mutex);
|
||||
@ -1567,9 +1582,6 @@ static bool obs_source_filter_remove_refless(obs_source_t *source,
|
||||
struct calldata cd = {0};
|
||||
size_t idx;
|
||||
|
||||
if (!source || !filter)
|
||||
return false;
|
||||
|
||||
pthread_mutex_lock(&source->filter_mutex);
|
||||
|
||||
idx = da_find(source->filters, &filter, 0);
|
||||
@ -1605,6 +1617,11 @@ static bool obs_source_filter_remove_refless(obs_source_t *source,
|
||||
|
||||
void obs_source_filter_remove(obs_source_t *source, obs_source_t *filter)
|
||||
{
|
||||
if (!obs_source_valid(source, "obs_source_filter_remove"))
|
||||
return;
|
||||
if (!obs_ptr_valid(filter, "obs_source_filter_remove"))
|
||||
return;
|
||||
|
||||
if (obs_source_filter_remove_refless(source, filter))
|
||||
obs_source_release(filter);
|
||||
}
|
||||
@ -1695,7 +1712,10 @@ void obs_source_filter_set_order(obs_source_t *source, obs_source_t *filter,
|
||||
enum obs_order_movement movement)
|
||||
{
|
||||
bool success;
|
||||
if (!source || !filter)
|
||||
|
||||
if (!obs_source_valid(source, "obs_source_filter_set_order"))
|
||||
return;
|
||||
if (!obs_ptr_valid(filter, "obs_source_filter_set_order"))
|
||||
return;
|
||||
|
||||
pthread_mutex_lock(&source->filter_mutex);
|
||||
@ -1708,7 +1728,8 @@ void obs_source_filter_set_order(obs_source_t *source, obs_source_t *filter,
|
||||
|
||||
obs_data_t *obs_source_get_settings(const obs_source_t *source)
|
||||
{
|
||||
if (!source) return NULL;
|
||||
if (!obs_source_valid(source, "obs_source_get_settings"))
|
||||
return NULL;
|
||||
|
||||
obs_data_addref(source->context.settings);
|
||||
return source->context.settings;
|
||||
@ -1909,7 +1930,7 @@ static inline struct obs_source_frame *cache_video(struct obs_source *source,
|
||||
void obs_source_output_video(obs_source_t *source,
|
||||
const struct obs_source_frame *frame)
|
||||
{
|
||||
if (!source)
|
||||
if (!obs_source_valid(source, "obs_source_output_video"))
|
||||
return;
|
||||
|
||||
if (!frame) {
|
||||
@ -2074,7 +2095,9 @@ void obs_source_output_audio(obs_source_t *source,
|
||||
{
|
||||
struct obs_audio_data *output;
|
||||
|
||||
if (!source || !audio)
|
||||
if (!obs_source_valid(source, "obs_source_output_audio"))
|
||||
return;
|
||||
if (!obs_ptr_valid(audio, "obs_source_output_audio"))
|
||||
return;
|
||||
|
||||
process_audio(source, audio);
|
||||
@ -2239,7 +2262,7 @@ struct obs_source_frame *obs_source_get_frame(obs_source_t *source)
|
||||
{
|
||||
struct obs_source_frame *frame = NULL;
|
||||
|
||||
if (!source)
|
||||
if (!obs_source_valid(source, "obs_source_get_frame"))
|
||||
return NULL;
|
||||
|
||||
pthread_mutex_lock(&source->async_mutex);
|
||||
@ -2259,7 +2282,7 @@ struct obs_source_frame *obs_source_get_frame(obs_source_t *source)
|
||||
void obs_source_release_frame(obs_source_t *source,
|
||||
struct obs_source_frame *frame)
|
||||
{
|
||||
if (!frame)
|
||||
if (!obs_ptr_valid(frame, "obs_source_release_frame"))
|
||||
return;
|
||||
|
||||
if (!source) {
|
||||
@ -2278,12 +2301,14 @@ void obs_source_release_frame(obs_source_t *source,
|
||||
|
||||
const char *obs_source_get_name(const obs_source_t *source)
|
||||
{
|
||||
return source ? source->context.name : NULL;
|
||||
return obs_source_valid(source, "obs_source_get_name") ?
|
||||
source->context.name : NULL;
|
||||
}
|
||||
|
||||
void obs_source_set_name(obs_source_t *source, const char *name)
|
||||
{
|
||||
if (!source) return;
|
||||
if (!obs_source_valid(source, "obs_source_set_name"))
|
||||
return;
|
||||
|
||||
if (!name || !*name || strcmp(name, source->context.name) != 0) {
|
||||
struct calldata data;
|
||||
@ -2303,12 +2328,14 @@ void obs_source_set_name(obs_source_t *source, const char *name)
|
||||
|
||||
enum obs_source_type obs_source_get_type(const obs_source_t *source)
|
||||
{
|
||||
return source ? source->info.type : OBS_SOURCE_TYPE_INPUT;
|
||||
return obs_source_valid(source, "obs_source_get_type") ?
|
||||
source->info.type : OBS_SOURCE_TYPE_INPUT;
|
||||
}
|
||||
|
||||
const char *obs_source_get_id(const obs_source_t *source)
|
||||
{
|
||||
return source ? source->info.id : NULL;
|
||||
return obs_source_valid(source, "obs_source_get_id") ?
|
||||
source->info.id : NULL;
|
||||
}
|
||||
|
||||
static inline void render_filter_bypass(obs_source_t *target,
|
||||
@ -2365,7 +2392,8 @@ void obs_source_process_filter_begin(obs_source_t *filter,
|
||||
int cx, cy;
|
||||
bool use_matrix;
|
||||
|
||||
if (!filter) return;
|
||||
if (!obs_ptr_valid(filter, "obs_source_process_filter_begin"))
|
||||
return;
|
||||
|
||||
target = obs_filter_get_target(filter);
|
||||
parent = obs_filter_get_parent(filter);
|
||||
@ -2420,7 +2448,8 @@ void obs_source_process_filter_end(obs_source_t *filter, gs_effect_t *effect,
|
||||
uint32_t target_flags, parent_flags;
|
||||
bool use_matrix;
|
||||
|
||||
if (!filter) return;
|
||||
if (!obs_ptr_valid(filter, "obs_source_process_filter_end"))
|
||||
return;
|
||||
|
||||
target = obs_filter_get_target(filter);
|
||||
parent = obs_filter_get_parent(filter);
|
||||
@ -2443,7 +2472,8 @@ void obs_source_skip_video_filter(obs_source_t *filter)
|
||||
uint32_t parent_flags;
|
||||
bool use_matrix;
|
||||
|
||||
if (!filter) return;
|
||||
if (!obs_ptr_valid(filter, "obs_source_skip_video_filter"))
|
||||
return;
|
||||
|
||||
target = obs_filter_get_target(filter);
|
||||
parent = obs_filter_get_parent(filter);
|
||||
@ -2467,17 +2497,19 @@ void obs_source_skip_video_filter(obs_source_t *filter)
|
||||
|
||||
signal_handler_t *obs_source_get_signal_handler(const obs_source_t *source)
|
||||
{
|
||||
return source ? source->context.signals : NULL;
|
||||
return obs_source_valid(source, "obs_source_get_signal_handler") ?
|
||||
source->context.signals : NULL;
|
||||
}
|
||||
|
||||
proc_handler_t *obs_source_get_proc_handler(const obs_source_t *source)
|
||||
{
|
||||
return source ? source->context.procs : NULL;
|
||||
return obs_source_valid(source, "obs_source_get_proc_handler") ?
|
||||
source->context.procs : NULL;
|
||||
}
|
||||
|
||||
void obs_source_set_volume(obs_source_t *source, float volume)
|
||||
{
|
||||
if (source) {
|
||||
if (obs_source_valid(source, "obs_source_set_volume")) {
|
||||
struct calldata data = {0};
|
||||
calldata_set_ptr(&data, "source", source);
|
||||
calldata_set_float(&data, "volume", volume);
|
||||
@ -2503,23 +2535,25 @@ static void set_tree_preset_vol(obs_source_t *parent, obs_source_t *child,
|
||||
|
||||
void obs_source_set_present_volume(obs_source_t *source, float volume)
|
||||
{
|
||||
if (source)
|
||||
if (obs_source_valid(source, "obs_source_set_present_volume"))
|
||||
source->present_volume = volume;
|
||||
}
|
||||
|
||||
float obs_source_get_volume(const obs_source_t *source)
|
||||
{
|
||||
return source ? source->user_volume : 0.0f;
|
||||
return obs_source_valid(source, "obs_source_get_volume") ?
|
||||
source->user_volume : 0.0f;
|
||||
}
|
||||
|
||||
float obs_source_get_present_volume(const obs_source_t *source)
|
||||
{
|
||||
return source ? source->present_volume : 0.0f;
|
||||
return obs_source_valid(source, "obs_source_get_present_volume") ?
|
||||
source->present_volume : 0.0f;
|
||||
}
|
||||
|
||||
void obs_source_set_sync_offset(obs_source_t *source, int64_t offset)
|
||||
{
|
||||
if (source) {
|
||||
if (obs_source_valid(source, "obs_source_set_sync_offset")) {
|
||||
struct calldata data = {0};
|
||||
|
||||
calldata_set_ptr(&data, "source", source);
|
||||
@ -2535,7 +2569,8 @@ void obs_source_set_sync_offset(obs_source_t *source, int64_t offset)
|
||||
|
||||
int64_t obs_source_get_sync_offset(const obs_source_t *source)
|
||||
{
|
||||
return source ? source->sync_offset : 0;
|
||||
return obs_source_valid(source, "obs_source_get_sync_offset") ?
|
||||
source->sync_offset : 0;
|
||||
}
|
||||
|
||||
struct source_enum_data {
|
||||
@ -2610,7 +2645,15 @@ static void check_descendant(obs_source_t *parent, obs_source_t *child,
|
||||
bool obs_source_add_child(obs_source_t *parent, obs_source_t *child)
|
||||
{
|
||||
struct descendant_info info = {false, parent};
|
||||
if (!parent || !child || parent == child) return false;
|
||||
|
||||
if (!obs_ptr_valid(parent, "obs_source_add_child"))
|
||||
return false;
|
||||
if (!obs_ptr_valid(parent, "obs_source_add_child"))
|
||||
return false;
|
||||
if (parent == child) {
|
||||
blog(LOG_WARNING, "obs_source_add_child: parent == child");
|
||||
return false;
|
||||
}
|
||||
|
||||
obs_source_enum_tree(child, check_descendant, &info);
|
||||
if (info.exists)
|
||||
@ -2627,7 +2670,10 @@ bool obs_source_add_child(obs_source_t *parent, obs_source_t *child)
|
||||
|
||||
void obs_source_remove_child(obs_source_t *parent, obs_source_t *child)
|
||||
{
|
||||
if (!parent || !child) return;
|
||||
if (!obs_ptr_valid(parent, "obs_source_remove_child"))
|
||||
return;
|
||||
if (!obs_ptr_valid(parent, "obs_source_remove_child"))
|
||||
return;
|
||||
|
||||
for (int i = 0; i < parent->show_refs; i++) {
|
||||
enum view_type type;
|
||||
@ -2658,12 +2704,14 @@ void obs_source_load(obs_source_t *source)
|
||||
|
||||
bool obs_source_active(const obs_source_t *source)
|
||||
{
|
||||
return source ? source->activate_refs != 0 : false;
|
||||
return obs_source_valid(source, "obs_source_active") ?
|
||||
source->activate_refs != 0 : false;
|
||||
}
|
||||
|
||||
bool obs_source_showing(const obs_source_t *source)
|
||||
{
|
||||
return source ? source->show_refs != 0 : false;
|
||||
return obs_source_valid(source, "obs_source_showing") ?
|
||||
source->show_refs != 0 : false;
|
||||
}
|
||||
|
||||
static inline void signal_flags_updated(obs_source_t *source)
|
||||
@ -2680,7 +2728,8 @@ static inline void signal_flags_updated(obs_source_t *source)
|
||||
|
||||
void obs_source_set_flags(obs_source_t *source, uint32_t flags)
|
||||
{
|
||||
if (!source) return;
|
||||
if (!obs_source_valid(source, "obs_source_set_flags"))
|
||||
return;
|
||||
|
||||
if (flags != source->flags) {
|
||||
source->flags = flags;
|
||||
@ -2690,14 +2739,16 @@ void obs_source_set_flags(obs_source_t *source, uint32_t flags)
|
||||
|
||||
void obs_source_set_default_flags(obs_source_t *source, uint32_t flags)
|
||||
{
|
||||
if (!source) return;
|
||||
if (!obs_source_valid(source, "obs_source_set_default_flags"))
|
||||
return;
|
||||
|
||||
source->default_flags = flags;
|
||||
}
|
||||
|
||||
uint32_t obs_source_get_flags(const obs_source_t *source)
|
||||
{
|
||||
return source ? source->flags : 0;
|
||||
return obs_source_valid(source, "obs_source_get_flags") ?
|
||||
source->flags : 0;
|
||||
}
|
||||
|
||||
void obs_source_set_audio_mixers(obs_source_t *source, uint32_t mixers)
|
||||
@ -2705,8 +2756,10 @@ void obs_source_set_audio_mixers(obs_source_t *source, uint32_t mixers)
|
||||
struct calldata data = {0};
|
||||
uint32_t cur_mixers;
|
||||
|
||||
if (!source) return;
|
||||
if ((source->info.output_flags & OBS_SOURCE_AUDIO) == 0) return;
|
||||
if (!obs_source_valid(source, "obs_source_set_audio_mixers"))
|
||||
return;
|
||||
if ((source->info.output_flags & OBS_SOURCE_AUDIO) == 0)
|
||||
return;
|
||||
|
||||
cur_mixers = audio_line_get_mixers(source->audio_line);
|
||||
if (cur_mixers == mixers)
|
||||
@ -2725,8 +2778,10 @@ void obs_source_set_audio_mixers(obs_source_t *source, uint32_t mixers)
|
||||
|
||||
uint32_t obs_source_get_audio_mixers(const obs_source_t *source)
|
||||
{
|
||||
if (!source) return 0;
|
||||
if ((source->info.output_flags & OBS_SOURCE_AUDIO) == 0) return 0;
|
||||
if (!obs_source_valid(source, "obs_source_get_audio_mixers"))
|
||||
return 0;
|
||||
if ((source->info.output_flags & OBS_SOURCE_AUDIO) == 0)
|
||||
return 0;
|
||||
|
||||
return audio_line_get_mixers(source->audio_line);
|
||||
}
|
||||
@ -2747,16 +2802,13 @@ void obs_source_draw_set_color_matrix(const struct matrix4 *color_matrix,
|
||||
gs_eparam_t *range_max;
|
||||
|
||||
if (!effect) {
|
||||
blog(LOG_WARNING, "obs_source_draw_set_color_matrix: NULL "
|
||||
"effect");
|
||||
blog(LOG_WARNING, "obs_source_draw_set_color_matrix: no "
|
||||
"active effect!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!color_matrix) {
|
||||
blog(LOG_WARNING, "obs_source_draw_set_color_matrix: NULL "
|
||||
"color_matrix");
|
||||
if (!obs_ptr_valid(color_matrix, "obs_source_draw_set_color_matrix"))
|
||||
return;
|
||||
}
|
||||
|
||||
if (!color_range_min)
|
||||
color_range_min = &color_range_min_def;
|
||||
@ -2780,14 +2832,12 @@ void obs_source_draw(gs_texture_t *texture, int x, int y, uint32_t cx,
|
||||
gs_eparam_t *image;
|
||||
|
||||
if (!effect) {
|
||||
blog(LOG_WARNING, "obs_source_draw: NULL effect");
|
||||
blog(LOG_WARNING, "obs_source_draw: no active effect!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!texture) {
|
||||
blog(LOG_WARNING, "obs_source_draw: NULL texture");
|
||||
if (!obs_ptr_valid(texture, "obs_source_draw"))
|
||||
return;
|
||||
}
|
||||
|
||||
image = gs_effect_get_param_by_name(effect, "image");
|
||||
gs_effect_set_texture(image, texture);
|
||||
@ -2851,7 +2901,14 @@ static void get_source_base_vol(obs_source_t *parent, obs_source_t *child,
|
||||
float obs_source_get_target_volume(obs_source_t *source, obs_source_t *target)
|
||||
{
|
||||
struct base_vol_enum_info info = {target, 0.0f};
|
||||
bool transition = source->info.type == OBS_SOURCE_TYPE_TRANSITION;
|
||||
bool transition;
|
||||
|
||||
if (!obs_source_valid(source, "obs_source_get_target_volume"))
|
||||
return 0.0f;
|
||||
if (!obs_ptr_valid(target, "obs_source_get_target_volume"))
|
||||
return 0.0f;
|
||||
|
||||
transition = source->info.type == OBS_SOURCE_TYPE_TRANSITION;
|
||||
|
||||
if (source == target)
|
||||
return 1.0f;
|
||||
@ -2869,18 +2926,22 @@ float obs_source_get_target_volume(obs_source_t *source, obs_source_t *target)
|
||||
|
||||
void obs_source_inc_showing(obs_source_t *source)
|
||||
{
|
||||
obs_source_activate(source, AUX_VIEW);
|
||||
if (obs_source_valid(source, "obs_source_inc_showing"))
|
||||
obs_source_activate(source, AUX_VIEW);
|
||||
}
|
||||
|
||||
void obs_source_dec_showing(obs_source_t *source)
|
||||
{
|
||||
obs_source_deactivate(source, AUX_VIEW);
|
||||
if (obs_source_valid(source, "obs_source_dec_showing"))
|
||||
obs_source_deactivate(source, AUX_VIEW);
|
||||
}
|
||||
|
||||
void obs_source_enum_filters(obs_source_t *source,
|
||||
obs_source_enum_proc_t callback, void *param)
|
||||
{
|
||||
if (!source || !callback)
|
||||
if (!obs_source_valid(source, "obs_source_enum_filters"))
|
||||
return;
|
||||
if (!obs_ptr_valid(callback, "obs_source_enum_filters"))
|
||||
return;
|
||||
|
||||
pthread_mutex_lock(&source->filter_mutex);
|
||||
@ -2898,7 +2959,9 @@ obs_source_t *obs_source_get_filter_by_name(obs_source_t *source,
|
||||
{
|
||||
obs_source_t *filter = NULL;
|
||||
|
||||
if (!source || !name)
|
||||
if (!obs_source_valid(source, "obs_source_get_filter_by_name"))
|
||||
return NULL;
|
||||
if (!obs_ptr_valid(name, "obs_source_get_filter_by_name"))
|
||||
return NULL;
|
||||
|
||||
pthread_mutex_lock(&source->filter_mutex);
|
||||
@ -2919,14 +2982,15 @@ obs_source_t *obs_source_get_filter_by_name(obs_source_t *source,
|
||||
|
||||
bool obs_source_enabled(const obs_source_t *source)
|
||||
{
|
||||
return source ? source->enabled : false;
|
||||
return obs_source_valid(source, "obs_source_enabled") ?
|
||||
source->enabled : false;
|
||||
}
|
||||
|
||||
void obs_source_set_enabled(obs_source_t *source, bool enabled)
|
||||
{
|
||||
struct calldata data = {0};
|
||||
|
||||
if (!source)
|
||||
if (!obs_source_valid(source, "obs_source_set_enabled"))
|
||||
return;
|
||||
|
||||
source->enabled = enabled;
|
||||
@ -2941,14 +3005,15 @@ void obs_source_set_enabled(obs_source_t *source, bool enabled)
|
||||
|
||||
bool obs_source_muted(const obs_source_t *source)
|
||||
{
|
||||
return source ? source->muted : false;
|
||||
return obs_source_valid(source, "obs_source_muted") ?
|
||||
source->muted : false;
|
||||
}
|
||||
|
||||
void obs_source_set_muted(obs_source_t *source, bool muted)
|
||||
{
|
||||
struct calldata data = {0};
|
||||
|
||||
if (!source)
|
||||
if (!obs_source_valid(source, "obs_source_set_muted"))
|
||||
return;
|
||||
|
||||
source->muted = muted;
|
||||
@ -2988,7 +3053,8 @@ static void source_signal_push_to_delay(obs_source_t *source,
|
||||
bool obs_source_push_to_mute_enabled(obs_source_t *source)
|
||||
{
|
||||
bool enabled;
|
||||
if (!source) return false;
|
||||
if (!obs_source_valid(source, "obs_source_push_to_mute_enabled"))
|
||||
return false;
|
||||
|
||||
pthread_mutex_lock(&source->audio_mutex);
|
||||
enabled = source->push_to_mute_enabled;
|
||||
@ -2999,7 +3065,8 @@ bool obs_source_push_to_mute_enabled(obs_source_t *source)
|
||||
|
||||
void obs_source_enable_push_to_mute(obs_source_t *source, bool enabled)
|
||||
{
|
||||
if (!source) return;
|
||||
if (!obs_source_valid(source, "obs_source_enable_push_to_mute"))
|
||||
return;
|
||||
|
||||
pthread_mutex_lock(&source->audio_mutex);
|
||||
bool changed = source->push_to_mute_enabled != enabled;
|
||||
@ -3019,7 +3086,8 @@ void obs_source_enable_push_to_mute(obs_source_t *source, bool enabled)
|
||||
uint64_t obs_source_get_push_to_mute_delay(obs_source_t *source)
|
||||
{
|
||||
uint64_t delay;
|
||||
if (!source) return 0;
|
||||
if (!obs_source_valid(source, "obs_source_get_push_to_mute_delay"))
|
||||
return 0;
|
||||
|
||||
pthread_mutex_lock(&source->audio_mutex);
|
||||
delay = source->push_to_mute_delay;
|
||||
@ -3030,7 +3098,8 @@ uint64_t obs_source_get_push_to_mute_delay(obs_source_t *source)
|
||||
|
||||
void obs_source_set_push_to_mute_delay(obs_source_t *source, uint64_t delay)
|
||||
{
|
||||
if (!source) return;
|
||||
if (!obs_source_valid(source, "obs_source_set_push_to_mute_delay"))
|
||||
return;
|
||||
|
||||
pthread_mutex_lock(&source->audio_mutex);
|
||||
source->push_to_mute_delay = delay;
|
||||
@ -3042,7 +3111,8 @@ void obs_source_set_push_to_mute_delay(obs_source_t *source, uint64_t delay)
|
||||
bool obs_source_push_to_talk_enabled(obs_source_t *source)
|
||||
{
|
||||
bool enabled;
|
||||
if (!source) return false;
|
||||
if (!obs_source_valid(source, "obs_source_push_to_talk_enabled"))
|
||||
return false;
|
||||
|
||||
pthread_mutex_lock(&source->audio_mutex);
|
||||
enabled = source->push_to_talk_enabled;
|
||||
@ -3053,7 +3123,8 @@ bool obs_source_push_to_talk_enabled(obs_source_t *source)
|
||||
|
||||
void obs_source_enable_push_to_talk(obs_source_t *source, bool enabled)
|
||||
{
|
||||
if (!source) return;
|
||||
if (!obs_source_valid(source, "obs_source_enable_push_to_talk"))
|
||||
return;
|
||||
|
||||
pthread_mutex_lock(&source->audio_mutex);
|
||||
bool changed = source->push_to_talk_enabled != enabled;
|
||||
@ -3073,7 +3144,8 @@ void obs_source_enable_push_to_talk(obs_source_t *source, bool enabled)
|
||||
uint64_t obs_source_get_push_to_talk_delay(obs_source_t *source)
|
||||
{
|
||||
uint64_t delay;
|
||||
if (!source) return 0;
|
||||
if (!obs_source_valid(source, "obs_source_get_push_to_talk_delay"))
|
||||
return 0;
|
||||
|
||||
pthread_mutex_lock(&source->audio_mutex);
|
||||
delay = source->push_to_talk_delay;
|
||||
@ -3084,7 +3156,8 @@ uint64_t obs_source_get_push_to_talk_delay(obs_source_t *source)
|
||||
|
||||
void obs_source_set_push_to_talk_delay(obs_source_t *source, uint64_t delay)
|
||||
{
|
||||
if (!source) return;
|
||||
if (!obs_source_valid(source, "obs_source_set_push_to_talk_delay"))
|
||||
return;
|
||||
|
||||
pthread_mutex_lock(&source->audio_mutex);
|
||||
source->push_to_talk_delay = delay;
|
||||
|
Loading…
x
Reference in New Issue
Block a user