GstBuffer * buffer, GstClockTime * start, GstClockTime * end);
static gboolean gst_base_audio_sink_setcaps (GstBaseSink * bsink,
GstCaps * caps);
+static void gst_base_audio_sink_fixate (GstBaseSink * bsink, GstCaps * caps);
/* static guint gst_base_audio_sink_signals[LAST_SIGNAL] = { 0 }; */
gstbasesink_class->get_times =
GST_DEBUG_FUNCPTR (gst_base_audio_sink_get_times);
gstbasesink_class->set_caps = GST_DEBUG_FUNCPTR (gst_base_audio_sink_setcaps);
+ gstbasesink_class->fixate = GST_DEBUG_FUNCPTR (gst_base_audio_sink_fixate);
gstbasesink_class->async_play =
GST_DEBUG_FUNCPTR (gst_base_audio_sink_async_play);
gstbasesink_class->activate_pull =
}
}
+static void
+gst_base_audio_sink_fixate (GstBaseSink * bsink, GstCaps * caps)
+{
+ GstStructure *s;
+ gint width, depth;
+
+ s = gst_caps_get_structure (caps, 0);
+
+ /* fields for all formats */
+ gst_structure_fixate_field_nearest_int (s, "rate", 44100);
+ gst_structure_fixate_field_nearest_int (s, "channels", 2);
+ gst_structure_fixate_field_nearest_int (s, "width", 16);
+
+ /* fields for int */
+ if (gst_structure_has_field (s, "depth")) {
+ gst_structure_get_int (s, "width", &width);
+ /* round width to nearest multiple of 8 for the depth */
+ depth = GST_ROUND_UP_8 (width);
+ gst_structure_fixate_field_nearest_int (s, "depth", depth);
+ }
+ if (gst_structure_has_field (s, "signed"))
+ gst_structure_fixate_field_boolean (s, "signed", TRUE);
+ if (gst_structure_has_field (s, "endianness"))
+ gst_structure_fixate_field_nearest_int (s, "endianness", G_BYTE_ORDER);
+}
+
static void
gst_base_audio_sink_get_times (GstBaseSink * bsink, GstBuffer * buffer,
GstClockTime * start, GstClockTime * end)
GstBaseAudioSink *sink = GST_BASE_AUDIO_SINK (basesink);
if (active) {
- GstCaps *sinkcaps, *peercaps, *caps;
-
gst_ring_buffer_set_callback (sink->ringbuffer,
gst_base_audio_sink_callback, sink);
-
- /* need to spawn a thread to start pulling. that's the ring buffer thread,
- which is started in ring_buffer_acquire(), which is called due to a sink
- setcaps(). So we need to setcaps, which is tough because we don't know
- exactly what caps we'll be getting. We can guess, though, and that's as
- good as we're going to get without the user telling us explicitly e.g.
- via a capsfilter before the sink. */
- sinkcaps = gst_pad_get_caps (basesink->sinkpad);
- peercaps = gst_pad_peer_get_caps (basesink->sinkpad);
- caps = gst_caps_intersect (sinkcaps, peercaps);
- gst_caps_unref (sinkcaps);
- gst_caps_unref (peercaps);
- gst_caps_truncate (caps);
- gst_pad_fixate_caps (basesink->sinkpad, caps);
-
- GST_DEBUG_OBJECT (sink, "initializing pull-mode ringbuffer with caps %"
- GST_PTR_FORMAT, caps);
- ret = gst_pad_set_caps (basesink->sinkpad, caps);
- gst_caps_unref (caps);
+ ret = gst_ring_buffer_start (sink->ringbuffer);
} else {
gst_ring_buffer_set_callback (sink->ringbuffer, NULL, NULL);
/* stop thread */
GstBuffer *buf;
GstFlowReturn ret;
- basesink = GST_BASE_SINK (data);
- sink = GST_BASE_AUDIO_SINK (data);
+ basesink = GST_BASE_SINK (user_data);
+ sink = GST_BASE_AUDIO_SINK (user_data);
/* would be nice to arrange for pad_alloc_buffer to return data -- as it is we
will copy twice, once into data, once into DMA */
static void gst_base_audio_src_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
-static void gst_base_audio_src_fixate (GstPad * pad, GstCaps * caps);
-
static GstStateChangeReturn gst_base_audio_src_change_state (GstElement *
element, GstStateChange transition);
static void gst_base_audio_src_get_times (GstBaseSrc * bsrc,
GstBuffer * buffer, GstClockTime * start, GstClockTime * end);
static gboolean gst_base_audio_src_setcaps (GstBaseSrc * bsrc, GstCaps * caps);
+static void gst_base_audio_src_fixate (GstBaseSrc * bsrc, GstCaps * caps);
/* static guint gst_base_audio_src_signals[LAST_SIGNAL] = { 0 }; */
gstbasesrc_class->create = GST_DEBUG_FUNCPTR (gst_base_audio_src_create);
gstbasesrc_class->check_get_range =
GST_DEBUG_FUNCPTR (gst_base_audio_src_check_get_range);
+ gstbasesrc_class->fixate = GST_DEBUG_FUNCPTR (gst_base_audio_src_fixate);
}
static void
baseaudiosrc->clock = gst_audio_clock_new ("clock",
(GstAudioClockGetTimeFunc) gst_base_audio_src_get_time, baseaudiosrc);
- gst_pad_set_fixatecaps_function (GST_BASE_SRC_PAD (baseaudiosrc),
- gst_base_audio_src_fixate);
-
/* we are always a live source */
gst_base_src_set_live (GST_BASE_SRC (baseaudiosrc), TRUE);
/* we operate in time */
}
static void
-gst_base_audio_src_fixate (GstPad * pad, GstCaps * caps)
+gst_base_audio_src_fixate (GstBaseSrc * bsrc, GstCaps * caps)
{
GstStructure *s;
gint width, depth;