gst-plugins-base: audioencoder: provide CODEC/AUDIO_CODEC handling
Mark Nauwelaerts
mnauw at kemper.freedesktop.org
Mon Sep 26 06:16:34 PDT 2011
Module: gst-plugins-base
Branch: master
Commit: a99b313c262da8938ede02402da6889430fc5c64
URL: http://cgit.freedesktop.org/gstreamer/gst-plugins-base/commit/?id=a99b313c262da8938ede02402da6889430fc5c64
Author: Mark Nauwelaerts <mark.nauwelaerts at collabora.co.uk>
Date: Mon Sep 26 14:48:55 2011 +0200
audioencoder: provide CODEC/AUDIO_CODEC handling
---
gst-libs/gst/audio/gstaudioencoder.c | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/gst-libs/gst/audio/gstaudioencoder.c b/gst-libs/gst/audio/gstaudioencoder.c
index 514ec53..32543f2 100644
--- a/gst-libs/gst/audio/gstaudioencoder.c
+++ b/gst-libs/gst/audio/gstaudioencoder.c
@@ -155,6 +155,7 @@
#include "gstaudioencoder.h"
#include <gst/base/gstadapter.h>
#include <gst/audio/audio.h>
+#include <gst/pbutils/descriptions.h>
#include <stdlib.h>
#include <string.h>
@@ -239,6 +240,9 @@ struct _GstAudioEncoderPrivate
gboolean perfect_ts;
gboolean hard_resync;
gboolean granule;
+
+ /* pending tags */
+ GstTagList *tags;
};
@@ -399,12 +403,18 @@ gst_audio_encoder_reset (GstAudioEncoder * enc, gboolean full)
{
GST_OBJECT_LOCK (enc);
+ GST_LOG_OBJECT (enc, "reset full %d", full);
+
if (full) {
enc->priv->active = FALSE;
enc->priv->samples_in = 0;
enc->priv->bytes_out = 0;
gst_audio_info_clear (&enc->priv->ctx.info);
memset (&enc->priv->ctx, 0, sizeof (enc->priv->ctx));
+
+ if (enc->priv->tags)
+ gst_tag_list_free (enc->priv->tags);
+ enc->priv->tags = NULL;
}
gst_segment_init (&enc->segment, GST_FORMAT_TIME);
@@ -475,6 +485,21 @@ gst_audio_encoder_finish_frame (GstAudioEncoder * enc, GstBuffer * buf,
g_return_val_if_fail (buf == NULL || GST_BUFFER_SIZE (buf) > 0,
GST_FLOW_ERROR);
+ if (G_UNLIKELY (enc->priv->tags)) {
+ GstTagList *tags;
+
+ /* add codec info to pending tags */
+ tags = enc->priv->tags;
+ /* no more pending */
+ enc->priv->tags = NULL;
+ gst_pb_utils_add_codec_description_to_tag_list (tags, GST_TAG_CODEC,
+ GST_PAD_CAPS (enc->srcpad));
+ gst_pb_utils_add_codec_description_to_tag_list (tags, GST_TAG_AUDIO_CODEC,
+ GST_PAD_CAPS (enc->srcpad));
+ GST_DEBUG_OBJECT (enc, "sending tags %" GST_PTR_FORMAT, tags);
+ gst_element_found_tags_for_pad (GST_ELEMENT (enc), enc->srcpad, tags);
+ }
+
GST_LOG_OBJECT (enc, "accepting %d bytes encoded data as %d samples",
buf ? GST_BUFFER_SIZE (buf) : -1, samples);
@@ -1557,6 +1582,11 @@ gst_audio_encoder_activate (GstAudioEncoder * enc, gboolean active)
GST_DEBUG_OBJECT (enc, "activate %d", active);
if (active) {
+
+ if (enc->priv->tags)
+ gst_tag_list_free (enc->priv->tags);
+ enc->priv->tags = gst_tag_list_new ();
+
if (!enc->priv->active && klass->start)
result = klass->start (enc);
} else {
More information about the gstreamer-commits
mailing list