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 \ 30 (gst_raw_audio_parse_get_type()) 31 #define GST_RAW_AUDIO_PARSE(obj) \ 32 (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_RAW_AUDIO_PARSE, GstRawAudioParse)) 33 #define GST_RAW_AUDIO_PARSE_CAST(obj) \ 34 ((GstRawAudioParse *)(obj)) 35 #define GST_RAW_AUDIO_PARSE_CLASS(klass) \ 36 (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_RAW_AUDIO_PARSE, GstRawAudioParseClass)) 37 #define GST_IS_RAW_AUDIO_PARSE(obj) \ 38 (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_RAW_AUDIO_PARSE)) 39 #define GST_IS_RAW_AUDIO_PARSE_CLASS(klass) \ 40 (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_RAW_AUDIO_PARSE)) 41 42 typedef enum _GstRawAudioParseFormat GstRawAudioParseFormat; 43 44 typedef struct _GstRawAudioParseConfig GstRawAudioParseConfig; 45 typedef struct _GstRawAudioParse GstRawAudioParse; 46 typedef struct _GstRawAudioParseClass GstRawAudioParseClass; 47 48 enum _GstRawAudioParseFormat 49 { 50 GST_RAW_AUDIO_PARSE_FORMAT_PCM, 51 GST_RAW_AUDIO_PARSE_FORMAT_MULAW, 52 GST_RAW_AUDIO_PARSE_FORMAT_ALAW 53 }; 54 55 /* Contains information about the sample rate, format, and channel count to use. */ 56 struct _GstRawAudioParseConfig 57 { 58 /* If TRUE, then this configuration is ready to use */ 59 gboolean ready; 60 /* Format of the configuration. Can be PCM, a-law, mu-law. */ 61 GstRawAudioParseFormat format; 62 /* If format is set to PCM, this specifies the exact PCM format in use. 63 * Meaningless if format is set to anything other than PCM. */ 64 GstAudioFormat pcm_format; 65 /* Bytes per frame. Calculated as: bpf = bytes_per_sample * num_channels 66 * Must be nonzero. This is the size of one frame, the value returned 67 * by the GstRawBaseParseClass get_config_frame_size() vfunc. */ 68 guint bpf; 69 /* Sample rate in Hz - must be nonzero */ 70 guint sample_rate; 71 /* Number of channels - must be nonzero */ 72 guint num_channels; 73 /* TRUE if the data is interleaved, FALSE otherwise */ 74 gboolean interleaved; 75 76 /* Array of channel positions, one position per channel; its first 77 * num_channels values are valid. They are computed out of the number 78 * of channels if no positions are explicitely given. */ 79 GstAudioChannelPosition channel_positions[64]; 80 81 /* If the channel_positions are in a valid GStreamer channel order, then 82 * this is not used, and needs_channel_reordering is FALSE. Otherwise, 83 * this contains the same positions as in channel_positions, but in the 84 * order GStreamer expects. needs_channel_reordering will be TRUE in that 85 * case. This is used for reordering samples in outgoing buffers if 86 * necessary. */ 87 GstAudioChannelPosition reordered_channel_positions[64]; 88 89 /* TRUE if channel reordering is necessary, FALSE otherwise. See above 90 * for details. */ 91 gboolean needs_channel_reordering; 92 }; 93 94 struct _GstRawAudioParse 95 { 96 GstRawBaseParse parent; 97 98 /*< private > */ 99 100 /* Configuration controlled by the object properties. Its ready value 101 * is set to TRUE from the start, so it can be used right away. 102 */ 103 GstRawAudioParseConfig properties_config; 104 /* Configuration controlled by the sink caps. Its ready value is 105 * initially set to FALSE until valid sink caps come in. It is set to 106 * FALSE again when the stream-start event is observed. 107 */ 108 GstRawAudioParseConfig sink_caps_config; 109 /* Currently active configuration. Points either to properties_config 110 * or to sink_caps_config. This is never NULL. */ 111 GstRawAudioParseConfig *current_config; 112 }; 113 114 struct _GstRawAudioParseClass 115 { 116 GstRawBaseParseClass parent_class; 117 }; 118 119 GType gst_raw_audio_parse_get_type (void); 120 GType gst_raw_audio_parse_format_get_type (void); 121 122 G_END_DECLS 123 124 #endif 125