mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-08-28 17:42:28 +08:00
libobs, frontend: Add monitoring hotkeys
This commit is contained in:
@@ -1454,6 +1454,8 @@ Mute="Mute"
|
||||
Unmute="Unmute"
|
||||
Push-to-mute="Push-to-mute"
|
||||
Push-to-talk="Push-to-talk"
|
||||
MonitorOn="Enable Monitoring"
|
||||
MonitorOff="Disable Monitoring"
|
||||
|
||||
# scene item hotkeys
|
||||
SceneItemShow="Show '%1'"
|
||||
|
||||
@@ -67,8 +67,8 @@ void OBSBasic::InitHotkeys()
|
||||
t.escape = Str("Hotkeys.Escape");
|
||||
obs_hotkeys_set_translations(&t);
|
||||
|
||||
obs_hotkeys_set_audio_hotkeys_translations(Str("Mute"), Str("Unmute"), Str("Push-to-mute"),
|
||||
Str("Push-to-talk"));
|
||||
obs_hotkeys_set_audio_hotkeys_translations(Str("Mute"), Str("Unmute"), Str("Push-to-mute"), Str("Push-to-talk"),
|
||||
Str("MonitorOn"), Str("MonitorOff"));
|
||||
|
||||
obs_hotkeys_set_sceneitem_hotkeys_translations(Str("SceneItemShow"), Str("SceneItemHide"));
|
||||
|
||||
|
||||
+4
-1
@@ -1374,7 +1374,8 @@ void obs_hotkey_update_atomic(obs_hotkey_atomic_update_func func, void *data)
|
||||
}
|
||||
|
||||
void obs_hotkeys_set_audio_hotkeys_translations(const char *mute, const char *unmute, const char *push_to_mute,
|
||||
const char *push_to_talk)
|
||||
const char *push_to_talk, const char *monitor_on,
|
||||
const char *monitor_off)
|
||||
{
|
||||
#define SET_T(n) \
|
||||
bfree(obs->hotkeys.n); \
|
||||
@@ -1383,6 +1384,8 @@ void obs_hotkeys_set_audio_hotkeys_translations(const char *mute, const char *un
|
||||
SET_T(unmute);
|
||||
SET_T(push_to_mute);
|
||||
SET_T(push_to_talk);
|
||||
SET_T(monitor_on);
|
||||
SET_T(monitor_off);
|
||||
#undef SET_T
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -134,7 +134,8 @@ EXPORT void obs_hotkeys_set_translations_s(struct obs_hotkeys_translations *tran
|
||||
obs_hotkeys_set_translations_s(translations, sizeof(struct obs_hotkeys_translations))
|
||||
|
||||
EXPORT void obs_hotkeys_set_audio_hotkeys_translations(const char *mute, const char *unmute, const char *push_to_mute,
|
||||
const char *push_to_talk);
|
||||
const char *push_to_talk, const char *monitor_on,
|
||||
const char *monitor_off);
|
||||
|
||||
EXPORT void obs_hotkeys_set_sceneitem_hotkeys_translations(const char *show, const char *hide);
|
||||
|
||||
|
||||
@@ -537,6 +537,8 @@ struct obs_core_hotkeys {
|
||||
char *push_to_talk;
|
||||
char *sceneitem_show;
|
||||
char *sceneitem_hide;
|
||||
char *monitor_on;
|
||||
char *monitor_off;
|
||||
};
|
||||
|
||||
typedef DARRAY(struct obs_source_info) obs_source_info_array_t;
|
||||
@@ -992,6 +994,7 @@ struct obs_source {
|
||||
struct audio_monitor *monitor;
|
||||
enum obs_monitoring_type monitoring_type;
|
||||
bool monitoring_enabled;
|
||||
obs_hotkey_pair_id monitor_on_off_key;
|
||||
|
||||
/* media action queue */
|
||||
DARRAY(struct media_action) media_actions;
|
||||
|
||||
+37
-2
@@ -349,10 +349,40 @@ static void obs_source_hotkey_push_to_talk(void *data, obs_hotkey_id id, obs_hot
|
||||
source->user_push_to_talk_pressed = pressed;
|
||||
}
|
||||
|
||||
static bool obs_source_hotkey_monitor_on(void *data, obs_hotkey_pair_id id, obs_hotkey_t *key, bool pressed)
|
||||
{
|
||||
UNUSED_PARAMETER(id);
|
||||
UNUSED_PARAMETER(key);
|
||||
|
||||
struct obs_source *source = data;
|
||||
|
||||
if (!pressed || obs_source_get_monitoring_enabled(source))
|
||||
return false;
|
||||
|
||||
obs_source_set_monitoring_enabled(source, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool obs_source_hotkey_monitor_off(void *data, obs_hotkey_pair_id id, obs_hotkey_t *key, bool pressed)
|
||||
{
|
||||
UNUSED_PARAMETER(id);
|
||||
UNUSED_PARAMETER(key);
|
||||
|
||||
struct obs_source *source = data;
|
||||
|
||||
if (!pressed || !obs_source_get_monitoring_enabled(source))
|
||||
return false;
|
||||
|
||||
obs_source_set_monitoring_enabled(source, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void obs_source_init_audio_hotkeys(struct obs_source *source)
|
||||
{
|
||||
if (!(source->info.output_flags & OBS_SOURCE_AUDIO) || source->info.type != OBS_SOURCE_TYPE_INPUT) {
|
||||
source->mute_unmute_key = OBS_INVALID_HOTKEY_ID;
|
||||
source->mute_unmute_key = OBS_INVALID_HOTKEY_PAIR_ID;
|
||||
source->monitor_on_off_key = OBS_INVALID_HOTKEY_PAIR_ID;
|
||||
source->push_to_mute_key = OBS_INVALID_HOTKEY_ID;
|
||||
source->push_to_talk_key = OBS_INVALID_HOTKEY_ID;
|
||||
return;
|
||||
}
|
||||
@@ -362,6 +392,10 @@ static void obs_source_init_audio_hotkeys(struct obs_source *source)
|
||||
obs_source_hotkey_mute, obs_source_hotkey_unmute,
|
||||
source, source);
|
||||
|
||||
source->monitor_on_off_key = obs_hotkey_pair_register_source(
|
||||
source, "libobs.monitor-on", obs->hotkeys.monitor_on, "libobs.monitor-off", obs->hotkeys.monitor_off,
|
||||
obs_source_hotkey_monitor_on, obs_source_hotkey_monitor_off, source, source);
|
||||
|
||||
source->push_to_mute_key = obs_hotkey_register_source(source, "libobs.push-to-mute", obs->hotkeys.push_to_mute,
|
||||
obs_source_hotkey_push_to_mute, source);
|
||||
|
||||
@@ -459,6 +493,7 @@ static obs_source_t *obs_source_create_internal(const char *id, const char *name
|
||||
}
|
||||
|
||||
source->mute_unmute_key = OBS_INVALID_HOTKEY_PAIR_ID;
|
||||
source->monitor_on_off_key = OBS_INVALID_HOTKEY_PAIR_ID;
|
||||
source->push_to_mute_key = OBS_INVALID_HOTKEY_ID;
|
||||
source->push_to_talk_key = OBS_INVALID_HOTKEY_ID;
|
||||
source->last_obs_ver = last_obs_ver;
|
||||
@@ -785,6 +820,7 @@ static void obs_source_destroy_defer(struct obs_source *source)
|
||||
obs_hotkey_unregister(source->push_to_talk_key);
|
||||
obs_hotkey_unregister(source->push_to_mute_key);
|
||||
obs_hotkey_pair_unregister(source->mute_unmute_key);
|
||||
obs_hotkey_pair_unregister(source->monitor_on_off_key);
|
||||
|
||||
for (i = 0; i < source->async_cache.num; i++)
|
||||
obs_source_frame_decref(source->async_cache.array[i].frame);
|
||||
@@ -5557,7 +5593,6 @@ void obs_source_remove_audio_capture_callback(obs_source_t *source, obs_source_a
|
||||
pthread_mutex_unlock(&source->audio_cb_mutex);
|
||||
}
|
||||
|
||||
|
||||
void obs_source_set_monitoring_enabled(obs_source_t *source, bool enabled)
|
||||
{
|
||||
struct calldata data;
|
||||
|
||||
Reference in New Issue
Block a user