add audio metadata
authorWim Taymans <wim.taymans@collabora.co.uk>
Tue, 20 Dec 2011 11:02:25 +0000 (12:02 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Tue, 20 Dec 2011 11:02:25 +0000 (12:02 +0100)
Add some audio metadata to describe a downmix matrix.
Add metadata to media type document.

docs/design/part-mediatype-audio-raw.txt
docs/design/part-mediatype-video-raw.txt
gst-libs/gst/audio/Makefile.am
gst-libs/gst/audio/gstaudiometa.c [new file with mode: 0644]
gst-libs/gst/audio/gstaudiometa.h [new file with mode: 0644]

index b582672..1a45342 100644 (file)
@@ -16,6 +16,13 @@ Media Types
   channel-positions, G_TYPE_VALUE_ARRAY
    An array with a channel position for each channel. The number of items in
    this array must be the same as the channels property.
+
+
+Metadata
+--------
+
+ "GstAudioDownmixMeta"
+   A matrix for downmixing multichannel audio to mono or stereo.
    
 
 Formats
index 9f62a31..2f55b8b 100644 (file)
@@ -59,6 +59,21 @@ Media Types
     The format of the video, see the Formats section for a list of valid format
     strings.
 
+Metadata
+--------
+
+ "GstVideoMeta"
+   contains the description of one video field or frame. It has
+   stride support and support for having multiple memory regions per frame.
+
+   Multiple GstVideoMeta can be added to a buffer and can be identified with a
+   unique id. This id can be used to select fields in interlaced formats or
+   views in multiview formats.
+
+ "GstVideoCropMeta"
+   Contains the cropping region of the video.
+
+
 Formats
 -------
 
index 163465f..69f6bcd 100644 (file)
@@ -34,6 +34,7 @@ libgstaudio_@GST_MAJORMINOR@_la_SOURCES = \
        gstaudiobasesink.c \
        gstaudiobasesrc.c \
        gstaudiofilter.c \
+       gstaudiometa.c \
        gstaudiosink.c \
        gstaudiosrc.c \
        streamvolume.c \
@@ -52,6 +53,7 @@ libgstaudio_@GST_MAJORMINOR@include_HEADERS = \
        gstaudioencoder.h \
        gstaudiobasesink.h \
        gstaudiobasesrc.h \
+       gstaudiometa.h \
        gstaudiosink.h \
        gstaudiosrc.h \
        mixer.h \
diff --git a/gst-libs/gst/audio/gstaudiometa.c b/gst-libs/gst/audio/gstaudiometa.c
new file mode 100644 (file)
index 0000000..53fb8b9
--- /dev/null
@@ -0,0 +1,49 @@
+/* GStreamer
+ * Copyright (C) <2011> Wim Taymans <wim.taymans@gmail.com>
+ *
+ * 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.
+ */
+
+#include <string.h>
+
+#include "gstaudiometa.h"
+
+static void
+gst_audio_downmix_meta_copy (GstBuffer * dest, GstMeta * meta,
+    GstBuffer * buffer, gsize offset, gsize size)
+{
+  GstAudioDownmixMeta *dmeta, *smeta;
+
+  smeta = (GstAudioDownmixMeta *) meta;
+  dmeta = gst_buffer_add_audio_downmix_meta (dest);
+
+  memcpy (dmeta, smeta, sizeof (GstAudioDownmixMeta));
+}
+
+const GstMetaInfo *
+gst_audio_downmix_meta_get_info (void)
+{
+  static const GstMetaInfo *audio_downmix_meta_info = NULL;
+
+  if (audio_downmix_meta_info == NULL) {
+    audio_downmix_meta_info =
+        gst_meta_register (GST_AUDIO_DOWNMIX_META_API, "GstAudioDownmixMeta",
+        sizeof (GstAudioDownmixMeta), (GstMetaInitFunction) NULL,
+        (GstMetaFreeFunction) NULL, gst_audio_downmix_meta_copy,
+        (GstMetaTransformFunction) NULL);
+  }
+  return audio_downmix_meta_info;
+}
diff --git a/gst-libs/gst/audio/gstaudiometa.h b/gst-libs/gst/audio/gstaudiometa.h
new file mode 100644 (file)
index 0000000..80e717f
--- /dev/null
@@ -0,0 +1,57 @@
+/* GStreamer
+ * Copyright (C) <2011> Wim Taymans <wim.taymans@gmail.com>
+ *
+ * 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 __GST_AUDIO_META_H__
+#define __GST_AUDIO_META_H__
+
+#include <gst/gst.h>
+
+#include <gst/audio/audio.h>
+
+G_BEGIN_DECLS
+
+#define GST_AUDIO_DOWNMIX_META_API   "GstAudioDownmixMeta"
+#define GST_AUDIO_DOWNMIX_META_INFO  (gst_audio_downmix_meta_get_info())
+typedef struct _GstAudioDownmixMeta GstAudioDownmixMeta;
+
+/**
+ * GstAudioDownmixMeta:
+ * @meta: parent #GstMeta
+ * @channels: the number of channels of the destination
+ * @matrix: the matrix coefficients.
+ *
+ * Extra buffer metadata describing audio downmixing matrix. This metadata is
+ * attached to audio buffers and contains a matrix to downmix the buffer number
+ * of channels to @channels.
+ */
+struct _GstAudioDownmixMeta {
+  GstMeta      meta;
+
+  guint        channels;
+  gfloat       matrix[64];
+};
+
+const GstMetaInfo * gst_audio_downmix_meta_get_info (void);
+
+#define gst_buffer_get_audio_downmix_meta(b) ((GstAudioDownmixMeta*)gst_buffer_get_meta((b),GST_AUDIO_DOWNMIX_META_INFO))
+#define gst_buffer_add_audio_downmix_meta(b) ((GstAudioDownmixMeta*)gst_buffer_add_meta((b),GST_AUDIO_DOWNMIX_META_INFO, NULL))
+
+G_END_DECLS
+
+#endif /* __GST_AUDIO_META_H__ */