From b1089fb5207697ba26edb4ff66ed0f465c6df3cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 4 Aug 2015 20:59:17 +0300 Subject: [PATCH] rtp: Copy metadata in the (de)payloader, but only the relevant ones The payloader didn't copy anything so far, the depayloader copied every possible meta. Let's make it consistent and just copy all metas without tags or with only the video tag. https://bugzilla.gnome.org/show_bug.cgi?id=751774 --- gst/rtp/Makefile.am | 6 ++- gst/rtp/gstrtpL16depay.c | 4 ++ gst/rtp/gstrtpL24depay.c | 5 ++ gst/rtp/gstrtpac3depay.c | 7 ++- gst/rtp/gstrtpac3pay.c | 5 ++ gst/rtp/gstrtpamrdepay.c | 8 +++ gst/rtp/gstrtpamrpay.c | 9 +++- gst/rtp/gstrtpbvdepay.c | 7 +++ gst/rtp/gstrtpceltdepay.c | 5 ++ gst/rtp/gstrtpceltpay.c | 5 ++ gst/rtp/gstrtpdvdepay.c | 15 ++++++ gst/rtp/gstrtpdvpay.c | 2 + gst/rtp/gstrtpg722depay.c | 6 +++ gst/rtp/gstrtpg723pay.c | 5 +- gst/rtp/gstrtpg726depay.c | 7 +++ gst/rtp/gstrtpg729depay.c | 5 ++ gst/rtp/gstrtpg729pay.c | 4 ++ gst/rtp/gstrtpgsmdepay.c | 7 +++ gst/rtp/gstrtpgsmpay.c | 2 + gst/rtp/gstrtpgstdepay.c | 5 ++ gst/rtp/gstrtpgstpay.c | 2 + gst/rtp/gstrtph261depay.c | 4 ++ gst/rtp/gstrtph261pay.c | 19 +++++--- gst/rtp/gstrtph263depay.c | 5 ++ gst/rtp/gstrtph263pay.c | 5 ++ gst/rtp/gstrtph263pdepay.c | 5 ++ gst/rtp/gstrtph263ppay.c | 4 ++ gst/rtp/gstrtph264depay.c | 28 +++++++++++ gst/rtp/gstrtph264pay.c | 13 +++-- gst/rtp/gstrtpilbcdepay.c | 7 +++ gst/rtp/gstrtpj2kdepay.c | 8 ++- gst/rtp/gstrtpj2kpay.c | 7 ++- gst/rtp/gstrtpjpegdepay.c | 5 ++ gst/rtp/gstrtpjpegpay.c | 6 ++- gst/rtp/gstrtpmp1sdepay.c | 6 ++- gst/rtp/gstrtpmp2tdepay.c | 6 ++- gst/rtp/gstrtpmp2tpay.c | 2 + gst/rtp/gstrtpmp4adepay.c | 7 ++- gst/rtp/gstrtpmp4apay.c | 4 ++ gst/rtp/gstrtpmp4gdepay.c | 4 ++ gst/rtp/gstrtpmp4gpay.c | 2 + gst/rtp/gstrtpmp4vdepay.c | 5 ++ gst/rtp/gstrtpmp4vpay.c | 7 ++- gst/rtp/gstrtpmpadepay.c | 7 +++ gst/rtp/gstrtpmpapay.c | 4 ++ gst/rtp/gstrtpmpvdepay.c | 5 ++ gst/rtp/gstrtpmpvpay.c | 4 ++ gst/rtp/gstrtppcmadepay.c | 5 ++ gst/rtp/gstrtppcmudepay.c | 5 ++ gst/rtp/gstrtpqcelpdepay.c | 5 ++ gst/rtp/gstrtpqdmdepay.c | 2 + gst/rtp/gstrtpsbcdepay.c | 4 ++ gst/rtp/gstrtpsbcpay.c | 4 ++ gst/rtp/gstrtpsirendepay.c | 7 +++ gst/rtp/gstrtpspeexdepay.c | 7 ++- gst/rtp/gstrtpspeexpay.c | 4 ++ gst/rtp/gstrtpsv3vdepay.c | 4 ++ gst/rtp/gstrtptheoradepay.c | 53 +++++++++----------- gst/rtp/gstrtptheorapay.c | 61 +++++++++++++++++------ gst/rtp/gstrtptheorapay.h | 1 + gst/rtp/gstrtputils.c | 97 +++++++++++++++++++++++++++++++++++++ gst/rtp/gstrtputils.h | 33 +++++++++++++ gst/rtp/gstrtpvorbisdepay.c | 75 ++++++++++++++++------------ gst/rtp/gstrtpvorbispay.c | 59 ++++++++++++++++------ gst/rtp/gstrtpvorbispay.h | 1 + gst/rtp/gstrtpvp8depay.c | 4 ++ gst/rtp/gstrtpvp8pay.c | 5 +- gst/rtp/gstrtpvrawdepay.c | 8 ++- gst/rtp/gstrtpvrawpay.c | 6 +++ 69 files changed, 628 insertions(+), 122 deletions(-) create mode 100644 gst/rtp/gstrtputils.c create mode 100644 gst/rtp/gstrtputils.h diff --git a/gst/rtp/Makefile.am b/gst/rtp/Makefile.am index e97641c677..00a2e08b14 100644 --- a/gst/rtp/Makefile.am +++ b/gst/rtp/Makefile.am @@ -84,7 +84,8 @@ libgstrtp_la_SOURCES = \ gstrtpvrawdepay.c \ gstrtpvrawpay.c \ gstrtpstreampay.c \ - gstrtpstreamdepay.c + gstrtpstreamdepay.c \ + gstrtputils.c libgstrtp_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) \ $(GST_CFLAGS) -Dvp8_norm=gst_rtpvp8_vp8_norm \ @@ -185,6 +186,7 @@ noinst_HEADERS = \ gstrtpvrawdepay.h \ gstrtpvrawpay.h \ gstrtpstreampay.h \ - gstrtpstreamdepay.h + gstrtpstreamdepay.h \ + gstrtputils.h EXTRA_DIST = dboolhuff.LICENSE diff --git a/gst/rtp/gstrtpL16depay.c b/gst/rtp/gstrtpL16depay.c index 0f6b2b4d92..41a8fff427 100644 --- a/gst/rtp/gstrtpL16depay.c +++ b/gst/rtp/gstrtpL16depay.c @@ -44,6 +44,7 @@ #include "gstrtpL16depay.h" #include "gstrtpchannels.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpL16depay_debug); #define GST_CAT_DEFAULT (rtpL16depay_debug) @@ -257,6 +258,9 @@ gst_rtp_L16_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) goto reorder_failed; } + gst_rtp_drop_meta (GST_ELEMENT_CAST (rtpL16depay), outbuf, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); + return outbuf; /* ERRORS */ diff --git a/gst/rtp/gstrtpL24depay.c b/gst/rtp/gstrtpL24depay.c index d1f13651c7..dc7a338823 100644 --- a/gst/rtp/gstrtpL24depay.c +++ b/gst/rtp/gstrtpL24depay.c @@ -44,6 +44,7 @@ #include "gstrtpL24depay.h" #include "gstrtpchannels.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpL24depay_debug); #define GST_CAT_DEFAULT (rtpL24depay_debug) @@ -228,6 +229,10 @@ gst_rtp_L24_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) } outbuf = gst_buffer_make_writable (outbuf); + if (outbuf) { + gst_rtp_drop_meta (GST_ELEMENT_CAST (rtpL24depay), outbuf, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); + } if (rtpL24depay->order && !gst_audio_buffer_reorder_channels (outbuf, rtpL24depay->info.finfo->format, rtpL24depay->info.channels, diff --git a/gst/rtp/gstrtpac3depay.c b/gst/rtp/gstrtpac3depay.c index 2839b8d057..b9df488e53 100644 --- a/gst/rtp/gstrtpac3depay.c +++ b/gst/rtp/gstrtpac3depay.c @@ -38,9 +38,11 @@ #endif #include +#include #include #include "gstrtpac3depay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpac3depay_debug); #define GST_CAT_DEFAULT (rtpac3depay_debug) @@ -153,9 +155,12 @@ gst_rtp_ac3_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) /* We don't bother with fragmented packets yet */ outbuf = gst_rtp_buffer_get_payload_subbuffer (rtp, 2, -1); - if (outbuf) + if (outbuf) { + gst_rtp_drop_meta (GST_ELEMENT_CAST (rtpac3depay), outbuf, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); GST_DEBUG_OBJECT (rtpac3depay, "pushing buffer of size %" G_GSIZE_FORMAT, gst_buffer_get_size (outbuf)); + } return outbuf; diff --git a/gst/rtp/gstrtpac3pay.c b/gst/rtp/gstrtpac3pay.c index 4464150a2d..986589494c 100644 --- a/gst/rtp/gstrtpac3pay.c +++ b/gst/rtp/gstrtpac3pay.c @@ -40,8 +40,10 @@ #include #include +#include #include "gstrtpac3pay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpac3pay_debug); #define GST_CAT_DEFAULT (rtpac3pay_debug) @@ -321,6 +323,9 @@ gst_rtp_ac3_pay_flush (GstRtpAC3Pay * rtpac3pay) payload_buffer = gst_adapter_take_buffer_fast (rtpac3pay->adapter, payload_len); + gst_rtp_copy_meta (GST_ELEMENT_CAST (rtpac3pay), outbuf, payload_buffer, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); + outbuf = gst_buffer_append (outbuf, payload_buffer); avail -= payload_len; diff --git a/gst/rtp/gstrtpamrdepay.c b/gst/rtp/gstrtpamrdepay.c index 79e6420519..3c55341382 100644 --- a/gst/rtp/gstrtpamrdepay.c +++ b/gst/rtp/gstrtpamrdepay.c @@ -44,10 +44,12 @@ #endif #include +#include #include #include #include "gstrtpamrdepay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpamrdepay_debug); #define GST_CAT_DEFAULT (rtpamrdepay_debug) @@ -304,6 +306,7 @@ gst_rtp_amr_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) gint i, num_packets, num_nonempty_packets; gint amr_len; gint ILL, ILP; + GstBuffer *buf; payload_len = gst_rtp_buffer_get_payload_len (rtp); @@ -424,6 +427,11 @@ gst_rtp_amr_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) GST_DEBUG_OBJECT (depayload, "pushing buffer of size %" G_GSIZE_FORMAT, gst_buffer_get_size (outbuf)); + + buf = gst_rtp_buffer_get_payload_buffer (rtp); + gst_rtp_copy_meta (GST_ELEMENT_CAST (rtpamrdepay), outbuf, buf, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); + gst_buffer_unref (buf); } return outbuf; diff --git a/gst/rtp/gstrtpamrpay.c b/gst/rtp/gstrtpamrpay.c index 0f56c4cd89..f4849a8c69 100644 --- a/gst/rtp/gstrtpamrpay.c +++ b/gst/rtp/gstrtpamrpay.c @@ -53,8 +53,10 @@ #include #include +#include #include "gstrtpamrpay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpamrpay_debug); #define GST_CAT_DEFAULT (rtpamrpay_debug) @@ -388,10 +390,13 @@ gst_rtp_amr_pay_handle_buffer (GstRTPBasePayload * basepayload, } gst_buffer_unmap (buffer, &map); - gst_buffer_unref (buffer); - gst_rtp_buffer_unmap (&rtp); + gst_rtp_copy_meta (GST_ELEMENT_CAST (rtpamrpay), outbuf, buffer, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); + + gst_buffer_unref (buffer); + ret = gst_rtp_base_payload_push (basepayload, outbuf); return ret; diff --git a/gst/rtp/gstrtpbvdepay.c b/gst/rtp/gstrtpbvdepay.c index 75cea9a3a1..6b7bb18b5b 100644 --- a/gst/rtp/gstrtpbvdepay.c +++ b/gst/rtp/gstrtpbvdepay.c @@ -33,7 +33,9 @@ #include #include +#include #include "gstrtpbvdepay.h" +#include "gstrtputils.h" static GstStaticPadTemplate gst_rtp_bv_depay_sink_template = GST_STATIC_PAD_TEMPLATE ("sink", @@ -173,6 +175,11 @@ gst_rtp_bv_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_RESYNC); } + if (outbuf) { + gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload), outbuf, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); + } + return outbuf; } diff --git a/gst/rtp/gstrtpceltdepay.c b/gst/rtp/gstrtpceltdepay.c index 6f231043cc..ed5b3ae94b 100644 --- a/gst/rtp/gstrtpceltdepay.c +++ b/gst/rtp/gstrtpceltdepay.c @@ -24,8 +24,10 @@ #include #include #include +#include #include "gstrtpceltdepay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpceltdepay_debug); #define GST_CAT_DEFAULT (rtpceltdepay_debug) @@ -258,6 +260,9 @@ gst_rtp_celt_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) GST_TIME_ARGS (GST_BUFFER_PTS (outbuf)), GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf))); + gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload), outbuf, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); + gst_rtp_base_depayload_push (depayload, outbuf); } diff --git a/gst/rtp/gstrtpceltpay.c b/gst/rtp/gstrtpceltpay.c index 3e701d75fc..6f16ba2029 100644 --- a/gst/rtp/gstrtpceltpay.c +++ b/gst/rtp/gstrtpceltpay.c @@ -24,8 +24,10 @@ #include #include #include +#include #include "gstrtpceltpay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpceltpay_debug); #define GST_CAT_DEFAULT (rtpceltpay_debug) @@ -350,6 +352,9 @@ gst_rtp_celt_pay_flush_queued (GstRtpCELTPay * rtpceltpay) gst_buffer_extract (buf, 0, payload, size); payload += size; + gst_rtp_copy_meta (GST_ELEMENT_CAST (rtpceltpay), outbuf, buf, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); + gst_buffer_unref (buf); } gst_rtp_buffer_unmap (&rtp); diff --git a/gst/rtp/gstrtpdvdepay.c b/gst/rtp/gstrtpdvdepay.c index 7c83517501..16898a98c9 100644 --- a/gst/rtp/gstrtpdvdepay.c +++ b/gst/rtp/gstrtpdvdepay.c @@ -33,6 +33,7 @@ #include #include "gstrtpdvdepay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY (rtpdvdepay_debug); #define GST_CAT_DEFAULT (rtpdvdepay_debug) @@ -280,6 +281,13 @@ calculate_difblock_location (guint8 * block) return location; } +static gboolean +foreach_metadata_drop (GstBuffer * inbuf, GstMeta ** meta, gpointer user_data) +{ + *meta = NULL; + return TRUE; +} + /* Process one RTP packet. Accumulate RTP payload in the proper place in a DV * frame, and return that frame if we detect a new frame, or NULL otherwise. * We assume a DV frame is 144000 bytes. That should accomodate PAL as well as @@ -289,6 +297,7 @@ static GstBuffer * gst_rtp_dv_depay_process (GstRTPBaseDepayload * base, GstRTPBuffer * rtp) { GstBuffer *out = NULL; + GstBuffer *payload_buf; guint8 *payload; guint32 rtp_ts; guint payload_len, location; @@ -311,11 +320,13 @@ gst_rtp_dv_depay_process (GstRTPBaseDepayload * base, GstRTPBuffer * rtp) /* return copy of accumulator. */ out = gst_buffer_copy (dvdepay->acc); + gst_buffer_foreach_meta (dvdepay->acc, foreach_metadata_drop, NULL); } /* Extract the payload */ payload_len = gst_rtp_buffer_get_payload_len (rtp); payload = gst_rtp_buffer_get_payload (rtp); + payload_buf = gst_rtp_buffer_get_payload_buffer (rtp); /* copy all DIF chunks in their place. */ gst_buffer_map (dvdepay->acc, &map, GST_MAP_READWRITE); @@ -341,6 +352,8 @@ gst_rtp_dv_depay_process (GstRTPBaseDepayload * base, GstRTPBuffer * rtp) /* And copy it in, provided the location is sane. */ if (offset <= dvdepay->frame_size - 80) { memcpy (map.data + offset, payload, 80); + gst_rtp_copy_meta (GST_ELEMENT_CAST (dvdepay), dvdepay->acc, + payload_buf, 0); } } @@ -348,6 +361,7 @@ gst_rtp_dv_depay_process (GstRTPBaseDepayload * base, GstRTPBuffer * rtp) payload_len -= 80; } gst_buffer_unmap (dvdepay->acc, &map); + gst_buffer_unref (payload_buf); if (marker) { GST_DEBUG_OBJECT (dvdepay, "marker bit complete frame %u", rtp_ts); @@ -357,6 +371,7 @@ gst_rtp_dv_depay_process (GstRTPBaseDepayload * base, GstRTPBuffer * rtp) * will change the timestamp but we won't copy the accumulator again because * we set the prev_ts to -1. */ out = gst_buffer_copy (dvdepay->acc); + gst_buffer_foreach_meta (dvdepay->acc, foreach_metadata_drop, NULL); } else { GST_WARNING_OBJECT (dvdepay, "waiting for frame headers %02x", dvdepay->header_mask); diff --git a/gst/rtp/gstrtpdvpay.c b/gst/rtp/gstrtpdvpay.c index ef93bc1d25..ddda67e689 100644 --- a/gst/rtp/gstrtpdvpay.c +++ b/gst/rtp/gstrtpdvpay.c @@ -27,6 +27,7 @@ #include #include "gstrtpdvpay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY (rtpdvpay_debug); #define GST_CAT_DEFAULT (rtpdvpay_debug) @@ -372,6 +373,7 @@ gst_rtp_dv_pay_handle_buffer (GstRTPBasePayload * basepayload, /* Push out the created piece, and check for errors. */ gst_rtp_buffer_unmap (&rtp); + gst_rtp_copy_meta (GST_ELEMENT_CAST (basepayload), outbuf, buffer, 0); ret = gst_rtp_base_payload_push (basepayload, outbuf); if (ret != GST_FLOW_OK) break; diff --git a/gst/rtp/gstrtpg722depay.c b/gst/rtp/gstrtpg722depay.c index 021e9a3a36..31c6ab4f31 100644 --- a/gst/rtp/gstrtpg722depay.c +++ b/gst/rtp/gstrtpg722depay.c @@ -28,6 +28,7 @@ #include "gstrtpg722depay.h" #include "gstrtpchannels.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpg722depay_debug); #define GST_CAT_DEFAULT (rtpg722depay_debug) @@ -238,6 +239,11 @@ gst_rtp_g722_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_RESYNC); } + if (outbuf) { + gst_rtp_drop_meta (GST_ELEMENT_CAST (rtpg722depay), outbuf, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); + } + return outbuf; /* ERRORS */ diff --git a/gst/rtp/gstrtpg723pay.c b/gst/rtp/gstrtpg723pay.c index 4122bc9378..ddf9075b19 100644 --- a/gst/rtp/gstrtpg723pay.c +++ b/gst/rtp/gstrtpg723pay.c @@ -26,8 +26,10 @@ #include #include #include +#include #include "gstrtpg723pay.h" +#include "gstrtputils.h" #define G723_FRAME_DURATION (30 * GST_MSECOND) @@ -162,7 +164,8 @@ gst_rtp_g723_pay_flush (GstRTPG723Pay * pay) pay->discont = FALSE; } gst_rtp_buffer_unmap (&rtp); - + gst_rtp_drop_meta (GST_ELEMENT_CAST (pay), outbuf, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); outbuf = gst_buffer_append (outbuf, payload_buf); ret = gst_rtp_base_payload_push (GST_RTP_BASE_PAYLOAD (pay), outbuf); diff --git a/gst/rtp/gstrtpg726depay.c b/gst/rtp/gstrtpg726depay.c index 7bab5be7b0..efaadea5f5 100644 --- a/gst/rtp/gstrtpg726depay.c +++ b/gst/rtp/gstrtpg726depay.c @@ -28,8 +28,10 @@ #include #include #include +#include #include "gstrtpg726depay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpg726depay_debug); #define GST_CAT_DEFAULT (rtpg726depay_debug) @@ -226,6 +228,8 @@ gst_rtp_g726_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) outbuf = gst_rtp_buffer_get_payload_buffer (rtp); if (!outbuf) goto bad_len; + gst_rtp_drop_meta (GST_ELEMENT_CAST (depay), outbuf, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); } else { guint8 *in, *out, tmp; guint len; @@ -239,6 +243,9 @@ gst_rtp_g726_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) goto bad_len; outbuf = gst_buffer_make_writable (outbuf); + gst_rtp_drop_meta (GST_ELEMENT_CAST (depay), outbuf, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); + gst_buffer_map (outbuf, &map, GST_MAP_WRITE); out = map.data; diff --git a/gst/rtp/gstrtpg729depay.c b/gst/rtp/gstrtpg729depay.c index 2ad96c8143..56f921a0dd 100644 --- a/gst/rtp/gstrtpg729depay.c +++ b/gst/rtp/gstrtpg729depay.c @@ -21,10 +21,12 @@ #endif #include +#include #include #include #include "gstrtpg729depay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpg729depay_debug); #define GST_CAT_DEFAULT (rtpg729depay_debug) @@ -200,6 +202,9 @@ gst_rtp_g729_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_RESYNC); } + gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload), outbuf, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); + GST_LOG_OBJECT (depayload, "pushing buffer of size %" G_GSIZE_FORMAT, gst_buffer_get_size (outbuf)); diff --git a/gst/rtp/gstrtpg729pay.c b/gst/rtp/gstrtpg729pay.c index c11c8c1cb5..ad89734a02 100644 --- a/gst/rtp/gstrtpg729pay.c +++ b/gst/rtp/gstrtpg729pay.c @@ -32,8 +32,10 @@ #include #include #include +#include #include "gstrtpg729pay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpg729pay_debug); #define GST_CAT_DEFAULT (rtpg729pay_debug) @@ -188,6 +190,8 @@ gst_rtp_g729_pay_push (GstRTPG729Pay * rtpg729pay, GstBuffer * buf) gst_rtp_buffer_unmap (&rtp); /* append payload */ + gst_rtp_copy_meta (GST_ELEMENT_CAST (basepayload), outbuf, buf, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); outbuf = gst_buffer_append (outbuf, buf); ret = gst_rtp_base_payload_push (basepayload, outbuf); diff --git a/gst/rtp/gstrtpgsmdepay.c b/gst/rtp/gstrtpgsmdepay.c index 69ac61869e..7b781e26cd 100644 --- a/gst/rtp/gstrtpgsmdepay.c +++ b/gst/rtp/gstrtpgsmdepay.c @@ -24,7 +24,9 @@ #include #include +#include #include "gstrtpgsmdepay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpgsmdepay_debug); #define GST_CAT_DEFAULT (rtpgsmdepay_debug) @@ -135,6 +137,11 @@ gst_rtp_gsm_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_RESYNC); } + if (outbuf) { + gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload), outbuf, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); + } + return outbuf; } diff --git a/gst/rtp/gstrtpgsmpay.c b/gst/rtp/gstrtpgsmpay.c index 19cc99b656..3765805f48 100644 --- a/gst/rtp/gstrtpgsmpay.c +++ b/gst/rtp/gstrtpgsmpay.c @@ -25,8 +25,10 @@ #include #include #include +#include #include "gstrtpgsmpay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpgsmpay_debug); #define GST_CAT_DEFAULT (rtpgsmpay_debug) diff --git a/gst/rtp/gstrtpgstdepay.c b/gst/rtp/gstrtpgstdepay.c index d4c771e73b..aaea3d472f 100644 --- a/gst/rtp/gstrtpgstdepay.c +++ b/gst/rtp/gstrtpgstdepay.c @@ -25,6 +25,7 @@ #include #include "gstrtpgstdepay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpgstdepay_debug); #define GST_CAT_DEFAULT (rtpgstdepay_debug) @@ -523,6 +524,10 @@ gst_rtp_gst_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) } } + if (outbuf) { + gst_rtp_drop_meta (GST_ELEMENT_CAST (rtpgstdepay), outbuf, 0); + } + return outbuf; /* ERRORS */ diff --git a/gst/rtp/gstrtpgstpay.c b/gst/rtp/gstrtpgstpay.c index be20529436..8d50b6cd5a 100644 --- a/gst/rtp/gstrtpgstpay.c +++ b/gst/rtp/gstrtpgstpay.c @@ -26,6 +26,7 @@ #include #include "gstrtpgstpay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (gst_rtp_pay_debug); #define GST_CAT_DEFAULT gst_rtp_pay_debug @@ -336,6 +337,7 @@ gst_rtp_gst_pay_create_from_adapter (GstRtpGSTPay * rtpgstpay, paybuf = gst_adapter_take_buffer_fast (rtpgstpay->adapter, payload_len); /* create a new group to hold the rtp header and the payload */ + gst_rtp_copy_meta (GST_ELEMENT_CAST (rtpgstpay), outbuf, paybuf, 0); outbuf = gst_buffer_append (outbuf, paybuf); GST_BUFFER_PTS (outbuf) = timestamp; diff --git a/gst/rtp/gstrtph261depay.c b/gst/rtp/gstrtph261depay.c index 0c9680c19b..d50ff1c2cf 100644 --- a/gst/rtp/gstrtph261depay.c +++ b/gst/rtp/gstrtph261depay.c @@ -45,8 +45,10 @@ #include #include +#include #include "gstrtph261depay.h" #include "gstrtph261pay.h" /* GstRtpH261PayHeader */ +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtph261depay_debug); #define GST_CAT_DEFAULT (rtph261depay_debug) @@ -168,6 +170,8 @@ skip: avail = gst_adapter_available (depay->adapter); outbuf = gst_adapter_take_buffer (depay->adapter, avail); + gst_rtp_drop_meta (GST_ELEMENT_CAST (depay), outbuf, + g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); /* Note that the I flag does not mean intra frame, but that the entire * stream is intra coded. */ diff --git a/gst/rtp/gstrtph261pay.c b/gst/rtp/gstrtph261pay.c index 653d1711d7..7cdd323929 100644 --- a/gst/rtp/gstrtph261pay.c +++ b/gst/rtp/gstrtph261pay.c @@ -49,7 +49,9 @@ #endif #include "gstrtph261pay.h" +#include "gstrtputils.h" #include +#include #include #include @@ -798,9 +800,9 @@ gst_rtp_h261_pay_init_gobs (GstRtpH261Pay * pay, Gob * gobs, gint num_gobs, } static GstFlowReturn -gst_rtp_h261_pay_fragment_push (GstRtpH261Pay * pay, const guint8 * bits, - guint start, guint end, const Macroblock * last_mb_in_previous_packet, - gboolean marker) +gst_rtp_h261_pay_fragment_push (GstRtpH261Pay * pay, GstBuffer * buffer, + const guint8 * bits, guint start, guint end, + const Macroblock * last_mb_in_previous_packet, gboolean marker) { GstBuffer *outbuf; guint8 *payload; @@ -848,12 +850,15 @@ gst_rtp_h261_pay_fragment_push (GstRtpH261Pay * pay, const guint8 * bits, gst_rtp_buffer_unmap (&rtp); + gst_rtp_copy_meta (GST_ELEMENT_CAST (pay), outbuf, buffer, + g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); + return gst_rtp_base_payload_push (GST_RTP_BASE_PAYLOAD_CAST (pay), outbuf); } static GstFlowReturn -gst_rtp_h261_packetize_and_push (GstRtpH261Pay * pay, const guint8 * bits, - gsize len) +gst_rtp_h261_packetize_and_push (GstRtpH261Pay * pay, GstBuffer * buffer, + const guint8 * bits, gsize len) { GstFlowReturn ret = GST_FLOW_OK; GstBitReader br_; @@ -923,7 +928,7 @@ gst_rtp_h261_packetize_and_push (GstRtpH261Pay * pay, const guint8 * bits, goto beach; marker = result == PARSE_END_OF_FRAME; - ret = gst_rtp_h261_pay_fragment_push (pay, bits, startpos, endpos, + ret = gst_rtp_h261_pay_fragment_push (pay, buffer, bits, startpos, endpos, &last_mb_in_previous_packet, marker); last_mb_in_previous_packet = gob->last; @@ -1003,7 +1008,7 @@ gst_rtp_h261_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer) shift = pay->offset - psc_offset; bits = gst_rtp_h261_pay_shift_buffer (pay, map.data, map.size, shift, &len); - ret = gst_rtp_h261_packetize_and_push (pay, bits, len); + ret = gst_rtp_h261_packetize_and_push (pay, buffer, bits, len); g_free (bits); beach: diff --git a/gst/rtp/gstrtph263depay.c b/gst/rtp/gstrtph263depay.c index 8f94bd6e17..4b31b9e62e 100644 --- a/gst/rtp/gstrtph263depay.c +++ b/gst/rtp/gstrtph263depay.c @@ -30,7 +30,9 @@ #include #include +#include #include "gstrtph263depay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtph263depay_debug); #define GST_CAT_DEFAULT (rtph263depay_debug) @@ -384,6 +386,9 @@ skip: GST_DEBUG ("Pushing out a buffer of %d bytes", avail); + gst_rtp_drop_meta (GST_ELEMENT_CAST (rtph263depay), outbuf, + g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); + gst_rtp_base_depayload_push (depayload, outbuf); rtph263depay->offset = 0; rtph263depay->leftover = 0; diff --git a/gst/rtp/gstrtph263pay.c b/gst/rtp/gstrtph263pay.c index 28a0b6345f..f60721a557 100644 --- a/gst/rtp/gstrtph263pay.c +++ b/gst/rtp/gstrtph263pay.c @@ -27,8 +27,10 @@ #include #include #include +#include #include "gstrtph263pay.h" +#include "gstrtputils.h" typedef enum { @@ -1307,6 +1309,9 @@ gst_rtp_h263_pay_push (GstRtpH263Pay * rtph263pay, gst_buffer_copy_into (package->outbuf, rtph263pay->current_buffer, GST_BUFFER_COPY_MEMORY, package->payload_start - rtph263pay->map.data, package->payload_len); + gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph263pay), package->outbuf, + rtph263pay->current_buffer, + g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); ret = gst_rtp_base_payload_push (GST_RTP_BASE_PAYLOAD (rtph263pay), diff --git a/gst/rtp/gstrtph263pdepay.c b/gst/rtp/gstrtph263pdepay.c index d794b07b03..6aea8e1a17 100644 --- a/gst/rtp/gstrtph263pdepay.c +++ b/gst/rtp/gstrtph263pdepay.c @@ -24,7 +24,9 @@ #include #include +#include #include "gstrtph263pdepay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtph263pdepay_debug); #define GST_CAT_DEFAULT (rtph263pdepay_debug) @@ -329,6 +331,9 @@ gst_rtp_h263p_depay_process (GstRTPBaseDepayload * depayload, outbuf = gst_buffer_append (outbuf, padbuf); } + gst_rtp_drop_meta (GST_ELEMENT_CAST (rtph263pdepay), outbuf, + g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); + return outbuf; } else { /* frame not completed: store in adapter */ diff --git a/gst/rtp/gstrtph263ppay.c b/gst/rtp/gstrtph263ppay.c index 85467ca353..9c09ad0b65 100644 --- a/gst/rtp/gstrtph263ppay.c +++ b/gst/rtp/gstrtph263ppay.c @@ -26,8 +26,10 @@ #include #include +#include #include "gstrtph263ppay.h" +#include "gstrtputils.h" #define DEFAULT_FRAGMENTATION_MODE GST_FRAGMENTATION_MODE_NORMAL @@ -735,6 +737,8 @@ gst_rtp_h263p_pay_flush (GstRtpH263PPay * rtph263ppay) gst_rtp_buffer_unmap (&rtp); payload_buf = gst_adapter_take_buffer_fast (rtph263ppay->adapter, towrite); + gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph263ppay), outbuf, payload_buf, + g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); outbuf = gst_buffer_append (outbuf, payload_buf); avail -= towrite; diff --git a/gst/rtp/gstrtph264depay.c b/gst/rtp/gstrtph264depay.c index 940f8a9826..cd05e62051 100644 --- a/gst/rtp/gstrtph264depay.c +++ b/gst/rtp/gstrtph264depay.c @@ -27,7 +27,9 @@ #include #include #include +#include #include "gstrtph264depay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtph264depay_debug); #define GST_CAT_DEFAULT (rtph264depay_debug) @@ -880,12 +882,18 @@ gst_rtp_h264_depay_handle_nal (GstRtpH264Depay * rtph264depay, GstBuffer * nal, /* prepend codec_data */ if (rtph264depay->codec_data) { GST_DEBUG_OBJECT (depayload, "prepending codec_data"); + gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph264depay), + rtph264depay->codec_data, outbuf, + g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); outbuf = gst_buffer_append (rtph264depay->codec_data, outbuf); rtph264depay->codec_data = NULL; out_keyframe = TRUE; } outbuf = gst_buffer_make_writable (outbuf); + gst_rtp_drop_meta (GST_ELEMENT_CAST (rtph264depay), outbuf, + g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); + GST_BUFFER_PTS (outbuf) = out_timestamp; if (out_keyframe) @@ -947,6 +955,7 @@ static GstBuffer * gst_rtp_h264_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) { GstRtpH264Depay *rtph264depay; + GstBuffer *buf; GstBuffer *outbuf = NULL; guint8 nal_unit_type; @@ -973,6 +982,7 @@ gst_rtp_h264_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) payload_len = gst_rtp_buffer_get_payload_len (rtp); payload = gst_rtp_buffer_get_payload (rtp); + buf = gst_rtp_buffer_get_payload_buffer (rtp); marker = gst_rtp_buffer_get_marker (rtp); GST_DEBUG_OBJECT (rtph264depay, "receiving %d bytes", payload_len); @@ -1057,6 +1067,9 @@ gst_rtp_h264_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) memcpy (map.data + sizeof (sync_bytes), payload, nalu_size); gst_buffer_unmap (outbuf, &map); + gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph264depay), outbuf, buf, + g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); + outbuf = gst_rtp_h264_depay_handle_nal (rtph264depay, outbuf, timestamp, marker); @@ -1140,6 +1153,9 @@ gst_rtp_h264_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) map.data[sizeof (sync_bytes)] = nal_header; gst_buffer_unmap (outbuf, &map); + gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph264depay), outbuf, buf, + g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); + GST_DEBUG_OBJECT (rtph264depay, "queueing %d bytes", outsize); /* and assemble in the adapter */ @@ -1153,6 +1169,9 @@ gst_rtp_h264_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) outbuf = gst_buffer_new_and_alloc (outsize); gst_buffer_fill (outbuf, 0, payload, outsize); + gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph264depay), outbuf, buf, + g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); + GST_DEBUG_OBJECT (rtph264depay, "queueing %d bytes", outsize); /* and assemble in the adapter */ @@ -1188,6 +1207,9 @@ gst_rtp_h264_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) memcpy (map.data + sizeof (sync_bytes), payload, nalu_size); gst_buffer_unmap (outbuf, &map); + gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph264depay), outbuf, buf, + g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); + outbuf = gst_rtp_h264_depay_handle_nal (rtph264depay, outbuf, timestamp, marker); break; @@ -1195,29 +1217,35 @@ gst_rtp_h264_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) } } + gst_buffer_unref (buf); + return outbuf; /* ERRORS */ empty_packet: { GST_DEBUG_OBJECT (rtph264depay, "empty packet"); + gst_buffer_unref (buf); return NULL; } undefined_type: { GST_ELEMENT_WARNING (rtph264depay, STREAM, DECODE, (NULL), ("Undefined packet type")); + gst_buffer_unref (buf); return NULL; } waiting_start: { GST_DEBUG_OBJECT (rtph264depay, "waiting for start"); + gst_buffer_unref (buf); return NULL; } not_implemented: { GST_ELEMENT_ERROR (rtph264depay, STREAM, FORMAT, (NULL), ("NAL unit type %d not supported yet", nal_unit_type)); + gst_buffer_unref (buf); return NULL; } } diff --git a/gst/rtp/gstrtph264pay.c b/gst/rtp/gstrtph264pay.c index 3c565aeb31..ea1aa50c28 100644 --- a/gst/rtp/gstrtph264pay.c +++ b/gst/rtp/gstrtph264pay.c @@ -26,11 +26,13 @@ #include #include +#include /* Included to not duplicate gst_rtp_h264_add_sps_pps () */ #include "gstrtph264depay.h" #include "gstrtph264pay.h" +#include "gstrtputils.h" #define IDR_TYPE_ID 5 @@ -877,6 +879,8 @@ gst_rtp_h264_pay_payload_nal (GstRTPBasePayload * basepayload, gst_rtp_buffer_unmap (&rtp); /* insert payload memory block */ + gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph264pay), outbuf, paybuf, + g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); outbuf = gst_buffer_append (outbuf, paybuf); /* push the buffer to the next element */ @@ -936,9 +940,10 @@ gst_rtp_h264_pay_payload_nal (GstRTPBasePayload * basepayload, gst_rtp_buffer_unmap (&rtp); /* insert payload memory block */ - gst_buffer_append (outbuf, - gst_buffer_copy_region (paybuf, GST_BUFFER_COPY_MEMORY, pos, - limitedSize)); + gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph264pay), outbuf, paybuf, + g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); + gst_buffer_copy_into (outbuf, paybuf, GST_BUFFER_COPY_MEMORY, pos, + limitedSize); if (!delta_unit) /* Only the first packet sent should not have the flag */ @@ -1088,7 +1093,7 @@ gst_rtp_h264_pay_handle_buffer (GstRTPBasePayload * basepayload, end_of_au = TRUE; } - paybuf = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_MEMORY, offset, + paybuf = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, offset, nal_len); ret = gst_rtp_h264_pay_payload_nal (basepayload, paybuf, dts, pts, diff --git a/gst/rtp/gstrtpilbcdepay.c b/gst/rtp/gstrtpilbcdepay.c index 2fdd451cd9..9af6d2942e 100644 --- a/gst/rtp/gstrtpilbcdepay.c +++ b/gst/rtp/gstrtpilbcdepay.c @@ -24,7 +24,9 @@ #include #include #include +#include #include "gstrtpilbcdepay.h" +#include "gstrtputils.h" /* RtpiLBCDepay signals and args */ enum @@ -188,6 +190,11 @@ gst_rtp_ilbc_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_RESYNC); } + if (outbuf) { + gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload), outbuf, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); + } + return outbuf; } diff --git a/gst/rtp/gstrtpj2kdepay.c b/gst/rtp/gstrtpj2kdepay.c index b278a85214..04e69b726d 100644 --- a/gst/rtp/gstrtpj2kdepay.c +++ b/gst/rtp/gstrtpj2kdepay.c @@ -22,9 +22,11 @@ #endif #include +#include #include #include "gstrtpj2kdepay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpj2kdepay_debug); #define GST_CAT_DEFAULT (rtpj2kdepay_debug) @@ -400,8 +402,12 @@ gst_rtp_j2k_depay_flush_frame (GstRTPBaseDepayload * depayload) buflist = gst_buffer_list_new (); - for (walk = list; walk; walk = g_list_next (walk)) + for (walk = list; walk; walk = g_list_next (walk)) { + gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload), + GST_BUFFER_CAST (walk->data), + g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); gst_buffer_list_add (buflist, GST_BUFFER_CAST (walk->data)); + } g_list_free (list); diff --git a/gst/rtp/gstrtpj2kpay.c b/gst/rtp/gstrtpj2kpay.c index 41b37dd9f2..0088ffd876 100644 --- a/gst/rtp/gstrtpj2kpay.c +++ b/gst/rtp/gstrtpj2kpay.c @@ -34,8 +34,10 @@ #include #include +#include #include "gstrtpj2kpay.h" +#include "gstrtputils.h" static GstStaticPadTemplate gst_rtp_j2k_pay_sink_template = GST_STATIC_PAD_TEMPLATE ("sink", @@ -481,9 +483,10 @@ gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * basepayload, gst_rtp_buffer_unmap (&rtp); /* make subbuffer of j2k data */ - paybuf = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_MEMORY, + paybuf = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, offset, data_size); - + gst_rtp_copy_meta (GST_ELEMENT_CAST (basepayload), outbuf, paybuf, + g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); outbuf = gst_buffer_append (outbuf, paybuf); gst_buffer_list_add (list, outbuf); diff --git a/gst/rtp/gstrtpjpegdepay.c b/gst/rtp/gstrtpjpegdepay.c index 81a62cc3fd..c804aea9d5 100644 --- a/gst/rtp/gstrtpjpegdepay.c +++ b/gst/rtp/gstrtpjpegdepay.c @@ -22,12 +22,14 @@ #endif #include +#include #include #include #include #include #include "gstrtpjpegdepay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpjpegdepay_debug); #define GST_CAT_DEFAULT (rtpjpegdepay_debug) @@ -712,6 +714,9 @@ gst_rtp_jpeg_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) rtpjpegdepay->discont = FALSE; } + gst_rtp_drop_meta (GST_ELEMENT_CAST (rtpjpegdepay), outbuf, + g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); + GST_DEBUG_OBJECT (rtpjpegdepay, "returning %u bytes", avail); } diff --git a/gst/rtp/gstrtpjpegpay.c b/gst/rtp/gstrtpjpegpay.c index c3ab13edc3..65fcb172ff 100644 --- a/gst/rtp/gstrtpjpegpay.c +++ b/gst/rtp/gstrtpjpegpay.c @@ -38,8 +38,10 @@ #include #include +#include #include "gstrtpjpegpay.h" +#include "gstrtputils.h" static GstStaticPadTemplate gst_rtp_jpeg_pay_sink_template = GST_STATIC_PAD_TEMPLATE ("sink", @@ -891,10 +893,12 @@ gst_rtp_jpeg_pay_handle_buffer (GstRTPBasePayload * basepayload, gst_rtp_buffer_unmap (&rtp); /* create a new buf to hold the payload */ - paybuf = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_MEMORY, + paybuf = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, jpeg_header_size + offset, payload_size); /* join memory parts */ + gst_rtp_copy_meta (GST_ELEMENT_CAST (pay), outbuf, paybuf, + g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); outbuf = gst_buffer_append (outbuf, paybuf); GST_BUFFER_PTS (outbuf) = timestamp; diff --git a/gst/rtp/gstrtpmp1sdepay.c b/gst/rtp/gstrtpmp1sdepay.c index 59dd003e33..f6c71b911c 100644 --- a/gst/rtp/gstrtpmp1sdepay.c +++ b/gst/rtp/gstrtpmp1sdepay.c @@ -25,6 +25,7 @@ #include #include "gstrtpmp1sdepay.h" +#include "gstrtputils.h" /* RtpMP1SDepay signals and args */ enum @@ -124,10 +125,13 @@ gst_rtp_mp1s_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) outbuf = gst_rtp_buffer_get_payload_buffer (rtp); - if (outbuf) + if (outbuf) { GST_DEBUG ("gst_rtp_mp1s_depay_chain: pushing buffer of size %" G_GSIZE_FORMAT, gst_buffer_get_size (outbuf)); + gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload), outbuf, 0); + } + return outbuf; } diff --git a/gst/rtp/gstrtpmp2tdepay.c b/gst/rtp/gstrtpmp2tdepay.c index da73db6516..6f4d933d09 100644 --- a/gst/rtp/gstrtpmp2tdepay.c +++ b/gst/rtp/gstrtpmp2tdepay.c @@ -25,6 +25,7 @@ #include #include "gstrtpmp2tdepay.h" +#include "gstrtputils.h" /* RtpMP2TDepay signals and args */ enum @@ -180,10 +181,13 @@ gst_rtp_mp2t_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) gst_rtp_buffer_get_payload_subbuffer (rtp, rtpmp2tdepay->skip_first_bytes, payload_len); - if (outbuf) + if (outbuf) { GST_DEBUG ("gst_rtp_mp2t_depay_chain: pushing buffer of size %" G_GSIZE_FORMAT, gst_buffer_get_size (outbuf)); + gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload), outbuf, 0); + } + return outbuf; /* ERRORS */ diff --git a/gst/rtp/gstrtpmp2tpay.c b/gst/rtp/gstrtpmp2tpay.c index 089c07c458..3ddb429ce2 100644 --- a/gst/rtp/gstrtpmp2tpay.c +++ b/gst/rtp/gstrtpmp2tpay.c @@ -26,6 +26,7 @@ #include #include "gstrtpmp2tpay.h" +#include "gstrtputils.h" static GstStaticPadTemplate gst_rtp_mp2t_pay_sink_template = GST_STATIC_PAD_TEMPLATE ("sink", @@ -155,6 +156,7 @@ gst_rtp_mp2t_pay_flush (GstRTPMP2TPay * rtpmp2tpay) /* get payload */ paybuf = gst_adapter_take_buffer_fast (rtpmp2tpay->adapter, payload_len); + gst_rtp_copy_meta (GST_ELEMENT_CAST (rtpmp2tpay), outbuf, paybuf, 0); outbuf = gst_buffer_append (outbuf, paybuf); avail -= payload_len; diff --git a/gst/rtp/gstrtpmp4adepay.c b/gst/rtp/gstrtpmp4adepay.c index 09c6f2452d..40080f1ffd 100644 --- a/gst/rtp/gstrtpmp4adepay.c +++ b/gst/rtp/gstrtpmp4adepay.c @@ -23,9 +23,11 @@ #include #include +#include #include #include "gstrtpmp4adepay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpmp4adepay_debug); #define GST_CAT_DEFAULT (rtpmp4adepay_debug) @@ -359,8 +361,7 @@ gst_rtp_mp4a_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) /* take data out, skip the header */ pos += skip; - tmp = gst_buffer_copy_region (outbuf, GST_BUFFER_COPY_MEMORY, pos, - data_len); + tmp = gst_buffer_copy_region (outbuf, GST_BUFFER_COPY_ALL, pos, data_len); /* skip data too */ skip += data_len; @@ -371,6 +372,8 @@ gst_rtp_mp4a_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) avail -= skip; GST_BUFFER_PTS (tmp) = timestamp; + gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload), tmp, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); gst_rtp_base_depayload_push (depayload, tmp); /* shift ts for next buffers */ diff --git a/gst/rtp/gstrtpmp4apay.c b/gst/rtp/gstrtpmp4apay.c index 8cd29ed66d..b42cffdc8f 100644 --- a/gst/rtp/gstrtpmp4apay.c +++ b/gst/rtp/gstrtpmp4apay.c @@ -24,8 +24,10 @@ #include #include +#include #include "gstrtpmp4apay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpmp4apay_debug); #define GST_CAT_DEFAULT (rtpmp4apay_debug) @@ -433,6 +435,8 @@ gst_rtp_mp4a_pay_handle_buffer (GstRTPBasePayload * basepayload, offset, payload_len); /* join memory parts */ + gst_rtp_copy_meta (GST_ELEMENT_CAST (rtpmp4apay), outbuf, paybuf, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); outbuf = gst_buffer_append (outbuf, paybuf); gst_buffer_list_add (list, outbuf); offset += payload_len; diff --git a/gst/rtp/gstrtpmp4gdepay.c b/gst/rtp/gstrtpmp4gdepay.c index 15e6873200..347fd49e5a 100644 --- a/gst/rtp/gstrtpmp4gdepay.c +++ b/gst/rtp/gstrtpmp4gdepay.c @@ -26,6 +26,7 @@ #include #include "gstrtpmp4gdepay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpmp4gdepay_debug); #define GST_CAT_DEFAULT (rtpmp4gdepay_debug) @@ -347,6 +348,7 @@ gst_rtp_mp4g_depay_flush_queue (GstRtpMP4GDepay * rtpmp4gdepay) } GST_DEBUG_OBJECT (rtpmp4gdepay, "pushing AU_index %u", AU_index); + gst_rtp_drop_meta (GST_ELEMENT_CAST (rtpmp4gdepay), outbuf, 0); gst_rtp_base_depayload_push (GST_RTP_BASE_DEPAYLOAD (rtpmp4gdepay), outbuf); rtpmp4gdepay->next_AU_index = AU_index + 1; } @@ -367,6 +369,7 @@ gst_rtp_mp4g_depay_queue (GstRtpMP4GDepay * rtpmp4gdepay, GstBuffer * outbuf) /* we received the expected packet, push it and flush as much as we can from * the queue */ + gst_rtp_drop_meta (GST_ELEMENT_CAST (rtpmp4gdepay), outbuf, 0); gst_rtp_base_depayload_push (GST_RTP_BASE_DEPAYLOAD (rtpmp4gdepay), outbuf); rtpmp4gdepay->next_AU_index++; @@ -379,6 +382,7 @@ gst_rtp_mp4g_depay_queue (GstRtpMP4GDepay * rtpmp4gdepay, GstBuffer * outbuf) GST_DEBUG_OBJECT (rtpmp4gdepay, "pushing expected AU_index %u", AU_index); outbuf = g_queue_pop_head (rtpmp4gdepay->packets); + gst_rtp_drop_meta (GST_ELEMENT_CAST (rtpmp4gdepay), outbuf, 0); gst_rtp_base_depayload_push (GST_RTP_BASE_DEPAYLOAD (rtpmp4gdepay), outbuf); rtpmp4gdepay->next_AU_index++; diff --git a/gst/rtp/gstrtpmp4gpay.c b/gst/rtp/gstrtpmp4gpay.c index a9977e388a..366ebf5a69 100644 --- a/gst/rtp/gstrtpmp4gpay.c +++ b/gst/rtp/gstrtpmp4gpay.c @@ -27,6 +27,7 @@ #include #include "gstrtpmp4gpay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpmp4gpay_debug); #define GST_CAT_DEFAULT (rtpmp4gpay_debug) @@ -533,6 +534,7 @@ gst_rtp_mp4g_pay_flush (GstRtpMP4GPay * rtpmp4gpay) gst_rtp_buffer_unmap (&rtp); paybuf = gst_adapter_take_buffer_fast (rtpmp4gpay->adapter, payload_len); + gst_rtp_copy_meta (GST_ELEMENT_CAST (rtpmp4gpay), outbuf, paybuf, 0); outbuf = gst_buffer_append (outbuf, paybuf); GST_BUFFER_PTS (outbuf) = rtpmp4gpay->first_timestamp; diff --git a/gst/rtp/gstrtpmp4vdepay.c b/gst/rtp/gstrtpmp4vdepay.c index 9ffca2883a..a62d64a2b0 100644 --- a/gst/rtp/gstrtpmp4vdepay.c +++ b/gst/rtp/gstrtpmp4vdepay.c @@ -22,9 +22,11 @@ #endif #include +#include #include #include "gstrtpmp4vdepay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpmp4vdepay_debug); #define GST_CAT_DEFAULT (rtpmp4vdepay_debug) @@ -185,7 +187,10 @@ gst_rtp_mp4v_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) GST_DEBUG ("gst_rtp_mp4v_depay_chain: pushing buffer of size %" G_GSIZE_FORMAT, gst_buffer_get_size (outbuf)); + gst_rtp_drop_meta (GST_ELEMENT_CAST (rtpmp4vdepay), outbuf, + g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); } + return outbuf; } diff --git a/gst/rtp/gstrtpmp4vpay.c b/gst/rtp/gstrtpmp4vpay.c index 7d24176296..5509579564 100644 --- a/gst/rtp/gstrtpmp4vpay.c +++ b/gst/rtp/gstrtpmp4vpay.c @@ -24,8 +24,10 @@ #include #include +#include #include "gstrtpmp4vpay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpmp4vpay_debug); #define GST_CAT_DEFAULT (rtpmp4vpay_debug) @@ -285,7 +287,8 @@ gst_rtp_mp4v_pay_flush (GstRtpMP4VPay * rtpmp4vpay) gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp); gst_rtp_buffer_set_marker (&rtp, avail == 0); gst_rtp_buffer_unmap (&rtp); - + gst_rtp_copy_meta (GST_ELEMENT_CAST (rtpmp4vpay), outbuf, outbuf_data, + g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); outbuf = gst_buffer_append (outbuf, outbuf_data); GST_BUFFER_PTS (outbuf) = rtpmp4vpay->first_timestamp; @@ -462,7 +465,7 @@ gst_rtp_mp4v_pay_handle_buffer (GstRTPBasePayload * basepayload, (gint) size - strip); /* strip off header */ - subbuf = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_MEMORY, strip, + subbuf = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, strip, size - strip); GST_BUFFER_PTS (subbuf) = timestamp; gst_buffer_unref (buffer); diff --git a/gst/rtp/gstrtpmpadepay.c b/gst/rtp/gstrtpmpadepay.c index 367d4039e9..ccb4633ce9 100644 --- a/gst/rtp/gstrtpmpadepay.c +++ b/gst/rtp/gstrtpmpadepay.c @@ -22,9 +22,11 @@ #endif #include +#include #include #include "gstrtpmpadepay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpmpadepay_debug); #define GST_CAT_DEFAULT (rtpmpadepay_debug) @@ -154,6 +156,11 @@ gst_rtp_mpa_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) "gst_rtp_mpa_depay_chain: pushing buffer of size %" G_GSIZE_FORMAT "", gst_buffer_get_size (outbuf)); + if (outbuf) { + gst_rtp_drop_meta (GST_ELEMENT_CAST (rtpmpadepay), outbuf, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); + } + /* FIXME, we can push half mpeg frames when they are split over multiple * RTP packets */ return outbuf; diff --git a/gst/rtp/gstrtpmpapay.c b/gst/rtp/gstrtpmpapay.c index b963554b46..fe2f3a7e63 100644 --- a/gst/rtp/gstrtpmpapay.c +++ b/gst/rtp/gstrtpmpapay.c @@ -24,8 +24,10 @@ #include #include +#include #include "gstrtpmpapay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpmpapay_debug); #define GST_CAT_DEFAULT (rtpmpapay_debug) @@ -241,6 +243,8 @@ gst_rtp_mpa_pay_flush (GstRtpMPAPay * rtpmpapay) gst_rtp_buffer_unmap (&rtp); paybuf = gst_adapter_take_buffer_fast (rtpmpapay->adapter, payload_len); + gst_rtp_copy_meta (GST_ELEMENT_CAST (rtpmpapay), outbuf, paybuf, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); outbuf = gst_buffer_append (outbuf, paybuf); GST_BUFFER_PTS (outbuf) = rtpmpapay->first_ts; diff --git a/gst/rtp/gstrtpmpvdepay.c b/gst/rtp/gstrtpmpvdepay.c index 223b661a78..ff98fc049d 100644 --- a/gst/rtp/gstrtpmpvdepay.c +++ b/gst/rtp/gstrtpmpvdepay.c @@ -22,9 +22,11 @@ #endif #include +#include #include #include "gstrtpmpvdepay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpmpvdepay_debug); #define GST_CAT_DEFAULT (rtpmpvdepay_debug) @@ -172,6 +174,9 @@ gst_rtp_mpv_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) GST_DEBUG_OBJECT (rtpmpvdepay, "gst_rtp_mpv_depay_chain: pushing buffer of size %" G_GSIZE_FORMAT, gst_buffer_get_size (outbuf)); + gst_rtp_drop_meta (GST_ELEMENT_CAST (rtpmpvdepay), outbuf, + g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); + } } diff --git a/gst/rtp/gstrtpmpvpay.c b/gst/rtp/gstrtpmpvpay.c index cb074fa7a9..40bda45bbb 100644 --- a/gst/rtp/gstrtpmpvpay.c +++ b/gst/rtp/gstrtpmpvpay.c @@ -24,8 +24,10 @@ #include #include #include +#include #include "gstrtpmpvpay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpmpvpay_debug); #define GST_CAT_DEFAULT (rtpmpvpay_debug) @@ -226,6 +228,8 @@ gst_rtp_mpv_pay_flush (GstRTPMPVPay * rtpmpvpay) gst_rtp_buffer_unmap (&rtp); paybuf = gst_adapter_take_buffer_fast (rtpmpvpay->adapter, payload_len); + gst_rtp_copy_meta (GST_ELEMENT_CAST (rtpmpvpay), outbuf, paybuf, + g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); outbuf = gst_buffer_append (outbuf, paybuf); GST_BUFFER_PTS (outbuf) = rtpmpvpay->first_ts; diff --git a/gst/rtp/gstrtppcmadepay.c b/gst/rtp/gstrtppcmadepay.c index 3d17101090..5556dc0718 100644 --- a/gst/rtp/gstrtppcmadepay.c +++ b/gst/rtp/gstrtppcmadepay.c @@ -25,7 +25,9 @@ #include #include +#include #include "gstrtppcmadepay.h" +#include "gstrtputils.h" /* RtpPcmaDepay signals and args */ enum @@ -147,6 +149,9 @@ gst_rtp_pcma_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) /* mark start of talkspurt with RESYNC */ GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_RESYNC); } + + gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload), outbuf, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); } return outbuf; diff --git a/gst/rtp/gstrtppcmudepay.c b/gst/rtp/gstrtppcmudepay.c index 8d4bb90e43..450ca9e87e 100644 --- a/gst/rtp/gstrtppcmudepay.c +++ b/gst/rtp/gstrtppcmudepay.c @@ -25,7 +25,9 @@ #include #include +#include #include "gstrtppcmudepay.h" +#include "gstrtputils.h" /* RtpPcmuDepay signals and args */ enum @@ -148,6 +150,9 @@ gst_rtp_pcmu_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) /* mark start of talkspurt with RESYNC */ GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_RESYNC); } + + gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload), outbuf, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); } return outbuf; diff --git a/gst/rtp/gstrtpqcelpdepay.c b/gst/rtp/gstrtpqcelpdepay.c index b835feea18..58815dc698 100644 --- a/gst/rtp/gstrtpqcelpdepay.c +++ b/gst/rtp/gstrtpqcelpdepay.c @@ -22,10 +22,12 @@ #endif #include +#include #include #include #include "gstrtpqcelpdepay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpqcelpdepay_debug); #define GST_CAT_DEFAULT (rtpqcelpdepay_debug) @@ -355,6 +357,9 @@ gst_rtp_qcelp_depay_process (GstRTPBaseDepayload * depayload, GST_BUFFER_PTS (outbuf) = timestamp; GST_BUFFER_DURATION (outbuf) = FRAME_DURATION; + gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload), outbuf, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); + if (!depay->interleaved || index == 0) { /* not interleaved or first frame in packet, just push */ gst_rtp_base_depayload_push (depayload, outbuf); diff --git a/gst/rtp/gstrtpqdmdepay.c b/gst/rtp/gstrtpqdmdepay.c index 063bbef5c0..fc12c79ce3 100644 --- a/gst/rtp/gstrtpqdmdepay.c +++ b/gst/rtp/gstrtpqdmdepay.c @@ -24,7 +24,9 @@ #include #include +#include #include "gstrtpqdmdepay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY (rtpqdm2depay_debug); #define GST_CAT_DEFAULT rtpqdm2depay_debug diff --git a/gst/rtp/gstrtpsbcdepay.c b/gst/rtp/gstrtpsbcdepay.c index c0f61b711b..4863fc8247 100644 --- a/gst/rtp/gstrtpsbcdepay.c +++ b/gst/rtp/gstrtpsbcdepay.c @@ -25,7 +25,9 @@ #endif #include +#include #include "gstrtpsbcdepay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpsbcdepay_debug); #define GST_CAT_DEFAULT (rtpsbcdepay_debug) @@ -241,6 +243,8 @@ gst_rtp_sbc_depay_process (GstRTPBaseDepayload * base, GstRTPBuffer * rtp) if (last) { data = gst_adapter_take_buffer (depay->adapter, gst_adapter_available (depay->adapter)); + gst_rtp_drop_meta (GST_ELEMENT_CAST (depay), data, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); } else data = NULL; diff --git a/gst/rtp/gstrtpsbcpay.c b/gst/rtp/gstrtpsbcpay.c index 1b455ca6bb..70cde09157 100644 --- a/gst/rtp/gstrtpsbcpay.c +++ b/gst/rtp/gstrtpsbcpay.c @@ -23,9 +23,11 @@ #include #endif +#include #include "gstrtpsbcpay.h" #include #include +#include "gstrtputils.h" #define RTP_SBC_PAYLOAD_HEADER_SIZE 1 #define DEFAULT_MIN_FRAMES 0 @@ -199,6 +201,8 @@ gst_rtp_sbc_pay_flush_buffers (GstRtpSBCPay * sbcpay) gst_rtp_buffer_unmap (&rtp); paybuf = gst_adapter_take_buffer_fast (sbcpay->adapter, payload_length); + gst_rtp_copy_meta (GST_ELEMENT_CAST (sbcpay), outbuf, paybuf, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); outbuf = gst_buffer_append (outbuf, paybuf); /* FIXME: what about duration? */ diff --git a/gst/rtp/gstrtpsirendepay.c b/gst/rtp/gstrtpsirendepay.c index 9258d836b4..d5e95eb41e 100644 --- a/gst/rtp/gstrtpsirendepay.c +++ b/gst/rtp/gstrtpsirendepay.c @@ -26,7 +26,9 @@ #include #include #include +#include #include "gstrtpsirendepay.h" +#include "gstrtputils.h" static GstStaticPadTemplate gst_rtp_siren_depay_sink_template = GST_STATIC_PAD_TEMPLATE ("sink", @@ -108,6 +110,11 @@ gst_rtp_siren_depay_process (GstRTPBaseDepayload * depayload, outbuf = gst_rtp_buffer_get_payload_buffer (rtp); + if (outbuf) { + gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload), outbuf, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); + } + return outbuf; } diff --git a/gst/rtp/gstrtpspeexdepay.c b/gst/rtp/gstrtpspeexdepay.c index 9f28f9f87e..eb9d8e4009 100644 --- a/gst/rtp/gstrtpspeexdepay.c +++ b/gst/rtp/gstrtpspeexdepay.c @@ -24,8 +24,10 @@ #include #include #include +#include #include "gstrtpspeexdepay.h" +#include "gstrtputils.h" /* RtpSPEEXDepay signals and args */ enum @@ -208,8 +210,11 @@ gst_rtp_speex_depay_process (GstRTPBaseDepayload * depayload, /* nothing special to be done */ outbuf = gst_rtp_buffer_get_payload_buffer (rtp); - if (outbuf) + if (outbuf) { GST_BUFFER_DURATION (outbuf) = 20 * GST_MSECOND; + gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload), outbuf, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); + } return outbuf; } diff --git a/gst/rtp/gstrtpspeexpay.c b/gst/rtp/gstrtpspeexpay.c index 082146f141..4ba86ba93f 100644 --- a/gst/rtp/gstrtpspeexpay.c +++ b/gst/rtp/gstrtpspeexpay.c @@ -24,8 +24,10 @@ #include #include #include +#include #include "gstrtpspeexpay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpspeexpay_debug); #define GST_CAT_DEFAULT (rtpspeexpay_debug) @@ -287,6 +289,8 @@ gst_rtp_speex_pay_handle_buffer (GstRTPBasePayload * basepayload, GST_BUFFER_PTS (outbuf) = timestamp; GST_BUFFER_DURATION (outbuf) = duration; + gst_rtp_copy_meta (GST_ELEMENT_CAST (basepayload), outbuf, buffer, + g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); outbuf = gst_buffer_append (outbuf, buffer); buffer = NULL; diff --git a/gst/rtp/gstrtpsv3vdepay.c b/gst/rtp/gstrtpsv3vdepay.c index 57ab5e8f6c..7900dece06 100644 --- a/gst/rtp/gstrtpsv3vdepay.c +++ b/gst/rtp/gstrtpsv3vdepay.c @@ -24,7 +24,9 @@ #include #include +#include #include "gstrtpsv3vdepay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY (rtpsv3vdepay_debug); #define GST_CAT_DEFAULT rtpsv3vdepay_debug @@ -263,6 +265,8 @@ gst_rtp_sv3v_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) avail = gst_adapter_available (rtpsv3vdepay->adapter); GST_DEBUG ("Returning completed output buffer [%d bytes]", avail); outbuf = gst_adapter_take_buffer (rtpsv3vdepay->adapter, avail); + gst_rtp_drop_meta (GST_ELEMENT_CAST (rtpsv3vdepay), outbuf, + g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); } } diff --git a/gst/rtp/gstrtptheoradepay.c b/gst/rtp/gstrtptheoradepay.c index 1322dc7f3e..5061de6f97 100644 --- a/gst/rtp/gstrtptheoradepay.c +++ b/gst/rtp/gstrtptheoradepay.c @@ -23,9 +23,11 @@ #include #include +#include #include #include "gstrtptheoradepay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtptheoradepay_debug); #define GST_CAT_DEFAULT (rtptheoradepay_debug) @@ -253,8 +255,9 @@ gst_rtp_theora_depay_parse_configuration (GstRtpTheoraDepay * rtptheoradepay, GST_DEBUG_OBJECT (rtptheoradepay, "reading header %d, size %u", j, h_size); - buf = gst_buffer_new_and_alloc (h_size); - gst_buffer_fill (buf, 0, data, h_size); + buf = + gst_buffer_copy_region (confbuf, GST_BUFFER_COPY_ALL, data - map.data, + h_size); conf->headers = g_list_append (conf->headers, buf); data += h_size; size -= h_size; @@ -395,13 +398,16 @@ gst_rtp_theora_depay_process (GstRTPBaseDepayload * depayload, GstBuffer *outbuf; GstFlowReturn ret; gint payload_len; - guint8 *payload, *to_free = NULL; + GstMapInfo map; + GstBuffer *payload_buffer = NULL; + guint8 *payload; guint32 header, ident; guint8 F, TDT, packets; guint length; rtptheoradepay = GST_RTP_THEORA_DEPAY (depayload); + payload = gst_rtp_buffer_get_payload (rtp); payload_len = gst_rtp_buffer_get_payload_len (rtp); GST_DEBUG_OBJECT (depayload, "got RTP packet of size %d", payload_len); @@ -453,10 +459,6 @@ gst_rtp_theora_depay_process (GstRTPBaseDepayload * depayload, } } - /* skip header */ - payload += 4; - payload_len -= 4; - /* fragmented packets, assemble */ if (F != 0) { GstBuffer *vdata; @@ -485,20 +487,18 @@ gst_rtp_theora_depay_process (GstRTPBaseDepayload * depayload, goto no_output; /* construct assembled buffer */ - payload_len = gst_adapter_available (rtptheoradepay->adapter); - payload = gst_adapter_take (rtptheoradepay->adapter, payload_len); - - /* use this length */ - length = payload_len - 2; - - to_free = payload; + payload_buffer = + gst_adapter_take_buffer (rtptheoradepay->adapter, payload_len); } else { - /* read length from data */ - length = 0; + payload_buffer = gst_rtp_buffer_get_payload_subbuffer (rtp, 4, -1); } GST_DEBUG_OBJECT (depayload, "assemble done, payload_len %d", payload_len); + gst_buffer_map (payload_buffer, &map, GST_MAP_READ); + payload = map.data; + payload_len = map.size; + /* we not assembling anymore now */ rtptheoradepay->assembling = FALSE; gst_adapter_clear (rtptheoradepay->adapter); @@ -519,9 +519,6 @@ gst_rtp_theora_depay_process (GstRTPBaseDepayload * depayload, * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+* */ while (payload_len >= 2) { - if (length == 0) - length = GST_READ_UINT16_BE (payload); - payload += 2; payload_len -= 2; @@ -542,15 +539,9 @@ gst_rtp_theora_depay_process (GstRTPBaseDepayload * depayload, } /* create buffer for packet */ - if (G_UNLIKELY (to_free)) { - outbuf = - gst_buffer_new_wrapped_full (0, to_free, (payload - to_free) + length, - payload - to_free, length, to_free, g_free); - to_free = NULL; - } else { - outbuf = gst_buffer_new_and_alloc (length); - gst_buffer_fill (outbuf, 0, payload, length); - } + outbuf = + gst_buffer_copy_region (payload_buffer, GST_BUFFER_COPY_ALL, + payload - map.data, length); if (payload_len > 0 && (payload[0] & 0xC0) == 0x0) { rtptheoradepay->needs_keyframe = FALSE; @@ -574,7 +565,11 @@ gst_rtp_theora_depay_process (GstRTPBaseDepayload * depayload, out: no_output: - g_free (to_free); + if (payload_buffer) { + gst_buffer_unmap (payload_buffer, &map); + gst_buffer_unref (payload_buffer); + } + return NULL; /* ERORRS */ diff --git a/gst/rtp/gstrtptheorapay.c b/gst/rtp/gstrtptheorapay.c index 5e95d0d1e3..702483560d 100644 --- a/gst/rtp/gstrtptheorapay.c +++ b/gst/rtp/gstrtptheorapay.c @@ -24,9 +24,11 @@ #include #include +#include #include "fnv1hash.h" #include "gstrtptheorapay.h" +#include "gstrtputils.h" #define THEORA_ID_LEN 42 @@ -151,6 +153,11 @@ gst_rtp_theora_pay_clear_packet (GstRtpTheoraPay * rtptheorapay) if (rtptheorapay->packet) gst_buffer_unref (rtptheorapay->packet); rtptheorapay->packet = NULL; + + g_list_foreach (rtptheorapay->packet_buffers, (GFunc) gst_mini_object_unref, + NULL); + g_list_free (rtptheorapay->packet_buffers); + rtptheorapay->packet_buffers = NULL; } static void @@ -279,6 +286,11 @@ gst_rtp_theora_pay_init_packet (GstRtpTheoraPay * rtptheorapay, guint8 TDT, if (rtptheorapay->packet) gst_buffer_unref (rtptheorapay->packet); + g_list_foreach (rtptheorapay->packet_buffers, (GFunc) gst_mini_object_unref, + NULL); + g_list_free (rtptheorapay->packet_buffers); + rtptheorapay->packet_buffers = NULL; + /* new packet allocate max packet size */ rtptheorapay->packet = gst_rtp_buffer_new_allocate_len (GST_RTP_BASE_PAYLOAD_MTU @@ -295,6 +307,7 @@ gst_rtp_theora_pay_flush_packet (GstRtpTheoraPay * rtptheorapay) guint8 *payload; guint hlen; GstRTPBuffer rtp = { NULL }; + GList *l; /* check for empty packet */ if (!rtptheorapay->packet || rtptheorapay->payload_pos <= 4) @@ -332,6 +345,15 @@ gst_rtp_theora_pay_flush_packet (GstRtpTheoraPay * rtptheorapay) GST_BUFFER_DURATION (rtptheorapay->packet) = rtptheorapay->payload_duration; + for (l = g_list_last (rtptheorapay->packet_buffers); l; l = l->prev) { + GstBuffer *buf = GST_BUFFER_CAST (l->data); + gst_rtp_copy_meta (GST_ELEMENT_CAST (rtptheorapay), rtptheorapay->packet, + buf, g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); + gst_buffer_unref (buf); + } + g_list_free (rtptheorapay->packet_buffers); + rtptheorapay->packet_buffers = NULL; + /* push, this gives away our ref to the packet, so clear it. */ ret = gst_rtp_base_payload_push (GST_RTP_BASE_PAYLOAD (rtptheorapay), @@ -498,10 +520,7 @@ gst_rtp_theora_pay_finish_headers (GstRTPBasePayload * basepayload) gst_buffer_extract (buf, 0, data, gst_buffer_get_size (buf)); data += gst_buffer_get_size (buf); - gst_buffer_unref (buf); } - g_list_free (rtptheorapay->headers); - rtptheorapay->headers = NULL; rtptheorapay->need_headers = FALSE; /* serialize to base64 */ @@ -619,8 +638,8 @@ invalid_version: static GstFlowReturn gst_rtp_theora_pay_payload_buffer (GstRtpTheoraPay * rtptheorapay, guint8 TDT, - guint8 * data, guint size, GstClockTime timestamp, GstClockTime duration, - guint not_in_length) + GstBuffer * buffer, guint8 * data, guint size, GstClockTime timestamp, + GstClockTime duration, guint not_in_length) { GstFlowReturn ret = GST_FLOW_OK; guint newsize; @@ -677,6 +696,21 @@ gst_rtp_theora_pay_payload_buffer (GstRtpTheoraPay * rtptheorapay, guint8 TDT, if (plen) memcpy (&ppos[2], data, plen); + if (buffer) { + if (!rtptheorapay->packet_buffers + || rtptheorapay->packet_buffers->data != (gpointer) buffer) + rtptheorapay->packet_buffers = + g_list_prepend (rtptheorapay->packet_buffers, + gst_buffer_ref (buffer)); + } else { + GList *l; + + for (l = rtptheorapay->headers; l; l = l->next) + rtptheorapay->packet_buffers = + g_list_prepend (rtptheorapay->packet_buffers, + gst_buffer_ref (buffer)); + } + /* only first (only) configuration cuts length field */ /* NOTE: spec (if any) is not clear on this ... */ not_in_length = 0; @@ -790,15 +824,9 @@ gst_rtp_theora_pay_handle_buffer (GstRTPBasePayload * basepayload, rtptheorapay->headers = g_list_append (rtptheorapay->headers, buffer); ret = GST_FLOW_OK; goto done; - } else if (rtptheorapay->headers) { - if (rtptheorapay->need_headers) { - if (!gst_rtp_theora_pay_finish_headers (basepayload)) - goto header_error; - } else { - g_list_free_full (rtptheorapay->headers, - (GDestroyNotify) gst_buffer_unref); - rtptheorapay->headers = NULL; - } + } else if (rtptheorapay->headers && rtptheorapay->need_headers) { + if (!gst_rtp_theora_pay_finish_headers (basepayload)) + goto header_error; } /* there is a config request, see if we need to insert it */ @@ -839,7 +867,7 @@ gst_rtp_theora_pay_handle_buffer (GstRTPBasePayload * basepayload, /* we need to send config now first */ /* different TDT type forces flush */ gst_rtp_theora_pay_payload_buffer (rtptheorapay, 1, - rtptheorapay->config_data, rtptheorapay->config_size, + NULL, rtptheorapay->config_data, rtptheorapay->config_size, timestamp, GST_CLOCK_TIME_NONE, rtptheorapay->config_extra_len); if (timestamp != -1) { @@ -848,7 +876,8 @@ gst_rtp_theora_pay_handle_buffer (GstRTPBasePayload * basepayload, } } - ret = gst_rtp_theora_pay_payload_buffer (rtptheorapay, TDT, data, size, + ret = + gst_rtp_theora_pay_payload_buffer (rtptheorapay, TDT, buffer, data, size, timestamp, duration, 0); gst_buffer_unmap (buffer, &map); diff --git a/gst/rtp/gstrtptheorapay.h b/gst/rtp/gstrtptheorapay.h index 3f197b4e63..22bc01df19 100644 --- a/gst/rtp/gstrtptheorapay.h +++ b/gst/rtp/gstrtptheorapay.h @@ -50,6 +50,7 @@ struct _GstRtpTheoraPay /* queues of buffers along with some stats. */ GstBuffer *packet; + GList *packet_buffers; guint payload_pos; guint payload_left; guint32 payload_ident; diff --git a/gst/rtp/gstrtputils.c b/gst/rtp/gstrtputils.c new file mode 100644 index 0000000000..2b95c29502 --- /dev/null +++ b/gst/rtp/gstrtputils.c @@ -0,0 +1,97 @@ +/* GStreamer + * Copyright (C) 2015 Sebastian Dröge + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "gstrtputils.h" + +typedef struct +{ + GstElement *element; + GstBuffer *outbuf; + GQuark copy_tag; +} CopyMetaData; + +static gboolean +foreach_metadata_copy (GstBuffer * inbuf, GstMeta ** meta, gpointer user_data) +{ + CopyMetaData *data = user_data; + GstElement *element = data->element; + GstBuffer *outbuf = data->outbuf; + GQuark copy_tag = data->copy_tag; + const GstMetaInfo *info = (*meta)->info; + const gchar *const *tags = gst_meta_api_type_get_tags (info->api); + + if (!tags || (copy_tag != 0 && g_strv_length ((gchar **) tags) == 1 + && gst_meta_api_type_has_tag (info->api, copy_tag))) { + GstMetaTransformCopy copy_data = { FALSE, 0, -1 }; + GST_DEBUG_OBJECT (element, "copy metadata %s", g_type_name (info->api)); + /* simply copy then */ + info->transform_func (outbuf, *meta, inbuf, + _gst_meta_transform_copy, ©_data); + } else { + GST_DEBUG_OBJECT (element, "not copying metadata %s", + g_type_name (info->api)); + } + + return TRUE; +} + +/* TODO: Should probably make copy_tag an array at some point */ +void +gst_rtp_copy_meta (GstElement * element, GstBuffer * outbuf, GstBuffer * inbuf, + GQuark copy_tag) +{ + CopyMetaData data = { element, outbuf, copy_tag }; + + gst_buffer_foreach_meta (inbuf, foreach_metadata_copy, &data); +} + +typedef struct +{ + GstElement *element; + GQuark keep_tag; +} DropMetaData; + +static gboolean +foreach_metadata_drop (GstBuffer * inbuf, GstMeta ** meta, gpointer user_data) +{ + DropMetaData *data = user_data; + GstElement *element = data->element; + GQuark keep_tag = data->keep_tag; + const GstMetaInfo *info = (*meta)->info; + const gchar *const *tags = gst_meta_api_type_get_tags (info->api); + + if (!tags || (keep_tag != 0 && g_strv_length ((gchar **) tags) == 1 + && gst_meta_api_type_has_tag (info->api, keep_tag))) { + GST_DEBUG_OBJECT (element, "keeping metadata %s", g_type_name (info->api)); + } else { + GST_DEBUG_OBJECT (element, "dropping metadata %s", g_type_name (info->api)); + *meta = NULL; + } + + return TRUE; +} + +/* TODO: Should probably make keep_tag an array at some point */ +void +gst_rtp_drop_meta (GstElement * element, GstBuffer * buf, GQuark keep_tag) +{ + DropMetaData data = { element, keep_tag }; + + gst_buffer_foreach_meta (buf, foreach_metadata_drop, &data); +} diff --git a/gst/rtp/gstrtputils.h b/gst/rtp/gstrtputils.h new file mode 100644 index 0000000000..d0b66fabcb --- /dev/null +++ b/gst/rtp/gstrtputils.h @@ -0,0 +1,33 @@ +/* GStreamer + * Copyright (C) 2015 Sebastian Dröge + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_RTP_UTILS_H__ +#define __GST_RTP_UTILS_H__ + +#include + +G_BEGIN_DECLS + +void gst_rtp_copy_meta (GstElement * element, GstBuffer *outbuf, GstBuffer *inbuf, GQuark copy_tag); +void gst_rtp_drop_meta (GstElement * element, GstBuffer *buf, GQuark keep_tag); + + +G_END_DECLS + +#endif /* __GST_RTP_UTILS_H__ */ diff --git a/gst/rtp/gstrtpvorbisdepay.c b/gst/rtp/gstrtpvorbisdepay.c index fd80c09204..bb6aa63d73 100644 --- a/gst/rtp/gstrtpvorbisdepay.c +++ b/gst/rtp/gstrtpvorbisdepay.c @@ -23,9 +23,11 @@ #include #include +#include #include #include "gstrtpvorbisdepay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpvorbisdepay_debug); #define GST_CAT_DEFAULT (rtpvorbisdepay_debug) @@ -288,7 +290,7 @@ gst_rtp_vorbis_depay_parse_configuration (GstRtpVorbisDepay * rtpvorbisdepay, GST_DEBUG_OBJECT (rtpvorbisdepay, "reading header %d, size %u", j, h_size); - buf = gst_buffer_copy_region (confbuf, GST_BUFFER_COPY_MEMORY, offset, + buf = gst_buffer_copy_region (confbuf, GST_BUFFER_COPY_ALL, offset, h_size); conf->headers = g_list_append (conf->headers, buf); offset += h_size; @@ -443,13 +445,16 @@ gst_rtp_vorbis_depay_process (GstRTPBaseDepayload * depayload, GstBuffer *outbuf; GstFlowReturn ret; gint payload_len; - guint8 *payload, *to_free = NULL; + GstBuffer *payload_buffer = NULL; + guint8 *payload; + GstMapInfo map; guint32 header, ident; guint8 F, VDT, packets; guint length; rtpvorbisdepay = GST_RTP_VORBIS_DEPAY (depayload); + payload = gst_rtp_buffer_get_payload (rtp); payload_len = gst_rtp_buffer_get_payload_len (rtp); GST_DEBUG_OBJECT (depayload, "got RTP packet of size %d", payload_len); @@ -458,8 +463,6 @@ gst_rtp_vorbis_depay_process (GstRTPBaseDepayload * depayload, if (G_UNLIKELY (payload_len < 4)) goto packet_short; - payload = gst_rtp_buffer_get_payload (rtp); - header = GST_READ_UINT32_BE (payload); /* * 0 1 2 3 @@ -501,10 +504,6 @@ gst_rtp_vorbis_depay_process (GstRTPBaseDepayload * depayload, } } - /* skip header */ - payload += 4; - payload_len -= 4; - GST_DEBUG_OBJECT (depayload, "ident: %u, F: %d, VDT: %d, packets: %d", ident, F, VDT, packets); @@ -536,20 +535,18 @@ gst_rtp_vorbis_depay_process (GstRTPBaseDepayload * depayload, goto no_output; /* construct assembled buffer */ - payload_len = gst_adapter_available (rtpvorbisdepay->adapter); - payload = gst_adapter_take (rtpvorbisdepay->adapter, payload_len); - - /* use this length */ - length = payload_len - 2; - - to_free = payload; + payload_buffer = + gst_adapter_take_buffer (rtpvorbisdepay->adapter, payload_len); } else { - /* read length from data */ - length = 0; + payload_buffer = gst_rtp_buffer_get_payload_subbuffer (rtp, 4, -1); } GST_DEBUG_OBJECT (depayload, "assemble done"); + gst_buffer_map (payload_buffer, &map, GST_MAP_READ); + payload = map.data; + payload_len = map.size; + /* we not assembling anymore now */ rtpvorbisdepay->assembling = FALSE; gst_adapter_clear (rtpvorbisdepay->adapter); @@ -570,8 +567,7 @@ gst_rtp_vorbis_depay_process (GstRTPBaseDepayload * depayload, * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+* */ while (payload_len > 2) { - if (length == 0) - length = GST_READ_UINT16_BE (payload); + length = GST_READ_UINT16_BE (payload); payload += 2; payload_len -= 2; @@ -593,17 +589,9 @@ gst_rtp_vorbis_depay_process (GstRTPBaseDepayload * depayload, } /* create buffer for packet */ - if (G_UNLIKELY (to_free)) { - outbuf = gst_buffer_new (); - gst_buffer_append_memory (outbuf, - gst_memory_new_wrapped (0, to_free, - (payload - to_free) + length, payload - to_free, length, to_free, - g_free)); - to_free = NULL; - } else { - outbuf = gst_buffer_new_and_alloc (length); - gst_buffer_fill (outbuf, 0, payload, length); - } + outbuf = + gst_buffer_copy_region (payload_buffer, GST_BUFFER_COPY_ALL, + payload - map.data, length); payload += length; payload_len -= length; @@ -615,12 +603,17 @@ gst_rtp_vorbis_depay_process (GstRTPBaseDepayload * depayload, break; } - g_free (to_free); + gst_buffer_unmap (payload_buffer, &map); + gst_buffer_unref (payload_buffer); return NULL; no_output: { + if (payload_buffer) { + gst_buffer_unmap (payload_buffer, &map); + gst_buffer_unref (payload_buffer); + } return NULL; } /* ERORRS */ @@ -628,23 +621,39 @@ switch_failed: { GST_ELEMENT_WARNING (rtpvorbisdepay, STREAM, DECODE, (NULL), ("Could not switch codebooks")); + if (payload_buffer) { + gst_buffer_unmap (payload_buffer, &map); + gst_buffer_unref (payload_buffer); + } return NULL; } packet_short: { GST_ELEMENT_WARNING (rtpvorbisdepay, STREAM, DECODE, (NULL), ("Packet was too short (%d < 4)", payload_len)); + if (payload_buffer) { + gst_buffer_unmap (payload_buffer, &map); + gst_buffer_unref (payload_buffer); + } return NULL; } ignore_reserved: { GST_WARNING_OBJECT (rtpvorbisdepay, "reserved VDT ignored"); + if (payload_buffer) { + gst_buffer_unmap (payload_buffer, &map); + gst_buffer_unref (payload_buffer); + } return NULL; } length_short: { GST_ELEMENT_WARNING (rtpvorbisdepay, STREAM, DECODE, (NULL), ("Packet contains invalid data")); + if (payload_buffer) { + gst_buffer_unmap (payload_buffer, &map); + gst_buffer_unref (payload_buffer); + } return NULL; } invalid_configuration: @@ -652,6 +661,10 @@ invalid_configuration: /* fatal, as we otherwise risk carrying on without output */ GST_ELEMENT_ERROR (rtpvorbisdepay, STREAM, DECODE, (NULL), ("Packet contains invalid configuration")); + if (payload_buffer) { + gst_buffer_unmap (payload_buffer, &map); + gst_buffer_unref (payload_buffer); + } return NULL; } } diff --git a/gst/rtp/gstrtpvorbispay.c b/gst/rtp/gstrtpvorbispay.c index 22327a1e87..3bc1c6fe2d 100644 --- a/gst/rtp/gstrtpvorbispay.c +++ b/gst/rtp/gstrtpvorbispay.c @@ -24,9 +24,11 @@ #include #include +#include #include "fnv1hash.h" #include "gstrtpvorbispay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpvorbispay_debug); #define GST_CAT_DEFAULT (rtpvorbispay_debug) @@ -143,6 +145,10 @@ gst_rtp_vorbis_pay_clear_packet (GstRtpVorbisPay * rtpvorbispay) if (rtpvorbispay->packet) gst_buffer_unref (rtpvorbispay->packet); rtpvorbispay->packet = NULL; + g_list_foreach (rtpvorbispay->packet_buffers, (GFunc) gst_mini_object_unref, + NULL); + g_list_free (rtpvorbispay->packet_buffers); + rtpvorbispay->packet_buffers = NULL; } static void @@ -273,6 +279,10 @@ gst_rtp_vorbis_pay_init_packet (GstRtpVorbisPay * rtpvorbispay, guint8 VDT, if (rtpvorbispay->packet) gst_buffer_unref (rtpvorbispay->packet); + g_list_foreach (rtpvorbispay->packet_buffers, (GFunc) gst_mini_object_unref, + NULL); + g_list_free (rtpvorbispay->packet_buffers); + rtpvorbispay->packet_buffers = NULL; /* new packet allocate max packet size */ rtpvorbispay->packet = @@ -290,6 +300,7 @@ gst_rtp_vorbis_pay_flush_packet (GstRtpVorbisPay * rtpvorbispay) guint8 *payload; guint hlen; GstRTPBuffer rtp = { NULL }; + GList *l; /* check for empty packet */ if (!rtpvorbispay->packet || rtpvorbispay->payload_pos <= 4) @@ -327,6 +338,15 @@ gst_rtp_vorbis_pay_flush_packet (GstRtpVorbisPay * rtpvorbispay) GST_BUFFER_DURATION (rtpvorbispay->packet) = rtpvorbispay->payload_duration; + for (l = g_list_last (rtpvorbispay->packet_buffers); l; l = l->prev) { + GstBuffer *buf = GST_BUFFER_CAST (l->data); + gst_rtp_copy_meta (GST_ELEMENT_CAST (rtpvorbispay), rtpvorbispay->packet, + buf, g_quark_from_static_string (GST_META_TAG_AUDIO_STR)); + gst_buffer_unref (buf); + } + g_list_free (rtpvorbispay->packet_buffers); + rtpvorbispay->packet_buffers = NULL; + /* push, this gives away our ref to the packet, so clear it. */ ret = gst_rtp_base_payload_push (GST_RTP_BASE_PAYLOAD (rtpvorbispay), @@ -490,10 +510,7 @@ gst_rtp_vorbis_pay_finish_headers (GstRTPBasePayload * basepayload) gst_buffer_extract (buf, 0, data, gst_buffer_get_size (buf)); data += gst_buffer_get_size (buf); - gst_buffer_unref (buf); } - g_list_free (rtpvorbispay->headers); - rtpvorbispay->headers = NULL; rtpvorbispay->need_headers = FALSE; /* serialize to base64 */ @@ -597,8 +614,8 @@ invalid_channels: static GstFlowReturn gst_rtp_vorbis_pay_payload_buffer (GstRtpVorbisPay * rtpvorbispay, guint8 VDT, - guint8 * data, guint size, GstClockTime timestamp, GstClockTime duration, - guint not_in_length) + GstBuffer * buffer, guint8 * data, guint size, GstClockTime timestamp, + GstClockTime duration, guint not_in_length) { GstFlowReturn ret = GST_FLOW_OK; guint newsize; @@ -655,6 +672,21 @@ gst_rtp_vorbis_pay_payload_buffer (GstRtpVorbisPay * rtpvorbispay, guint8 VDT, if (plen) memcpy (&ppos[2], data, plen); + if (buffer) { + if (!rtpvorbispay->packet_buffers + || rtpvorbispay->packet_buffers->data != (gpointer) buffer) + rtpvorbispay->packet_buffers = + g_list_prepend (rtpvorbispay->packet_buffers, + gst_buffer_ref (buffer)); + } else { + GList *l; + + for (l = rtpvorbispay->headers; l; l = l->next) + rtpvorbispay->packet_buffers = + g_list_prepend (rtpvorbispay->packet_buffers, + gst_buffer_ref (buffer)); + } + /* only first (only) configuration cuts length field */ /* NOTE: spec (if any) is not clear on this ... */ not_in_length = 0; @@ -765,15 +797,9 @@ gst_rtp_vorbis_pay_handle_buffer (GstRTPBasePayload * basepayload, rtpvorbispay->headers = g_list_append (rtpvorbispay->headers, buffer); ret = GST_FLOW_OK; goto done; - } else if (rtpvorbispay->headers) { - if (rtpvorbispay->need_headers) { - if (!gst_rtp_vorbis_pay_finish_headers (basepayload)) - goto header_error; - } else { - g_list_free_full (rtpvorbispay->headers, - (GDestroyNotify) gst_buffer_unref); - rtpvorbispay->headers = NULL; - } + } else if (rtpvorbispay->headers && rtpvorbispay->need_headers) { + if (!gst_rtp_vorbis_pay_finish_headers (basepayload)) + goto header_error; } /* there is a config request, see if we need to insert it */ @@ -813,7 +839,7 @@ gst_rtp_vorbis_pay_handle_buffer (GstRTPBasePayload * basepayload, /* we need to send config now first */ /* different TDT type forces flush */ gst_rtp_vorbis_pay_payload_buffer (rtpvorbispay, 1, - rtpvorbispay->config_data, rtpvorbispay->config_size, + NULL, rtpvorbispay->config_data, rtpvorbispay->config_size, timestamp, GST_CLOCK_TIME_NONE, rtpvorbispay->config_extra_len); if (timestamp != -1) { @@ -822,7 +848,8 @@ gst_rtp_vorbis_pay_handle_buffer (GstRTPBasePayload * basepayload, } } - ret = gst_rtp_vorbis_pay_payload_buffer (rtpvorbispay, VDT, data, size, + ret = + gst_rtp_vorbis_pay_payload_buffer (rtpvorbispay, VDT, buffer, data, size, timestamp, duration, 0); gst_buffer_unmap (buffer, &map); diff --git a/gst/rtp/gstrtpvorbispay.h b/gst/rtp/gstrtpvorbispay.h index 8f0974a0b3..a5d693a723 100644 --- a/gst/rtp/gstrtpvorbispay.h +++ b/gst/rtp/gstrtpvorbispay.h @@ -50,6 +50,7 @@ struct _GstRtpVorbisPay /* queues of buffers along with some stats. */ GstBuffer *packet; + GList *packet_buffers; guint payload_pos; guint payload_left; guint32 payload_ident; diff --git a/gst/rtp/gstrtpvp8depay.c b/gst/rtp/gstrtpvp8depay.c index f87a80fefa..4357a5f3d4 100644 --- a/gst/rtp/gstrtpvp8depay.c +++ b/gst/rtp/gstrtpvp8depay.c @@ -23,6 +23,7 @@ #endif #include "gstrtpvp8depay.h" +#include "gstrtputils.h" #include @@ -184,6 +185,9 @@ gst_rtp_vp8_depay_process (GstRTPBaseDepayload * depay, GstRTPBuffer * rtp) /* mark keyframes */ out = gst_buffer_make_writable (out); + /* Filter away all metas that are not sensible to copy */ + gst_rtp_drop_meta (GST_ELEMENT_CAST (self), out, + g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); if ((header[0] & 0x01)) { GST_BUFFER_FLAG_SET (out, GST_BUFFER_FLAG_DELTA_UNIT); diff --git a/gst/rtp/gstrtpvp8pay.c b/gst/rtp/gstrtpvp8pay.c index d611520cde..1c4c625007 100644 --- a/gst/rtp/gstrtpvp8pay.c +++ b/gst/rtp/gstrtpvp8pay.c @@ -30,8 +30,10 @@ #include #include #include +#include #include "dboolhuff.h" #include "gstrtpvp8pay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (gst_rtp_vp8_pay_debug); #define GST_CAT_DEFAULT gst_rtp_vp8_pay_debug @@ -411,7 +413,6 @@ gst_rtp_vp8_create_header_buffer (GstRtpVP8Pay * self, guint8 partid, return out; } - static guint gst_rtp_vp8_payload_next (GstRtpVP8Pay * self, GstBufferList * list, guint offset, GstBuffer * buffer, gsize buffer_size, gsize max_payload_len) @@ -438,6 +439,8 @@ gst_rtp_vp8_payload_next (GstRtpVP8Pay * self, GstBufferList * list, offset == self->partition_offset[partition], mark, buffer); sub = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, offset, available); + gst_rtp_copy_meta (GST_ELEMENT_CAST (self), header, buffer, + g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); out = gst_buffer_append (header, sub); gst_buffer_list_insert (list, -1, out); diff --git a/gst/rtp/gstrtpvrawdepay.c b/gst/rtp/gstrtpvrawdepay.c index 91d089a1d4..051e3124c0 100644 --- a/gst/rtp/gstrtpvrawdepay.c +++ b/gst/rtp/gstrtpvrawdepay.c @@ -22,10 +22,12 @@ #endif #include +#include #include #include #include "gstrtpvrawdepay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY_STATIC (rtpvrawdepay_debug); #define GST_CAT_DEFAULT (rtpvrawdepay_debug) @@ -328,7 +330,7 @@ gst_rtp_vraw_depay_process_packet (GstRTPBaseDepayload * depayload, gint width, height, xinc, yinc; GstVideoFrame *frame; gboolean marker; - GstBuffer *outbuf = NULL; + GstBuffer *buf, *outbuf = NULL; rtpvrawdepay = GST_RTP_VRAW_DEPAY (depayload); @@ -396,6 +398,7 @@ gst_rtp_vraw_depay_process_packet (GstRTPBaseDepayload * depayload, payload = gst_rtp_buffer_get_payload (rtp); payload_len = gst_rtp_buffer_get_payload_len (rtp); + buf = gst_rtp_buffer_get_payload_buffer (rtp); if (payload_len < 3) goto short_packet; @@ -407,6 +410,9 @@ gst_rtp_vraw_depay_process_packet (GstRTPBaseDepayload * depayload, /* remember header position */ headers = payload; + gst_rtp_copy_meta (GST_ELEMENT_CAST (rtpvrawdepay), frame->buffer, buf, + g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); + /* find data start */ do { if (payload_len < 6) diff --git a/gst/rtp/gstrtpvrawpay.c b/gst/rtp/gstrtpvrawpay.c index 0592fc08fc..0843486c67 100644 --- a/gst/rtp/gstrtpvrawpay.c +++ b/gst/rtp/gstrtpvrawpay.c @@ -24,8 +24,10 @@ #include #include +#include #include "gstrtpvrawpay.h" +#include "gstrtputils.h" enum { @@ -555,6 +557,10 @@ gst_rtp_vraw_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer) gst_buffer_resize (out, 0, gst_buffer_get_size (out) - left); } + gst_rtp_copy_meta (GST_ELEMENT_CAST (rtpvrawpay), out, buffer, + g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); + + /* Now either push out the buffer directly */ if (!use_buffer_lists) { ret = gst_rtp_base_payload_push (payload, out);