From dcb5afd351b6ad89abf93e22a43a421a1722c489 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Urba=C5=84ski?= Date: Tue, 16 Mar 2010 23:43:39 +0100 Subject: [PATCH] flvmux: Put width and height in the metadata Some players use that info to scale their display. See #613094. --- gst/flv/gstflvmux.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/gst/flv/gstflvmux.c b/gst/flv/gstflvmux.c index 4b12715..446a810 100644 --- a/gst/flv/gstflvmux.c +++ b/gst/flv/gstflvmux.c @@ -752,12 +752,43 @@ gst_flv_mux_create_metadata (GstFlvMux * mux) if (video_pad && GST_PAD_CAPS (video_pad)) { GstStructure *s = gst_caps_get_structure (GST_PAD_CAPS (video_pad), 0); + gint size; gint par_x, par_y; + if (gst_structure_get_int (s, "width", &size)) { + GST_DEBUG_OBJECT (mux, "putting width %d in the metadata", size); + + tmp = gst_buffer_new_and_alloc (2 + 5 + 1 + 8); + data = GST_BUFFER_DATA (tmp); + data[0] = 0; + data[1] = 5; /* 5 bytes name */ + memcpy (&data[2], "width", 5); + data[7] = 0; /* double */ + GST_WRITE_DOUBLE_BE (data + 8, size); + script_tag = gst_buffer_join (script_tag, tmp); + tags_written++; + } + + if (gst_structure_get_int (s, "height", &size)) { + GST_DEBUG_OBJECT (mux, "putting height %d in the metadata", size); + + tmp = gst_buffer_new_and_alloc (2 + 6 + 1 + 8); + data = GST_BUFFER_DATA (tmp); + data[0] = 0; + data[1] = 6; /* 6 bytes name */ + memcpy (&data[2], "height", 6); + data[8] = 0; /* double */ + GST_WRITE_DOUBLE_BE (data + 9, size); + script_tag = gst_buffer_join (script_tag, tmp); + tags_written++; + } + if (gst_structure_get_fraction (s, "pixel-aspect-ratio", &par_x, &par_y)) { gdouble d; d = par_x; + GST_DEBUG_OBJECT (mux, "putting AspectRatioX %f in the metadata", d); + tmp = gst_buffer_new_and_alloc (2 + 12 + 1 + 8); data = GST_BUFFER_DATA (tmp); data[0] = 0; /* 12 bytes name */ @@ -769,6 +800,8 @@ gst_flv_mux_create_metadata (GstFlvMux * mux) tags_written++; d = par_y; + GST_DEBUG_OBJECT (mux, "putting AspectRatioY %f in the metadata", d); + tmp = gst_buffer_new_and_alloc (2 + 12 + 1 + 8); data = GST_BUFFER_DATA (tmp); data[0] = 0; /* 12 bytes name */ -- 2.7.4