diff --git a/data/org.gnome.Calls.gschema.xml b/data/org.gnome.Calls.gschema.xml index eee5440..517e1bd 100644 --- a/data/org.gnome.Calls.gschema.xml +++ b/data/org.gnome.Calls.gschema.xml @@ -20,5 +20,11 @@ These plugins will be automatically loaded on application startup. + + ["PCMA", "PCMU", "GSM", "G722"] + Audio codecs to use for VoIP calls in order of preference + The preferred audio codecs to use for VoIP calls (if available) + + diff --git a/src/calls-settings.c b/src/calls-settings.c index b0cd1f4..9701c80 100644 --- a/src/calls-settings.c +++ b/src/calls-settings.c @@ -41,6 +41,7 @@ enum { PROP_AUTO_USE_DEFAULT_ORIGINS, PROP_COUNTRY_CODE, PROP_AUTOLOAD_PLUGINS, + PROP_PREFERRED_AUDIO_CODECS, PROP_LAST_PROP }; static GParamSpec *props[PROP_LAST_PROP]; @@ -75,6 +76,10 @@ calls_settings_set_property (GObject *object, calls_settings_set_autoload_plugins (self, g_value_get_boxed (value)); break; + case PROP_PREFERRED_AUDIO_CODECS: + calls_settings_set_preferred_audio_codecs (self, g_value_get_boxed (value)); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -103,6 +108,10 @@ calls_settings_get_property (GObject *object, g_value_set_boxed (value, calls_settings_get_autoload_plugins (self)); break; + case PROP_PREFERRED_AUDIO_CODECS: + g_value_set_boxed (value, calls_settings_get_preferred_audio_codecs (self)); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -123,6 +132,8 @@ calls_settings_constructed (GObject *object) self, "country-code", G_SETTINGS_BIND_DEFAULT); g_settings_bind (self->settings, "autoload-plugins", self, "autoload-plugins", G_SETTINGS_BIND_DEFAULT); + g_settings_bind (self->settings, "preferred-audio-codecs", + self, "preferred-audio-codecs", G_SETTINGS_BIND_DEFAULT); } @@ -167,6 +178,13 @@ calls_settings_class_init (CallsSettingsClass *klass) G_TYPE_STRV, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + props[PROP_PREFERRED_AUDIO_CODECS] = + g_param_spec_boxed ("preferred-audio-codecs", + "Preferred audio codecs", + "The audio codecs to prefer for VoIP calls", + G_TYPE_STRV, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + g_object_class_install_properties (object_class, PROP_LAST_PROP, props); } @@ -283,3 +301,35 @@ calls_settings_set_autoload_plugins (CallsSettings *self, g_settings_set_strv (G_SETTINGS (self->settings), "autoload-plugins", plugins); } + + +/** + * calls_settings_get_preferred_audio_codecs: + * @self: A #CallsSettings + * + * Returns: (transfer full): List of preferred audio codecs for VoIP calls. + * Free with g_strfreev() when done. + */ +char ** +calls_settings_get_preferred_audio_codecs (CallsSettings *self) +{ + g_return_val_if_fail (CALLS_IS_SETTINGS (self), NULL); + + return g_settings_get_strv (self->settings, "preferred-audio-codecs"); +} + +/** + * calls_settings_set_preferred_audio_codecs: + * @self: A #CallsSettings + * @codecs: (nullable) (array zero-terminated=1): The preferred codecs + * + * Set the preferred audio codecs for VoIP calls. + */ +void +calls_settings_set_preferred_audio_codecs (CallsSettings *self, + const char * const *codecs) +{ + g_return_if_fail (CALLS_IS_SETTINGS (self)); + + g_settings_set_strv (self->settings, "preferred-audio-codecs", codecs); +} diff --git a/src/calls-settings.h b/src/calls-settings.h index 8c23b64..de19376 100644 --- a/src/calls-settings.h +++ b/src/calls-settings.h @@ -42,6 +42,9 @@ void calls_settings_set_country_code (CallsSettings char **calls_settings_get_autoload_plugins (CallsSettings *self); void calls_settings_set_autoload_plugins (CallsSettings *self, const char * const *plugins); +char **calls_settings_get_preferred_audio_codecs (CallsSettings *self); +void calls_settings_set_preferred_audio_codecs (CallsSettings *self, + const char * const *codecs); G_END_DECLS