| 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 |  * GstAudioInfo: | 
| 48 |  * @finfo: the format info of the audio | 
| 49 |  * @flags: additional audio flags | 
| 50 |  * @layout: audio layout | 
| 51 |  * @rate: the audio sample rate | 
| 52 |  * @channels: the number of channels | 
| 53 |  * @bpf: the number of bytes for one frame, this is the size of one | 
| 54 |  *         sample * @channels | 
| 55 |  * @position: the positions for each channel | 
| 56 |  * | 
| 57 |  * Information describing audio properties. This information can be filled | 
| 58 |  * in from GstCaps with gst_audio_info_from_caps(). | 
| 59 |  * | 
| 60 |  * Use the provided macros to access the info in this structure. | 
| 61 |  */ | 
| 62 | struct _GstAudioInfo { | 
| 63 |   const GstAudioFormatInfo *finfo; | 
| 64 |   GstAudioFlags             flags; | 
| 65 |   GstAudioLayout            layout; | 
| 66 |   gint                      rate; | 
| 67 |   gint                      channels; | 
| 68 |   gint                      bpf; | 
| 69 |   GstAudioChannelPosition   position[64]; | 
| 70 |  | 
| 71 |   /*< private >*/ | 
| 72 |   gpointer _gst_reserved[GST_PADDING]; | 
| 73 | }; | 
| 74 |  | 
| 75 | #define GST_TYPE_AUDIO_INFO                  (gst_audio_info_get_type ()) | 
| 76 | GST_AUDIO_API | 
| 77 | GType gst_audio_info_get_type                (void); | 
| 78 |  | 
| 79 | #define GST_AUDIO_INFO_IS_VALID(i)           ((i)->finfo != NULL && (i)->rate > 0 && (i)->channels > 0 && (i)->bpf > 0) | 
| 80 |  | 
| 81 | #define GST_AUDIO_INFO_FORMAT(i)             (GST_AUDIO_FORMAT_INFO_FORMAT((i)->finfo)) | 
| 82 | #define GST_AUDIO_INFO_NAME(i)               (GST_AUDIO_FORMAT_INFO_NAME((i)->finfo)) | 
| 83 | #define GST_AUDIO_INFO_WIDTH(i)              (GST_AUDIO_FORMAT_INFO_WIDTH((i)->finfo)) | 
| 84 | #define GST_AUDIO_INFO_DEPTH(i)              (GST_AUDIO_FORMAT_INFO_DEPTH((i)->finfo)) | 
| 85 | #define GST_AUDIO_INFO_BPS(info)             (GST_AUDIO_INFO_DEPTH(info) >> 3) | 
| 86 |  | 
| 87 | #define GST_AUDIO_INFO_IS_INTEGER(i)         (GST_AUDIO_FORMAT_INFO_IS_INTEGER((i)->finfo)) | 
| 88 | #define GST_AUDIO_INFO_IS_FLOAT(i)           (GST_AUDIO_FORMAT_INFO_IS_FLOAT((i)->finfo)) | 
| 89 | #define GST_AUDIO_INFO_IS_SIGNED(i)          (GST_AUDIO_FORMAT_INFO_IS_SIGNED((i)->finfo)) | 
| 90 |  | 
| 91 | #define GST_AUDIO_INFO_ENDIANNESS(i)         (GST_AUDIO_FORMAT_INFO_ENDIANNESS((i)->finfo)) | 
| 92 | #define GST_AUDIO_INFO_IS_LITTLE_ENDIAN(i)   (GST_AUDIO_FORMAT_INFO_IS_LITTLE_ENDIAN((i)->finfo)) | 
| 93 | #define GST_AUDIO_INFO_IS_BIG_ENDIAN(i)      (GST_AUDIO_FORMAT_INFO_IS_BIG_ENDIAN((i)->finfo)) | 
| 94 |  | 
| 95 | #define GST_AUDIO_INFO_FLAGS(info)           ((info)->flags) | 
| 96 | #define GST_AUDIO_INFO_IS_UNPOSITIONED(info) (((info)->flags & GST_AUDIO_FLAG_UNPOSITIONED) != 0) | 
| 97 | #define GST_AUDIO_INFO_LAYOUT(info)          ((info)->layout) | 
| 98 |  | 
| 99 | #define GST_AUDIO_INFO_RATE(info)            ((info)->rate) | 
| 100 | #define GST_AUDIO_INFO_CHANNELS(info)        ((info)->channels) | 
| 101 | #define GST_AUDIO_INFO_BPF(info)             ((info)->bpf) | 
| 102 | #define GST_AUDIO_INFO_POSITION(info,c)      ((info)->position[c]) | 
| 103 |  | 
| 104 | GST_AUDIO_API | 
| 105 | GstAudioInfo * gst_audio_info_new         (void); | 
| 106 |  | 
| 107 | GST_AUDIO_API | 
| 108 | GstAudioInfo * gst_audio_info_new_from_caps (const GstCaps * caps); | 
| 109 |  | 
| 110 | GST_AUDIO_API | 
| 111 | void           gst_audio_info_init        (GstAudioInfo *info); | 
| 112 |  | 
| 113 | GST_AUDIO_API | 
| 114 | GstAudioInfo * gst_audio_info_copy        (const GstAudioInfo *info); | 
| 115 |  | 
| 116 | GST_AUDIO_API | 
| 117 | void           gst_audio_info_free        (GstAudioInfo *info); | 
| 118 |  | 
| 119 | GST_AUDIO_API | 
| 120 | void           gst_audio_info_set_format  (GstAudioInfo *info, GstAudioFormat format, | 
| 121 |                                            gint rate, gint channels, | 
| 122 |                                            const GstAudioChannelPosition *position); | 
| 123 |  | 
| 124 | GST_AUDIO_API | 
| 125 | gboolean       gst_audio_info_from_caps   (GstAudioInfo *info, const GstCaps *caps); | 
| 126 |  | 
| 127 | GST_AUDIO_API | 
| 128 | GstCaps *      gst_audio_info_to_caps     (const GstAudioInfo *info); | 
| 129 |  | 
| 130 | GST_AUDIO_API | 
| 131 | gboolean       gst_audio_info_convert     (const GstAudioInfo * info, | 
| 132 |                                            GstFormat src_fmt, gint64 src_val, | 
| 133 |                                            GstFormat dest_fmt, gint64 * dest_val); | 
| 134 |  | 
| 135 | GST_AUDIO_API | 
| 136 | gboolean       gst_audio_info_is_equal    (const GstAudioInfo *info, | 
| 137 |                                            const GstAudioInfo *other); | 
| 138 |  | 
| 139 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAudioInfo, gst_audio_info_free) | 
| 140 |  | 
| 141 | G_END_DECLS | 
| 142 |  | 
| 143 | #endif /* __GST_AUDIO_INFO_H__ */ | 
| 144 |  |