static GstStateChangeReturn gst_pulsesink_change_state (GstElement * element,
GstStateChange transition);
-static GstStaticPadTemplate pad_template = GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (PULSE_SINK_TEMPLATE_CAPS));
-
#define gst_pulsesink_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstPulseSink, gst_pulsesink, GST_TYPE_AUDIO_BASE_SINK,
gst_pulsesink_init_contexts ();
GstBaseSinkClass *bc;
GstAudioBaseSinkClass *gstaudiosink_class = GST_AUDIO_BASE_SINK_CLASS (klass);
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
+ GstCaps *caps;
gchar *clientname;
gobject_class->finalize = gst_pulsesink_finalize;
gst_element_class_set_static_metadata (gstelement_class,
"PulseAudio Audio Sink",
"Sink/Audio", "Plays audio to a PulseAudio server", "Lennart Poettering");
- gst_element_class_add_static_pad_template (gstelement_class, &pad_template);
+
+ caps =
+ gst_pulse_fix_pcm_caps (gst_caps_from_string (PULSE_SINK_TEMPLATE_CAPS));
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, caps));
+ gst_caps_unref (caps);
}
static void
static GstClockTime gst_pulsesrc_get_time (GstClock * clock, GstPulseSrc * src);
-static GstStaticPadTemplate pad_template = GST_STATIC_PAD_TEMPLATE ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (_PULSE_CAPS_PCM)
- );
-
#define gst_pulsesrc_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstPulseSrc, gst_pulsesrc, GST_TYPE_AUDIO_SRC,
G_IMPLEMENT_INTERFACE (GST_TYPE_STREAM_VOLUME, NULL));
GstAudioSrcClass *gstaudiosrc_class = GST_AUDIO_SRC_CLASS (klass);
GstBaseSrcClass *gstbasesrc_class = GST_BASE_SRC_CLASS (klass);
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
+ GstCaps *caps;
gchar *clientname;
gobject_class->finalize = gst_pulsesrc_finalize;
"PulseAudio Audio Source",
"Source/Audio",
"Captures audio from a PulseAudio server", "Lennart Poettering");
- gst_element_class_add_static_pad_template (gstelement_class, &pad_template);
+
+ caps = gst_pulse_fix_pcm_caps (gst_caps_from_string (_PULSE_CAPS_PCM));
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, caps));
+ gst_caps_unref (caps);
/**
* GstPulseSrc:volume:
if (pa_format_info_get_prop_string (format,
PA_PROP_FORMAT_SAMPLE_FORMAT, &tmp)) {
/* No specific sample format means any sample format */
- ret = gst_caps_from_string (_PULSE_CAPS_PCM);
+ ret = gst_pulse_fix_pcm_caps (gst_caps_from_string (_PULSE_CAPS_PCM));
goto out;
} else if (ss.format == PA_SAMPLE_ALAW) {
out:
return ret;
}
+
+GstCaps *
+gst_pulse_fix_pcm_caps (GstCaps * incaps)
+{
+ GstCaps *outcaps;
+ int i;
+
+ outcaps = gst_caps_make_writable (incaps);
+
+ for (i = 0; i < gst_caps_get_size (outcaps); i++) {
+ GstStructure *st = gst_caps_get_structure (outcaps, i);
+ const gchar *format = gst_structure_get_name (st);
+ const GValue *value;
+ GValue new_value = G_VALUE_INIT;
+ gint min, max, step;
+
+ if (!(g_str_equal (format, "audio/x-raw") ||
+ g_str_equal (format, "audio/x-alaw") ||
+ g_str_equal (format, "audio/x-mulaw")))
+ continue;
+
+ value = gst_structure_get_value (st, "rate");
+
+ if (!GST_VALUE_HOLDS_INT_RANGE (value))
+ continue;
+
+ min = gst_value_get_int_range_min (value);
+ max = gst_value_get_int_range_max (value);
+ step = gst_value_get_int_range_step (value);
+
+ if (min > PA_RATE_MAX)
+ min = PA_RATE_MAX;
+ if (max > PA_RATE_MAX)
+ max = PA_RATE_MAX;
+
+ g_value_init (&new_value, GST_TYPE_INT_RANGE);
+ gst_value_set_int_range_step (&new_value, min, max, step);
+
+ gst_structure_take_value (st, "rate", &new_value);
+ }
+
+ return outcaps;
+}
"S24BE, S24LE, S24_32BE, S24_32LE, U8 }"
#endif
+/* NOTE! that we do NOT actually support rate=MAX. This must be fixed up using
+ * gst_pulse_fix_pcm_caps() before being used. */
#define _PULSE_CAPS_LINEAR \
"audio/x-raw, " \
"format = (string) " _PULSE_FORMATS ", " \
GstStructure *gst_pulse_make_structure (pa_proplist *properties);
GstCaps * gst_pulse_format_info_to_caps (pa_format_info * format);
+GstCaps * gst_pulse_fix_pcm_caps (GstCaps * incaps);
#endif