From f6255bb8d0a8e926e428eebc23da07b0550d9f48 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Thu, 27 Oct 2011 00:37:03 +1100 Subject: [PATCH 1/2] flvmux: add some comments and defines to clarify code. --- gst/flv/amfdefs.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ gst/flv/gstflvmux.c | 25 +++++++++++++------------ 2 files changed, 57 insertions(+), 12 deletions(-) create mode 100644 gst/flv/amfdefs.h diff --git a/gst/flv/amfdefs.h b/gst/flv/amfdefs.h new file mode 100644 index 0000000000..6c14f3f71f --- /dev/null +++ b/gst/flv/amfdefs.h @@ -0,0 +1,44 @@ +/* GStreamer + * + * Copyright (c) 2011 Jan Schmidt + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __AMFDEFS_H__ +#define __AMFDEFS_H__ + +#include + +#define AMF0_NUMBER_MARKER 0x0 +#define AMF0_BOOLEAN_MARKER 0x1 +#define AMF0_STRING_MARKER 0x2 +#define AMF0_OBJECT_MARKER 0x3 +#define AMF0_MOVIECLIP_MARKER 0x4 // Reserved, not supported +#define AMF0_NULL_MARKER 0x5 +#define AMF0_UNDEFINED_MARKER 0x6 +#define AMF0_REFERENCE_MARKER 0x7 +#define AMF0_ECMA_ARRAY_MARKER 0x8 +#define AMF0_OBJECT_END_MARKER 0x9 +#define AMF0_STRICT_ARRAY_MARKER 0xA +#define AMF0_DATE_MARKER 0xB +#define AMF0_LONG_STRING_MARKER 0xC +#define AMF0_UNSUPPORTED_MARKER 0xD +#define AMF0_RECORDSET_MARKER 0xE // Reserved, not supported +#define AMF0_XML_DOCUMENT_MARKER 0xF +#define AMF0_TYPED_OBJECT_MARKER 0x10 + +#endif diff --git a/gst/flv/gstflvmux.c b/gst/flv/gstflvmux.c index 4b0e56b58e..47d5ba9569 100644 --- a/gst/flv/gstflvmux.c +++ b/gst/flv/gstflvmux.c @@ -39,6 +39,7 @@ #include #include "gstflvmux.h" +#include "amfdefs.h" GST_DEBUG_CATEGORY_STATIC (flvmux_debug); #define GST_CAT_DEFAULT flvmux_debug @@ -624,7 +625,7 @@ gst_flv_mux_preallocate_index (GstFlvMux * mux) /* prefill the space with a gstfiller: script tag variable */ GST_WRITE_UINT16_BE (data, 9); /* 9 characters */ memcpy (data + 2, "gstfiller", 9); - GST_WRITE_UINT8 (data + 11, 2); /* a string value */ + GST_WRITE_UINT8 (data + 11, AMF0_STRING_MARKER); /* a string value */ GST_WRITE_UINT16_BE (data + 12, preallocate_size - 14); memset (data + 14, ' ', preallocate_size - 14); /* the rest is spaces */ return tmp; @@ -635,11 +636,14 @@ gst_flv_mux_create_number_script_value (const gchar * name, gdouble value) { GstBuffer *tmp = gst_buffer_new_and_alloc (2 + strlen (name) + 1 + 8); guint8 *data = GST_BUFFER_DATA (tmp); + gsize len = strlen (name); - GST_WRITE_UINT16_BE (data, strlen (name)); /* name length */ - memcpy (&data[2], name, strlen (name)); - data[2 + strlen (name)] = 0; /* double */ - GST_WRITE_DOUBLE_BE (data + 2 + strlen (name) + 1, value); + GST_WRITE_UINT16_BE (data, len); + data += 2; /* name length */ + memcpy (data, name, len); + data += len; + *data++ = AMF0_NUMBER_MARKER; /* double type */ + GST_WRITE_DOUBLE_BE (data, value); return tmp; } @@ -674,7 +678,7 @@ gst_flv_mux_create_metadata (GstFlvMux * mux) tmp = gst_buffer_new_and_alloc (13); data = GST_BUFFER_DATA (tmp); - data[0] = 2; /* string */ + data[0] = AMF0_STRING_MARKER; /* string */ data[1] = 0; data[2] = 10; /* length 10 */ memcpy (&data[3], "onMetaData", 10); @@ -694,17 +698,14 @@ gst_flv_mux_create_metadata (GstFlvMux * mux) tmp = gst_flv_mux_create_number_script_value ("duration", 86400); script_tag = gst_buffer_join (script_tag, tmp); tags_written++; - } - /* Sometimes the information about the total file size is useful for the - player. It will be filled later, after getting EOS */ - if (!mux->streamable) { + /* Sometimes the information about the total file size is useful for the + player. It will be filled later, after getting EOS */ tmp = gst_flv_mux_create_number_script_value ("filesize", 0); script_tag = gst_buffer_join (script_tag, tmp); tags_written++; - } - if (!mux->streamable) { + /* Preallocate space for the index to be written at EOS */ tmp = gst_flv_mux_preallocate_index (mux); script_tag = gst_buffer_join (script_tag, tmp); } else { From 3b03db5e403b3c8736d00aca8071113b656995c1 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Fri, 28 Oct 2011 00:41:45 +1100 Subject: [PATCH 2/2] deinterlace: Don't pointlessly hold object lock over caps operations Avoids a deadlock when getcaps is recursive due to the getcaps being reflected upstream/downstream. The lock isn't actually protecting anything here. --- gst/deinterlace/gstdeinterlace.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/gst/deinterlace/gstdeinterlace.c b/gst/deinterlace/gstdeinterlace.c index 8e505a8eb8..e1210d1f7c 100644 --- a/gst/deinterlace/gstdeinterlace.c +++ b/gst/deinterlace/gstdeinterlace.c @@ -2091,8 +2091,6 @@ gst_deinterlace_getcaps (GstPad * pad) const GstCaps *ourcaps; GstCaps *peercaps; - GST_OBJECT_LOCK (self); - otherpad = (pad == self->srcpad) ? self->sinkpad : self->srcpad; ourcaps = gst_pad_get_pad_template_caps (pad); @@ -2106,8 +2104,6 @@ gst_deinterlace_getcaps (GstPad * pad) ret = gst_caps_copy (ourcaps); } - GST_OBJECT_UNLOCK (self); - for (len = gst_caps_get_size (ret); len > 0; len--) { GstStructure *s = gst_caps_get_structure (ret, len - 1);