GST_CLOCK_TIME_TO_FRAMES
GST_META_TAG_AUDIO_STR
GST_META_TAG_AUDIO_CHANNELS_STR
+GST_META_TAG_AUDIO_RATE_STR
GST_AUDIO_NE
GST_AUDIO_OE
GST_AUDIO_RATE_RANGE
gst_buffer_add_audio_downmix_meta
gst_buffer_get_audio_downmix_meta
gst_buffer_get_audio_downmix_meta_for_channels
+
+GstAudioClippingMeta
+gst_buffer_add_audio_clipping_meta
+gst_buffer_get_audio_clipping_meta
<SUBSECTION Standard>
-GST_AUDIO_DOWNMIX_META_API_TYPE
-GST_AUDIO_DOWNMIX_META_INFO
-gst_audio_downmix_meta_api_get_type
-gst_audio_downmix_meta_get_info
+GST_AUDIO_CLIPPING_META_API_TYPE
+GST_AUDIO_CLIPPING_META_INFO
+gst_audio_clipping_meta_api_get_type
+gst_audio_clipping_meta_get_info
</SECTION>
<SECTION>
}
return audio_downmix_meta_info;
}
+
+static gboolean
+gst_audio_clipping_meta_init (GstMeta * meta, gpointer params,
+ GstBuffer * buffer)
+{
+ GstAudioClippingMeta *cmeta = (GstAudioClippingMeta *) meta;
+
+ cmeta->format = GST_FORMAT_UNDEFINED;
+ cmeta->start = cmeta->end = 0;
+
+ return TRUE;
+}
+
+static gboolean
+gst_audio_clipping_meta_transform (GstBuffer * dest, GstMeta * meta,
+ GstBuffer * buffer, GQuark type, gpointer data)
+{
+ GstAudioClippingMeta *smeta, *dmeta;
+
+ smeta = (GstAudioClippingMeta *) meta;
+
+ if (GST_META_TRANSFORM_IS_COPY (type)) {
+ GstMetaTransformCopy *copy = data;
+
+ if (copy->region)
+ return FALSE;
+
+ dmeta =
+ gst_buffer_add_audio_clipping_meta (dest, smeta->format, smeta->start,
+ smeta->end);
+ if (!dmeta)
+ return FALSE;
+ } else {
+ /* TODO: Could implement an automatic transform for resampling */
+ /* return FALSE, if transform type is not supported */
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/**
+ * gst_buffer_add_audio_clipping_meta:
+ * @buffer: a #GstBuffer
+ * @format: GstFormat of @start and @stop, GST_FORMAT_DEFAULT is samples
+ * @start: Amount of audio to clip from start of buffer
+ * @end: Amount of to clip from end of buffer
+ *
+ * Attaches #GstAudioClippingMeta metadata to @buffer with the given parameters.
+ *
+ * Returns: (transfer none): the #GstAudioClippingMeta on @buffer.
+ *
+ * Since: 1.8
+ */
+GstAudioClippingMeta *
+gst_buffer_add_audio_clipping_meta (GstBuffer * buffer,
+ GstFormat format, guint64 start, guint64 end)
+{
+ GstAudioClippingMeta *meta;
+
+ g_return_val_if_fail (format != GST_FORMAT_UNDEFINED, NULL);
+
+ meta =
+ (GstAudioClippingMeta *) gst_buffer_add_meta (buffer,
+ GST_AUDIO_CLIPPING_META_INFO, NULL);
+
+ meta->format = format;
+ meta->start = start;
+ meta->end = end;
+
+ return meta;
+}
+
+GType
+gst_audio_clipping_meta_api_get_type (void)
+{
+ static volatile GType type;
+ static const gchar *tags[] =
+ { GST_META_TAG_AUDIO_STR, GST_META_TAG_AUDIO_RATE_STR, NULL };
+
+ if (g_once_init_enter (&type)) {
+ GType _type = gst_meta_api_type_register ("GstAudioClippingMetaAPI", tags);
+ g_once_init_leave (&type, _type);
+ }
+ return type;
+}
+
+const GstMetaInfo *
+gst_audio_clipping_meta_get_info (void)
+{
+ static const GstMetaInfo *audio_clipping_meta_info = NULL;
+
+ if (g_once_init_enter (&audio_clipping_meta_info)) {
+ const GstMetaInfo *meta =
+ gst_meta_register (GST_AUDIO_CLIPPING_META_API_TYPE,
+ "GstAudioClippingMeta", sizeof (GstAudioClippingMeta),
+ gst_audio_clipping_meta_init, NULL,
+ gst_audio_clipping_meta_transform);
+ g_once_init_leave (&audio_clipping_meta_info, meta);
+ }
+ return audio_clipping_meta_info;
+}
gint to_channels,
const gfloat **matrix);
+
+#define GST_AUDIO_CLIPPING_META_API_TYPE (gst_audio_clipping_meta_api_get_type())
+#define GST_AUDIO_CLIPPING_META_INFO (gst_audio_clipping_meta_get_info())
+
+typedef struct _GstAudioClippingMeta GstAudioClippingMeta;
+
+/**
+ * GstAudioClippingMeta:
+ * @meta: parent #GstMeta
+ * @format: GstFormat of @start and @stop, GST_FORMAT_DEFAULT is samples
+ * @start: Amount of audio to clip from start of buffer
+ * @end: Amount of to clip from end of buffer
+ *
+ * Extra buffer metadata describing how much audio has to be clipped from
+ * the start or end of a buffer. This is used for compressed formats, where
+ * the first frame usually has some additional samples due to encoder and
+ * decoder delays, and the last frame usually has some additional samples to
+ * be able to fill the complete last frame.
+ *
+ * This is used to ensure that decoded data in the end has the same amount of
+ * samples, and multiply decoded streams can be gaplessly concatenated.
+ *
+ * Note: If clipping of the start is done by adjusting the segment, this meta
+ * has to be dropped from buffers as otherwise clipping could happen twice.
+ *
+ * Since: 1.8
+ */
+struct _GstAudioClippingMeta {
+ GstMeta meta;
+
+ GstFormat format;
+ guint64 start;
+ guint64 end;
+};
+
+GType gst_audio_clipping_meta_api_get_type (void);
+const GstMetaInfo * gst_audio_clipping_meta_get_info (void);
+
+#define gst_buffer_get_audio_clipping_meta(b) ((GstAudioClippingMeta*)gst_buffer_get_meta((b), GST_AUDIO_CLIPPING_META_API_TYPE))
+
+GstAudioClippingMeta * gst_buffer_add_audio_clipping_meta (GstBuffer *buffer,
+ GstFormat format,
+ guint64 start,
+ guint64 end);
+
G_END_DECLS
#endif /* __GST_AUDIO_META_H__ */