summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2015-03-23 13:15:30 +0100
committerSebastian Dröge <sebastian@centricular.com>2015-03-23 13:15:30 +0100
commit6f33c20b00cf23ededb6324453be8d8115db6b5b (patch)
treeaf403cde1dff4e54820bc032a6b21aa3c776ef68
parent78634dc2c384e2b39b35ab8f06133fbac7dc53e0 (diff)
downloadgstreamer-plugins-base-6f33c20b00cf23ededb6324453be8d8115db6b5b.tar.gz
opusenc: Set output format immediately after creating the encoder instance
We know the caps by then, there's no need to wait until we actually receive the first buffer.
-rw-r--r--ext/opus/gstopusenc.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/ext/opus/gstopusenc.c b/ext/opus/gstopusenc.c
index 5f897c82f..ef1553fc3 100644
--- a/ext/opus/gstopusenc.c
+++ b/ext/opus/gstopusenc.c
@@ -693,6 +693,8 @@ static gboolean
gst_opus_enc_setup (GstOpusEnc * enc)
{
int error = OPUS_OK;
+ GstCaps *caps;
+ gboolean ret;
#ifndef GST_DISABLE_GST_DEBUG
GST_DEBUG_OBJECT (enc,
@@ -732,7 +734,18 @@ gst_opus_enc_setup (GstOpusEnc * enc)
GST_LOG_OBJECT (enc, "we have frame size %d", enc->frame_size);
- return TRUE;
+ gst_opus_header_create_caps (&caps, NULL, enc->n_channels,
+ enc->n_stereo_streams, enc->sample_rate, enc->channel_mapping_family,
+ enc->decoding_channel_mapping,
+ gst_tag_setter_get_tag_list (GST_TAG_SETTER (enc)));
+
+ /* negotiate with these caps */
+ GST_DEBUG_OBJECT (enc, "here are the caps: %" GST_PTR_FORMAT, caps);
+
+ ret = gst_audio_encoder_set_output_format (GST_AUDIO_ENCODER (enc), caps);
+ gst_caps_unref (caps);
+
+ return ret;
encoder_creation_failed:
GST_ERROR_OBJECT (enc, "Encoder creation failed");
@@ -962,22 +975,6 @@ gst_opus_enc_handle_frame (GstAudioEncoder * benc, GstBuffer * buf)
enc = GST_OPUS_ENC (benc);
GST_DEBUG_OBJECT (enc, "handle_frame");
-
- if (!gst_pad_has_current_caps (GST_AUDIO_ENCODER_SRC_PAD (benc))) {
- GstCaps *caps;
-
- gst_opus_header_create_caps (&caps, NULL, enc->n_channels,
- enc->n_stereo_streams, enc->sample_rate, enc->channel_mapping_family,
- enc->decoding_channel_mapping,
- gst_tag_setter_get_tag_list (GST_TAG_SETTER (enc)));
-
- /* negotiate with these caps */
- GST_DEBUG_OBJECT (enc, "here are the caps: %" GST_PTR_FORMAT, caps);
-
- gst_audio_encoder_set_output_format (benc, caps);
- gst_caps_unref (caps);
- }
-
GST_DEBUG_OBJECT (enc, "received buffer %p of %" G_GSIZE_FORMAT " bytes", buf,
buf ? gst_buffer_get_size (buf) : 0);