From ad245a0dc28669d0b8e84dc8f433144a8f98f222 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Mon, 10 Oct 2011 19:02:58 +0100 Subject: [PATCH 1/5] matroska-demux: don't leak audio codec_data buffer --- gst/matroska/matroska-demux.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c index 7a1a41c070..eaa6dfd044 100644 --- a/gst/matroska/matroska-demux.c +++ b/gst/matroska/matroska-demux.c @@ -5266,6 +5266,7 @@ gst_matroska_demux_audio_caps (GstMatroskaTrackAudioContext * "framed", G_TYPE_BOOLEAN, TRUE, NULL); gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, priv, NULL); *codec_name = g_strdup_printf ("MPEG-%d AAC audio", mpegversion); + gst_buffer_unref (priv); } } else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_TTA)) { caps = gst_caps_new_simple ("audio/x-tta", From 95db64851666bc3c5e852da77913764978588194 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Tue, 27 Sep 2011 19:25:53 +0100 Subject: [PATCH 2/5] jpegdec: Implement upstream negotiation Add upstream negotiation for jpegdec. Fixes #660275 --- ext/jpeg/gstjpegdec.c | 47 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/ext/jpeg/gstjpegdec.c b/ext/jpeg/gstjpegdec.c index 23e8f23b8c..2770696d23 100644 --- a/ext/jpeg/gstjpegdec.c +++ b/ext/jpeg/gstjpegdec.c @@ -113,6 +113,7 @@ static void gst_jpeg_dec_get_property (GObject * object, guint prop_id, static GstFlowReturn gst_jpeg_dec_chain (GstPad * pad, GstBuffer * buffer); static gboolean gst_jpeg_dec_setcaps (GstPad * pad, GstCaps * caps); +static GstCaps *gst_jpeg_dec_getcaps (GstPad * pad); static gboolean gst_jpeg_dec_sink_event (GstPad * pad, GstEvent * event); static gboolean gst_jpeg_dec_src_event (GstPad * pad, GstEvent * event); static GstStateChangeReturn gst_jpeg_dec_change_state (GstElement * element, @@ -406,6 +407,8 @@ gst_jpeg_dec_init (GstJpegDec * dec) gst_element_add_pad (GST_ELEMENT (dec), dec->sinkpad); gst_pad_set_setcaps_function (dec->sinkpad, GST_DEBUG_FUNCPTR (gst_jpeg_dec_setcaps)); + gst_pad_set_getcaps_function (dec->sinkpad, + GST_DEBUG_FUNCPTR (gst_jpeg_dec_getcaps)); gst_pad_set_chain_function (dec->sinkpad, GST_DEBUG_FUNCPTR (gst_jpeg_dec_chain)); gst_pad_set_event_function (dec->sinkpad, @@ -769,6 +772,50 @@ gst_jpeg_dec_setcaps (GstPad * pad, GstCaps * caps) return TRUE; } +static GstCaps * +gst_jpeg_dec_getcaps (GstPad * pad) +{ + GstJpegDec *dec; + GstCaps *caps; + GstPad *peer; + + dec = GST_JPEG_DEC (GST_OBJECT_PARENT (pad)); + + if (GST_PAD_CAPS (pad)) + return gst_caps_ref (GST_PAD_CAPS (pad)); + + peer = gst_pad_get_peer (dec->srcpad); + + if (peer) { + GstCaps *peer_caps; + const GstCaps *templ_caps; + GstStructure *s; + guint i, n; + + peer_caps = gst_pad_get_caps (peer); + + /* Translate peercaps to image/jpeg */ + peer_caps = gst_caps_make_writable (peer_caps); + n = gst_caps_get_size (peer_caps); + for (i = 0; i < n; i++) { + s = gst_caps_get_structure (peer_caps, i); + + gst_structure_set_name (s, "image/jpeg"); + } + + templ_caps = gst_pad_get_pad_template_caps (pad); + caps = gst_caps_intersect_full (peer_caps, templ_caps, + GST_CAPS_INTERSECT_FIRST); + + gst_object_unref (peer); + } else { + caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad)); + } + + return caps; +} + + /* yuk */ static void hresamplecpy1 (guint8 * dest, const guint8 * src, guint len) From bf65acf11fd107376e5591e24f0d93de05057fab Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Mon, 10 Oct 2011 19:01:23 +0100 Subject: [PATCH 3/5] gstrtpg722pay: Compensate for clockrate vs. samplerate difference The RTP clock-rate used for G722 is 8000, even though the samplerate is 16000. Compensate for this by pretending G722 has 8 bits per sample instead of the 4 bits as if it were a codec that ran at half the speed, but with twice the number of bits. Fixes #661376 --- gst/rtp/gstrtpg722pay.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gst/rtp/gstrtpg722pay.c b/gst/rtp/gstrtpg722pay.c index 29cd22a647..45ba4bb7b4 100644 --- a/gst/rtp/gstrtpg722pay.c +++ b/gst/rtp/gstrtpg722pay.c @@ -160,9 +160,11 @@ gst_rtp_g722_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps) rtpg722pay->rate = rate; rtpg722pay->channels = channels; - /* octet-per-sample is 1 * channels for G722 */ + /* bits-per-sample is 4 * channels for G722, but as the RTP clock runs at + * half speed (8 instead of 16 khz), pretend it's 8 bits per sample + * channels. */ gst_base_rtp_audio_payload_set_samplebits_options (basertpaudiopayload, - 4 * rtpg722pay->channels); + 8 * rtpg722pay->channels); return res; From 26d0812543dfc8ed9be018e69b860c39d9e0bded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Stadler?= Date: Tue, 11 Oct 2011 14:58:43 +0200 Subject: [PATCH 4/5] matroskamux: fix segment handling, so we actually use running time gst_matroska_mux_best_pad adjusts the buffer timestamp to running time using the segment stored in the pad's collect data. However, the event handler didn't pass the newsegment event on to collectpads' handler, so this segment was never updated at all. Re-fixes bug #432612. --- gst/matroska/matroska-mux.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/gst/matroska/matroska-mux.c b/gst/matroska/matroska-mux.c index 2398d78e5e..b0ff579ae0 100644 --- a/gst/matroska/matroska-mux.c +++ b/gst/matroska/matroska-mux.c @@ -658,12 +658,18 @@ gst_matroska_mux_handle_sink_event (GstPad * pad, GstEvent * event) event = NULL; break; } - case GST_EVENT_NEWSEGMENT: - /* We don't support NEWSEGMENT events */ - ret = FALSE; - gst_event_unref (event); - event = NULL; + case GST_EVENT_NEWSEGMENT:{ + GstFormat format; + + gst_event_parse_new_segment (event, NULL, NULL, &format, NULL, NULL, + NULL); + if (format != GST_FORMAT_TIME) { + ret = FALSE; + gst_event_unref (event); + event = NULL; + } break; + } case GST_EVENT_CUSTOM_DOWNSTREAM:{ const GstStructure *structure; @@ -2491,6 +2497,10 @@ gst_matroska_mux_best_pad (GstMatroskaMux * mux, gboolean * popped) collect_pad->buffer = NULL; return NULL; } else { + GST_LOG_OBJECT (mux, "buffer ts %" GST_TIME_FORMAT " -> %" + GST_TIME_FORMAT " running time", + GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (collect_pad->buffer)), + GST_TIME_ARGS (time)); collect_pad->buffer = gst_buffer_make_metadata_writable (collect_pad->buffer); GST_BUFFER_TIMESTAMP (collect_pad->buffer) = time; From 1b56d401703c16068c6e7dcb8245351556d37789 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Wed, 12 Oct 2011 11:26:50 +0200 Subject: [PATCH 5/5] rtpvrawpay: Only use 24 LSB for depth=24 RGB caps ... and indent the masks for clarity --- gst/rtp/gstrtpvrawpay.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/gst/rtp/gstrtpvrawpay.c b/gst/rtp/gstrtpvrawpay.c index c354639564..749d3e38cb 100644 --- a/gst/rtp/gstrtpvrawpay.c +++ b/gst/rtp/gstrtpvrawpay.c @@ -38,18 +38,18 @@ static GstStaticPadTemplate gst_rtp_vraw_pay_sink_template = "bpp = (int) 24, " "depth = (int) 24, " "endianness = (int) BIG_ENDIAN, " - "red_mask = (int) 0xFF000000, " - "green_mask = (int) 0x00FF0000, " - "blue_mask = (int) 0x0000FF00, " + "red_mask = (int) 0x00FF0000, " + "green_mask = (int) 0x0000FF00, " + "blue_mask = (int) 0x000000FF, " "width = (int) [ 1, 32767 ], " "height = (int) [ 1, 32767 ]; " "video/x-raw-rgb, " "bpp = (int) 32, " "depth = (int) 32, " "endianness = (int) BIG_ENDIAN, " - "red_mask = (int) 0xFF000000, " + "red_mask = (int) 0xFF000000, " "green_mask = (int) 0x00FF0000, " - "blue_mask = (int) 0x0000FF00, " + "blue_mask = (int) 0x0000FF00, " "alpha_mask = (int) 0x000000FF, " "width = (int) [ 1, 32767 ], " "height = (int) [ 1, 32767 ]; " @@ -57,18 +57,18 @@ static GstStaticPadTemplate gst_rtp_vraw_pay_sink_template = "bpp = (int) 24, " "depth = (int) 24, " "endianness = (int) BIG_ENDIAN, " - "red_mask = (int) 0x0000FF00, " - "green_mask = (int) 0x00FF0000, " - "blue_mask = (int) 0xFF000000, " + "red_mask = (int) 0x000000FF, " + "green_mask = (int) 0x0000FF00, " + "blue_mask = (int) 0x00FF0000, " "width = (int) [ 1, 32767 ], " "height = (int) [ 1, 32767 ]; " "video/x-raw-rgb, " "bpp = (int) 32, " "depth = (int) 32, " "endianness = (int) BIG_ENDIAN, " - "red_mask = (int) 0x0000FF00, " + "red_mask = (int) 0x0000FF00, " "green_mask = (int) 0x00FF0000, " - "blue_mask = (int) 0xFF000000, " + "blue_mask = (int) 0xFF000000, " "alpha_mask = (int) 0x000000FF, " "width = (int) [ 1, 32767 ], " "height = (int) [ 1, 32767 ]; " @@ -219,7 +219,7 @@ gst_rtp_vraw_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps) } else { pgroup = 3; ystride = GST_ROUND_UP_4 (width * 3); - if (rmask == 0xFF000000) { + if (rmask == 0x00FF0000) { sampling = GST_VIDEO_FORMAT_RGB; samplingstr = "RGB"; } else {