summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Raghavan <arun.raghavan@collabora.co.uk>2012-09-27 12:40:04 +0800
committerArun Raghavan <arun.raghavan@collabora.co.uk>2012-09-27 12:40:04 +0800
commitd28d758fee578995fabffb96456e87efe8e9daac (patch)
treec7666fb6e34b510e99df7e39cf872a4171fb5cb6
parent0941b10070cf85bba0b14880e0a59f52a63349d1 (diff)
WIP audio: Minor cleanups to rtpsbcdepayarun-ccu/master
-rw-r--r--audio/gstrtpsbcdepay.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/audio/gstrtpsbcdepay.c b/audio/gstrtpsbcdepay.c
index 4b947f4c..34e139c0 100644
--- a/audio/gstrtpsbcdepay.c
+++ b/audio/gstrtpsbcdepay.c
@@ -111,6 +111,7 @@ static void gst_rtp_sbc_depay_finalize (GObject * object)
G_OBJECT_CLASS(parent_class)->finalize(object);
}
+/* FIXME: this could likely go into codec-utils at some point */
static int gst_rtp_sbc_depay_get_framelen(GstRtpSBCDepay *depay)
{
int blocks, channel_mode, channels, subbands, bitpool;
@@ -160,21 +161,24 @@ static gboolean gst_rtp_sbc_depay_setcaps(GstBaseRTPDepayload *base,
{
GstRtpSBCDepay *depay = GST_RTP_SBC_DEPAY(base);
GstStructure *structure;
- GstCaps *outcaps;
- gint rate, channels, blocks, subbands, bitpool;
- gchar *mode, *allocation;
+ GstCaps *outcaps, *oldcaps;
+ int rate;
structure = gst_caps_get_structure(caps, 0);
if (!gst_structure_get_int(structure, "clock-rate", &rate))
goto bad_caps;
- caps = gst_caps_new_simple("audio/x-sbc", "rate", G_TYPE_INT, rate,
+ outcaps = gst_caps_new_simple("audio/x-sbc", "rate", G_TYPE_INT, rate,
NULL);
- gst_pad_set_caps(GST_BASE_RTP_DEPAYLOAD_SRCPAD(base), caps);
+ gst_pad_set_caps(GST_BASE_RTP_DEPAYLOAD_SRCPAD(base), outcaps);
- /* XXX: Flush old data if caps changed */
+ oldcaps = GST_PAD_CAPS(GST_BASE_RTP_DEPAYLOAD_SINKPAD(base));
+ if (oldcaps && !gst_caps_can_intersect(oldcaps, caps)) {
+ /* Caps have changed, flush old data */
+ gst_adapter_clear(depay->adapter);
+ }
return TRUE;
@@ -183,6 +187,7 @@ bad_caps:
GST_PTR_FORMAT, caps);
return FALSE;
}
+
static GstBuffer* gst_rtp_sbc_depay_process(GstBaseRTPDepayload *base,
GstBuffer *in)
{
@@ -200,10 +205,6 @@ static GstBuffer* gst_rtp_sbc_depay_process(GstBaseRTPDepayload *base,
goto bad_packet;
}
- /* XXX: will we get here without setcaps first being called? */
-
- /* XXX: handle changes to payload_type */
-
/* XXX: is basedepayload timestamp handling good enough for us? */
payload = gst_rtp_buffer_get_payload(in);
@@ -215,6 +216,8 @@ static GstBuffer* gst_rtp_sbc_depay_process(GstBaseRTPDepayload *base,
nframes = payload[0] & 0x0f;
if (fragment) {
+ /* Got a packet with a fragment */
+
if (start && gst_adapter_available(depay->adapter)) {
GST_WARNING_OBJECT(depay, "Missing last fragment");
gst_adapter_clear(depay->adapter);
@@ -235,16 +238,13 @@ static GstBuffer* gst_rtp_sbc_depay_process(GstBaseRTPDepayload *base,
data = NULL;
} else {
/* !fragment */
- /* XXX: split the output buffer into individual frames if
- * nframes > 1 */
- int framelen;
GST_DEBUG_OBJECT(depay, "Got %d frames", nframes);
gst_adapter_push(depay->adapter, data);
while (nframes && gst_adapter_available(depay->adapter)) {
- framelen = gst_rtp_sbc_depay_get_framelen(depay);
+ int framelen = gst_rtp_sbc_depay_get_framelen(depay);
if (framelen < 0) {
/* Not enough data to make a frame, should