mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-17 22:06:41 +00:00
opus: make it build against current, and remove cruft
https://bugzilla.gnome.org/show_bug.cgi?id=660364
This commit is contained in:
parent
e4856a2965
commit
ae510870e9
2 changed files with 19 additions and 83 deletions
|
@ -566,7 +566,7 @@ static GstFlowReturn
|
||||||
opus_dec_chain_parse_header (GstOpusDec * dec, GstBuffer * buf)
|
opus_dec_chain_parse_header (GstOpusDec * dec, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
//gint error = OPUS_OK;
|
int err;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
dec->samples_per_frame = opus_packet_get_samples_per_frame (
|
dec->samples_per_frame = opus_packet_get_samples_per_frame (
|
||||||
|
@ -578,42 +578,10 @@ opus_dec_chain_parse_header (GstOpusDec * dec, GstBuffer * buf)
|
||||||
goto invalid_header;
|
goto invalid_header;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
dec->state = opus_decoder_create (dec->sample_rate, dec->n_channels, &err);
|
||||||
#ifdef HAVE_OPUS_0_7
|
if (!dec->state || err != OPUS_OK)
|
||||||
dec->mode =
|
|
||||||
opus_mode_create (dec->sample_rate, dec->header.frame_size, &error);
|
|
||||||
#else
|
|
||||||
dec->mode =
|
|
||||||
opus_mode_create (dec->sample_rate, dec->header.nb_channels,
|
|
||||||
dec->header.frame_size, &error);
|
|
||||||
#endif
|
|
||||||
if (!dec->mode)
|
|
||||||
goto mode_init_failed;
|
|
||||||
|
|
||||||
/* initialize the decoder */
|
|
||||||
#ifdef HAVE_OPUS_0_11
|
|
||||||
dec->state =
|
|
||||||
opus_decoder_create_custom (dec->mode, dec->header.nb_channels, &error);
|
|
||||||
#else
|
|
||||||
#ifdef HAVE_OPUS_0_7
|
|
||||||
dec->state = opus_decoder_create (dec->mode, dec->header.nb_channels, &error);
|
|
||||||
#else
|
|
||||||
dec->state = opus_decoder_create (dec->mode);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
dec->state = opus_decoder_create (dec->sample_rate, dec->n_channels);
|
|
||||||
if (!dec->state)
|
|
||||||
goto init_failed;
|
goto init_failed;
|
||||||
|
|
||||||
#if 0
|
|
||||||
#ifdef HAVE_OPUS_0_8
|
|
||||||
dec->frame_size = dec->header.frame_size;
|
|
||||||
#else
|
|
||||||
opus_mode_info (dec->mode, OPUS_GET_FRAME_SIZE, &dec->frame_size);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
dec->frame_duration = gst_util_uint64_scale_int (dec->frame_size,
|
dec->frame_duration = gst_util_uint64_scale_int (dec->frame_size,
|
||||||
GST_SECOND, dec->sample_rate);
|
GST_SECOND, dec->sample_rate);
|
||||||
|
|
||||||
|
@ -711,7 +679,7 @@ opus_dec_chain_parse_data (GstOpusDec * dec, GstBuffer * buf,
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
gint16 *out_data;
|
gint16 *out_data;
|
||||||
int n;
|
int n, err;
|
||||||
|
|
||||||
if (timestamp != -1) {
|
if (timestamp != -1) {
|
||||||
dec->segment.last_stop = timestamp;
|
dec->segment.last_stop = timestamp;
|
||||||
|
@ -721,7 +689,9 @@ opus_dec_chain_parse_data (GstOpusDec * dec, GstBuffer * buf,
|
||||||
if (dec->state == NULL) {
|
if (dec->state == NULL) {
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
|
||||||
dec->state = opus_decoder_create (dec->sample_rate, dec->n_channels);
|
dec->state = opus_decoder_create (dec->sample_rate, dec->n_channels, &err);
|
||||||
|
if (!dec->state || err != OPUS_OK)
|
||||||
|
goto creation_failed;
|
||||||
|
|
||||||
/* set caps */
|
/* set caps */
|
||||||
caps = gst_caps_new_simple ("audio/x-raw-int",
|
caps = gst_caps_new_simple ("audio/x-raw-int",
|
||||||
|
@ -805,6 +775,10 @@ opus_dec_chain_parse_data (GstOpusDec * dec, GstBuffer * buf,
|
||||||
GST_DEBUG_OBJECT (dec, "flow: %s", gst_flow_get_name (res));
|
GST_DEBUG_OBJECT (dec, "flow: %s", gst_flow_get_name (res));
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
|
creation_failed:
|
||||||
|
GST_ERROR_OBJECT (dec, "Failed to create Opus decoder: %d", err);
|
||||||
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
|
|
|
@ -63,7 +63,7 @@ gst_opus_enc_bandwidth_get_type (void)
|
||||||
{OPUS_BANDWIDTH_WIDEBAND, "Wide band", "wideband"},
|
{OPUS_BANDWIDTH_WIDEBAND, "Wide band", "wideband"},
|
||||||
{OPUS_BANDWIDTH_SUPERWIDEBAND, "Super wide band", "superwideband"},
|
{OPUS_BANDWIDTH_SUPERWIDEBAND, "Super wide band", "superwideband"},
|
||||||
{OPUS_BANDWIDTH_FULLBAND, "Full band", "fullband"},
|
{OPUS_BANDWIDTH_FULLBAND, "Full band", "fullband"},
|
||||||
{OPUS_BANDWIDTH_AUTO, "Auto", "auto"},
|
{OPUS_AUTO, "Auto", "auto"},
|
||||||
{0, NULL, NULL}
|
{0, NULL, NULL}
|
||||||
};
|
};
|
||||||
static volatile GType id = 0;
|
static volatile GType id = 0;
|
||||||
|
@ -664,62 +664,24 @@ gst_opus_enc_create_metadata_buffer (GstOpusEnc * enc)
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_opus_enc_setup (GstOpusEnc * enc)
|
gst_opus_enc_setup (GstOpusEnc * enc)
|
||||||
{
|
{
|
||||||
//gint error = OPUS_OK;
|
int error = OPUS_OK;
|
||||||
|
|
||||||
enc->setup = FALSE;
|
enc->setup = FALSE;
|
||||||
|
|
||||||
#if 0
|
|
||||||
#ifdef HAVE_OPUS_0_7
|
|
||||||
enc->mode = opus_mode_create (enc->rate, enc->frame_size, &error);
|
|
||||||
#else
|
|
||||||
enc->mode =
|
|
||||||
opus_mode_create (enc->rate, enc->n_channels, enc->frame_size, &error);
|
|
||||||
#endif
|
|
||||||
if (!enc->mode)
|
|
||||||
goto mode_initialization_failed;
|
|
||||||
|
|
||||||
#ifdef HAVE_OPUS_0_11
|
|
||||||
opus_header_init (&enc->header, enc->mode, enc->frame_size, enc->n_channels);
|
|
||||||
#else
|
|
||||||
#ifdef HAVE_OPUS_0_7
|
|
||||||
opus_header_init (&enc->header, enc->mode, enc->n_channels);
|
|
||||||
#else
|
|
||||||
opus_header_init (&enc->header, enc->mode);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
enc->header.nb_channels = enc->n_channels;
|
|
||||||
|
|
||||||
#ifdef HAVE_OPUS_0_8
|
|
||||||
enc->frame_size = enc->header.frame_size;
|
|
||||||
#else
|
|
||||||
opus_mode_info (enc->mode, OPUS_GET_FRAME_SIZE, &enc->frame_size);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
#ifdef HAVE_OPUS_0_11
|
|
||||||
enc->state = opus_encoder_create_custom (enc->mode, enc->n_channels, &error);
|
|
||||||
#else
|
|
||||||
#ifdef HAVE_OPUS_0_7
|
|
||||||
enc->state = opus_encoder_create (enc->mode, enc->n_channels, &error);
|
|
||||||
#else
|
|
||||||
enc->state = opus_encoder_create (enc->mode);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
enc->state = opus_encoder_create (enc->sample_rate, enc->n_channels,
|
enc->state = opus_encoder_create (enc->sample_rate, enc->n_channels,
|
||||||
enc->audio_or_voip ? OPUS_APPLICATION_AUDIO : OPUS_APPLICATION_VOIP);
|
enc->audio_or_voip ? OPUS_APPLICATION_AUDIO : OPUS_APPLICATION_VOIP,
|
||||||
if (!enc->state)
|
&error);
|
||||||
|
if (!enc->state || error != OPUS_OK)
|
||||||
goto encoder_creation_failed;
|
goto encoder_creation_failed;
|
||||||
|
|
||||||
opus_encoder_ctl (enc->state, OPUS_SET_BITRATE (enc->bitrate), 0);
|
opus_encoder_ctl (enc->state, OPUS_SET_BITRATE (enc->bitrate), 0);
|
||||||
opus_encoder_ctl (enc->state, OPUS_SET_BANDWIDTH (enc->bandwidth), 0);
|
opus_encoder_ctl (enc->state, OPUS_SET_BANDWIDTH (enc->bandwidth), 0);
|
||||||
opus_encoder_ctl (enc->state, OPUS_SET_VBR_FLAG (!enc->cbr), 0);
|
opus_encoder_ctl (enc->state, OPUS_SET_VBR (!enc->cbr), 0);
|
||||||
opus_encoder_ctl (enc->state, OPUS_SET_VBR_CONSTRAINT (enc->constrained_vbr),
|
opus_encoder_ctl (enc->state, OPUS_SET_VBR_CONSTRAINT (enc->constrained_vbr),
|
||||||
0);
|
0);
|
||||||
opus_encoder_ctl (enc->state, OPUS_SET_COMPLEXITY (enc->complexity), 0);
|
opus_encoder_ctl (enc->state, OPUS_SET_COMPLEXITY (enc->complexity), 0);
|
||||||
opus_encoder_ctl (enc->state, OPUS_SET_INBAND_FEC_FLAG (enc->inband_fec), 0);
|
opus_encoder_ctl (enc->state, OPUS_SET_INBAND_FEC (enc->inband_fec), 0);
|
||||||
opus_encoder_ctl (enc->state, OPUS_SET_DTX_FLAG (enc->dtx), 0);
|
opus_encoder_ctl (enc->state, OPUS_SET_DTX (enc->dtx), 0);
|
||||||
opus_encoder_ctl (enc->state,
|
opus_encoder_ctl (enc->state,
|
||||||
OPUS_SET_PACKET_LOSS_PERC (enc->packet_loss_percentage), 0);
|
OPUS_SET_PACKET_LOSS_PERC (enc->packet_loss_percentage), 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue