diff options
author | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2008-01-24 14:25:29 +0000 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2008-01-24 14:25:29 +0000 |
commit | 449c9728f515a3b1263f6961c608328b3ad582a9 (patch) | |
tree | ce5f7affe29df1c19fa165ecf850fd181c1c586d | |
parent | 6f15a199e037d789188b3b89e77ac78acee7812f (diff) |
Fix gtreamer payloader sending fragmented frames.
-rw-r--r-- | audio/gstrtpsbcpay.c | 16 | ||||
-rw-r--r-- | audio/gstsbcutil.c | 21 |
2 files changed, 28 insertions, 9 deletions
diff --git a/audio/gstrtpsbcpay.c b/audio/gstrtpsbcpay.c index fdb42d18..25bf70eb 100644 --- a/audio/gstrtpsbcpay.c +++ b/audio/gstrtpsbcpay.c @@ -162,6 +162,8 @@ static GstFlowReturn gst_rtp_sbc_pay_flush_buffers(GstRtpSBCPay *sbcpay) GstBuffer* outbuf; guint8 *payload_data; guint8 *data; + guint frame_count; + guint payload_length; struct rtp_payload *payload; if (sbcpay->frame_length == 0) { @@ -176,25 +178,27 @@ static GstFlowReturn gst_rtp_sbc_pay_flush_buffers(GstRtpSBCPay *sbcpay) 0, 0); max_payload = MIN(max_payload, available); + frame_count = max_payload / sbcpay->frame_length; + payload_length = frame_count * sbcpay->frame_length; - outbuf = gst_rtp_buffer_new_allocate(max_payload + + outbuf = gst_rtp_buffer_new_allocate(payload_length + RTP_SBC_PAYLOAD_HEADER_SIZE, 0, 0); gst_rtp_buffer_set_payload_type(outbuf, GST_BASE_RTP_PAYLOAD_PT(sbcpay)); - data = gst_adapter_take(sbcpay->adapter, max_payload); payload_data = gst_rtp_buffer_get_payload(outbuf); - payload = (struct rtp_payload*) payload_data; memset(payload, 0, sizeof(struct rtp_payload)); - payload->frame_count = max_payload / sbcpay->frame_length; + payload->frame_count = frame_count; - memcpy(payload_data + RTP_SBC_PAYLOAD_HEADER_SIZE, data, max_payload); + data = gst_adapter_take(sbcpay->adapter, payload_length); + memcpy(payload_data + RTP_SBC_PAYLOAD_HEADER_SIZE, data, + payload_length); g_free(data); GST_BUFFER_TIMESTAMP(outbuf) = sbcpay->timestamp; - GST_DEBUG_OBJECT (sbcpay, "Pushing %d bytes", max_payload); + GST_DEBUG_OBJECT (sbcpay, "Pushing %d bytes", payload_length); return gst_basertppayload_push(GST_BASE_RTP_PAYLOAD(sbcpay), outbuf); } diff --git a/audio/gstsbcutil.c b/audio/gstsbcutil.c index 04b7217a..78024f7e 100644 --- a/audio/gstsbcutil.c +++ b/audio/gstsbcutil.c @@ -100,8 +100,8 @@ const gchar *gst_sbc_get_mode_from_list(const GValue *list) for (i = 0; i < size; i++) { value = gst_value_list_get_value(list, i); aux = g_value_get_string(value); - if (strcmp("stereo", aux) == 0) { - return "stereo"; + if (strcmp("joint", aux) == 0) { + return "joint"; } } return g_value_get_string(gst_value_list_get_value(list, size-1)); @@ -135,6 +135,19 @@ gint gst_sbc_get_mode_int(const gchar *mode) return -1; } +/* FIXME add dual when sbc_t supports it */ +gboolean gst_sbc_get_mode_int_for_sbc_t(const gchar *mode) +{ + if (g_ascii_strcasecmp(mode, "joint") == 0) + return TRUE; + else if (g_ascii_strcasecmp(mode, "stereo") == 0) + return FALSE; + else if (g_ascii_strcasecmp(mode, "mono") == 0) + return FALSE; + else + return -1; +} + const gchar *gst_sbc_get_mode_string(int joint) { switch (joint) { @@ -183,6 +196,8 @@ const gchar *gst_sbc_get_mode_string_from_sbc_t(int channels, int joint) return "joint"; else if (channels == 2 && joint == 0) return "stereo"; + else if (channels == 1 && joint == 0) + return "mono"; else return NULL; } @@ -434,7 +449,7 @@ gboolean gst_sbc_util_fill_sbc_params(sbc_t *sbc, GstCaps *caps) sbc->blocks = blocks; sbc->subbands = subbands; sbc->bitpool = bitpool; - sbc->joint = gst_sbc_get_mode_int(mode); + sbc->joint = gst_sbc_get_mode_int_for_sbc_t(mode); sbc->allocation = gst_sbc_get_allocation_mode_int(allocation); return TRUE; |