From 983f57dc7dfc5f76e29ab0f768fa779166633987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 8 Aug 2015 17:34:50 +0200 Subject: [PATCH] rtptheorapay: Extract pixel format from the ident header to put it into the sampling field of the caps We always put 4:2:0 into the caps before, which obviously is wrong for 4:2:2 and 4:4:4 formats. --- gst/rtp/gstrtptheorapay.c | 24 ++++++++++++++++++++---- gst/rtp/gstrtptheorapay.h | 1 + 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/gst/rtp/gstrtptheorapay.c b/gst/rtp/gstrtptheorapay.c index dc8ae8e754..334be07397 100644 --- a/gst/rtp/gstrtptheorapay.c +++ b/gst/rtp/gstrtptheorapay.c @@ -351,6 +351,7 @@ gst_rtp_theora_pay_finish_headers (GstRTPBasePayload * basepayload) guint8 *data, *config; guint32 ident; gboolean res; + const gchar *sampling = NULL; GST_DEBUG_OBJECT (rtptheorapay, "finish headers"); @@ -518,13 +519,27 @@ gst_rtp_theora_pay_finish_headers (GstRTPBasePayload * basepayload) g_free (config); /* configure payloader settings */ + switch (rtptheorapay->pixel_format) { + case 2: + sampling = "YCbCr-4:2:2"; + break; + case 3: + sampling = "YCbCr-4:4:4"; + break; + case 0: + default: + sampling = "YCbCr-4:2:0"; + break; + } + + wstr = g_strdup_printf ("%d", rtptheorapay->width); hstr = g_strdup_printf ("%d", rtptheorapay->height); gst_rtp_base_payload_set_options (basepayload, "video", TRUE, "THEORA", 90000); res = gst_rtp_base_payload_set_outcaps (basepayload, "sampling", G_TYPE_STRING, - "YCbCr-4:2:0", "width", G_TYPE_STRING, wstr, "height", G_TYPE_STRING, + sampling, "width", G_TYPE_STRING, wstr, "height", G_TYPE_STRING, hstr, "configuration", G_TYPE_STRING, configuration, "delivery-method", G_TYPE_STRING, "inline", /* don't set the other defaults @@ -549,7 +564,7 @@ gst_rtp_theora_pay_parse_id (GstRTPBasePayload * basepayload, guint8 * data, guint size) { GstRtpTheoraPay *rtptheorapay; - gint width, height; + gint width, height, pixel_format; rtptheorapay = GST_RTP_THEORA_PAY (basepayload); @@ -569,11 +584,12 @@ gst_rtp_theora_pay_parse_id (GstRTPBasePayload * basepayload, guint8 * data, width = GST_READ_UINT16_BE (data) << 4; data += 2; height = GST_READ_UINT16_BE (data) << 4; - data += 2; + data += 29; - /* FIXME, parse pixel format */ + pixel_format = (GST_READ_UINT8 (data) >> 3) & 0x03; /* store values */ + rtptheorapay->pixel_format = pixel_format; rtptheorapay->width = width; rtptheorapay->height = height; diff --git a/gst/rtp/gstrtptheorapay.h b/gst/rtp/gstrtptheorapay.h index 0a1d4725d4..3f197b4e63 100644 --- a/gst/rtp/gstrtptheorapay.h +++ b/gst/rtp/gstrtptheorapay.h @@ -66,6 +66,7 @@ struct _GstRtpTheoraPay guint config_interval; GstClockTime last_config; + gint pixel_format; gint width; gint height; };