1 /*
2  * GStreamer
3  * Copyright (C) 2016 Sebastian Dröge <sebastian@centricular.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef __GST_AUDIO_BUFFER_SPLIT_H__
22 #define __GST_AUDIO_BUFFER_SPLIT_H__
23 
24 #include <gst/gst.h>
25 #include <gst/base/base.h>
26 #include <gst/audio/audio.h>
27 
28 G_BEGIN_DECLS
29 
30 #define GST_TYPE_AUDIO_BUFFER_SPLIT            (gst_audio_buffer_split_get_type())
31 #define GST_AUDIO_BUFFER_SPLIT(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_BUFFER_SPLIT,GstAudioBufferSplit))
32 #define GST_IS_AUDIO_BUFFER_SPLIT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_BUFFER_SPLIT))
33 #define GST_AUDIO_BUFFER_SPLIT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass) ,GST_TYPE_AUDIO_BUFFER_SPLIT,GstAudioBufferSplitClass))
34 #define GST_IS_AUDIO_BUFFER_SPLIT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass) ,GST_TYPE_AUDIO_BUFFER_SPLIT))
35 #define GST_AUDIO_BUFFER_SPLIT_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj) ,GST_TYPE_AUDIO_BUFFER_SPLIT,GstAudioBufferSplitClass))
36 
37 typedef struct _GstAudioBufferSplit      GstAudioBufferSplit;
38 typedef struct _GstAudioBufferSplitClass GstAudioBufferSplitClass;
39 
40 struct _GstAudioBufferSplit {
41   GstElement parent;
42 
43   GstPad *srcpad, *sinkpad;
44 
45   /* Properties */
46   gint output_buffer_duration_n;
47   gint output_buffer_duration_d;
48 
49   /* State */
50   GstSegment segment;
51   GstAudioInfo info;
52 
53   GstAdapter *adapter;
54 
55   GstAudioStreamAlign *stream_align;
56   GstClockTime resync_time;
57   guint64 current_offset; /* offset from start time in samples */
58   guint64 drop_samples; /* number of samples to drop in gapless mode */
59 
60   guint samples_per_buffer;
61   guint error_per_buffer;
62   guint accumulated_error;
63 
64   gboolean strict_buffer_size;
65   gboolean gapless;
66   GstClockTime max_silence_time;
67 };
68 
69 struct _GstAudioBufferSplitClass {
70   GstElementClass parent_class;
71 };
72 
73 GType gst_audio_buffer_split_get_type (void);
74 
75 G_END_DECLS
76 
77 #endif /* __GST_AUDIO_BUFFER_SPLIT_H__ */
78