2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * SECTION:element-audiorate
22 * @see_also: #GstVideoRate
24 * This element takes an incoming stream of timestamped raw audio frames and
25 * produces a perfect stream by inserting or dropping samples as needed.
27 * This operation may be of use to link to elements that require or otherwise
28 * implicitly assume a perfect stream as they do not store timestamps,
29 * but derive this by some means (e.g. bitrate for some AVI cases).
31 * The properties #GstAudioRate:in, #GstAudioRate:out, #GstAudioRate:add
32 * and #GstAudioRate:drop can be read to obtain information about number of
33 * input samples, output samples, dropped samples (i.e. the number of unused
34 * input samples) and inserted samples (i.e. the number of samples added to
37 * When the #GstAudioRate:silent property is set to FALSE, a GObject property
38 * notification will be emitted whenever one of the #GstAudioRate:add or
39 * #GstAudioRate:drop values changes.
40 * This can potentially cause performance degradation.
41 * Note that property notification will happen from the streaming thread, so
42 * applications should be prepared for this.
44 * If the #GstAudioRate:tolerance property is non-zero, and an incoming buffer's
45 * timestamp deviates less than the property indicates from what would make a
46 * 'perfect time', then no samples will be added or dropped.
47 * Note that the output is still guaranteed to be a perfect stream, which means
48 * that the incoming data is then simply shifted (by less than the indicated
49 * tolerance) to a perfect time.
52 * <title>Example pipelines</title>
54 * gst-launch -v alsasrc ! audiorate ! wavenc ! filesink location=alsa.wav
55 * ]| Capture audio from an ALSA device, and turn it into a perfect stream
56 * for saving in a raw audio file.
67 #include "gstaudiorate.h"
69 #define GST_CAT_DEFAULT audio_rate_debug
70 GST_DEBUG_CATEGORY_STATIC (audio_rate_debug);
72 /* GstAudioRate signals and args */
79 #define DEFAULT_SILENT TRUE
80 #define DEFAULT_TOLERANCE 0
81 #define DEFAULT_SKIP_TO_FIRST FALSE
95 static GstStaticPadTemplate gst_audio_rate_src_template =
96 GST_STATIC_PAD_TEMPLATE ("src",
99 GST_STATIC_CAPS (GST_AUDIO_CAPS_MAKE (GST_AUDIO_FORMATS_ALL))
102 static GstStaticPadTemplate gst_audio_rate_sink_template =
103 GST_STATIC_PAD_TEMPLATE ("sink",
106 GST_STATIC_CAPS (GST_AUDIO_CAPS_MAKE (GST_AUDIO_FORMATS_ALL))
109 static gboolean gst_audio_rate_sink_event (GstPad * pad, GstEvent * event);
110 static gboolean gst_audio_rate_src_event (GstPad * pad, GstEvent * event);
111 static GstFlowReturn gst_audio_rate_chain (GstPad * pad, GstBuffer * buf);
113 static void gst_audio_rate_set_property (GObject * object,
114 guint prop_id, const GValue * value, GParamSpec * pspec);
115 static void gst_audio_rate_get_property (GObject * object,
116 guint prop_id, GValue * value, GParamSpec * pspec);
118 static GstStateChangeReturn gst_audio_rate_change_state (GstElement * element,
119 GstStateChange transition);
121 /*static guint gst_audio_rate_signals[LAST_SIGNAL] = { 0 }; */
123 static GParamSpec *pspec_drop = NULL;
124 static GParamSpec *pspec_add = NULL;
126 #define gst_audio_rate_parent_class parent_class
127 G_DEFINE_TYPE (GstAudioRate, gst_audio_rate, GST_TYPE_ELEMENT);
130 gst_audio_rate_class_init (GstAudioRateClass * klass)
132 GObjectClass *object_class = G_OBJECT_CLASS (klass);
133 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
135 object_class->set_property = gst_audio_rate_set_property;
136 object_class->get_property = gst_audio_rate_get_property;
138 g_object_class_install_property (object_class, ARG_IN,
139 g_param_spec_uint64 ("in", "In",
140 "Number of input samples", 0, G_MAXUINT64, 0,
141 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
142 g_object_class_install_property (object_class, ARG_OUT,
143 g_param_spec_uint64 ("out", "Out", "Number of output samples", 0,
144 G_MAXUINT64, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
145 pspec_add = g_param_spec_uint64 ("add", "Add", "Number of added samples",
146 0, G_MAXUINT64, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
147 g_object_class_install_property (object_class, ARG_ADD, pspec_add);
148 pspec_drop = g_param_spec_uint64 ("drop", "Drop", "Number of dropped samples",
149 0, G_MAXUINT64, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
150 g_object_class_install_property (object_class, ARG_DROP, pspec_drop);
151 g_object_class_install_property (object_class, ARG_SILENT,
152 g_param_spec_boolean ("silent", "silent",
153 "Don't emit notify for dropped and duplicated frames", DEFAULT_SILENT,
154 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
156 * GstAudioRate:tolerance
158 * The difference between incoming timestamp and next timestamp must exceed
159 * the given value for audiorate to add or drop samples.
163 g_object_class_install_property (object_class, ARG_TOLERANCE,
164 g_param_spec_uint64 ("tolerance", "tolerance",
165 "Only act if timestamp jitter/imperfection exceeds indicated tolerance (ns)",
166 0, G_MAXUINT64, DEFAULT_TOLERANCE,
167 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
170 * GstAudioRate:skip-to-first:
172 * Don't produce buffers before the first one we receive.
176 g_object_class_install_property (object_class, ARG_SKIP_TO_FIRST,
177 g_param_spec_boolean ("skip-to-first", "Skip to first buffer",
178 "Don't produce buffers before the first one we receive",
179 DEFAULT_SKIP_TO_FIRST, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
181 gst_element_class_set_details_simple (element_class,
182 "Audio rate adjuster", "Filter/Effect/Audio",
183 "Drops/duplicates/adjusts timestamps on audio samples to make a perfect stream",
184 "Wim Taymans <wim@fluendo.com>");
186 gst_element_class_add_pad_template (element_class,
187 gst_static_pad_template_get (&gst_audio_rate_sink_template));
188 gst_element_class_add_pad_template (element_class,
189 gst_static_pad_template_get (&gst_audio_rate_src_template));
191 element_class->change_state = gst_audio_rate_change_state;
195 gst_audio_rate_reset (GstAudioRate * audiorate)
197 audiorate->next_offset = -1;
198 audiorate->next_ts = -1;
199 audiorate->discont = TRUE;
200 gst_segment_init (&audiorate->sink_segment, GST_FORMAT_UNDEFINED);
201 gst_segment_init (&audiorate->src_segment, GST_FORMAT_TIME);
203 GST_DEBUG_OBJECT (audiorate, "handle reset");
207 gst_audio_rate_setcaps (GstAudioRate * audiorate, GstCaps * caps)
211 if (!gst_audio_info_from_caps (&info, caps))
214 audiorate->info = info;
221 GST_DEBUG_OBJECT (audiorate, "could not parse caps");
227 gst_audio_rate_init (GstAudioRate * audiorate)
230 gst_pad_new_from_static_template (&gst_audio_rate_sink_template, "sink");
231 gst_pad_set_event_function (audiorate->sinkpad, gst_audio_rate_sink_event);
232 gst_pad_set_chain_function (audiorate->sinkpad, gst_audio_rate_chain);
233 gst_pad_set_getcaps_function (audiorate->sinkpad, gst_pad_proxy_getcaps);
234 gst_element_add_pad (GST_ELEMENT (audiorate), audiorate->sinkpad);
237 gst_pad_new_from_static_template (&gst_audio_rate_src_template, "src");
238 gst_pad_set_event_function (audiorate->srcpad, gst_audio_rate_src_event);
239 gst_pad_set_getcaps_function (audiorate->srcpad, gst_pad_proxy_getcaps);
240 gst_element_add_pad (GST_ELEMENT (audiorate), audiorate->srcpad);
246 audiorate->silent = DEFAULT_SILENT;
247 audiorate->tolerance = DEFAULT_TOLERANCE;
251 gst_audio_rate_fill_to_time (GstAudioRate * audiorate, GstClockTime time)
255 GST_DEBUG_OBJECT (audiorate, "next_ts: %" GST_TIME_FORMAT
256 ", filling to %" GST_TIME_FORMAT, GST_TIME_ARGS (audiorate->next_ts),
257 GST_TIME_ARGS (time));
259 if (!GST_CLOCK_TIME_IS_VALID (time) ||
260 !GST_CLOCK_TIME_IS_VALID (audiorate->next_ts))
263 /* feed an empty buffer to chain with the given timestamp,
264 * it will take care of filling */
265 buf = gst_buffer_new ();
266 GST_BUFFER_TIMESTAMP (buf) = time;
267 gst_audio_rate_chain (audiorate->sinkpad, buf);
271 gst_audio_rate_sink_event (GstPad * pad, GstEvent * event)
274 GstAudioRate *audiorate;
276 audiorate = GST_AUDIO_RATE (gst_pad_get_parent (pad));
278 switch (GST_EVENT_TYPE (event)) {
283 gst_event_parse_caps (event, &caps);
284 if ((res = gst_audio_rate_setcaps (audiorate, caps))) {
285 res = gst_pad_push_event (audiorate->srcpad, event);
287 gst_event_unref (event);
291 case GST_EVENT_FLUSH_STOP:
292 GST_DEBUG_OBJECT (audiorate, "handling FLUSH_STOP");
293 gst_audio_rate_reset (audiorate);
294 res = gst_pad_push_event (audiorate->srcpad, event);
296 case GST_EVENT_SEGMENT:
298 gst_event_copy_segment (event, &audiorate->sink_segment);
300 GST_DEBUG_OBJECT (audiorate, "handle NEWSEGMENT");
302 /* FIXME: bad things will likely happen if rate < 0 ... */
304 /* a new segment starts. We need to figure out what will be the next
305 * sample offset. We mark the offsets as invalid so that the _chain
306 * function will perform this calculation. */
307 gst_audio_rate_fill_to_time (audiorate, audiorate->src_segment.stop);
309 audiorate->next_offset = -1;
310 audiorate->next_ts = -1;
313 gst_audio_rate_fill_to_time (audiorate, audiorate->src_segment.start);
317 GST_DEBUG_OBJECT (audiorate, "updated segment: %" GST_SEGMENT_FORMAT,
318 &audiorate->sink_segment);
320 if (audiorate->sink_segment.format == GST_FORMAT_TIME) {
321 /* TIME formats can be copied to src and forwarded */
322 res = gst_pad_push_event (audiorate->srcpad, event);
323 gst_segment_copy_into (&audiorate->sink_segment,
324 &audiorate->src_segment);
326 /* other formats will be handled in the _chain function */
327 gst_event_unref (event);
333 /* Fill segment until the end */
334 if (GST_CLOCK_TIME_IS_VALID (audiorate->src_segment.stop))
335 gst_audio_rate_fill_to_time (audiorate, audiorate->src_segment.stop);
336 res = gst_pad_push_event (audiorate->srcpad, event);
339 res = gst_pad_push_event (audiorate->srcpad, event);
343 gst_object_unref (audiorate);
349 gst_audio_rate_src_event (GstPad * pad, GstEvent * event)
352 GstAudioRate *audiorate;
354 audiorate = GST_AUDIO_RATE (gst_pad_get_parent (pad));
356 switch (GST_EVENT_TYPE (event)) {
358 res = gst_pad_push_event (audiorate->sinkpad, event);
362 gst_object_unref (audiorate);
368 gst_audio_rate_convert (GstAudioRate * audiorate,
369 GstFormat src_fmt, guint64 src_val, GstFormat dest_fmt, guint64 * dest_val)
371 return gst_audio_info_convert (&audiorate->info, src_fmt, src_val, dest_fmt,
372 (gint64 *) dest_val);
377 gst_audio_rate_convert_segments (GstAudioRate * audiorate)
379 GstFormat src_fmt, dst_fmt;
381 src_fmt = audiorate->sink_segment.format;
382 dst_fmt = audiorate->src_segment.format;
384 #define CONVERT_VAL(field) gst_audio_rate_convert (audiorate, \
385 src_fmt, audiorate->sink_segment.field, \
386 dst_fmt, &audiorate->src_segment.field);
388 audiorate->sink_segment.rate = audiorate->src_segment.rate;
389 audiorate->sink_segment.flags = audiorate->src_segment.flags;
390 audiorate->sink_segment.applied_rate = audiorate->src_segment.applied_rate;
395 CONVERT_VAL (position);
402 gst_audio_rate_notify_drop (GstAudioRate * audiorate)
404 #if !GLIB_CHECK_VERSION(2,26,0)
405 g_object_notify ((GObject *) audiorate, "drop");
407 g_object_notify_by_pspec ((GObject *) audiorate, pspec_drop);
412 gst_audio_rate_notify_add (GstAudioRate * audiorate)
414 #if !GLIB_CHECK_VERSION(2,26,0)
415 g_object_notify ((GObject *) audiorate, "add");
417 g_object_notify_by_pspec ((GObject *) audiorate, pspec_add);
422 gst_audio_rate_chain (GstPad * pad, GstBuffer * buf)
424 GstAudioRate *audiorate;
425 GstClockTime in_time;
426 guint64 in_offset, in_offset_end, in_samples;
428 GstFlowReturn ret = GST_FLOW_OK;
429 GstClockTimeDiff diff;
432 audiorate = GST_AUDIO_RATE (gst_pad_get_parent (pad));
434 rate = GST_AUDIO_INFO_RATE (&audiorate->info);
435 bpf = GST_AUDIO_INFO_BPF (&audiorate->info);
437 /* need to be negotiated now */
441 /* we have a new pending segment */
442 if (audiorate->next_offset == -1) {
445 /* update the TIME segment */
446 gst_audio_rate_convert_segments (audiorate);
448 /* first buffer, we are negotiated and we have a segment, calculate the
449 * current expected offsets based on the segment.start, which is the first
450 * media time of the segment and should match the media time of the first
451 * buffer in that segment, which is the offset expressed in DEFAULT units.
453 /* convert first timestamp of segment to sample position */
454 pos = gst_util_uint64_scale_int (audiorate->src_segment.start,
455 GST_AUDIO_INFO_RATE (&audiorate->info), GST_SECOND);
457 GST_DEBUG_OBJECT (audiorate, "resync to offset %" G_GINT64_FORMAT, pos);
459 /* resyncing is a discont */
460 audiorate->discont = TRUE;
462 audiorate->next_offset = pos;
463 audiorate->next_ts = gst_util_uint64_scale_int (audiorate->next_offset,
464 GST_SECOND, GST_AUDIO_INFO_RATE (&audiorate->info));
466 if (audiorate->skip_to_first && GST_BUFFER_TIMESTAMP_IS_VALID (buf)) {
467 GST_DEBUG_OBJECT (audiorate, "but skipping to first buffer instead");
468 pos = gst_util_uint64_scale_int (GST_BUFFER_TIMESTAMP (buf),
469 GST_AUDIO_INFO_RATE (&audiorate->info), GST_SECOND);
470 GST_DEBUG_OBJECT (audiorate, "so resync to offset %" G_GINT64_FORMAT,
472 audiorate->next_offset = pos;
473 audiorate->next_ts = GST_BUFFER_TIMESTAMP (buf);
479 in_time = GST_BUFFER_TIMESTAMP (buf);
480 if (in_time == GST_CLOCK_TIME_NONE) {
481 GST_DEBUG_OBJECT (audiorate, "no timestamp, using expected next time");
482 in_time = audiorate->next_ts;
485 in_size = gst_buffer_get_size (buf);
486 in_samples = in_size / bpf;
488 /* calculate the buffer offset */
489 in_offset = gst_util_uint64_scale_int_round (in_time, rate, GST_SECOND);
490 in_offset_end = in_offset + in_samples;
492 GST_LOG_OBJECT (audiorate,
493 "in_time:%" GST_TIME_FORMAT ", in_duration:%" GST_TIME_FORMAT
494 ", in_size:%u, in_offset:%" G_GUINT64_FORMAT ", in_offset_end:%"
495 G_GUINT64_FORMAT ", ->next_offset:%" G_GUINT64_FORMAT ", ->next_ts:%"
496 GST_TIME_FORMAT, GST_TIME_ARGS (in_time),
497 GST_TIME_ARGS (GST_FRAMES_TO_CLOCK_TIME (in_samples, rate)),
498 in_size, in_offset, in_offset_end, audiorate->next_offset,
499 GST_TIME_ARGS (audiorate->next_ts));
501 diff = in_time - audiorate->next_ts;
502 if (diff <= (GstClockTimeDiff) audiorate->tolerance &&
503 diff >= (GstClockTimeDiff) - audiorate->tolerance) {
504 /* buffer time close enough to expected time,
505 * so produce a perfect stream by simply 'shifting'
506 * it to next ts and offset and sending */
507 GST_LOG_OBJECT (audiorate, "within tolerance %" GST_TIME_FORMAT,
508 GST_TIME_ARGS (audiorate->tolerance));
509 /* The outgoing buffer's offset will be set to ->next_offset, we also
510 * need to adjust the offset_end value accordingly */
511 in_offset_end = audiorate->next_offset + in_samples;
515 /* do we need to insert samples */
516 if (in_offset > audiorate->next_offset) {
521 /* We don't want to allocate a single unreasonably huge buffer - it might
522 be hundreds of megabytes. So, limit each output buffer to one second of
524 fillsamples = in_offset - audiorate->next_offset;
526 while (fillsamples > 0) {
527 guint64 cursamples = MIN (fillsamples, rate);
530 fillsamples -= cursamples;
531 fillsize = cursamples * bpf;
533 fill = gst_buffer_new_and_alloc (fillsize);
535 data = gst_buffer_map (fill, NULL, NULL, GST_MAP_WRITE);
536 /* FIXME, 0 might not be the silence byte for the negotiated format. */
537 memset (data, 0, fillsize);
538 gst_buffer_unmap (fill, data, fillsize);
540 GST_DEBUG_OBJECT (audiorate, "inserting %" G_GUINT64_FORMAT " samples",
543 GST_BUFFER_OFFSET (fill) = audiorate->next_offset;
544 audiorate->next_offset += cursamples;
545 GST_BUFFER_OFFSET_END (fill) = audiorate->next_offset;
547 /* Use next timestamp, then calculate following timestamp based on
548 * offset to get duration. Neccesary complexity to get 'perfect'
550 GST_BUFFER_TIMESTAMP (fill) = audiorate->next_ts;
551 audiorate->next_ts = gst_util_uint64_scale_int (audiorate->next_offset,
553 GST_BUFFER_DURATION (fill) = audiorate->next_ts -
554 GST_BUFFER_TIMESTAMP (fill);
556 /* we created this buffer to fill a gap */
557 GST_BUFFER_FLAG_SET (fill, GST_BUFFER_FLAG_GAP);
558 /* set discont if it's pending, this is mostly done for the first buffer
559 * and after a flushing seek */
560 if (audiorate->discont) {
561 GST_BUFFER_FLAG_SET (fill, GST_BUFFER_FLAG_DISCONT);
562 audiorate->discont = FALSE;
565 ret = gst_pad_push (audiorate->srcpad, fill);
566 if (ret != GST_FLOW_OK)
569 audiorate->add += cursamples;
571 if (!audiorate->silent)
572 gst_audio_rate_notify_add (audiorate);
575 } else if (in_offset < audiorate->next_offset) {
576 /* need to remove samples */
577 if (in_offset_end <= audiorate->next_offset) {
578 guint64 drop = in_size / bpf;
580 audiorate->drop += drop;
582 GST_DEBUG_OBJECT (audiorate, "dropping %" G_GUINT64_FORMAT " samples",
585 /* we can drop the buffer completely */
586 gst_buffer_unref (buf);
589 if (!audiorate->silent)
590 gst_audio_rate_notify_drop (audiorate);
594 guint64 truncsamples;
595 guint truncsize, leftsize;
598 /* truncate buffer */
599 truncsamples = audiorate->next_offset - in_offset;
600 truncsize = truncsamples * bpf;
601 leftsize = in_size - truncsize;
604 gst_buffer_copy_region (buf, GST_BUFFER_COPY_ALL, truncsize,
607 gst_buffer_unref (buf);
610 audiorate->drop += truncsamples;
611 GST_DEBUG_OBJECT (audiorate, "truncating %" G_GUINT64_FORMAT " samples",
614 if (!audiorate->silent)
615 gst_audio_rate_notify_drop (audiorate);
620 if (gst_buffer_get_size (buf) == 0)
623 /* Now calculate parameters for whichever buffer (either the original
624 * or truncated one) we're pushing. */
625 GST_BUFFER_OFFSET (buf) = audiorate->next_offset;
626 GST_BUFFER_OFFSET_END (buf) = in_offset_end;
628 GST_BUFFER_TIMESTAMP (buf) = audiorate->next_ts;
629 audiorate->next_ts = gst_util_uint64_scale_int (in_offset_end,
631 GST_BUFFER_DURATION (buf) = audiorate->next_ts - GST_BUFFER_TIMESTAMP (buf);
633 if (audiorate->discont) {
634 /* we need to output a discont buffer, do so now */
635 GST_DEBUG_OBJECT (audiorate, "marking DISCONT on output buffer");
636 buf = gst_buffer_make_writable (buf);
637 GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
638 audiorate->discont = FALSE;
639 } else if (GST_BUFFER_IS_DISCONT (buf)) {
640 /* else we make everything continuous so we can safely remove the DISCONT
641 * flag from the buffer if there was one */
642 GST_DEBUG_OBJECT (audiorate, "removing DISCONT from buffer");
643 buf = gst_buffer_make_writable (buf);
644 GST_BUFFER_FLAG_UNSET (buf, GST_BUFFER_FLAG_DISCONT);
647 /* set last_stop on segment */
648 audiorate->src_segment.position =
649 GST_BUFFER_TIMESTAMP (buf) + GST_BUFFER_DURATION (buf);
651 ret = gst_pad_push (audiorate->srcpad, buf);
655 audiorate->next_offset = in_offset_end;
659 gst_buffer_unref (buf);
661 gst_object_unref (audiorate);
668 gst_buffer_unref (buf);
670 GST_ELEMENT_ERROR (audiorate, STREAM, FORMAT,
671 (NULL), ("pipeline error, format was not negotiated"));
672 return GST_FLOW_NOT_NEGOTIATED;
677 gst_audio_rate_set_property (GObject * object,
678 guint prop_id, const GValue * value, GParamSpec * pspec)
680 GstAudioRate *audiorate = GST_AUDIO_RATE (object);
684 audiorate->silent = g_value_get_boolean (value);
687 audiorate->tolerance = g_value_get_uint64 (value);
689 case ARG_SKIP_TO_FIRST:
690 audiorate->skip_to_first = g_value_get_boolean (value);
693 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
699 gst_audio_rate_get_property (GObject * object,
700 guint prop_id, GValue * value, GParamSpec * pspec)
702 GstAudioRate *audiorate = GST_AUDIO_RATE (object);
706 g_value_set_uint64 (value, audiorate->in);
709 g_value_set_uint64 (value, audiorate->out);
712 g_value_set_uint64 (value, audiorate->add);
715 g_value_set_uint64 (value, audiorate->drop);
718 g_value_set_boolean (value, audiorate->silent);
721 g_value_set_uint64 (value, audiorate->tolerance);
723 case ARG_SKIP_TO_FIRST:
724 g_value_set_boolean (value, audiorate->skip_to_first);
727 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
732 static GstStateChangeReturn
733 gst_audio_rate_change_state (GstElement * element, GstStateChange transition)
735 GstAudioRate *audiorate = GST_AUDIO_RATE (element);
737 switch (transition) {
738 case GST_STATE_CHANGE_PAUSED_TO_READY:
740 case GST_STATE_CHANGE_READY_TO_PAUSED:
745 gst_audio_info_init (&audiorate->info);
746 gst_audio_rate_reset (audiorate);
752 return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
756 plugin_init (GstPlugin * plugin)
758 GST_DEBUG_CATEGORY_INIT (audio_rate_debug, "audiorate", 0,
759 "AudioRate stream fixer");
761 return gst_element_register (plugin, "audiorate", GST_RANK_NONE,
762 GST_TYPE_AUDIO_RATE);
765 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
768 "Adjusts audio frames",
769 plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)