summaryrefslogtreecommitdiffstats
path: root/audio/gstsbcenc.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2007-11-23 17:00:13 +0000
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2007-11-23 17:00:13 +0000
commitd509d4960ff6fb74bf86bf2791067197d3795440 (patch)
treea86fe1cfed50ef1bcfa8c45d55f6139b8303b284 /audio/gstsbcenc.c
parent6e49d2d6ab859761671b51b10a40b5750551e152 (diff)
Code cleanup.
Diffstat (limited to 'audio/gstsbcenc.c')
-rw-r--r--audio/gstsbcenc.c57
1 files changed, 18 insertions, 39 deletions
diff --git a/audio/gstsbcenc.c b/audio/gstsbcenc.c
index 021ecacf..185151f5 100644
--- a/audio/gstsbcenc.c
+++ b/audio/gstsbcenc.c
@@ -345,23 +345,11 @@ gboolean gst_sbc_enc_fill_sbc_params(GstSbcEnc *enc, GstCaps *caps)
enc->sbc.bitpool = bitpool;
enc->mode = enc->sbc.joint = gst_sbc_get_mode_int(mode);
enc->allocation = enc->sbc.allocation = gst_sbc_get_allocation_mode_int(allocation);
-
- return TRUE;
-}
-
-static gboolean gst_sbc_enc_change_caps(GstSbcEnc *enc, GstCaps *caps)
-{
- GST_INFO_OBJECT(enc, "Changing srcpad caps (renegotiation)");
-
- if (!gst_pad_accept_caps(enc->srcpad, caps)) {
- GST_WARNING_OBJECT(enc, "Src pad refused caps");
- return FALSE;
- }
-
- if (!gst_sbc_enc_fill_sbc_params(enc, caps)) {
- GST_ERROR_OBJECT(enc, "couldn't get sbc parameters from caps");
- return FALSE;
- }
+ enc->codesize = sbc_get_codesize(&enc->sbc);
+ enc->frame_length = sbc_get_frame_length(&enc->sbc);
+ enc->frame_duration = sbc_get_frame_duration(&enc->sbc);
+ GST_DEBUG("codesize: %d, frame_length: %d, frame_duration: %d",
+ enc->codesize, enc->frame_length, enc->frame_duration);
return TRUE;
}
@@ -371,45 +359,36 @@ static GstFlowReturn sbc_enc_chain(GstPad *pad, GstBuffer *buffer)
GstSbcEnc *enc = GST_SBC_ENC(gst_pad_get_parent(pad));
GstAdapter *adapter = enc->adapter;
GstFlowReturn res = GST_FLOW_OK;
- gint codesize, frame_len;
- codesize = sbc_get_codesize(&enc->sbc);
- frame_len = sbc_get_frame_length(&enc->sbc);
gst_adapter_push(adapter, buffer);
- while (gst_adapter_available(adapter) >= codesize && res == GST_FLOW_OK) {
+ while (gst_adapter_available(adapter) >= enc->codesize &&
+ res == GST_FLOW_OK) {
GstBuffer *output;
GstCaps *caps;
const guint8 *data;
int consumed;
caps = GST_PAD_CAPS(enc->srcpad);
-
res = gst_pad_alloc_buffer_and_set_caps(enc->srcpad,
GST_BUFFER_OFFSET_NONE,
- frame_len, caps, &output);
+ enc->frame_length, caps,
+ &output);
+ if (res != GST_FLOW_OK)
+ goto done;
- data = gst_adapter_peek(adapter, codesize);
- consumed = sbc_encode(&enc->sbc, (gpointer) data, codesize,
- GST_BUFFER_DATA(output), frame_len,
- NULL);
+ data = gst_adapter_peek(adapter, enc->codesize);
+ consumed = sbc_encode(&enc->sbc, (gpointer) data,
+ enc->codesize,
+ GST_BUFFER_DATA(output),
+ GST_BUFFER_SIZE(output), NULL);
if (consumed <= 0) {
- GST_ERROR ("comsumed < 0, codesize: %d", codesize);
+ GST_ERROR ("comsumed < 0, codesize: %d",
+ enc->codesize);
break;
}
gst_adapter_flush(adapter, consumed);
- if (res != GST_FLOW_OK)
- goto done;
-
- if (!gst_caps_is_equal(caps, GST_BUFFER_CAPS(output)))
- if (!gst_sbc_enc_change_caps(enc,
- GST_BUFFER_CAPS(output))) {
- res = GST_FLOW_ERROR;
- GST_ERROR_OBJECT(enc, "couldn't renegotiate caps");
- goto done;
- }
-
GST_BUFFER_TIMESTAMP(output) = GST_BUFFER_TIMESTAMP(buffer);
res = gst_pad_push(enc->srcpad, output);