mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-20 23:36:38 +00:00
opusenc: change audio property to audio-type
This is now an enum with values generic (default) and voice. https://bugzilla.gnome.org/show_bug.cgi?id=740891
This commit is contained in:
parent
fb29483259
commit
da4f7e5387
2 changed files with 52 additions and 10 deletions
|
@ -114,6 +114,28 @@ gst_opus_enc_frame_size_get_type (void)
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define GST_OPUS_ENC_TYPE_AUDIO_TYPE (gst_opus_enc_audio_type_get_type())
|
||||||
|
static GType
|
||||||
|
gst_opus_enc_audio_type_get_type (void)
|
||||||
|
{
|
||||||
|
static const GEnumValue values[] = {
|
||||||
|
{OPUS_APPLICATION_AUDIO, "Generic audio", "generic"},
|
||||||
|
{OPUS_APPLICATION_VOIP, "Voice", "voice"},
|
||||||
|
{0, NULL, NULL}
|
||||||
|
};
|
||||||
|
static volatile GType id = 0;
|
||||||
|
|
||||||
|
if (g_once_init_enter ((gsize *) & id)) {
|
||||||
|
GType _id;
|
||||||
|
|
||||||
|
_id = g_enum_register_static ("GstOpusEncAudioType", values);
|
||||||
|
|
||||||
|
g_once_init_leave ((gsize *) & id, _id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
#define FORMAT_STR GST_AUDIO_NE(S16)
|
#define FORMAT_STR GST_AUDIO_NE(S16)
|
||||||
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
|
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
|
@ -132,6 +154,7 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
);
|
);
|
||||||
|
|
||||||
#define DEFAULT_AUDIO TRUE
|
#define DEFAULT_AUDIO TRUE
|
||||||
|
#define DEFAULT_AUDIO_TYPE OPUS_APPLICATION_AUDIO
|
||||||
#define DEFAULT_BITRATE 64000
|
#define DEFAULT_BITRATE 64000
|
||||||
#define DEFAULT_BANDWIDTH OPUS_BANDWIDTH_FULLBAND
|
#define DEFAULT_BANDWIDTH OPUS_BANDWIDTH_FULLBAND
|
||||||
#define DEFAULT_FRAMESIZE 20
|
#define DEFAULT_FRAMESIZE 20
|
||||||
|
@ -147,6 +170,7 @@ enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_AUDIO,
|
PROP_AUDIO,
|
||||||
|
PROP_AUDIO_TYPE,
|
||||||
PROP_BITRATE,
|
PROP_BITRATE,
|
||||||
PROP_BANDWIDTH,
|
PROP_BANDWIDTH,
|
||||||
PROP_FRAME_SIZE,
|
PROP_FRAME_SIZE,
|
||||||
|
@ -218,13 +242,18 @@ gst_opus_enc_class_init (GstOpusEncClass * klass)
|
||||||
base_class->getcaps = GST_DEBUG_FUNCPTR (gst_opus_enc_sink_getcaps);
|
base_class->getcaps = GST_DEBUG_FUNCPTR (gst_opus_enc_sink_getcaps);
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class, PROP_AUDIO,
|
g_object_class_install_property (gobject_class, PROP_AUDIO,
|
||||||
g_param_spec_boolean ("audio", "Audio or voice",
|
g_param_spec_boolean ("audio",
|
||||||
"Audio or voice", DEFAULT_AUDIO,
|
"Audio or voice (obsolete, use audio-type)",
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
"Audio or voice (obsolete, use audio-type)", DEFAULT_AUDIO,
|
||||||
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_DEPRECATED));
|
||||||
|
g_object_class_install_property (gobject_class, PROP_AUDIO_TYPE,
|
||||||
|
g_param_spec_enum ("audio-type", "What type of audio to optimize for",
|
||||||
|
"What type of audio to optimize for", GST_OPUS_ENC_TYPE_AUDIO_TYPE,
|
||||||
|
DEFAULT_AUDIO_TYPE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_BITRATE,
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_BITRATE,
|
||||||
g_param_spec_int ("bitrate", "Encoding Bit-rate",
|
g_param_spec_int ("bitrate", "Encoding Bit-rate",
|
||||||
"Specify an encoding bit-rate (in bps).",
|
"Specify an encoding bit-rate (in bps).", LOWEST_BITRATE,
|
||||||
LOWEST_BITRATE, HIGHEST_BITRATE, DEFAULT_BITRATE,
|
HIGHEST_BITRATE, DEFAULT_BITRATE,
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||||
GST_PARAM_MUTABLE_PLAYING));
|
GST_PARAM_MUTABLE_PLAYING));
|
||||||
g_object_class_install_property (gobject_class, PROP_BANDWIDTH,
|
g_object_class_install_property (gobject_class, PROP_BANDWIDTH,
|
||||||
|
@ -315,6 +344,7 @@ gst_opus_enc_init (GstOpusEnc * enc)
|
||||||
enc->dtx = DEFAULT_DTX;
|
enc->dtx = DEFAULT_DTX;
|
||||||
enc->packet_loss_percentage = DEFAULT_PACKET_LOSS_PERCENT;
|
enc->packet_loss_percentage = DEFAULT_PACKET_LOSS_PERCENT;
|
||||||
enc->max_payload_size = DEFAULT_MAX_PAYLOAD_SIZE;
|
enc->max_payload_size = DEFAULT_MAX_PAYLOAD_SIZE;
|
||||||
|
enc->audio_type = DEFAULT_AUDIO_TYPE;
|
||||||
|
|
||||||
/* arrange granulepos marking (and required perfect ts) */
|
/* arrange granulepos marking (and required perfect ts) */
|
||||||
gst_audio_encoder_set_mark_granule (benc, TRUE);
|
gst_audio_encoder_set_mark_granule (benc, TRUE);
|
||||||
|
@ -658,8 +688,7 @@ gst_opus_enc_setup (GstOpusEnc * enc)
|
||||||
enc->state = opus_multistream_encoder_create (enc->sample_rate,
|
enc->state = opus_multistream_encoder_create (enc->sample_rate,
|
||||||
enc->n_channels, enc->n_channels - enc->n_stereo_streams,
|
enc->n_channels, enc->n_channels - enc->n_stereo_streams,
|
||||||
enc->n_stereo_streams, enc->encoding_channel_mapping,
|
enc->n_stereo_streams, enc->encoding_channel_mapping,
|
||||||
enc->audio_or_voip ? OPUS_APPLICATION_AUDIO : OPUS_APPLICATION_VOIP,
|
enc->audio_type, &error);
|
||||||
&error);
|
|
||||||
if (!enc->state || error != OPUS_OK)
|
if (!enc->state || error != OPUS_OK)
|
||||||
goto encoder_creation_failed;
|
goto encoder_creation_failed;
|
||||||
|
|
||||||
|
@ -952,7 +981,13 @@ gst_opus_enc_get_property (GObject * object, guint prop_id, GValue * value,
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_AUDIO:
|
case PROP_AUDIO:
|
||||||
g_value_set_boolean (value, enc->audio_or_voip);
|
g_warning
|
||||||
|
("opusenc's audio property is obsolete, use audio-type instead");
|
||||||
|
g_value_set_boolean (value,
|
||||||
|
enc->audio_type == OPUS_APPLICATION_AUDIO ? TRUE : FALSE);
|
||||||
|
break;
|
||||||
|
case PROP_AUDIO_TYPE:
|
||||||
|
g_value_set_enum (value, enc->audio_type);
|
||||||
break;
|
break;
|
||||||
case PROP_BITRATE:
|
case PROP_BITRATE:
|
||||||
g_value_set_int (value, enc->bitrate);
|
g_value_set_int (value, enc->bitrate);
|
||||||
|
@ -1011,7 +1046,14 @@ gst_opus_enc_set_property (GObject * object, guint prop_id,
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_AUDIO:
|
case PROP_AUDIO:
|
||||||
enc->audio_or_voip = g_value_get_boolean (value);
|
g_warning
|
||||||
|
("opusenc's audio property is obsolete, use audio-type instead");
|
||||||
|
enc->audio_type =
|
||||||
|
g_value_get_boolean (value) ? OPUS_APPLICATION_AUDIO :
|
||||||
|
OPUS_APPLICATION_VOIP;
|
||||||
|
break;
|
||||||
|
case PROP_AUDIO_TYPE:
|
||||||
|
enc->audio_type = g_value_get_enum (value);
|
||||||
break;
|
break;
|
||||||
case PROP_BITRATE:
|
case PROP_BITRATE:
|
||||||
GST_OPUS_UPDATE_PROPERTY (bitrate, int, BITRATE);
|
GST_OPUS_UPDATE_PROPERTY (bitrate, int, BITRATE);
|
||||||
|
|
|
@ -57,7 +57,7 @@ struct _GstOpusEnc {
|
||||||
GMutex property_lock;
|
GMutex property_lock;
|
||||||
|
|
||||||
/* properties */
|
/* properties */
|
||||||
gboolean audio_or_voip;
|
gint audio_type;
|
||||||
gint bitrate;
|
gint bitrate;
|
||||||
gint bandwidth;
|
gint bandwidth;
|
||||||
gint frame_size;
|
gint frame_size;
|
||||||
|
|
Loading…
Reference in a new issue