1 /* GStreamer 2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu> 3 * Library <2001> Thomas Vander Stichele <thomas@apestaart.org> 4 * <2011> Wim Taymans <wim.taymans@gmail.com> 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Library General Public 8 * License as published by the Free Software Foundation; either 9 * version 2 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Library General Public License for more details. 15 * 16 * You should have received a copy of the GNU Library General Public 17 * License along with this library; if not, write to the 18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 19 * Boston, MA 02110-1301, USA. 20 */ 21 22 #ifndef __GST_AUDIO_AUDIO_H__ 23 #include <gst/audio/audio.h> 24 #endif 25 26 #ifndef __GST_AUDIO_INFO_H__ 27 #define __GST_AUDIO_INFO_H__ 28 29 G_BEGIN_DECLS 30 31 typedef struct _GstAudioInfo GstAudioInfo; 32 33 /** 34 * GstAudioFlags: 35 * @GST_AUDIO_FLAG_NONE: no valid flag 36 * @GST_AUDIO_FLAG_UNPOSITIONED: the position array explicitly 37 * contains unpositioned channels. 38 * 39 * Extra audio flags 40 */ 41 typedef enum { 42 GST_AUDIO_FLAG_NONE = 0, 43 GST_AUDIO_FLAG_UNPOSITIONED = (1 << 0) 44 } GstAudioFlags; 45 46 /** 47 * GstAudioLayout: 48 * @GST_AUDIO_LAYOUT_INTERLEAVED: interleaved audio 49 * @GST_AUDIO_LAYOUT_NON_INTERLEAVED: non-interleaved audio 50 * 51 * Layout of the audio samples for the different channels. 52 */ 53 typedef enum { 54 GST_AUDIO_LAYOUT_INTERLEAVED = 0, 55 GST_AUDIO_LAYOUT_NON_INTERLEAVED 56 } GstAudioLayout; 57 58 /** 59 * GstAudioInfo: 60 * @finfo: the format info of the audio 61 * @flags: additional audio flags 62 * @layout: audio layout 63 * @rate: the audio sample rate 64 * @channels: the number of channels 65 * @bpf: the number of bytes for one frame, this is the size of one 66 * sample * @channels 67 * @position: the positions for each channel 68 * 69 * Information describing audio properties. This information can be filled 70 * in from GstCaps with gst_audio_info_from_caps(). 71 * 72 * Use the provided macros to access the info in this structure. 73 */ 74 struct _GstAudioInfo { 75 const GstAudioFormatInfo *finfo; 76 GstAudioFlags flags; 77 GstAudioLayout layout; 78 gint rate; 79 gint channels; 80 gint bpf; 81 GstAudioChannelPosition position[64]; 82 83 /*< private >*/ 84 gpointer _gst_reserved[GST_PADDING]; 85 }; 86 87 #define GST_TYPE_AUDIO_INFO (gst_audio_info_get_type ()) 88 GST_AUDIO_API 89 GType gst_audio_info_get_type (void); 90 91 #define GST_AUDIO_INFO_IS_VALID(i) ((i)->finfo != NULL && (i)->rate > 0 && (i)->channels > 0 && (i)->bpf > 0) 92 93 #define GST_AUDIO_INFO_FORMAT(i) (GST_AUDIO_FORMAT_INFO_FORMAT((i)->finfo)) 94 #define GST_AUDIO_INFO_NAME(i) (GST_AUDIO_FORMAT_INFO_NAME((i)->finfo)) 95 #define GST_AUDIO_INFO_WIDTH(i) (GST_AUDIO_FORMAT_INFO_WIDTH((i)->finfo)) 96 #define GST_AUDIO_INFO_DEPTH(i) (GST_AUDIO_FORMAT_INFO_DEPTH((i)->finfo)) 97 #define GST_AUDIO_INFO_BPS(info) (GST_AUDIO_INFO_DEPTH(info) >> 3) 98 99 #define GST_AUDIO_INFO_IS_INTEGER(i) (GST_AUDIO_FORMAT_INFO_IS_INTEGER((i)->finfo)) 100 #define GST_AUDIO_INFO_IS_FLOAT(i) (GST_AUDIO_FORMAT_INFO_IS_FLOAT((i)->finfo)) 101 #define GST_AUDIO_INFO_IS_SIGNED(i) (GST_AUDIO_FORMAT_INFO_IS_SIGNED((i)->finfo)) 102 103 #define GST_AUDIO_INFO_ENDIANNESS(i) (GST_AUDIO_FORMAT_INFO_ENDIANNESS((i)->finfo)) 104 #define GST_AUDIO_INFO_IS_LITTLE_ENDIAN(i) (GST_AUDIO_FORMAT_INFO_IS_LITTLE_ENDIAN((i)->finfo)) 105 #define GST_AUDIO_INFO_IS_BIG_ENDIAN(i) (GST_AUDIO_FORMAT_INFO_IS_BIG_ENDIAN((i)->finfo)) 106 107 #define GST_AUDIO_INFO_FLAGS(info) ((info)->flags) 108 #define GST_AUDIO_INFO_IS_UNPOSITIONED(info) ((info)->flags & GST_AUDIO_FLAG_UNPOSITIONED) 109 #define GST_AUDIO_INFO_LAYOUT(info) ((info)->layout) 110 111 #define GST_AUDIO_INFO_RATE(info) ((info)->rate) 112 #define GST_AUDIO_INFO_CHANNELS(info) ((info)->channels) 113 #define GST_AUDIO_INFO_BPF(info) ((info)->bpf) 114 #define GST_AUDIO_INFO_POSITION(info,c) ((info)->position[c]) 115 116 GST_AUDIO_API 117 GstAudioInfo * gst_audio_info_new (void); 118 119 GST_AUDIO_API 120 void gst_audio_info_init (GstAudioInfo *info); 121 122 GST_AUDIO_API 123 GstAudioInfo * gst_audio_info_copy (const GstAudioInfo *info); 124 125 GST_AUDIO_API 126 void gst_audio_info_free (GstAudioInfo *info); 127 128 GST_AUDIO_API 129 void gst_audio_info_set_format (GstAudioInfo *info, GstAudioFormat format, 130 gint rate, gint channels, 131 const GstAudioChannelPosition *position); 132 133 GST_AUDIO_API 134 gboolean gst_audio_info_from_caps (GstAudioInfo *info, const GstCaps *caps); 135 136 GST_AUDIO_API 137 GstCaps * gst_audio_info_to_caps (const GstAudioInfo *info); 138 139 GST_AUDIO_API 140 gboolean gst_audio_info_convert (const GstAudioInfo * info, 141 GstFormat src_fmt, gint64 src_val, 142 GstFormat dest_fmt, gint64 * dest_val); 143 144 GST_AUDIO_API 145 gboolean gst_audio_info_is_equal (const GstAudioInfo *info, 146 const GstAudioInfo *other); 147 148 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC 149 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAudioInfo, gst_audio_info_free) 150 #endif 151 152 G_END_DECLS 153 154 #endif /* __GST_AUDIO_INFO_H__ */ 155