| 1 |
/* |
| 2 |
* Copyright (C) 2024 Piotr BrzeziĆski <[email protected]> |
| 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_ATENC_H_ |
| 21 |
#define _GST_ATENC_H_ |
| 22 |
|
| 23 |
#include <AudioToolbox/AudioToolbox.h> |
| 24 |
#include <gst/gst.h> |
| 25 |
#include <gst/audio/gstaudioencoder.h> |
| 26 |
#include <gst/pbutils/codec-utils.h> |
| 27 |
#include <gst/base/gstbytereader.h> |
| 28 |
#include <gst/base/gstqueuearray.h> |
| 29 |
|
| 30 |
#include "gstosxcoreaudiocommon.h" |
| 31 |
|
| 32 |
G_BEGIN_DECLS |
| 33 |
#define GST_TYPE_ATENC (gst_atenc_get_type()) |
| 34 |
#define GST_ATENC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ATENC,GstATEnc)) |
| 35 |
#define GST_ATENC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ATENC,GstATEncClass)) |
| 36 |
#define GST_IS_ATENC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ATENC)) |
| 37 |
#define GST_IS_ATENC_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ATENC)) |
| 38 |
typedef struct _GstATEnc GstATEnc; |
| 39 |
typedef struct _GstATEncClass GstATEncClass; |
| 40 |
|
| 41 |
/** |
| 42 |
* GstATEncRateControl: |
| 43 |
* @GST_ATENC_RATE_CONTROL_CONSTANT: Constant bitrate |
| 44 |
* @GST_ATENC_RATE_CONTROL_LONG_TERM_AVERAGE: Long-term-average bitrate |
| 45 |
* @GST_ATENC_RATE_CONTROL_VARIABLE_CONSTRAINED: Variable constrained bitrate |
| 46 |
* @GST_ATENC_RATE_CONTROL_VARIABLE: Variable bitrate |
| 47 |
* |
| 48 |
* Since: 1.26 |
| 49 |
*/ |
| 50 |
typedef enum |
| 51 |
{ |
| 52 |
GST_ATENC_RATE_CONTROL_CONSTANT = 0, |
| 53 |
GST_ATENC_RATE_CONTROL_LONG_TERM_AVERAGE = 1, |
| 54 |
GST_ATENC_RATE_CONTROL_VARIABLE_CONSTRAINED = 2, |
| 55 |
GST_ATENC_RATE_CONTROL_VARIABLE = 3, |
| 56 |
} GstATEncRateControl; |
| 57 |
|
| 58 |
typedef struct |
| 59 |
{ |
| 60 |
gint channels; |
| 61 |
AudioChannelLayoutTag aac_tag; |
| 62 |
GstAudioChannelPosition positions[8]; |
| 63 |
} GstATEncLayout; |
| 64 |
|
| 65 |
struct _GstATEnc |
| 66 |
{ |
| 67 |
GstAudioEncoder encoder; |
| 68 |
AudioConverterRef converter; |
| 69 |
UInt32 max_output_buffer_size; |
| 70 |
UInt32 n_output_samples; |
| 71 |
GstVecDeque *input_queue; |
| 72 |
GstAudioBuffer *used_buffer; |
| 73 |
gboolean input_eos; |
| 74 |
|
| 75 |
GstATEncRateControl rate_control; |
| 76 |
guint32 bitrate; |
| 77 |
guint32 vbr_quality; |
| 78 |
}; |
| 79 |
|
| 80 |
struct _GstATEncClass |
| 81 |
{ |
| 82 |
GstAudioEncoderClass encoder_class; |
| 83 |
}; |
| 84 |
|
| 85 |
GType gst_atenc_get_type (void); |
| 86 |
|
| 87 |
GST_ELEMENT_REGISTER_DECLARE (atenc); |
| 88 |
|
| 89 |
G_END_DECLS |
| 90 |
#endif |