1 /* GStreamer Opus Encoder 2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu> 3 * Copyright (C) <2008> Sebastian Dröge <sebastian.droege@collabora.co.uk> 4 * Copyright (C) <2011-2012> Vincent Penquerc'h <vincent.penquerch@collabora.co.uk> 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 23 #ifndef __GST_OPUS_ENC_H__ 24 #define __GST_OPUS_ENC_H__ 25 26 27 #include <gst/gst.h> 28 #include <gst/audio/gstaudioencoder.h> 29 30 #include <opus_multistream.h> 31 32 G_BEGIN_DECLS 33 34 #define GST_TYPE_OPUS_ENC \ 35 (gst_opus_enc_get_type()) 36 #define GST_OPUS_ENC(obj) \ 37 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OPUS_ENC,GstOpusEnc)) 38 #define GST_OPUS_ENC_CLASS(klass) \ 39 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OPUS_ENC,GstOpusEncClass)) 40 #define GST_IS_OPUS_ENC(obj) \ 41 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OPUS_ENC)) 42 #define GST_IS_OPUS_ENC_CLASS(klass) \ 43 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OPUS_ENC)) 44 45 #define MAX_FRAME_SIZE 2000*2 46 #define MAX_FRAME_BYTES 2000 47 48 typedef enum 49 { 50 BITRATE_TYPE_CBR, 51 BITRATE_TYPE_VBR, 52 BITRATE_TYPE_CONSTRAINED_VBR, 53 } GstOpusEncBitrateType; 54 55 typedef struct _GstOpusEnc GstOpusEnc; 56 typedef struct _GstOpusEncClass GstOpusEncClass; 57 58 struct _GstOpusEnc { 59 GstAudioEncoder element; 60 61 OpusMSEncoder *state; 62 63 /* Locks those properties which may be changed at play time */ 64 GMutex property_lock; 65 66 /* properties */ 67 gint audio_type; 68 gint bitrate; 69 gint bandwidth; 70 gint frame_size; 71 GstOpusEncBitrateType bitrate_type; 72 gint complexity; 73 gboolean inband_fec; 74 gboolean dtx; 75 gint packet_loss_percentage; 76 guint max_payload_size; 77 78 gint frame_samples; 79 gint n_channels; 80 gint sample_rate; 81 gboolean unpositioned; 82 83 guint64 encoded_samples, consumed_samples; 84 guint16 lookahead, pending_lookahead; 85 86 guint8 channel_mapping_family; 87 guint8 encoding_channel_mapping[256]; 88 guint8 decoding_channel_mapping[256]; 89 guint8 n_stereo_streams; 90 }; 91 92 struct _GstOpusEncClass { 93 GstAudioEncoderClass parent_class; 94 95 /* signals */ 96 void (*frame_encoded) (GstElement *element); 97 }; 98 99 GType gst_opus_enc_get_type (void); 100 101 G_END_DECLS 102 103 #endif /* __GST_OPUS_ENC_H__ */ 104