| 1 | /* GStreamer |
| 2 | * Copyright (C) <2018> Collabora Ltd. |
| 3 | * @author George Kiagiadakis <george.kiagiadakis@collabora.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_AUDIO_H__ |
| 22 | #include <gst/audio/audio.h> |
| 23 | #endif |
| 24 | |
| 25 | #ifndef __GST_AUDIO_BUFFER_H__ |
| 26 | #define __GST_AUDIO_BUFFER_H__ |
| 27 | |
| 28 | G_BEGIN_DECLS |
| 29 | |
| 30 | /** |
| 31 | * GstAudioBuffer: |
| 32 | * @info: a #GstAudioInfo describing the audio properties of this buffer |
| 33 | * @n_samples: the size of the buffer in samples |
| 34 | * @n_planes: the number of planes available |
| 35 | * @planes: an array of @n_planes pointers pointing to the start of each |
| 36 | * plane in the mapped buffer |
| 37 | * @buffer: the mapped buffer |
| 38 | * |
| 39 | * A structure containing the result of an audio buffer map operation, |
| 40 | * which is executed with gst_audio_buffer_map(). For non-interleaved (planar) |
| 41 | * buffers, the beginning of each channel in the buffer has its own pointer in |
| 42 | * the @planes array. For interleaved buffers, the @planes array only contains |
| 43 | * one item, which is the pointer to the beginning of the buffer, and @n_planes |
| 44 | * equals 1. |
| 45 | * |
| 46 | * The different channels in @planes are always in the GStreamer channel order. |
| 47 | * |
| 48 | * Since: 1.16 |
| 49 | */ |
| 50 | typedef struct { |
| 51 | GstAudioInfo info; |
| 52 | |
| 53 | gsize n_samples; |
| 54 | gint n_planes; |
| 55 | gpointer *planes; |
| 56 | |
| 57 | GstBuffer *buffer; |
| 58 | |
| 59 | /*< private >*/ |
| 60 | GstMapInfo *map_infos; |
| 61 | gpointer priv_planes_arr[8]; |
| 62 | GstMapInfo priv_map_infos_arr[8]; |
| 63 | |
| 64 | gpointer _gst_reserved[GST_PADDING]; |
| 65 | } GstAudioBuffer; |
| 66 | |
| 67 | |
| 68 | GST_AUDIO_API |
| 69 | gboolean gst_audio_buffer_map (GstAudioBuffer *buffer, const GstAudioInfo *info, |
| 70 | GstBuffer *gstbuffer, GstMapFlags flags); |
| 71 | |
| 72 | GST_AUDIO_API |
| 73 | void gst_audio_buffer_unmap (GstAudioBuffer *buffer); |
| 74 | |
| 75 | |
| 76 | #define GST_AUDIO_BUFFER_FORMAT(b) (GST_AUDIO_INFO_FORMAT(&(b)->info)) |
| 77 | #define GST_AUDIO_BUFFER_CHANNELS(b) (GST_AUDIO_INFO_CHANNELS(&(b)->info)) |
| 78 | #define GST_AUDIO_BUFFER_LAYOUT(b) (GST_AUDIO_INFO_LAYOUT(&(b)->info)) |
| 79 | #define GST_AUDIO_BUFFER_RATE(b) (GST_AUDIO_INFO_RATE(&(b)->info)) |
| 80 | |
| 81 | #define GST_AUDIO_BUFFER_WIDTH(b) (GST_AUDIO_INFO_WIDTH(&(b)->info)) |
| 82 | #define GST_AUDIO_BUFFER_DEPTH(b) (GST_AUDIO_INFO_DEPTH(&(b)->info)) |
| 83 | #define GST_AUDIO_BUFFER_SAMPLE_STRIDE(b) (GST_AUDIO_INFO_WIDTH(&(b)->info) >> 3) |
| 84 | #define GST_AUDIO_BUFFER_BPS(b) (GST_AUDIO_INFO_DEPTH(&(b)->info) >> 3) |
| 85 | #define GST_AUDIO_BUFFER_BPF(b) (GST_AUDIO_INFO_BPF(&(b)->info)) |
| 86 | |
| 87 | #define GST_AUDIO_BUFFER_N_SAMPLES(b) ((b)->n_samples) |
| 88 | #define GST_AUDIO_BUFFER_N_PLANES(b) ((b)->n_planes) |
| 89 | #define GST_AUDIO_BUFFER_PLANE_DATA(b,p) ((b)->planes[p]) |
| 90 | |
| 91 | /* the size of each plane in bytes */ |
| 92 | #define GST_AUDIO_BUFFER_PLANE_SIZE(b) \ |
| 93 | (GST_AUDIO_BUFFER_N_SAMPLES(b) * GST_AUDIO_BUFFER_SAMPLE_STRIDE(b) * \ |
| 94 | GST_AUDIO_BUFFER_CHANNELS(b) / GST_AUDIO_BUFFER_N_PLANES(b)) |
| 95 | |
| 96 | G_END_DECLS |
| 97 | |
| 98 | #endif /* __GST_AUDIO_BUFFER_H__ */ |
| 99 | |