diff --git a/docs/design/part-mediatype-audio-raw.txt b/docs/design/part-mediatype-audio-raw.txt index b5826722c6..1a45342b47 100644 --- a/docs/design/part-mediatype-audio-raw.txt +++ b/docs/design/part-mediatype-audio-raw.txt @@ -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 diff --git a/docs/design/part-mediatype-video-raw.txt b/docs/design/part-mediatype-video-raw.txt index 9f62a317f1..2f55b8b82c 100644 --- a/docs/design/part-mediatype-video-raw.txt +++ b/docs/design/part-mediatype-video-raw.txt @@ -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 ------- diff --git a/gst-libs/gst/audio/Makefile.am b/gst-libs/gst/audio/Makefile.am index 163465f7d9..69f6bcd77f 100644 --- a/gst-libs/gst/audio/Makefile.am +++ b/gst-libs/gst/audio/Makefile.am @@ -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 index 0000000000..53fb8b9e10 --- /dev/null +++ b/gst-libs/gst/audio/gstaudiometa.c @@ -0,0 +1,49 @@ +/* GStreamer + * Copyright (C) <2011> Wim Taymans + * + * 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 + +#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 index 0000000000..80e717f9a7 --- /dev/null +++ b/gst-libs/gst/audio/gstaudiometa.h @@ -0,0 +1,57 @@ +/* GStreamer + * Copyright (C) <2011> Wim Taymans + * + * 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 + +#include + +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__ */