obs_encoder_t obs_encoder_create(const char *id, const char *name, obs_data_t settings) { struct obs_encoder *encoder; struct obs_encoder_info *ei = get_encoder_info(id); if (!ei) return NULL; encoder = bzalloc(sizeof(struct obs_encoder)); encoder->info = *ei; if (pthread_mutex_init(&encoder->data_callbacks_mutex, NULL) != 0) { bfree(encoder); return NULL; } encoder->settings = obs_data_newref(settings); encoder->data = ei->create(encoder->settings, encoder); if (!encoder->data) { pthread_mutex_destroy(&encoder->data_callbacks_mutex); obs_data_release(encoder->settings); bfree(encoder); return NULL; } pthread_mutex_lock(&obs->data.encoders_mutex); da_push_back(obs->data.encoders, &encoder); pthread_mutex_unlock(&obs->data.encoders_mutex); encoder->name = bstrdup(name); return encoder; }
obs_output_t obs_output_create(const char *id, const char *name, obs_data_t settings) { const struct obs_output_info *info = find_output(id); struct obs_output *output; if (!info) { blog(LOG_ERROR, "Output '%s' not found", id); return NULL; } output = bzalloc(sizeof(struct obs_output)); output->signals = signal_handler_create(); if (!output->signals) goto fail; output->procs = proc_handler_create(); if (!output->procs) goto fail; output->info = *info; output->settings = obs_data_newref(settings); output->data = info->create(output->settings, output); if (!output->data) goto fail; output->name = bstrdup(name); pthread_mutex_lock(&obs->data.outputs_mutex); da_push_back(obs->data.outputs, &output); pthread_mutex_unlock(&obs->data.outputs_mutex); output->valid = true; return output; fail: obs_output_destroy(output); return NULL; }
static inline bool obs_context_data_init_wrap( struct obs_context_data *context, obs_data_t *settings, const char *name) { assert(context); memset(context, 0, sizeof(*context)); pthread_mutex_init_value(&context->rename_cache_mutex); if (pthread_mutex_init(&context->rename_cache_mutex, NULL) < 0) return false; context->signals = signal_handler_create(); if (!context->signals) return false; context->procs = proc_handler_create(); if (!context->procs) return false; context->name = dup_name(name); context->settings = obs_data_newref(settings); return true; }
obs_source_t obs_source_create(enum obs_source_type type, const char *id, const char *name, obs_data_t settings) { struct obs_source *source; const struct source_info *info = get_source_info(type, id); if (!info) { blog(LOG_WARNING, "Source '%s' not found", id); return NULL; } source = bmalloc(sizeof(struct obs_source)); memset(source, 0, sizeof(struct obs_source)); if (!obs_source_init_handlers(source)) goto fail; source->name = bstrdup(name); source->type = type; source->settings = obs_data_newref(settings); source->data = info->create(source->settings, source); if (!source->data) goto fail; if (!obs_source_init(source, info)) goto fail; obs_source_dosignal(source, "source-create"); return source; fail: blog(LOG_ERROR, "obs_source_create failed"); obs_source_destroy(source); return NULL; }