api: Add property to control PipeWire enablement

This commit is contained in:
Rafał Dzięgiel
2021-09-03 11:11:14 +02:00
parent b68c1a62b2
commit cf6d41b725

View File

@@ -52,6 +52,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_clapper_debug);
#define GST_CAT_DEFAULT gst_clapper_debug
#define DEFAULT_USE_PLAYBIN3 FALSE
#define DEFAULT_USE_PIPEWIRE FALSE
#define DEFAULT_STATE GST_CLAPPER_STATE_STOPPED
#define DEFAULT_URI NULL
#define DEFAULT_POSITION GST_CLOCK_TIME_NONE
@@ -82,6 +83,7 @@ enum
PROP_SIGNAL_DISPATCHER,
PROP_MPRIS,
PROP_USE_PLAYBIN3,
PROP_USE_PIPEWIRE,
PROP_STATE,
PROP_URI,
PROP_SUBURI,
@@ -198,6 +200,8 @@ struct _GstClapper
gchar *audio_sid;
gchar *subtitle_sid;
gulong stream_notify_id;
gboolean use_pipewire;
};
struct _GstClapperClass
@@ -331,6 +335,11 @@ gst_clapper_class_init (GstClapperClass * klass)
DEFAULT_USE_PLAYBIN3, G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
param_specs[PROP_USE_PIPEWIRE] =
g_param_spec_boolean ("use-pipewire", "Use PipeWire", "PipeWire audio output",
DEFAULT_USE_PIPEWIRE, G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
param_specs[PROP_STATE] =
g_param_spec_enum ("state", "Clapper State", "Current player state",
GST_TYPE_CLAPPER_STATE, DEFAULT_STATE, G_PARAM_READABLE |
@@ -695,6 +704,9 @@ gst_clapper_set_property (GObject * object, guint prop_id,
case PROP_USE_PLAYBIN3:
self->use_playbin3 = g_value_get_boolean (value);
break;
case PROP_USE_PIPEWIRE:
self->use_pipewire = g_value_get_boolean (value);
break;
case PROP_URI:{
g_mutex_lock (&self->lock);
g_free (self->uri);
@@ -3087,7 +3099,6 @@ gst_clapper_main (gpointer data)
GstBus *bus;
GSource *source;
GstElement *scaletempo, *pipewiresink;
const gchar *pw_env;
GST_TRACE_OBJECT (self, "Starting main thread");
@@ -3140,8 +3151,9 @@ gst_clapper_main (gpointer data)
}
}
pw_env = g_getenv ("GST_CLAPPER_USE_PIPEWIRE");
if (pw_env && g_str_has_prefix (pw_env, "1")) {
_update_from_env (&self->use_pipewire, "GST_CLAPPER_USE_PIPEWIRE");
if (self->use_pipewire) {
pipewiresink = gst_element_factory_make ("pipewiresink", NULL);
if (pipewiresink) {
g_object_set (self->playbin, "audio-sink", pipewiresink, NULL);