• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
2  * Copyright (C) <2016> Carlos Rafael Giani <dv at pseudoterminal dot org>
3  *
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.
8  *
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.
13  *
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., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #ifndef __GST_RAW_AUDIO_PARSE_H__
21 #define __GST_RAW_AUDIO_PARSE_H__
22 
23 #include <gst/gst.h>
24 #include <gst/audio/audio.h>
25 #include "gstrawbaseparse.h"
26 
27 G_BEGIN_DECLS
28 
29 #define GST_TYPE_RAW_AUDIO_PARSE (gst_raw_audio_parse_get_type())
30 #define GST_RAW_AUDIO_PARSE_CAST(obj) ((GstRawAudioParse *)(obj))
31 G_DECLARE_FINAL_TYPE (GstRawAudioParse, gst_raw_audio_parse,
32     GST, RAW_AUDIO_PARSE, GstRawBaseParse)
33 
34 typedef enum _GstRawAudioParseFormat GstRawAudioParseFormat;
35 
36 typedef struct _GstRawAudioParseConfig GstRawAudioParseConfig;
37 
38 enum _GstRawAudioParseFormat
39 {
40   GST_RAW_AUDIO_PARSE_FORMAT_PCM,
41   GST_RAW_AUDIO_PARSE_FORMAT_MULAW,
42   GST_RAW_AUDIO_PARSE_FORMAT_ALAW
43 };
44 
45 /* Contains information about the sample rate, format, and channel count to use. */
46 struct _GstRawAudioParseConfig
47 {
48   /* If TRUE, then this configuration is ready to use */
49   gboolean ready;
50   /* Format of the configuration. Can be PCM, a-law, mu-law. */
51   GstRawAudioParseFormat format;
52   /* If format is set to PCM, this specifies the exact PCM format in use.
53    * Meaningless if format is set to anything other than PCM. */
54   GstAudioFormat pcm_format;
55   /* Bytes per frame. Calculated as: bpf = bytes_per_sample * num_channels
56    * Must be nonzero. This is the size of one frame, the value returned
57    * by the GstRawBaseParseClass get_config_frame_size() vfunc. */
58   guint bpf;
59   /* Sample rate in Hz - must be nonzero */
60   guint sample_rate;
61   /* Number of channels - must be nonzero */
62   guint num_channels;
63   /* TRUE if the data is interleaved, FALSE otherwise */
64   gboolean interleaved;
65 
66   /* Array of channel positions, one position per channel; its first
67    * num_channels values are valid. They are computed out of the number
68    * of channels if no positions are explicitly given. */
69   GstAudioChannelPosition channel_positions[64];
70 
71   /* If the channel_positions are in a valid GStreamer channel order, then
72    * this is not used, and needs_channel_reordering is FALSE. Otherwise,
73    * this contains the same positions as in channel_positions, but in the
74    * order GStreamer expects. needs_channel_reordering will be TRUE in that
75    * case. This is used for reordering samples in outgoing buffers if
76    * necessary. */
77   GstAudioChannelPosition reordered_channel_positions[64];
78 
79   /* TRUE if channel reordering is necessary, FALSE otherwise. See above
80    * for details. */
81   gboolean needs_channel_reordering;
82 };
83 
84 struct _GstRawAudioParse
85 {
86   GstRawBaseParse parent;
87 
88   /*< private > */
89 
90   /* Configuration controlled by the object properties. Its ready value
91    * is set to TRUE from the start, so it can be used right away.
92    */
93   GstRawAudioParseConfig properties_config;
94   /* Configuration controlled by the sink caps. Its ready value is
95    * initially set to FALSE until valid sink caps come in. It is set to
96    * FALSE again when the stream-start event is observed.
97    */
98   GstRawAudioParseConfig sink_caps_config;
99   /* Currently active configuration. Points either to properties_config
100    * or to sink_caps_config. This is never NULL. */
101   GstRawAudioParseConfig *current_config;
102 };
103 
104 #define GST_TYPE_RAW_AUDIO_PARSE_FORMAT (gst_raw_audio_parse_format_get_type())
105 GType gst_raw_audio_parse_format_get_type (void);
106 
107 G_END_DECLS
108 
109 #endif
110