mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
rtpsv3vdepay: Properly fill codec_data and cleanup code a bite more.
This commit is contained in:
parent
65a2871e90
commit
e2b3665ae6
1 changed files with 110 additions and 95 deletions
|
@ -139,19 +139,6 @@ static GstBuffer *
|
|||
gst_rtp_sv3v_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
||||
{
|
||||
GstRtpSV3VDepay *rtpsv3vdepay;
|
||||
GstBuffer *outbuf;
|
||||
guint16 seq;
|
||||
|
||||
rtpsv3vdepay = GST_RTP_SV3V_DEPAY (depayload);
|
||||
|
||||
/* flush on sequence number gaps */
|
||||
seq = gst_rtp_buffer_get_seq (buf);
|
||||
if (seq != rtpsv3vdepay->nextseq) {
|
||||
gst_adapter_clear (rtpsv3vdepay->adapter);
|
||||
}
|
||||
rtpsv3vdepay->nextseq = seq + 1;
|
||||
|
||||
{
|
||||
static struct
|
||||
{
|
||||
guint width, height;
|
||||
|
@ -169,6 +156,22 @@ gst_rtp_sv3v_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
guint8 *payload;
|
||||
gboolean M;
|
||||
gboolean C, S, E;
|
||||
GstBuffer *outbuf = NULL;
|
||||
guint16 seq;
|
||||
|
||||
rtpsv3vdepay = GST_RTP_SV3V_DEPAY (depayload);
|
||||
|
||||
/* flush on sequence number gaps */
|
||||
seq = gst_rtp_buffer_get_seq (buf);
|
||||
|
||||
GST_DEBUG ("timestamp %" GST_TIME_FORMAT ", sequence number:%d",
|
||||
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)), seq);
|
||||
|
||||
if (seq != rtpsv3vdepay->nextseq) {
|
||||
GST_DEBUG ("Sequence discontinuity, clearing adapter");
|
||||
gst_adapter_clear (rtpsv3vdepay->adapter);
|
||||
}
|
||||
rtpsv3vdepay->nextseq = seq + 1;
|
||||
|
||||
payload_len = gst_rtp_buffer_get_payload_len (buf);
|
||||
if (payload_len < 3)
|
||||
|
@ -201,21 +204,24 @@ gst_rtp_sv3v_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
|
||||
GST_MEMDUMP ("incoming buffer", payload, payload_len);
|
||||
|
||||
if (C) {
|
||||
if (G_UNLIKELY (C)) {
|
||||
GstCaps *caps;
|
||||
GstBuffer *codec_data;
|
||||
GValue value = { 0 };
|
||||
guint8 res;
|
||||
|
||||
GST_DEBUG ("Configuration packet");
|
||||
|
||||
/* if we already have caps, we don't need to do anything. FIXME, check if
|
||||
* something changed. */
|
||||
if (GST_PAD_CAPS (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload)))
|
||||
return NULL;
|
||||
if (G_UNLIKELY (GST_PAD_CAPS (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload)))) {
|
||||
GST_DEBUG ("Already configured, skipping config parsing");
|
||||
goto beach;
|
||||
}
|
||||
|
||||
res = payload[2] >> 5;
|
||||
|
||||
/* width and height, according to http://wiki.multimedia.cx/index.php?title=Sorenson_Video_1#Stream_Format_And_Header */
|
||||
if (res < 7) {
|
||||
if (G_LIKELY (res < 7)) {
|
||||
rtpsv3vdepay->width = resolutions[res].width;
|
||||
rtpsv3vdepay->height = resolutions[res].height;
|
||||
} else {
|
||||
|
@ -225,10 +231,15 @@ gst_rtp_sv3v_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
(payload[3] & 0x1) << 11 | payload[4] << 3 | (payload[5] >> 5);
|
||||
}
|
||||
|
||||
/* we need a dummy empty codec data */
|
||||
g_value_init (&value, GST_TYPE_BUFFER);
|
||||
gst_value_deserialize (&value, "");
|
||||
codec_data = gst_value_get_buffer (&value);
|
||||
/* CodecData needs to be 'SEQH' + len (32bit) + data according to
|
||||
* ffmpeg's libavcodec/svq3.c:svq3_decode_init */
|
||||
codec_data = gst_buffer_new_and_alloc (payload_len + 6);
|
||||
memcpy (GST_BUFFER_DATA (codec_data), "SEQH", 4);
|
||||
GST_WRITE_UINT32_LE (GST_BUFFER_DATA (codec_data) + 4, payload_len - 2);
|
||||
memcpy (GST_BUFFER_DATA (codec_data) + 8, payload + 2, payload_len - 2);
|
||||
|
||||
GST_MEMDUMP ("codec_data", GST_BUFFER_DATA (codec_data),
|
||||
GST_BUFFER_SIZE (codec_data));
|
||||
|
||||
caps = gst_caps_new_simple ("video/x-svq",
|
||||
"svqversion", G_TYPE_INT, 3,
|
||||
|
@ -237,30 +248,34 @@ gst_rtp_sv3v_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
"codec_data", GST_TYPE_BUFFER, codec_data, NULL);
|
||||
gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), caps);
|
||||
gst_caps_unref (caps);
|
||||
g_value_unset (&value);
|
||||
|
||||
GST_DEBUG ("Depayloader now configured");
|
||||
|
||||
rtpsv3vdepay->configured = TRUE;
|
||||
|
||||
return NULL;
|
||||
goto beach;
|
||||
}
|
||||
|
||||
if (G_LIKELY (rtpsv3vdepay->configured)) {
|
||||
/* store data in adapter, stip off 2 bytes header */
|
||||
outbuf = gst_rtp_buffer_get_payload_subbuffer (buf, 2, -1);
|
||||
gst_adapter_push (rtpsv3vdepay->adapter, outbuf);
|
||||
GstBuffer *tmpbuf;
|
||||
|
||||
if (M) {
|
||||
GST_DEBUG ("Storing incoming payload");
|
||||
/* store data in adapter, stip off 2 bytes header */
|
||||
tmpbuf = gst_rtp_buffer_get_payload_subbuffer (buf, 2, -1);
|
||||
gst_adapter_push (rtpsv3vdepay->adapter, tmpbuf);
|
||||
|
||||
if (G_UNLIKELY (M)) {
|
||||
/* frame is completed: push contents of adapter */
|
||||
guint avail;
|
||||
|
||||
avail = gst_adapter_available (rtpsv3vdepay->adapter);
|
||||
GST_DEBUG ("Returning completed output buffer [%d bytes]", avail);
|
||||
outbuf = gst_adapter_take_buffer (rtpsv3vdepay->adapter, avail);
|
||||
}
|
||||
}
|
||||
|
||||
beach:
|
||||
return outbuf;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
/* ERRORS */
|
||||
bad_packet:
|
||||
|
|
Loading…
Reference in a new issue