(API Change) libobs: Add hotkey data to *_create functions
This commit is contained in:
parent
d0cae31a48
commit
1d39c3e9b6
@ -37,12 +37,13 @@ const char *obs_encoder_get_display_name(const char *id)
|
||||
}
|
||||
|
||||
static bool init_encoder(struct obs_encoder *encoder, const char *name,
|
||||
obs_data_t *settings)
|
||||
obs_data_t *settings, obs_data_t *hotkey_data)
|
||||
{
|
||||
pthread_mutex_init_value(&encoder->callbacks_mutex);
|
||||
pthread_mutex_init_value(&encoder->outputs_mutex);
|
||||
|
||||
if (!obs_context_data_init(&encoder->context, settings, name, NULL))
|
||||
if (!obs_context_data_init(&encoder->context, settings, name,
|
||||
hotkey_data))
|
||||
return false;
|
||||
if (pthread_mutex_init(&encoder->callbacks_mutex, NULL) != 0)
|
||||
return false;
|
||||
@ -57,7 +58,7 @@ static bool init_encoder(struct obs_encoder *encoder, const char *name,
|
||||
|
||||
static struct obs_encoder *create_encoder(const char *id,
|
||||
enum obs_encoder_type type, const char *name,
|
||||
obs_data_t *settings, size_t mixer_idx)
|
||||
obs_data_t *settings, size_t mixer_idx, obs_data_t *hotkey_data)
|
||||
{
|
||||
struct obs_encoder *encoder;
|
||||
struct obs_encoder_info *ei = find_encoder(id);
|
||||
@ -70,7 +71,7 @@ static struct obs_encoder *create_encoder(const char *id,
|
||||
encoder->info = *ei;
|
||||
encoder->mixer_idx = mixer_idx;
|
||||
|
||||
success = init_encoder(encoder, name, settings);
|
||||
success = init_encoder(encoder, name, settings, hotkey_data);
|
||||
if (!success) {
|
||||
obs_encoder_destroy(encoder);
|
||||
encoder = NULL;
|
||||
@ -88,17 +89,19 @@ static struct obs_encoder *create_encoder(const char *id,
|
||||
}
|
||||
|
||||
obs_encoder_t *obs_video_encoder_create(const char *id, const char *name,
|
||||
obs_data_t *settings)
|
||||
obs_data_t *settings, obs_data_t *hotkey_data)
|
||||
{
|
||||
if (!name || !id) return NULL;
|
||||
return create_encoder(id, OBS_ENCODER_VIDEO, name, settings, 0);
|
||||
return create_encoder(id, OBS_ENCODER_VIDEO, name, settings, 0,
|
||||
hotkey_data);
|
||||
}
|
||||
|
||||
obs_encoder_t *obs_audio_encoder_create(const char *id, const char *name,
|
||||
obs_data_t *settings, size_t mixer_idx)
|
||||
obs_data_t *settings, size_t mixer_idx, obs_data_t *hotkey_data)
|
||||
{
|
||||
if (!name || !id) return NULL;
|
||||
return create_encoder(id, OBS_ENCODER_AUDIO, name, settings, mixer_idx);
|
||||
return create_encoder(id, OBS_ENCODER_AUDIO, name, settings, mixer_idx,
|
||||
hotkey_data);
|
||||
}
|
||||
|
||||
static void receive_video(void *param, struct video_data *frame);
|
||||
|
@ -517,7 +517,8 @@ struct obs_source {
|
||||
extern const struct obs_source_info *find_source(struct darray *list,
|
||||
const char *id);
|
||||
extern bool obs_source_init_context(struct obs_source *source,
|
||||
obs_data_t *settings, const char *name);
|
||||
obs_data_t *settings, const char *name,
|
||||
obs_data_t *hotkey_data);
|
||||
extern bool obs_source_init(struct obs_source *source,
|
||||
const struct obs_source_info *info);
|
||||
|
||||
|
@ -47,9 +47,10 @@ static const char *output_signals[] = {
|
||||
};
|
||||
|
||||
static bool init_output_handlers(struct obs_output *output, const char *name,
|
||||
obs_data_t *settings)
|
||||
obs_data_t *settings, obs_data_t *hotkey_data)
|
||||
{
|
||||
if (!obs_context_data_init(&output->context, settings, name, NULL))
|
||||
if (!obs_context_data_init(&output->context, settings, name,
|
||||
hotkey_data))
|
||||
return false;
|
||||
|
||||
signal_handler_add_array(output->context.signals, output_signals);
|
||||
@ -57,7 +58,7 @@ static bool init_output_handlers(struct obs_output *output, const char *name,
|
||||
}
|
||||
|
||||
obs_output_t *obs_output_create(const char *id, const char *name,
|
||||
obs_data_t *settings)
|
||||
obs_data_t *settings, obs_data_t *hotkey_data)
|
||||
{
|
||||
const struct obs_output_info *info = find_output(id);
|
||||
struct obs_output *output;
|
||||
@ -73,7 +74,7 @@ obs_output_t *obs_output_create(const char *id, const char *name,
|
||||
|
||||
if (pthread_mutex_init(&output->interleaved_mutex, NULL) != 0)
|
||||
goto fail;
|
||||
if (!init_output_handlers(output, name, settings))
|
||||
if (!init_output_handlers(output, name, settings, hotkey_data))
|
||||
goto fail;
|
||||
|
||||
output->info = *info;
|
||||
|
@ -473,7 +473,8 @@ const struct obs_source_info scene_info =
|
||||
obs_scene_t *obs_scene_create(const char *name)
|
||||
{
|
||||
struct obs_source *source =
|
||||
obs_source_create(OBS_SOURCE_TYPE_INPUT, "scene", name, NULL);
|
||||
obs_source_create(OBS_SOURCE_TYPE_INPUT, "scene", name, NULL,
|
||||
NULL);
|
||||
return source->context.data;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ const char *obs_service_get_display_name(const char *id)
|
||||
}
|
||||
|
||||
obs_service_t *obs_service_create(const char *id, const char *name,
|
||||
obs_data_t *settings)
|
||||
obs_data_t *settings, obs_data_t *hotkey_data)
|
||||
{
|
||||
const struct obs_service_info *info = find_service(id);
|
||||
struct obs_service *service;
|
||||
@ -46,7 +46,8 @@ obs_service_t *obs_service_create(const char *id, const char *name,
|
||||
|
||||
service = bzalloc(sizeof(struct obs_service));
|
||||
|
||||
if (!obs_context_data_init(&service->context, settings, name, NULL)) {
|
||||
if (!obs_context_data_init(&service->context, settings, name,
|
||||
hotkey_data)) {
|
||||
bfree(service);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -94,9 +94,10 @@ static const char *source_signals[] = {
|
||||
};
|
||||
|
||||
bool obs_source_init_context(struct obs_source *source,
|
||||
obs_data_t *settings, const char *name)
|
||||
obs_data_t *settings, const char *name, obs_data_t *hotkey_data)
|
||||
{
|
||||
if (!obs_context_data_init(&source->context, settings, name, NULL))
|
||||
if (!obs_context_data_init(&source->context, settings, name,
|
||||
hotkey_data))
|
||||
return false;
|
||||
|
||||
return signal_handler_add_array(source->context.signals,
|
||||
@ -170,7 +171,7 @@ static inline void obs_source_dosignal(struct obs_source *source,
|
||||
}
|
||||
|
||||
obs_source_t *obs_source_create(enum obs_source_type type, const char *id,
|
||||
const char *name, obs_data_t *settings)
|
||||
const char *name, obs_data_t *settings, obs_data_t *hotkey_data)
|
||||
{
|
||||
struct obs_source *source = bzalloc(sizeof(struct obs_source));
|
||||
|
||||
@ -185,7 +186,7 @@ obs_source_t *obs_source_create(enum obs_source_type type, const char *id,
|
||||
source->info = *info;
|
||||
}
|
||||
|
||||
if (!obs_source_init_context(source, settings, name))
|
||||
if (!obs_source_init_context(source, settings, name, hotkey_data))
|
||||
goto fail;
|
||||
|
||||
if (info && info->get_defaults)
|
||||
|
@ -1425,11 +1425,9 @@ static obs_source_t *obs_load_source_type(obs_data_t *source_data,
|
||||
uint32_t flags;
|
||||
uint32_t mixers;
|
||||
|
||||
source = obs_source_create(type, id, name, settings);
|
||||
source = obs_source_create(type, id, name, settings, hotkeys);
|
||||
|
||||
obs_data_release(source->context.hotkey_data);
|
||||
source->context.hotkey_data = hotkeys;
|
||||
obs_hotkeys_load_source(source, hotkeys);
|
||||
obs_data_release(hotkeys);
|
||||
|
||||
obs_data_set_default_double(source_data, "volume", 1.0);
|
||||
volume = obs_data_get_double(source_data, "volume");
|
||||
|
12
libobs/obs.h
12
libobs/obs.h
@ -655,7 +655,8 @@ EXPORT const char *obs_source_get_display_name(enum obs_source_type type,
|
||||
* or modifying video/audio. Use obs_source_release to release it.
|
||||
*/
|
||||
EXPORT obs_source_t *obs_source_create(enum obs_source_type type,
|
||||
const char *id, const char *name, obs_data_t *settings);
|
||||
const char *id, const char *name, obs_data_t *settings,
|
||||
obs_data_t *hotkey_data);
|
||||
|
||||
/**
|
||||
* Adds/releases a reference to a source. When the last reference is
|
||||
@ -1092,7 +1093,7 @@ EXPORT const char *obs_output_get_display_name(const char *id);
|
||||
* directshow, or other custom outputs.
|
||||
*/
|
||||
EXPORT obs_output_t *obs_output_create(const char *id, const char *name,
|
||||
obs_data_t *settings);
|
||||
obs_data_t *settings, obs_data_t *hotkey_data);
|
||||
|
||||
/**
|
||||
* Adds/releases a reference to an output. When the last reference is
|
||||
@ -1302,7 +1303,7 @@ EXPORT const char *obs_encoder_get_display_name(const char *id);
|
||||
* @return The video encoder context, or NULL if failed or not found.
|
||||
*/
|
||||
EXPORT obs_encoder_t *obs_video_encoder_create(const char *id, const char *name,
|
||||
obs_data_t *settings);
|
||||
obs_data_t *settings, obs_data_t *hotkey_data);
|
||||
|
||||
/**
|
||||
* Creates an audio encoder context
|
||||
@ -1314,7 +1315,8 @@ EXPORT obs_encoder_t *obs_video_encoder_create(const char *id, const char *name,
|
||||
* @return The video encoder context, or NULL if failed or not found.
|
||||
*/
|
||||
EXPORT obs_encoder_t *obs_audio_encoder_create(const char *id, const char *name,
|
||||
obs_data_t *settings, size_t mixer_idx);
|
||||
obs_data_t *settings, size_t mixer_idx,
|
||||
obs_data_t *hotkey_data);
|
||||
|
||||
/**
|
||||
* Adds/releases a reference to an encoder. When the last reference is
|
||||
@ -1434,7 +1436,7 @@ EXPORT void obs_free_encoder_packet(struct encoder_packet *packet);
|
||||
EXPORT const char *obs_service_get_display_name(const char *id);
|
||||
|
||||
EXPORT obs_service_t *obs_service_create(const char *id, const char *name,
|
||||
obs_data_t *settings);
|
||||
obs_data_t *settings, obs_data_t *hotkey_data);
|
||||
|
||||
/**
|
||||
* Adds/releases a reference to a service. When the last reference is
|
||||
|
@ -367,7 +367,7 @@ void OBSBasicFilters::AddNewFilter(const char *id)
|
||||
}
|
||||
|
||||
obs_source_t *filter = obs_source_create(OBS_SOURCE_TYPE_FILTER,
|
||||
id, name.c_str(), nullptr);
|
||||
id, name.c_str(), nullptr, nullptr);
|
||||
if (filter) {
|
||||
obs_source_filter_add(source, filter);
|
||||
obs_source_release(filter);
|
||||
|
@ -65,26 +65,28 @@ struct SimpleOutput : BasicOutputHandler {
|
||||
SimpleOutput::SimpleOutput(OBSBasic *main_) : BasicOutputHandler(main_)
|
||||
{
|
||||
streamOutput = obs_output_create("rtmp_output", "simple_stream",
|
||||
nullptr);
|
||||
nullptr, nullptr);
|
||||
if (!streamOutput)
|
||||
throw "Failed to create stream output (simple output)";
|
||||
obs_output_release(streamOutput);
|
||||
|
||||
fileOutput = obs_output_create("flv_output", "simple_file_output",
|
||||
nullptr);
|
||||
nullptr, nullptr);
|
||||
if (!fileOutput)
|
||||
throw "Failed to create recording output (simple output)";
|
||||
obs_output_release(fileOutput);
|
||||
|
||||
h264 = obs_video_encoder_create("obs_x264", "simple_h264", nullptr);
|
||||
h264 = obs_video_encoder_create("obs_x264", "simple_h264", nullptr,
|
||||
nullptr);
|
||||
if (!h264)
|
||||
throw "Failed to create h264 encoder (simple output)";
|
||||
obs_encoder_release(h264);
|
||||
|
||||
aac = obs_audio_encoder_create("libfdk_aac", "simple_aac", nullptr, 0);
|
||||
aac = obs_audio_encoder_create("libfdk_aac", "simple_aac", nullptr, 0,
|
||||
nullptr);
|
||||
if (!aac)
|
||||
aac = obs_audio_encoder_create("ffmpeg_aac", "simple_aac",
|
||||
nullptr, 0);
|
||||
nullptr, 0, nullptr);
|
||||
if (!aac)
|
||||
throw "Failed to create audio encoder (simple output)";
|
||||
obs_encoder_release(aac);
|
||||
@ -322,21 +324,21 @@ AdvancedOutput::AdvancedOutput(OBSBasic *main_) : BasicOutputHandler(main_)
|
||||
"obs-studio/basic/recordEncoder.json");
|
||||
|
||||
streamOutput = obs_output_create("rtmp_output", "adv_stream",
|
||||
nullptr);
|
||||
nullptr, nullptr);
|
||||
if (!streamOutput)
|
||||
throw "Failed to create stream output (advanced output)";
|
||||
obs_output_release(streamOutput);
|
||||
|
||||
if (ffmpegRecording) {
|
||||
fileOutput = obs_output_create("ffmpeg_output",
|
||||
"adv_ffmpeg_output", nullptr);
|
||||
"adv_ffmpeg_output", nullptr, nullptr);
|
||||
if (!fileOutput)
|
||||
throw "Failed to create recording FFmpeg output "
|
||||
"(advanced output)";
|
||||
obs_output_release(fileOutput);
|
||||
} else {
|
||||
fileOutput = obs_output_create("flv_output", "adv_file_output",
|
||||
nullptr);
|
||||
nullptr, nullptr);
|
||||
if (!fileOutput)
|
||||
throw "Failed to create recording output "
|
||||
"(advanced output)";
|
||||
@ -344,7 +346,8 @@ AdvancedOutput::AdvancedOutput(OBSBasic *main_) : BasicOutputHandler(main_)
|
||||
|
||||
if (!useStreamEncoder) {
|
||||
h264Recording = obs_video_encoder_create(recordEncoder,
|
||||
"recording_h264", recordEncSettings);
|
||||
"recording_h264", recordEncSettings,
|
||||
nullptr);
|
||||
if (!h264Recording)
|
||||
throw "Failed to create recording h264 "
|
||||
"encoder (advanced output)";
|
||||
@ -353,7 +356,7 @@ AdvancedOutput::AdvancedOutput(OBSBasic *main_) : BasicOutputHandler(main_)
|
||||
}
|
||||
|
||||
h264Streaming = obs_video_encoder_create(streamEncoder,
|
||||
"streaming_h264", streamEncSettings);
|
||||
"streaming_h264", streamEncSettings, nullptr);
|
||||
if (!h264Streaming)
|
||||
throw "Failed to create streaming h264 encoder "
|
||||
"(advanced output)";
|
||||
@ -364,10 +367,10 @@ AdvancedOutput::AdvancedOutput(OBSBasic *main_) : BasicOutputHandler(main_)
|
||||
sprintf(name, "adv_aac%d", i);
|
||||
|
||||
aacTrack[i] = obs_audio_encoder_create("libfdk_aac",
|
||||
name, nullptr, i);
|
||||
name, nullptr, i, nullptr);
|
||||
if (!aacTrack[i])
|
||||
aacTrack[i] = obs_audio_encoder_create("ffmpeg_aac",
|
||||
name, nullptr, i);
|
||||
name, nullptr, i, nullptr);
|
||||
if (!aacTrack[i])
|
||||
throw "Failed to create audio encoder "
|
||||
"(advanced output)";
|
||||
|
@ -292,7 +292,7 @@ void OBSBasic::CreateDefaultScene()
|
||||
|
||||
#ifdef __APPLE__
|
||||
source = obs_source_create(OBS_SOURCE_TYPE_INPUT, "display_capture",
|
||||
Str("Basic.DisplayCapture"), NULL);
|
||||
Str("Basic.DisplayCapture"), NULL, nullptr);
|
||||
|
||||
if (source) {
|
||||
obs_scene_add(scene, source);
|
||||
@ -407,7 +407,8 @@ bool OBSBasic::LoadService()
|
||||
|
||||
obs_data_t *settings = obs_data_get_obj(data, "settings");
|
||||
|
||||
service = obs_service_create(type, "default_service", settings);
|
||||
service = obs_service_create(type, "default_service", settings,
|
||||
nullptr);
|
||||
obs_service_release(service);
|
||||
|
||||
obs_data_release(settings);
|
||||
@ -421,7 +422,8 @@ bool OBSBasic::InitService()
|
||||
if (LoadService())
|
||||
return true;
|
||||
|
||||
service = obs_service_create("rtmp_common", "default_service", nullptr);
|
||||
service = obs_service_create("rtmp_common", "default_service", nullptr,
|
||||
nullptr);
|
||||
if (!service)
|
||||
return false;
|
||||
obs_service_release(service);
|
||||
@ -1449,7 +1451,8 @@ void OBSBasic::RenderMain(void *data, uint32_t cx, uint32_t cy)
|
||||
obs_service_t *OBSBasic::GetService()
|
||||
{
|
||||
if (!service) {
|
||||
service = obs_service_create("rtmp_common", NULL, NULL);
|
||||
service = obs_service_create("rtmp_common", NULL, NULL,
|
||||
nullptr);
|
||||
obs_service_release(service);
|
||||
}
|
||||
return service;
|
||||
@ -1635,7 +1638,7 @@ void OBSBasic::ResetAudioDevice(const char *sourceId, const char *deviceName,
|
||||
obs_data_t *settings = obs_data_create();
|
||||
obs_data_set_string(settings, "device_id", deviceId);
|
||||
source = obs_source_create(OBS_SOURCE_TYPE_INPUT,
|
||||
sourceId, deviceDesc, settings);
|
||||
sourceId, deviceDesc, settings, nullptr);
|
||||
obs_data_release(settings);
|
||||
|
||||
obs_set_output_source(channel, source);
|
||||
|
@ -1318,7 +1318,8 @@ void OBSBasicSettings::SaveStream1Settings()
|
||||
QString streamType = GetComboData(ui->streamType);
|
||||
|
||||
obs_service_t *newService = obs_service_create(QT_TO_UTF8(streamType),
|
||||
"default_service", streamProperties->GetSettings());
|
||||
"default_service", streamProperties->GetSettings(),
|
||||
nullptr);
|
||||
if (!newService)
|
||||
return;
|
||||
|
||||
|
@ -111,7 +111,7 @@ bool AddNew(QWidget *parent, const char *id, const char *name)
|
||||
|
||||
} else {
|
||||
source = obs_source_create(OBS_SOURCE_TYPE_INPUT,
|
||||
id, name, NULL);
|
||||
id, name, NULL, nullptr);
|
||||
|
||||
if (source) {
|
||||
obs_add_source(source);
|
||||
|
@ -68,7 +68,7 @@ static SceneContext SetupScene()
|
||||
/* ------------------------------------------------------ */
|
||||
/* create source */
|
||||
SourceContext source{obs_source_create(OBS_SOURCE_TYPE_INPUT,
|
||||
"random", "a test source", nullptr)};
|
||||
"random", "a test source", nullptr, nullptr)};
|
||||
if (!source)
|
||||
throw "Couldn't create random test source";
|
||||
|
||||
|
@ -158,14 +158,15 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdLine,
|
||||
/* ------------------------------------------------------ */
|
||||
/* create source */
|
||||
SourceContext source = obs_source_create(OBS_SOURCE_TYPE_INPUT,
|
||||
"random", "some randon source", NULL);
|
||||
"random", "some randon source", NULL, nullptr);
|
||||
if (!source)
|
||||
throw "Couldn't create random test source";
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
/* create filter */
|
||||
SourceContext filter = obs_source_create(OBS_SOURCE_TYPE_FILTER,
|
||||
"test_filter", "a nice green filter", NULL);
|
||||
"test_filter", "a nice green filter", NULL,
|
||||
nullptr);
|
||||
if (!filter)
|
||||
throw "Couldn't create test filter";
|
||||
obs_source_filter_add(source, filter);
|
||||
|
Loading…
x
Reference in New Issue
Block a user