2012-07-08 17:19:38 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <2011> Stefan Kost <ensonic@users.sf.net>
|
2015-06-07 17:49:48 +00:00
|
|
|
* Copyright (C) <2015> Luis de Bethencourt <luis@debethencourt.com>
|
2012-07-08 17:19:38 +00:00
|
|
|
*
|
2012-07-16 19:58:23 +00:00
|
|
|
* gstaudiovisualizer.h: base class for audio visualisation elements
|
2012-07-08 17:19:38 +00:00
|
|
|
*
|
2015-04-25 16:45:50 +00:00
|
|
|
* 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.
|
2012-07-08 17:19:38 +00:00
|
|
|
*
|
2015-04-25 16:45:50 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2012-07-08 17:19:38 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2015-04-25 16:45:50 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
2012-07-08 17:19:38 +00:00
|
|
|
*
|
2015-04-25 16:45:50 +00:00
|
|
|
* 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., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2012-07-08 17:19:38 +00:00
|
|
|
*/
|
|
|
|
/**
|
2012-07-16 19:58:23 +00:00
|
|
|
* SECTION:gstaudiovisualizer
|
2017-01-23 19:36:11 +00:00
|
|
|
* @title: GstAudioVisualizer
|
2018-04-02 06:34:58 +00:00
|
|
|
* @short_description: Base class for visualizers.
|
2012-07-08 17:19:38 +00:00
|
|
|
*
|
2012-07-16 19:58:23 +00:00
|
|
|
* A baseclass for scopes (visualizers). It takes care of re-fitting the
|
2012-07-08 17:19:38 +00:00
|
|
|
* audio-rate to video-rate and handles renegotiation (downstream video size
|
|
|
|
* changes).
|
2016-02-25 10:47:17 +00:00
|
|
|
*
|
2012-07-08 17:19:38 +00:00
|
|
|
* It also provides several background shading effects. These effects are
|
2018-09-21 16:54:39 +00:00
|
|
|
* applied to a previous picture before the `render()` implementation can draw a
|
2012-07-08 17:19:38 +00:00
|
|
|
* new frame.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2012-08-13 11:47:01 +00:00
|
|
|
#include <gst/video/video.h>
|
|
|
|
#include <gst/video/gstvideometa.h>
|
|
|
|
#include <gst/video/gstvideopool.h>
|
|
|
|
|
2012-07-16 19:58:23 +00:00
|
|
|
#include "gstaudiovisualizer.h"
|
2016-02-25 18:39:04 +00:00
|
|
|
#include "pbutils-enumtypes.h"
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2012-07-16 19:58:23 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (audio_visualizer_debug);
|
|
|
|
#define GST_CAT_DEFAULT (audio_visualizer_debug)
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2012-07-16 19:58:23 +00:00
|
|
|
#define DEFAULT_SHADER GST_AUDIO_VISUALIZER_SHADER_FADE
|
2012-07-08 17:19:38 +00:00
|
|
|
#define DEFAULT_SHADE_AMOUNT 0x000a0a0a
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_SHADER,
|
|
|
|
PROP_SHADE_AMOUNT
|
|
|
|
};
|
|
|
|
|
|
|
|
static GstBaseTransformClass *parent_class = NULL;
|
2018-06-23 19:33:16 +00:00
|
|
|
static gint private_offset = 0;
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2012-07-16 19:58:23 +00:00
|
|
|
static void gst_audio_visualizer_class_init (GstAudioVisualizerClass * klass);
|
|
|
|
static void gst_audio_visualizer_init (GstAudioVisualizer * scope,
|
|
|
|
GstAudioVisualizerClass * g_class);
|
|
|
|
static void gst_audio_visualizer_set_property (GObject * object,
|
2012-07-08 17:19:38 +00:00
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec);
|
2012-07-16 19:58:23 +00:00
|
|
|
static void gst_audio_visualizer_get_property (GObject * object,
|
2012-07-08 17:19:38 +00:00
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec);
|
2015-10-01 10:55:59 +00:00
|
|
|
static void gst_audio_visualizer_dispose (GObject * object);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2012-07-16 19:58:23 +00:00
|
|
|
static gboolean gst_audio_visualizer_src_negotiate (GstAudioVisualizer * scope);
|
|
|
|
static gboolean gst_audio_visualizer_src_setcaps (GstAudioVisualizer *
|
2012-07-08 17:19:38 +00:00
|
|
|
scope, GstCaps * caps);
|
2012-07-16 19:58:23 +00:00
|
|
|
static gboolean gst_audio_visualizer_sink_setcaps (GstAudioVisualizer *
|
2012-07-08 17:19:38 +00:00
|
|
|
scope, GstCaps * caps);
|
|
|
|
|
2012-07-16 19:58:23 +00:00
|
|
|
static GstFlowReturn gst_audio_visualizer_chain (GstPad * pad,
|
2012-07-08 17:19:38 +00:00
|
|
|
GstObject * parent, GstBuffer * buffer);
|
|
|
|
|
2012-07-16 19:58:23 +00:00
|
|
|
static gboolean gst_audio_visualizer_src_event (GstPad * pad,
|
2012-07-08 17:19:38 +00:00
|
|
|
GstObject * parent, GstEvent * event);
|
2012-07-16 19:58:23 +00:00
|
|
|
static gboolean gst_audio_visualizer_sink_event (GstPad * pad,
|
2012-07-08 17:19:38 +00:00
|
|
|
GstObject * parent, GstEvent * event);
|
|
|
|
|
2012-07-16 19:58:23 +00:00
|
|
|
static gboolean gst_audio_visualizer_src_query (GstPad * pad,
|
2012-07-08 17:19:38 +00:00
|
|
|
GstObject * parent, GstQuery * query);
|
|
|
|
|
2012-07-16 19:58:23 +00:00
|
|
|
static GstStateChangeReturn gst_audio_visualizer_change_state (GstElement *
|
2012-07-08 17:19:38 +00:00
|
|
|
element, GstStateChange transition);
|
|
|
|
|
2013-01-29 09:18:06 +00:00
|
|
|
static gboolean gst_audio_visualizer_do_bufferpool (GstAudioVisualizer * scope,
|
|
|
|
GstCaps * outcaps);
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
default_decide_allocation (GstAudioVisualizer * scope, GstQuery * query);
|
|
|
|
|
2015-06-07 17:23:23 +00:00
|
|
|
struct _GstAudioVisualizerPrivate
|
|
|
|
{
|
|
|
|
gboolean negotiated;
|
|
|
|
|
|
|
|
GstBufferPool *pool;
|
|
|
|
gboolean pool_active;
|
|
|
|
GstAllocator *allocator;
|
|
|
|
GstAllocationParams params;
|
|
|
|
GstQuery *query;
|
|
|
|
|
|
|
|
/* pads */
|
|
|
|
GstPad *srcpad, *sinkpad;
|
|
|
|
|
|
|
|
GstAudioVisualizerShader shader_type;
|
|
|
|
GstAudioVisualizerShaderFunc shader;
|
|
|
|
guint32 shade_amount;
|
|
|
|
|
|
|
|
GstAdapter *adapter;
|
|
|
|
|
|
|
|
GstBuffer *inbuf;
|
|
|
|
GstBuffer *tempbuf;
|
|
|
|
GstVideoFrame tempframe;
|
|
|
|
|
|
|
|
guint spf; /* samples per video frame */
|
|
|
|
guint64 frame_duration;
|
|
|
|
|
|
|
|
/* QoS stuff *//* with LOCK */
|
|
|
|
gdouble proportion;
|
|
|
|
GstClockTime earliest_time;
|
|
|
|
|
|
|
|
guint dropped; /* frames dropped / not dropped */
|
|
|
|
guint processed;
|
|
|
|
|
|
|
|
/* configuration mutex */
|
|
|
|
GMutex config_lock;
|
|
|
|
|
|
|
|
GstSegment segment;
|
|
|
|
};
|
|
|
|
|
2012-07-08 17:19:38 +00:00
|
|
|
/* shading functions */
|
|
|
|
|
|
|
|
/* we're only supporting GST_VIDEO_FORMAT_xRGB right now) */
|
|
|
|
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
|
|
|
|
2012-08-13 11:47:01 +00:00
|
|
|
#define SHADE(_d, _s, _i, _r, _g, _b) \
|
|
|
|
G_STMT_START { \
|
|
|
|
_d[_i * 4 + 0] = (_s[_i * 4 + 0] > _b) ? _s[_i * 4 + 0] - _b : 0; \
|
|
|
|
_d[_i * 4 + 1] = (_s[_i * 4 + 1] > _g) ? _s[_i * 4 + 1] - _g : 0; \
|
|
|
|
_d[_i * 4 + 2] = (_s[_i * 4 + 2] > _r) ? _s[_i * 4 + 2] - _r : 0; \
|
|
|
|
_d[_i * 4 + 3] = 0; \
|
2012-07-08 17:19:38 +00:00
|
|
|
} G_STMT_END
|
|
|
|
|
2012-08-13 11:47:01 +00:00
|
|
|
#else /* G_BYTE_ORDER == G_LITTLE_ENDIAN */
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2012-08-13 11:47:01 +00:00
|
|
|
#define SHADE(_d, _s, _i, _r, _g, _b) \
|
|
|
|
G_STMT_START { \
|
|
|
|
_d[_i * 4 + 0] = 0; \
|
|
|
|
_d[_i * 4 + 1] = (_s[_i * 4 + 1] > _r) ? _s[_i * 4 + 1] - _r : 0; \
|
|
|
|
_d[_i * 4 + 2] = (_s[_i * 4 + 2] > _g) ? _s[_i * 4 + 2] - _g : 0; \
|
|
|
|
_d[_i * 4 + 3] = (_s[_i * 4 + 3] > _b) ? _s[_i * 4 + 3] - _b : 0; \
|
2012-07-08 17:19:38 +00:00
|
|
|
} G_STMT_END
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void
|
2012-08-13 11:47:01 +00:00
|
|
|
shader_fade (GstAudioVisualizer * scope, const GstVideoFrame * sframe,
|
|
|
|
GstVideoFrame * dframe)
|
2012-07-08 17:19:38 +00:00
|
|
|
{
|
2012-08-13 11:47:01 +00:00
|
|
|
guint i, j;
|
2015-10-01 14:27:55 +00:00
|
|
|
guint r = (scope->priv->shade_amount >> 16) & 0xff;
|
|
|
|
guint g = (scope->priv->shade_amount >> 8) & 0xff;
|
|
|
|
guint b = (scope->priv->shade_amount >> 0) & 0xff;
|
2012-08-13 11:47:01 +00:00
|
|
|
guint8 *s, *d;
|
|
|
|
gint ss, ds, width, height;
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2012-08-13 11:47:01 +00:00
|
|
|
s = GST_VIDEO_FRAME_PLANE_DATA (sframe, 0);
|
|
|
|
ss = GST_VIDEO_FRAME_PLANE_STRIDE (sframe, 0);
|
|
|
|
d = GST_VIDEO_FRAME_PLANE_DATA (dframe, 0);
|
|
|
|
ds = GST_VIDEO_FRAME_PLANE_STRIDE (dframe, 0);
|
|
|
|
|
|
|
|
width = GST_VIDEO_FRAME_WIDTH (sframe);
|
|
|
|
height = GST_VIDEO_FRAME_HEIGHT (sframe);
|
|
|
|
|
|
|
|
for (j = 0; j < height; j++) {
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
SHADE (d, s, i, r, g, b);
|
|
|
|
}
|
|
|
|
s += ss;
|
|
|
|
d += ds;
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-08-13 11:47:01 +00:00
|
|
|
shader_fade_and_move_up (GstAudioVisualizer * scope,
|
|
|
|
const GstVideoFrame * sframe, GstVideoFrame * dframe)
|
2012-07-08 17:19:38 +00:00
|
|
|
{
|
2012-08-13 11:47:01 +00:00
|
|
|
guint i, j;
|
2015-10-01 14:27:55 +00:00
|
|
|
guint r = (scope->priv->shade_amount >> 16) & 0xff;
|
|
|
|
guint g = (scope->priv->shade_amount >> 8) & 0xff;
|
|
|
|
guint b = (scope->priv->shade_amount >> 0) & 0xff;
|
2012-08-13 11:47:01 +00:00
|
|
|
guint8 *s, *d;
|
|
|
|
gint ss, ds, width, height;
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2012-08-13 11:47:01 +00:00
|
|
|
s = GST_VIDEO_FRAME_PLANE_DATA (sframe, 0);
|
|
|
|
ss = GST_VIDEO_FRAME_PLANE_STRIDE (sframe, 0);
|
|
|
|
d = GST_VIDEO_FRAME_PLANE_DATA (dframe, 0);
|
|
|
|
ds = GST_VIDEO_FRAME_PLANE_STRIDE (dframe, 0);
|
|
|
|
|
|
|
|
width = GST_VIDEO_FRAME_WIDTH (sframe);
|
|
|
|
height = GST_VIDEO_FRAME_HEIGHT (sframe);
|
|
|
|
|
|
|
|
for (j = 1; j < height; j++) {
|
|
|
|
s += ss;
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
SHADE (d, s, i, r, g, b);
|
|
|
|
}
|
|
|
|
d += ds;
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-08-13 11:47:01 +00:00
|
|
|
shader_fade_and_move_down (GstAudioVisualizer * scope,
|
|
|
|
const GstVideoFrame * sframe, GstVideoFrame * dframe)
|
2012-07-08 17:19:38 +00:00
|
|
|
{
|
2012-08-13 11:47:01 +00:00
|
|
|
guint i, j;
|
2015-10-01 14:27:55 +00:00
|
|
|
guint r = (scope->priv->shade_amount >> 16) & 0xff;
|
|
|
|
guint g = (scope->priv->shade_amount >> 8) & 0xff;
|
|
|
|
guint b = (scope->priv->shade_amount >> 0) & 0xff;
|
2012-08-13 11:47:01 +00:00
|
|
|
guint8 *s, *d;
|
|
|
|
gint ss, ds, width, height;
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2012-08-13 11:47:01 +00:00
|
|
|
s = GST_VIDEO_FRAME_PLANE_DATA (sframe, 0);
|
|
|
|
ss = GST_VIDEO_FRAME_PLANE_STRIDE (sframe, 0);
|
|
|
|
d = GST_VIDEO_FRAME_PLANE_DATA (dframe, 0);
|
|
|
|
ds = GST_VIDEO_FRAME_PLANE_STRIDE (dframe, 0);
|
|
|
|
|
|
|
|
width = GST_VIDEO_FRAME_WIDTH (sframe);
|
|
|
|
height = GST_VIDEO_FRAME_HEIGHT (sframe);
|
|
|
|
|
|
|
|
for (j = 1; j < height; j++) {
|
|
|
|
d += ds;
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
SHADE (d, s, i, r, g, b);
|
|
|
|
}
|
|
|
|
s += ss;
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-07-16 19:58:23 +00:00
|
|
|
shader_fade_and_move_left (GstAudioVisualizer * scope,
|
2012-08-13 11:47:01 +00:00
|
|
|
const GstVideoFrame * sframe, GstVideoFrame * dframe)
|
2012-07-08 17:19:38 +00:00
|
|
|
{
|
2012-08-13 11:47:01 +00:00
|
|
|
guint i, j;
|
2015-10-01 14:27:55 +00:00
|
|
|
guint r = (scope->priv->shade_amount >> 16) & 0xff;
|
|
|
|
guint g = (scope->priv->shade_amount >> 8) & 0xff;
|
|
|
|
guint b = (scope->priv->shade_amount >> 0) & 0xff;
|
2012-08-13 11:47:01 +00:00
|
|
|
guint8 *s, *d;
|
|
|
|
gint ss, ds, width, height;
|
|
|
|
|
|
|
|
s = GST_VIDEO_FRAME_PLANE_DATA (sframe, 0);
|
|
|
|
ss = GST_VIDEO_FRAME_PLANE_STRIDE (sframe, 0);
|
|
|
|
d = GST_VIDEO_FRAME_PLANE_DATA (dframe, 0);
|
|
|
|
ds = GST_VIDEO_FRAME_PLANE_STRIDE (dframe, 0);
|
|
|
|
|
|
|
|
width = GST_VIDEO_FRAME_WIDTH (sframe);
|
|
|
|
height = GST_VIDEO_FRAME_HEIGHT (sframe);
|
|
|
|
|
|
|
|
width -= 1;
|
|
|
|
s += 4;
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
/* move to the left */
|
2012-08-13 11:47:01 +00:00
|
|
|
for (j = 0; j < height; j++) {
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
SHADE (d, s, i, r, g, b);
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
2012-08-13 11:47:01 +00:00
|
|
|
d += ds;
|
|
|
|
s += ss;
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-07-16 19:58:23 +00:00
|
|
|
shader_fade_and_move_right (GstAudioVisualizer * scope,
|
2012-08-13 11:47:01 +00:00
|
|
|
const GstVideoFrame * sframe, GstVideoFrame * dframe)
|
2012-07-08 17:19:38 +00:00
|
|
|
{
|
2012-08-13 11:47:01 +00:00
|
|
|
guint i, j;
|
2015-10-01 14:27:55 +00:00
|
|
|
guint r = (scope->priv->shade_amount >> 16) & 0xff;
|
|
|
|
guint g = (scope->priv->shade_amount >> 8) & 0xff;
|
|
|
|
guint b = (scope->priv->shade_amount >> 0) & 0xff;
|
2012-08-13 11:47:01 +00:00
|
|
|
guint8 *s, *d;
|
|
|
|
gint ss, ds, width, height;
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2012-08-13 11:47:01 +00:00
|
|
|
s = GST_VIDEO_FRAME_PLANE_DATA (sframe, 0);
|
|
|
|
ss = GST_VIDEO_FRAME_PLANE_STRIDE (sframe, 0);
|
|
|
|
d = GST_VIDEO_FRAME_PLANE_DATA (dframe, 0);
|
|
|
|
ds = GST_VIDEO_FRAME_PLANE_STRIDE (dframe, 0);
|
|
|
|
|
|
|
|
width = GST_VIDEO_FRAME_WIDTH (sframe);
|
|
|
|
height = GST_VIDEO_FRAME_HEIGHT (sframe);
|
|
|
|
|
|
|
|
width -= 1;
|
|
|
|
d += 4;
|
|
|
|
|
|
|
|
/* move to the right */
|
|
|
|
for (j = 0; j < height; j++) {
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
SHADE (d, s, i, r, g, b);
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
2012-08-13 11:47:01 +00:00
|
|
|
d += ds;
|
|
|
|
s += ss;
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-07-16 19:58:23 +00:00
|
|
|
shader_fade_and_move_horiz_out (GstAudioVisualizer * scope,
|
2012-08-13 11:47:01 +00:00
|
|
|
const GstVideoFrame * sframe, GstVideoFrame * dframe)
|
2012-07-08 17:19:38 +00:00
|
|
|
{
|
2012-08-13 11:47:01 +00:00
|
|
|
guint i, j;
|
2015-10-01 14:27:55 +00:00
|
|
|
guint r = (scope->priv->shade_amount >> 16) & 0xff;
|
|
|
|
guint g = (scope->priv->shade_amount >> 8) & 0xff;
|
|
|
|
guint b = (scope->priv->shade_amount >> 0) & 0xff;
|
2012-08-13 11:47:01 +00:00
|
|
|
guint8 *s, *d;
|
|
|
|
gint ss, ds, width, height;
|
|
|
|
|
|
|
|
s = GST_VIDEO_FRAME_PLANE_DATA (sframe, 0);
|
|
|
|
ss = GST_VIDEO_FRAME_PLANE_STRIDE (sframe, 0);
|
|
|
|
d = GST_VIDEO_FRAME_PLANE_DATA (dframe, 0);
|
|
|
|
ds = GST_VIDEO_FRAME_PLANE_STRIDE (dframe, 0);
|
|
|
|
|
|
|
|
width = GST_VIDEO_FRAME_WIDTH (sframe);
|
|
|
|
height = GST_VIDEO_FRAME_HEIGHT (sframe);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
/* move upper half up */
|
2012-08-13 11:47:01 +00:00
|
|
|
for (j = 0; j < height / 2; j++) {
|
|
|
|
s += ss;
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
SHADE (d, s, i, r, g, b);
|
|
|
|
}
|
|
|
|
d += ds;
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
2022-02-20 13:05:05 +00:00
|
|
|
|
|
|
|
/* rewind one stride */
|
|
|
|
d -= ds;
|
|
|
|
|
2012-07-08 17:19:38 +00:00
|
|
|
/* move lower half down */
|
2012-08-13 11:47:01 +00:00
|
|
|
for (j = 0; j < height / 2; j++) {
|
|
|
|
d += ds;
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
SHADE (d, s, i, r, g, b);
|
|
|
|
}
|
|
|
|
s += ss;
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-07-16 19:58:23 +00:00
|
|
|
shader_fade_and_move_horiz_in (GstAudioVisualizer * scope,
|
2012-08-13 11:47:01 +00:00
|
|
|
const GstVideoFrame * sframe, GstVideoFrame * dframe)
|
2012-07-08 17:19:38 +00:00
|
|
|
{
|
2012-08-13 11:47:01 +00:00
|
|
|
guint i, j;
|
2015-10-01 14:27:55 +00:00
|
|
|
guint r = (scope->priv->shade_amount >> 16) & 0xff;
|
|
|
|
guint g = (scope->priv->shade_amount >> 8) & 0xff;
|
|
|
|
guint b = (scope->priv->shade_amount >> 0) & 0xff;
|
2012-08-13 11:47:01 +00:00
|
|
|
guint8 *s, *d;
|
|
|
|
gint ss, ds, width, height;
|
|
|
|
|
|
|
|
s = GST_VIDEO_FRAME_PLANE_DATA (sframe, 0);
|
|
|
|
ss = GST_VIDEO_FRAME_PLANE_STRIDE (sframe, 0);
|
|
|
|
d = GST_VIDEO_FRAME_PLANE_DATA (dframe, 0);
|
|
|
|
ds = GST_VIDEO_FRAME_PLANE_STRIDE (dframe, 0);
|
|
|
|
|
|
|
|
width = GST_VIDEO_FRAME_WIDTH (sframe);
|
|
|
|
height = GST_VIDEO_FRAME_HEIGHT (sframe);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
/* move upper half down */
|
2012-08-13 11:47:01 +00:00
|
|
|
for (j = 0; j < height / 2; j++) {
|
|
|
|
d += ds;
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
SHADE (d, s, i, r, g, b);
|
|
|
|
}
|
|
|
|
s += ss;
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
|
|
|
/* move lower half up */
|
2012-08-13 11:47:01 +00:00
|
|
|
for (j = 0; j < height / 2; j++) {
|
|
|
|
s += ss;
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
SHADE (d, s, i, r, g, b);
|
|
|
|
}
|
|
|
|
d += ds;
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-07-16 19:58:23 +00:00
|
|
|
shader_fade_and_move_vert_out (GstAudioVisualizer * scope,
|
2012-08-13 11:47:01 +00:00
|
|
|
const GstVideoFrame * sframe, GstVideoFrame * dframe)
|
2012-07-08 17:19:38 +00:00
|
|
|
{
|
2012-08-13 11:47:01 +00:00
|
|
|
guint i, j;
|
2015-10-01 14:27:55 +00:00
|
|
|
guint r = (scope->priv->shade_amount >> 16) & 0xff;
|
|
|
|
guint g = (scope->priv->shade_amount >> 8) & 0xff;
|
|
|
|
guint b = (scope->priv->shade_amount >> 0) & 0xff;
|
2012-08-13 11:47:01 +00:00
|
|
|
guint8 *s, *s1, *d, *d1;
|
|
|
|
gint ss, ds, width, height;
|
|
|
|
|
|
|
|
s = GST_VIDEO_FRAME_PLANE_DATA (sframe, 0);
|
|
|
|
ss = GST_VIDEO_FRAME_PLANE_STRIDE (sframe, 0);
|
|
|
|
d = GST_VIDEO_FRAME_PLANE_DATA (dframe, 0);
|
|
|
|
ds = GST_VIDEO_FRAME_PLANE_STRIDE (dframe, 0);
|
|
|
|
|
|
|
|
width = GST_VIDEO_FRAME_WIDTH (sframe);
|
|
|
|
height = GST_VIDEO_FRAME_HEIGHT (sframe);
|
|
|
|
|
|
|
|
for (j = 0; j < height; j++) {
|
|
|
|
/* move left half to the left */
|
|
|
|
s1 = s + 1;
|
|
|
|
for (i = 0; i < width / 2; i++) {
|
|
|
|
SHADE (d, s1, i, r, g, b);
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
2012-08-13 11:47:01 +00:00
|
|
|
/* move right half to the right */
|
|
|
|
d1 = d + 1;
|
|
|
|
for (; i < width - 1; i++) {
|
|
|
|
SHADE (d1, s, i, r, g, b);
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
2012-08-13 11:47:01 +00:00
|
|
|
s += ss;
|
|
|
|
d += ds;
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-07-16 19:58:23 +00:00
|
|
|
shader_fade_and_move_vert_in (GstAudioVisualizer * scope,
|
2012-08-13 11:47:01 +00:00
|
|
|
const GstVideoFrame * sframe, GstVideoFrame * dframe)
|
2012-07-08 17:19:38 +00:00
|
|
|
{
|
2012-08-13 11:47:01 +00:00
|
|
|
guint i, j;
|
2015-10-01 14:27:55 +00:00
|
|
|
guint r = (scope->priv->shade_amount >> 16) & 0xff;
|
|
|
|
guint g = (scope->priv->shade_amount >> 8) & 0xff;
|
|
|
|
guint b = (scope->priv->shade_amount >> 0) & 0xff;
|
2012-08-13 11:47:01 +00:00
|
|
|
guint8 *s, *s1, *d, *d1;
|
|
|
|
gint ss, ds, width, height;
|
|
|
|
|
|
|
|
s = GST_VIDEO_FRAME_PLANE_DATA (sframe, 0);
|
|
|
|
ss = GST_VIDEO_FRAME_PLANE_STRIDE (sframe, 0);
|
|
|
|
d = GST_VIDEO_FRAME_PLANE_DATA (dframe, 0);
|
|
|
|
ds = GST_VIDEO_FRAME_PLANE_STRIDE (dframe, 0);
|
|
|
|
|
|
|
|
width = GST_VIDEO_FRAME_WIDTH (sframe);
|
|
|
|
height = GST_VIDEO_FRAME_HEIGHT (sframe);
|
|
|
|
|
|
|
|
for (j = 0; j < height; j++) {
|
|
|
|
/* move left half to the right */
|
|
|
|
d1 = d + 1;
|
|
|
|
for (i = 0; i < width / 2; i++) {
|
|
|
|
SHADE (d1, s, i, r, g, b);
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
2012-08-13 11:47:01 +00:00
|
|
|
/* move right half to the left */
|
|
|
|
s1 = s + 1;
|
|
|
|
for (; i < width - 1; i++) {
|
|
|
|
SHADE (d, s1, i, r, g, b);
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
2012-08-13 11:47:01 +00:00
|
|
|
s += ss;
|
|
|
|
d += ds;
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-07-16 19:58:23 +00:00
|
|
|
gst_audio_visualizer_change_shader (GstAudioVisualizer * scope)
|
2012-07-08 17:19:38 +00:00
|
|
|
{
|
2015-06-07 17:23:23 +00:00
|
|
|
switch (scope->priv->shader_type) {
|
2012-07-16 19:58:23 +00:00
|
|
|
case GST_AUDIO_VISUALIZER_SHADER_NONE:
|
2015-10-01 14:27:55 +00:00
|
|
|
scope->priv->shader = NULL;
|
2012-07-08 17:19:38 +00:00
|
|
|
break;
|
2012-07-16 19:58:23 +00:00
|
|
|
case GST_AUDIO_VISUALIZER_SHADER_FADE:
|
2015-10-01 14:27:55 +00:00
|
|
|
scope->priv->shader = shader_fade;
|
2012-07-08 17:19:38 +00:00
|
|
|
break;
|
2012-07-16 19:58:23 +00:00
|
|
|
case GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_UP:
|
2015-10-01 14:27:55 +00:00
|
|
|
scope->priv->shader = shader_fade_and_move_up;
|
2012-07-08 17:19:38 +00:00
|
|
|
break;
|
2012-07-16 19:58:23 +00:00
|
|
|
case GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_DOWN:
|
2015-10-01 14:27:55 +00:00
|
|
|
scope->priv->shader = shader_fade_and_move_down;
|
2012-07-08 17:19:38 +00:00
|
|
|
break;
|
2012-07-16 19:58:23 +00:00
|
|
|
case GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_LEFT:
|
2015-10-01 14:27:55 +00:00
|
|
|
scope->priv->shader = shader_fade_and_move_left;
|
2012-07-08 17:19:38 +00:00
|
|
|
break;
|
2012-07-16 19:58:23 +00:00
|
|
|
case GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_RIGHT:
|
2015-10-01 14:27:55 +00:00
|
|
|
scope->priv->shader = shader_fade_and_move_right;
|
2012-07-08 17:19:38 +00:00
|
|
|
break;
|
2012-07-16 19:58:23 +00:00
|
|
|
case GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_HORIZ_OUT:
|
2015-10-01 14:27:55 +00:00
|
|
|
scope->priv->shader = shader_fade_and_move_horiz_out;
|
2012-07-08 17:19:38 +00:00
|
|
|
break;
|
2012-07-16 19:58:23 +00:00
|
|
|
case GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_HORIZ_IN:
|
2015-10-01 14:27:55 +00:00
|
|
|
scope->priv->shader = shader_fade_and_move_horiz_in;
|
2012-07-08 17:19:38 +00:00
|
|
|
break;
|
2012-07-16 19:58:23 +00:00
|
|
|
case GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_VERT_OUT:
|
2015-10-01 14:27:55 +00:00
|
|
|
scope->priv->shader = shader_fade_and_move_vert_out;
|
2012-07-08 17:19:38 +00:00
|
|
|
break;
|
2012-07-16 19:58:23 +00:00
|
|
|
case GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_VERT_IN:
|
2015-10-01 14:27:55 +00:00
|
|
|
scope->priv->shader = shader_fade_and_move_vert_in;
|
2012-07-08 17:19:38 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
GST_ERROR ("invalid shader function");
|
2015-10-01 14:27:55 +00:00
|
|
|
scope->priv->shader = NULL;
|
2012-07-08 17:19:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* base class */
|
|
|
|
|
|
|
|
GType
|
2015-10-01 10:55:59 +00:00
|
|
|
gst_audio_visualizer_get_type (void)
|
2012-07-08 17:19:38 +00:00
|
|
|
{
|
2021-03-18 08:18:36 +00:00
|
|
|
static gsize audio_visualizer_type = 0;
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2012-07-16 19:58:23 +00:00
|
|
|
if (g_once_init_enter (&audio_visualizer_type)) {
|
|
|
|
static const GTypeInfo audio_visualizer_info = {
|
|
|
|
sizeof (GstAudioVisualizerClass),
|
2012-07-08 17:19:38 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2012-07-16 19:58:23 +00:00
|
|
|
(GClassInitFunc) gst_audio_visualizer_class_init,
|
2012-07-08 17:19:38 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2012-07-16 19:58:23 +00:00
|
|
|
sizeof (GstAudioVisualizer),
|
2012-07-08 17:19:38 +00:00
|
|
|
0,
|
2012-07-16 19:58:23 +00:00
|
|
|
(GInstanceInitFunc) gst_audio_visualizer_init,
|
2012-07-08 17:19:38 +00:00
|
|
|
};
|
|
|
|
GType _type;
|
|
|
|
|
2012-07-16 19:58:23 +00:00
|
|
|
/* TODO: rename when exporting it as a library */
|
2012-07-08 17:19:38 +00:00
|
|
|
_type = g_type_register_static (GST_TYPE_ELEMENT,
|
2016-02-25 10:47:17 +00:00
|
|
|
"GstAudioVisualizer", &audio_visualizer_info, G_TYPE_FLAG_ABSTRACT);
|
2018-06-23 19:33:16 +00:00
|
|
|
|
|
|
|
private_offset =
|
|
|
|
g_type_add_instance_private (_type, sizeof (GstAudioVisualizerPrivate));
|
|
|
|
|
2012-07-16 19:58:23 +00:00
|
|
|
g_once_init_leave (&audio_visualizer_type, _type);
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
2012-07-16 19:58:23 +00:00
|
|
|
return (GType) audio_visualizer_type;
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
|
|
|
|
2018-06-23 19:33:16 +00:00
|
|
|
static inline GstAudioVisualizerPrivate *
|
|
|
|
gst_audio_visualizer_get_instance_private (GstAudioVisualizer * self)
|
|
|
|
{
|
|
|
|
return (G_STRUCT_MEMBER_P (self, private_offset));
|
|
|
|
}
|
|
|
|
|
2012-07-08 17:19:38 +00:00
|
|
|
static void
|
2012-07-16 19:58:23 +00:00
|
|
|
gst_audio_visualizer_class_init (GstAudioVisualizerClass * klass)
|
2012-07-08 17:19:38 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = (GObjectClass *) klass;
|
|
|
|
GstElementClass *element_class = (GstElementClass *) klass;
|
|
|
|
|
2018-06-23 19:33:16 +00:00
|
|
|
if (private_offset != 0)
|
|
|
|
g_type_class_adjust_private_offset (klass, &private_offset);
|
2013-01-29 09:18:06 +00:00
|
|
|
|
2012-07-08 17:19:38 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
|
|
|
|
2013-05-15 09:03:58 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (audio_visualizer_debug,
|
|
|
|
"baseaudiovisualizer-libvisual", 0,
|
|
|
|
"scope audio visualisation base class");
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2012-07-16 19:58:23 +00:00
|
|
|
gobject_class->set_property = gst_audio_visualizer_set_property;
|
|
|
|
gobject_class->get_property = gst_audio_visualizer_get_property;
|
2015-10-01 10:55:59 +00:00
|
|
|
gobject_class->dispose = gst_audio_visualizer_dispose;
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
element_class->change_state =
|
2012-07-16 19:58:23 +00:00
|
|
|
GST_DEBUG_FUNCPTR (gst_audio_visualizer_change_state);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2013-01-29 09:18:06 +00:00
|
|
|
klass->decide_allocation = GST_DEBUG_FUNCPTR (default_decide_allocation);
|
|
|
|
|
2012-07-08 17:19:38 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_SHADER,
|
|
|
|
g_param_spec_enum ("shader", "shader type",
|
|
|
|
"Shader function to apply on each frame",
|
2012-07-16 19:58:23 +00:00
|
|
|
GST_TYPE_AUDIO_VISUALIZER_SHADER, DEFAULT_SHADER,
|
2012-07-08 17:19:38 +00:00
|
|
|
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
|
|
|
g_object_class_install_property (gobject_class, PROP_SHADE_AMOUNT,
|
|
|
|
g_param_spec_uint ("shade-amount", "shade amount",
|
|
|
|
"Shading color to use (big-endian ARGB)", 0, G_MAXUINT32,
|
|
|
|
DEFAULT_SHADE_AMOUNT,
|
|
|
|
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-07-16 19:58:23 +00:00
|
|
|
gst_audio_visualizer_init (GstAudioVisualizer * scope,
|
|
|
|
GstAudioVisualizerClass * g_class)
|
2012-07-08 17:19:38 +00:00
|
|
|
{
|
|
|
|
GstPadTemplate *pad_template;
|
|
|
|
|
2018-06-23 19:33:16 +00:00
|
|
|
scope->priv = gst_audio_visualizer_get_instance_private (scope);
|
2013-01-29 09:18:06 +00:00
|
|
|
|
2012-07-08 17:19:38 +00:00
|
|
|
/* create the sink and src pads */
|
|
|
|
pad_template =
|
|
|
|
gst_element_class_get_pad_template (GST_ELEMENT_CLASS (g_class), "sink");
|
|
|
|
g_return_if_fail (pad_template != NULL);
|
2015-06-07 17:23:23 +00:00
|
|
|
scope->priv->sinkpad = gst_pad_new_from_template (pad_template, "sink");
|
|
|
|
gst_pad_set_chain_function (scope->priv->sinkpad,
|
2012-07-16 19:58:23 +00:00
|
|
|
GST_DEBUG_FUNCPTR (gst_audio_visualizer_chain));
|
2015-06-07 17:23:23 +00:00
|
|
|
gst_pad_set_event_function (scope->priv->sinkpad,
|
2012-07-16 19:58:23 +00:00
|
|
|
GST_DEBUG_FUNCPTR (gst_audio_visualizer_sink_event));
|
2015-06-07 17:23:23 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (scope), scope->priv->sinkpad);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
pad_template =
|
|
|
|
gst_element_class_get_pad_template (GST_ELEMENT_CLASS (g_class), "src");
|
|
|
|
g_return_if_fail (pad_template != NULL);
|
2015-06-07 17:23:23 +00:00
|
|
|
scope->priv->srcpad = gst_pad_new_from_template (pad_template, "src");
|
|
|
|
gst_pad_set_event_function (scope->priv->srcpad,
|
2012-07-16 19:58:23 +00:00
|
|
|
GST_DEBUG_FUNCPTR (gst_audio_visualizer_src_event));
|
2015-06-07 17:23:23 +00:00
|
|
|
gst_pad_set_query_function (scope->priv->srcpad,
|
2012-07-16 19:58:23 +00:00
|
|
|
GST_DEBUG_FUNCPTR (gst_audio_visualizer_src_query));
|
2015-06-07 17:23:23 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (scope), scope->priv->srcpad);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2015-06-07 17:23:23 +00:00
|
|
|
scope->priv->adapter = gst_adapter_new ();
|
|
|
|
scope->priv->inbuf = gst_buffer_new ();
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
/* properties */
|
2015-06-07 17:23:23 +00:00
|
|
|
scope->priv->shader_type = DEFAULT_SHADER;
|
2012-07-16 19:58:23 +00:00
|
|
|
gst_audio_visualizer_change_shader (scope);
|
2015-06-07 17:23:23 +00:00
|
|
|
scope->priv->shade_amount = DEFAULT_SHADE_AMOUNT;
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
/* reset the initial video state */
|
2012-08-13 11:47:01 +00:00
|
|
|
gst_video_info_init (&scope->vinfo);
|
2015-06-07 17:23:23 +00:00
|
|
|
scope->priv->frame_duration = GST_CLOCK_TIME_NONE;
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
/* reset the initial state */
|
|
|
|
gst_audio_info_init (&scope->ainfo);
|
|
|
|
gst_video_info_init (&scope->vinfo);
|
|
|
|
|
2015-06-07 17:23:23 +00:00
|
|
|
g_mutex_init (&scope->priv->config_lock);
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-07-16 19:58:23 +00:00
|
|
|
gst_audio_visualizer_set_property (GObject * object, guint prop_id,
|
2012-07-08 17:19:38 +00:00
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2012-07-16 19:58:23 +00:00
|
|
|
GstAudioVisualizer *scope = GST_AUDIO_VISUALIZER (object);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_SHADER:
|
2015-06-07 17:23:23 +00:00
|
|
|
scope->priv->shader_type = g_value_get_enum (value);
|
2012-07-16 19:58:23 +00:00
|
|
|
gst_audio_visualizer_change_shader (scope);
|
2012-07-08 17:19:38 +00:00
|
|
|
break;
|
|
|
|
case PROP_SHADE_AMOUNT:
|
2015-06-07 17:23:23 +00:00
|
|
|
scope->priv->shade_amount = g_value_get_uint (value);
|
2012-07-08 17:19:38 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-07-16 19:58:23 +00:00
|
|
|
gst_audio_visualizer_get_property (GObject * object, guint prop_id,
|
2012-07-08 17:19:38 +00:00
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2012-07-16 19:58:23 +00:00
|
|
|
GstAudioVisualizer *scope = GST_AUDIO_VISUALIZER (object);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_SHADER:
|
2015-06-07 17:23:23 +00:00
|
|
|
g_value_set_enum (value, scope->priv->shader_type);
|
2012-07-08 17:19:38 +00:00
|
|
|
break;
|
|
|
|
case PROP_SHADE_AMOUNT:
|
2015-06-07 17:23:23 +00:00
|
|
|
g_value_set_uint (value, scope->priv->shade_amount);
|
2012-07-08 17:19:38 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-10-01 10:55:59 +00:00
|
|
|
gst_audio_visualizer_dispose (GObject * object)
|
2012-07-08 17:19:38 +00:00
|
|
|
{
|
2012-07-16 19:58:23 +00:00
|
|
|
GstAudioVisualizer *scope = GST_AUDIO_VISUALIZER (object);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2015-10-01 14:27:55 +00:00
|
|
|
if (scope->priv->adapter) {
|
|
|
|
g_object_unref (scope->priv->adapter);
|
|
|
|
scope->priv->adapter = NULL;
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
2015-10-01 14:27:55 +00:00
|
|
|
if (scope->priv->inbuf) {
|
|
|
|
gst_buffer_unref (scope->priv->inbuf);
|
|
|
|
scope->priv->inbuf = NULL;
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
2015-10-01 14:27:55 +00:00
|
|
|
if (scope->priv->tempbuf) {
|
|
|
|
gst_video_frame_unmap (&scope->priv->tempframe);
|
|
|
|
gst_buffer_unref (scope->priv->tempbuf);
|
|
|
|
scope->priv->tempbuf = NULL;
|
|
|
|
}
|
|
|
|
if (scope->priv->config_lock.p) {
|
|
|
|
g_mutex_clear (&scope->priv->config_lock);
|
|
|
|
scope->priv->config_lock.p = NULL;
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
2015-10-01 10:55:59 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-07-16 19:58:23 +00:00
|
|
|
gst_audio_visualizer_reset (GstAudioVisualizer * scope)
|
2012-07-08 17:19:38 +00:00
|
|
|
{
|
2015-10-01 14:27:55 +00:00
|
|
|
gst_adapter_clear (scope->priv->adapter);
|
|
|
|
gst_segment_init (&scope->priv->segment, GST_FORMAT_UNDEFINED);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
GST_OBJECT_LOCK (scope);
|
2015-10-01 14:27:55 +00:00
|
|
|
scope->priv->proportion = 1.0;
|
|
|
|
scope->priv->earliest_time = -1;
|
|
|
|
scope->priv->dropped = 0;
|
|
|
|
scope->priv->processed = 0;
|
2012-07-08 17:19:38 +00:00
|
|
|
GST_OBJECT_UNLOCK (scope);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2012-07-16 19:58:23 +00:00
|
|
|
gst_audio_visualizer_sink_setcaps (GstAudioVisualizer * scope, GstCaps * caps)
|
2012-07-08 17:19:38 +00:00
|
|
|
{
|
|
|
|
GstAudioInfo info;
|
|
|
|
|
|
|
|
if (!gst_audio_info_from_caps (&info, caps))
|
|
|
|
goto wrong_caps;
|
|
|
|
|
|
|
|
scope->ainfo = info;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (scope, "audio: channels %d, rate %d",
|
|
|
|
GST_AUDIO_INFO_CHANNELS (&info), GST_AUDIO_INFO_RATE (&info));
|
|
|
|
|
2013-05-15 09:03:58 +00:00
|
|
|
if (!gst_audio_visualizer_src_negotiate (scope)) {
|
|
|
|
goto not_negotiated;
|
|
|
|
}
|
2013-01-29 09:18:06 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
/* Errors */
|
|
|
|
wrong_caps:
|
|
|
|
{
|
|
|
|
GST_WARNING_OBJECT (scope, "could not parse caps");
|
2013-01-29 09:18:06 +00:00
|
|
|
return FALSE;
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
2013-05-15 09:03:58 +00:00
|
|
|
not_negotiated:
|
|
|
|
{
|
|
|
|
GST_WARNING_OBJECT (scope, "failed to negotiate");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2012-07-16 19:58:23 +00:00
|
|
|
gst_audio_visualizer_src_setcaps (GstAudioVisualizer * scope, GstCaps * caps)
|
2012-07-08 17:19:38 +00:00
|
|
|
{
|
|
|
|
GstVideoInfo info;
|
2012-07-16 19:58:23 +00:00
|
|
|
GstAudioVisualizerClass *klass;
|
2015-01-13 16:09:49 +00:00
|
|
|
gboolean res;
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
if (!gst_video_info_from_caps (&info, caps))
|
|
|
|
goto wrong_caps;
|
|
|
|
|
2012-07-16 19:58:23 +00:00
|
|
|
klass = GST_AUDIO_VISUALIZER_CLASS (G_OBJECT_GET_CLASS (scope));
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
scope->vinfo = info;
|
|
|
|
|
2015-10-01 14:27:55 +00:00
|
|
|
scope->priv->frame_duration = gst_util_uint64_scale_int (GST_SECOND,
|
2012-08-13 11:47:01 +00:00
|
|
|
GST_VIDEO_INFO_FPS_D (&info), GST_VIDEO_INFO_FPS_N (&info));
|
2015-10-01 14:27:55 +00:00
|
|
|
scope->priv->spf =
|
|
|
|
gst_util_uint64_scale_int (GST_AUDIO_INFO_RATE (&scope->ainfo),
|
2012-08-13 11:47:01 +00:00
|
|
|
GST_VIDEO_INFO_FPS_D (&info), GST_VIDEO_INFO_FPS_N (&info));
|
2015-10-01 14:27:55 +00:00
|
|
|
scope->req_spf = scope->priv->spf;
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2015-10-01 14:27:55 +00:00
|
|
|
if (scope->priv->tempbuf) {
|
|
|
|
gst_video_frame_unmap (&scope->priv->tempframe);
|
|
|
|
gst_buffer_unref (scope->priv->tempbuf);
|
2012-08-17 21:03:52 +00:00
|
|
|
}
|
2015-10-01 14:27:55 +00:00
|
|
|
scope->priv->tempbuf = gst_buffer_new_wrapped (g_malloc0 (scope->vinfo.size),
|
2012-08-17 21:03:52 +00:00
|
|
|
scope->vinfo.size);
|
2015-10-01 14:27:55 +00:00
|
|
|
gst_video_frame_map (&scope->priv->tempframe, &scope->vinfo,
|
|
|
|
scope->priv->tempbuf, GST_MAP_READWRITE);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2015-01-13 16:58:34 +00:00
|
|
|
if (klass->setup && !klass->setup (scope))
|
2015-01-13 16:36:09 +00:00
|
|
|
goto setup_failed;
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (scope, "video: dimension %dx%d, framerate %d/%d",
|
2012-08-13 11:47:01 +00:00
|
|
|
GST_VIDEO_INFO_WIDTH (&info), GST_VIDEO_INFO_HEIGHT (&info),
|
|
|
|
GST_VIDEO_INFO_FPS_N (&info), GST_VIDEO_INFO_FPS_D (&info));
|
2015-10-01 14:27:55 +00:00
|
|
|
GST_DEBUG_OBJECT (scope, "blocks: spf %u, req_spf %u",
|
|
|
|
scope->priv->spf, scope->req_spf);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2015-10-01 14:27:55 +00:00
|
|
|
gst_pad_set_caps (scope->priv->srcpad, caps);
|
2013-01-29 09:18:06 +00:00
|
|
|
|
|
|
|
/* find a pool for the negotiated caps now */
|
2015-01-13 16:09:49 +00:00
|
|
|
res = gst_audio_visualizer_do_bufferpool (scope, caps);
|
2015-01-21 15:22:15 +00:00
|
|
|
gst_caps_unref (caps);
|
2015-01-13 16:09:49 +00:00
|
|
|
|
|
|
|
return res;
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
wrong_caps:
|
|
|
|
{
|
2015-01-21 15:22:15 +00:00
|
|
|
gst_caps_unref (caps);
|
2012-07-08 17:19:38 +00:00
|
|
|
GST_DEBUG_OBJECT (scope, "error parsing caps");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2015-01-13 16:36:09 +00:00
|
|
|
|
|
|
|
setup_failed:
|
|
|
|
{
|
|
|
|
GST_WARNING_OBJECT (scope, "failed to set up");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2012-07-16 19:58:23 +00:00
|
|
|
gst_audio_visualizer_src_negotiate (GstAudioVisualizer * scope)
|
2012-07-08 17:19:38 +00:00
|
|
|
{
|
|
|
|
GstCaps *othercaps, *target;
|
|
|
|
GstStructure *structure;
|
|
|
|
GstCaps *templ;
|
2013-01-29 09:18:06 +00:00
|
|
|
gboolean ret;
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2015-06-07 17:23:23 +00:00
|
|
|
templ = gst_pad_get_pad_template_caps (scope->priv->srcpad);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (scope, "performing negotiation");
|
|
|
|
|
|
|
|
/* see what the peer can do */
|
2015-06-07 17:23:23 +00:00
|
|
|
othercaps = gst_pad_peer_query_caps (scope->priv->srcpad, NULL);
|
2012-07-08 17:19:38 +00:00
|
|
|
if (othercaps) {
|
|
|
|
target = gst_caps_intersect (othercaps, templ);
|
|
|
|
gst_caps_unref (othercaps);
|
|
|
|
gst_caps_unref (templ);
|
|
|
|
|
|
|
|
if (gst_caps_is_empty (target))
|
|
|
|
goto no_format;
|
|
|
|
|
|
|
|
target = gst_caps_truncate (target);
|
|
|
|
} else {
|
|
|
|
target = templ;
|
|
|
|
}
|
|
|
|
|
|
|
|
target = gst_caps_make_writable (target);
|
|
|
|
structure = gst_caps_get_structure (target, 0);
|
2012-08-13 11:47:01 +00:00
|
|
|
gst_structure_fixate_field_nearest_int (structure, "width", 320);
|
|
|
|
gst_structure_fixate_field_nearest_int (structure, "height", 200);
|
|
|
|
gst_structure_fixate_field_nearest_fraction (structure, "framerate", 25, 1);
|
2018-04-11 19:40:23 +00:00
|
|
|
if (gst_structure_has_field (structure, "pixel-aspect-ratio"))
|
|
|
|
gst_structure_fixate_field_nearest_fraction (structure,
|
|
|
|
"pixel-aspect-ratio", 1, 1);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2012-07-24 10:25:08 +00:00
|
|
|
target = gst_caps_fixate (target);
|
|
|
|
|
2012-07-08 17:19:38 +00:00
|
|
|
GST_DEBUG_OBJECT (scope, "final caps are %" GST_PTR_FORMAT, target);
|
|
|
|
|
2013-01-29 09:18:06 +00:00
|
|
|
ret = gst_audio_visualizer_src_setcaps (scope, target);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2013-01-29 09:18:06 +00:00
|
|
|
return ret;
|
|
|
|
|
|
|
|
no_format:
|
|
|
|
{
|
|
|
|
gst_caps_unref (target);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* takes ownership of the pool, allocator and query */
|
|
|
|
static gboolean
|
|
|
|
gst_audio_visualizer_set_allocation (GstAudioVisualizer * scope,
|
|
|
|
GstBufferPool * pool, GstAllocator * allocator,
|
2021-01-04 22:25:10 +00:00
|
|
|
const GstAllocationParams * params, GstQuery * query)
|
2013-01-29 09:18:06 +00:00
|
|
|
{
|
|
|
|
GstAllocator *oldalloc;
|
|
|
|
GstBufferPool *oldpool;
|
|
|
|
GstQuery *oldquery;
|
|
|
|
GstAudioVisualizerPrivate *priv = scope->priv;
|
|
|
|
|
|
|
|
GST_OBJECT_LOCK (scope);
|
|
|
|
oldpool = priv->pool;
|
|
|
|
priv->pool = pool;
|
|
|
|
priv->pool_active = FALSE;
|
|
|
|
|
|
|
|
oldalloc = priv->allocator;
|
|
|
|
priv->allocator = allocator;
|
|
|
|
|
|
|
|
oldquery = priv->query;
|
|
|
|
priv->query = query;
|
|
|
|
|
|
|
|
if (params)
|
|
|
|
priv->params = *params;
|
|
|
|
else
|
|
|
|
gst_allocation_params_init (&priv->params);
|
|
|
|
GST_OBJECT_UNLOCK (scope);
|
|
|
|
|
|
|
|
if (oldpool) {
|
|
|
|
GST_DEBUG_OBJECT (scope, "deactivating old pool %p", oldpool);
|
|
|
|
gst_buffer_pool_set_active (oldpool, FALSE);
|
|
|
|
gst_object_unref (oldpool);
|
|
|
|
}
|
|
|
|
if (oldalloc) {
|
|
|
|
gst_object_unref (oldalloc);
|
|
|
|
}
|
|
|
|
if (oldquery) {
|
|
|
|
gst_query_unref (oldquery);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_audio_visualizer_do_bufferpool (GstAudioVisualizer * scope,
|
|
|
|
GstCaps * outcaps)
|
|
|
|
{
|
|
|
|
GstQuery *query;
|
|
|
|
gboolean result = TRUE;
|
|
|
|
GstBufferPool *pool = NULL;
|
|
|
|
GstAudioVisualizerClass *klass;
|
|
|
|
GstAllocator *allocator;
|
|
|
|
GstAllocationParams params;
|
|
|
|
|
|
|
|
/* not passthrough, we need to allocate */
|
2012-07-08 17:19:38 +00:00
|
|
|
/* find a pool for the negotiated caps now */
|
2013-01-29 09:18:06 +00:00
|
|
|
GST_DEBUG_OBJECT (scope, "doing allocation query");
|
|
|
|
query = gst_query_new_allocation (outcaps, TRUE);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2015-06-07 17:23:23 +00:00
|
|
|
if (!gst_pad_peer_query (scope->priv->srcpad, query)) {
|
2012-07-08 17:19:38 +00:00
|
|
|
/* not a problem, we use the query defaults */
|
|
|
|
GST_DEBUG_OBJECT (scope, "allocation query failed");
|
|
|
|
}
|
|
|
|
|
2013-01-29 09:18:06 +00:00
|
|
|
klass = GST_AUDIO_VISUALIZER_GET_CLASS (scope);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (scope, "calling decide_allocation");
|
|
|
|
g_assert (klass->decide_allocation != NULL);
|
|
|
|
result = klass->decide_allocation (scope, query);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (scope, "ALLOCATION (%d) params: %" GST_PTR_FORMAT, result,
|
|
|
|
query);
|
|
|
|
|
|
|
|
if (!result)
|
|
|
|
goto no_decide_allocation;
|
|
|
|
|
|
|
|
/* we got configuration from our peer or the decide_allocation method,
|
|
|
|
* parse them */
|
|
|
|
if (gst_query_get_n_allocation_params (query) > 0) {
|
|
|
|
gst_query_parse_nth_allocation_param (query, 0, &allocator, ¶ms);
|
|
|
|
} else {
|
|
|
|
allocator = NULL;
|
|
|
|
gst_allocation_params_init (¶ms);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gst_query_get_n_allocation_pools (query) > 0)
|
|
|
|
gst_query_parse_nth_allocation_pool (query, 0, &pool, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
/* now store */
|
|
|
|
result =
|
|
|
|
gst_audio_visualizer_set_allocation (scope, pool, allocator, ¶ms,
|
|
|
|
query);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
/* Errors */
|
|
|
|
no_decide_allocation:
|
|
|
|
{
|
|
|
|
GST_WARNING_OBJECT (scope, "Subclass failed to decide allocation");
|
|
|
|
gst_query_unref (query);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
default_decide_allocation (GstAudioVisualizer * scope, GstQuery * query)
|
|
|
|
{
|
|
|
|
GstCaps *outcaps;
|
|
|
|
GstBufferPool *pool;
|
|
|
|
guint size, min, max;
|
|
|
|
GstAllocator *allocator;
|
|
|
|
GstAllocationParams params;
|
|
|
|
GstStructure *config;
|
|
|
|
gboolean update_allocator;
|
2013-03-14 00:15:29 +00:00
|
|
|
gboolean update_pool;
|
2013-01-29 09:18:06 +00:00
|
|
|
|
|
|
|
gst_query_parse_allocation (query, &outcaps, NULL);
|
|
|
|
|
|
|
|
/* we got configuration from our peer or the decide_allocation method,
|
|
|
|
* parse them */
|
|
|
|
if (gst_query_get_n_allocation_params (query) > 0) {
|
|
|
|
/* try the allocator */
|
|
|
|
gst_query_parse_nth_allocation_param (query, 0, &allocator, ¶ms);
|
|
|
|
update_allocator = TRUE;
|
|
|
|
} else {
|
|
|
|
allocator = NULL;
|
|
|
|
gst_allocation_params_init (¶ms);
|
|
|
|
update_allocator = FALSE;
|
|
|
|
}
|
|
|
|
|
2012-07-08 17:19:38 +00:00
|
|
|
if (gst_query_get_n_allocation_pools (query) > 0) {
|
|
|
|
gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);
|
2013-03-14 00:15:29 +00:00
|
|
|
update_pool = TRUE;
|
2012-07-08 17:19:38 +00:00
|
|
|
} else {
|
|
|
|
pool = NULL;
|
2013-01-29 09:18:06 +00:00
|
|
|
size = GST_VIDEO_INFO_SIZE (&scope->vinfo);
|
2012-07-08 17:19:38 +00:00
|
|
|
min = max = 0;
|
2013-03-14 00:15:29 +00:00
|
|
|
update_pool = FALSE;
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pool == NULL) {
|
|
|
|
/* we did not get a pool, make one ourselves then */
|
2012-08-13 11:47:01 +00:00
|
|
|
pool = gst_video_buffer_pool_new ();
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
config = gst_buffer_pool_get_config (pool);
|
2013-01-29 09:18:06 +00:00
|
|
|
gst_buffer_pool_config_set_params (config, outcaps, size, min, max);
|
|
|
|
gst_buffer_pool_config_set_allocator (config, allocator, ¶ms);
|
2012-08-13 11:47:01 +00:00
|
|
|
gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_META);
|
2012-07-08 17:19:38 +00:00
|
|
|
gst_buffer_pool_set_config (pool, config);
|
|
|
|
|
2013-01-29 09:18:06 +00:00
|
|
|
if (update_allocator)
|
|
|
|
gst_query_set_nth_allocation_param (query, 0, allocator, ¶ms);
|
|
|
|
else
|
|
|
|
gst_query_add_allocation_param (query, allocator, ¶ms);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2013-01-29 09:18:06 +00:00
|
|
|
if (allocator)
|
|
|
|
gst_object_unref (allocator);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2013-03-14 00:15:29 +00:00
|
|
|
if (update_pool)
|
2013-01-29 09:18:06 +00:00
|
|
|
gst_query_set_nth_allocation_pool (query, 0, pool, size, min, max);
|
2013-03-14 00:15:29 +00:00
|
|
|
else
|
|
|
|
gst_query_add_allocation_pool (query, pool, size, min, max);
|
|
|
|
|
|
|
|
if (pool)
|
2013-01-29 09:18:06 +00:00
|
|
|
gst_object_unref (pool);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
2013-01-29 09:18:06 +00:00
|
|
|
default_prepare_output_buffer (GstAudioVisualizer * scope, GstBuffer ** outbuf)
|
2012-07-08 17:19:38 +00:00
|
|
|
{
|
2013-01-29 09:18:06 +00:00
|
|
|
GstAudioVisualizerPrivate *priv;
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2013-01-29 09:18:06 +00:00
|
|
|
priv = scope->priv;
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2013-01-29 09:18:06 +00:00
|
|
|
g_assert (priv->pool != NULL);
|
|
|
|
|
|
|
|
/* we can't reuse the input buffer */
|
|
|
|
if (!priv->pool_active) {
|
|
|
|
GST_DEBUG_OBJECT (scope, "setting pool %p active", priv->pool);
|
|
|
|
if (!gst_buffer_pool_set_active (priv->pool, TRUE))
|
|
|
|
goto activate_failed;
|
|
|
|
priv->pool_active = TRUE;
|
|
|
|
}
|
|
|
|
GST_DEBUG_OBJECT (scope, "using pool alloc");
|
|
|
|
|
|
|
|
return gst_buffer_pool_acquire_buffer (priv->pool, outbuf, NULL);
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
activate_failed:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (scope, RESOURCE, SETTINGS,
|
|
|
|
("failed to activate bufferpool"), ("failed to activate bufferpool"));
|
|
|
|
return GST_FLOW_ERROR;
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
2012-07-16 19:58:23 +00:00
|
|
|
gst_audio_visualizer_chain (GstPad * pad, GstObject * parent,
|
2012-07-08 17:19:38 +00:00
|
|
|
GstBuffer * buffer)
|
|
|
|
{
|
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
2012-07-16 19:58:23 +00:00
|
|
|
GstAudioVisualizer *scope;
|
|
|
|
GstAudioVisualizerClass *klass;
|
2024-03-11 17:30:08 +00:00
|
|
|
GstBuffer *inbuf, *databuf;
|
2012-07-08 17:19:38 +00:00
|
|
|
guint64 dist, ts;
|
|
|
|
guint avail, sbpf;
|
2016-06-11 02:36:32 +00:00
|
|
|
gint bpf, rate;
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2012-07-16 19:58:23 +00:00
|
|
|
scope = GST_AUDIO_VISUALIZER (parent);
|
|
|
|
klass = GST_AUDIO_VISUALIZER_CLASS (G_OBJECT_GET_CLASS (scope));
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
GST_LOG_OBJECT (scope, "chainfunc called");
|
|
|
|
|
|
|
|
/* resync on DISCONT */
|
|
|
|
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT)) {
|
2015-10-01 14:27:55 +00:00
|
|
|
gst_adapter_clear (scope->priv->adapter);
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure have an output format */
|
2015-10-01 14:27:55 +00:00
|
|
|
if (gst_pad_check_reconfigure (scope->priv->srcpad)) {
|
2013-01-29 09:18:06 +00:00
|
|
|
if (!gst_audio_visualizer_src_negotiate (scope)) {
|
2015-10-01 14:27:55 +00:00
|
|
|
gst_pad_mark_reconfigure (scope->priv->srcpad);
|
2013-01-29 09:18:06 +00:00
|
|
|
goto not_negotiated;
|
|
|
|
}
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
2013-01-29 09:18:06 +00:00
|
|
|
|
2012-07-08 17:19:38 +00:00
|
|
|
rate = GST_AUDIO_INFO_RATE (&scope->ainfo);
|
2016-06-11 02:50:41 +00:00
|
|
|
bpf = GST_AUDIO_INFO_BPF (&scope->ainfo);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2016-06-11 02:50:41 +00:00
|
|
|
if (bpf == 0) {
|
2012-07-08 17:19:38 +00:00
|
|
|
ret = GST_FLOW_NOT_NEGOTIATED;
|
|
|
|
goto beach;
|
|
|
|
}
|
|
|
|
|
2015-10-01 14:27:55 +00:00
|
|
|
gst_adapter_push (scope->priv->adapter, buffer);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2015-10-01 14:27:55 +00:00
|
|
|
g_mutex_lock (&scope->priv->config_lock);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
/* this is what we want */
|
2016-06-11 02:36:32 +00:00
|
|
|
sbpf = scope->req_spf * bpf;
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2015-10-01 14:27:55 +00:00
|
|
|
inbuf = scope->priv->inbuf;
|
2012-07-08 17:19:38 +00:00
|
|
|
/* FIXME: the timestamp in the adapter would be different */
|
|
|
|
gst_buffer_copy_into (inbuf, buffer, GST_BUFFER_COPY_METADATA, 0, -1);
|
|
|
|
|
|
|
|
/* this is what we have */
|
2015-10-01 14:27:55 +00:00
|
|
|
avail = gst_adapter_available (scope->priv->adapter);
|
2012-07-08 17:19:38 +00:00
|
|
|
GST_LOG_OBJECT (scope, "avail: %u, bpf: %u", avail, sbpf);
|
|
|
|
while (avail >= sbpf) {
|
|
|
|
GstBuffer *outbuf;
|
2012-08-13 11:47:01 +00:00
|
|
|
GstVideoFrame outframe;
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
/* get timestamp of the current adapter content */
|
2015-10-01 14:27:55 +00:00
|
|
|
ts = gst_adapter_prev_pts (scope->priv->adapter, &dist);
|
2012-07-08 17:19:38 +00:00
|
|
|
if (GST_CLOCK_TIME_IS_VALID (ts)) {
|
|
|
|
/* convert bytes to time */
|
2016-06-11 02:50:41 +00:00
|
|
|
ts += gst_util_uint64_scale_int (dist, GST_SECOND, rate * bpf);
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
|
|
|
|
2015-01-21 14:46:15 +00:00
|
|
|
/* check for QoS, don't compute buffers that are known to be late */
|
2012-07-08 17:19:38 +00:00
|
|
|
if (GST_CLOCK_TIME_IS_VALID (ts)) {
|
2015-01-21 14:46:15 +00:00
|
|
|
GstClockTime earliest_time;
|
|
|
|
gdouble proportion;
|
2012-07-08 17:19:38 +00:00
|
|
|
gint64 qostime;
|
|
|
|
|
|
|
|
qostime =
|
2015-10-01 14:27:55 +00:00
|
|
|
gst_segment_to_running_time (&scope->priv->segment,
|
|
|
|
GST_FORMAT_TIME, ts) + scope->priv->frame_duration;
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
GST_OBJECT_LOCK (scope);
|
2015-10-01 14:27:55 +00:00
|
|
|
earliest_time = scope->priv->earliest_time;
|
|
|
|
proportion = scope->priv->proportion;
|
2012-07-08 17:19:38 +00:00
|
|
|
GST_OBJECT_UNLOCK (scope);
|
|
|
|
|
2015-01-21 14:46:15 +00:00
|
|
|
if (GST_CLOCK_TIME_IS_VALID (earliest_time) && qostime <= earliest_time) {
|
|
|
|
GstClockTime stream_time, jitter;
|
|
|
|
GstMessage *qos_msg;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (scope,
|
2012-07-08 17:19:38 +00:00
|
|
|
"QoS: skip ts: %" GST_TIME_FORMAT ", earliest: %" GST_TIME_FORMAT,
|
2015-01-21 14:46:15 +00:00
|
|
|
GST_TIME_ARGS (qostime), GST_TIME_ARGS (earliest_time));
|
|
|
|
|
2015-10-01 14:27:55 +00:00
|
|
|
++scope->priv->dropped;
|
|
|
|
stream_time = gst_segment_to_stream_time (&scope->priv->segment,
|
2015-01-21 14:46:15 +00:00
|
|
|
GST_FORMAT_TIME, ts);
|
|
|
|
jitter = GST_CLOCK_DIFF (qostime, earliest_time);
|
|
|
|
qos_msg = gst_message_new_qos (GST_OBJECT (scope), FALSE, qostime,
|
|
|
|
stream_time, ts, GST_BUFFER_DURATION (buffer));
|
|
|
|
gst_message_set_qos_values (qos_msg, jitter, proportion, 1000000);
|
|
|
|
gst_message_set_qos_stats (qos_msg, GST_FORMAT_BUFFERS,
|
2015-10-01 14:27:55 +00:00
|
|
|
scope->priv->processed, scope->priv->dropped);
|
2015-01-21 14:46:15 +00:00
|
|
|
gst_element_post_message (GST_ELEMENT (scope), qos_msg);
|
|
|
|
|
2012-07-08 17:19:38 +00:00
|
|
|
goto skip;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-01 14:27:55 +00:00
|
|
|
++scope->priv->processed;
|
2015-01-21 14:46:15 +00:00
|
|
|
|
2015-10-01 14:27:55 +00:00
|
|
|
g_mutex_unlock (&scope->priv->config_lock);
|
2013-01-29 09:18:06 +00:00
|
|
|
ret = default_prepare_output_buffer (scope, &outbuf);
|
2015-10-01 14:27:55 +00:00
|
|
|
g_mutex_lock (&scope->priv->config_lock);
|
2012-07-08 17:19:38 +00:00
|
|
|
/* recheck as the value could have changed */
|
2016-06-11 02:36:32 +00:00
|
|
|
sbpf = scope->req_spf * bpf;
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
/* no buffer allocated, we don't care why. */
|
|
|
|
if (ret != GST_FLOW_OK)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* sync controlled properties */
|
2012-09-11 23:41:31 +00:00
|
|
|
if (GST_CLOCK_TIME_IS_VALID (ts))
|
|
|
|
gst_object_sync_values (GST_OBJECT (scope), ts);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2016-06-10 18:04:36 +00:00
|
|
|
GST_BUFFER_PTS (outbuf) = ts;
|
2015-10-01 14:27:55 +00:00
|
|
|
GST_BUFFER_DURATION (outbuf) = scope->priv->frame_duration;
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2012-08-13 11:47:01 +00:00
|
|
|
/* this can fail as the data size we need could have changed */
|
2024-03-11 17:30:08 +00:00
|
|
|
if (!(databuf = gst_adapter_get_buffer (scope->priv->adapter, sbpf)))
|
2012-08-13 11:47:01 +00:00
|
|
|
break;
|
|
|
|
|
2022-08-30 12:29:41 +00:00
|
|
|
gst_video_frame_map (&outframe, &scope->vinfo, outbuf,
|
|
|
|
GST_MAP_READWRITE | GST_VIDEO_FRAME_MAP_FLAG_NO_REF);
|
2012-08-13 11:47:01 +00:00
|
|
|
|
2015-10-01 14:27:55 +00:00
|
|
|
if (scope->priv->shader) {
|
|
|
|
gst_video_frame_copy (&outframe, &scope->priv->tempframe);
|
2012-07-08 17:19:38 +00:00
|
|
|
} else {
|
2012-08-17 21:03:52 +00:00
|
|
|
/* gst_video_frame_clear() or is output frame already cleared */
|
2013-03-12 03:55:28 +00:00
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; i < scope->vinfo.finfo->n_planes; i++) {
|
|
|
|
memset (outframe.data[i], 0, outframe.map[i].size);
|
|
|
|
}
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
|
|
|
|
2024-05-04 02:35:21 +00:00
|
|
|
gst_buffer_remove_all_memory (inbuf);
|
2024-03-11 17:30:08 +00:00
|
|
|
gst_buffer_copy_into (inbuf, databuf, GST_BUFFER_COPY_MEMORY, 0, sbpf);
|
|
|
|
gst_buffer_unref (databuf);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
/* call class->render() vmethod */
|
2012-08-13 09:55:58 +00:00
|
|
|
if (klass->render) {
|
2012-08-13 11:47:01 +00:00
|
|
|
if (!klass->render (scope, inbuf, &outframe)) {
|
2012-07-08 17:19:38 +00:00
|
|
|
ret = GST_FLOW_ERROR;
|
2015-01-12 15:27:18 +00:00
|
|
|
gst_video_frame_unmap (&outframe);
|
|
|
|
goto beach;
|
2012-07-08 17:19:38 +00:00
|
|
|
} else {
|
2012-09-08 21:56:56 +00:00
|
|
|
/* run various post processing (shading and geometric transformation) */
|
|
|
|
/* FIXME: SHADER assumes 32bpp */
|
2015-10-01 14:27:55 +00:00
|
|
|
if (scope->priv->shader &&
|
|
|
|
GST_VIDEO_INFO_COMP_PSTRIDE (&scope->vinfo, 0) == 4) {
|
|
|
|
scope->priv->shader (scope, &outframe, &scope->priv->tempframe);
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-08-13 11:47:01 +00:00
|
|
|
gst_video_frame_unmap (&outframe);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2015-10-01 14:27:55 +00:00
|
|
|
g_mutex_unlock (&scope->priv->config_lock);
|
|
|
|
ret = gst_pad_push (scope->priv->srcpad, outbuf);
|
2012-07-08 17:19:38 +00:00
|
|
|
outbuf = NULL;
|
2015-10-01 14:27:55 +00:00
|
|
|
g_mutex_lock (&scope->priv->config_lock);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
skip:
|
|
|
|
/* recheck as the value could have changed */
|
2016-06-11 02:36:32 +00:00
|
|
|
sbpf = scope->req_spf * bpf;
|
2012-07-08 17:19:38 +00:00
|
|
|
GST_LOG_OBJECT (scope, "avail: %u, bpf: %u", avail, sbpf);
|
|
|
|
/* we want to take less or more, depending on spf : req_spf */
|
|
|
|
if (avail - sbpf >= sbpf) {
|
2015-10-01 14:27:55 +00:00
|
|
|
gst_adapter_flush (scope->priv->adapter, sbpf);
|
|
|
|
gst_adapter_unmap (scope->priv->adapter);
|
2012-07-08 17:19:38 +00:00
|
|
|
} else if (avail >= sbpf) {
|
|
|
|
/* just flush a bit and stop */
|
2015-10-01 14:27:55 +00:00
|
|
|
gst_adapter_flush (scope->priv->adapter, (avail - sbpf));
|
|
|
|
gst_adapter_unmap (scope->priv->adapter);
|
2012-07-08 17:19:38 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-10-01 14:27:55 +00:00
|
|
|
avail = gst_adapter_available (scope->priv->adapter);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
if (ret != GST_FLOW_OK)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-10-01 14:27:55 +00:00
|
|
|
g_mutex_unlock (&scope->priv->config_lock);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
beach:
|
|
|
|
return ret;
|
2013-01-29 09:18:06 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
not_negotiated:
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (scope, "Failed to renegotiate");
|
|
|
|
return GST_FLOW_NOT_NEGOTIATED;
|
|
|
|
}
|
2012-07-08 17:19:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2012-07-16 19:58:23 +00:00
|
|
|
gst_audio_visualizer_src_event (GstPad * pad, GstObject * parent,
|
2012-07-08 17:19:38 +00:00
|
|
|
GstEvent * event)
|
|
|
|
{
|
|
|
|
gboolean res;
|
2012-07-16 19:58:23 +00:00
|
|
|
GstAudioVisualizer *scope;
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2012-07-16 19:58:23 +00:00
|
|
|
scope = GST_AUDIO_VISUALIZER (parent);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_QOS:
|
|
|
|
{
|
|
|
|
gdouble proportion;
|
|
|
|
GstClockTimeDiff diff;
|
|
|
|
GstClockTime timestamp;
|
|
|
|
|
|
|
|
gst_event_parse_qos (event, NULL, &proportion, &diff, ×tamp);
|
|
|
|
|
|
|
|
/* save stuff for the _chain() function */
|
|
|
|
GST_OBJECT_LOCK (scope);
|
2015-10-01 14:27:55 +00:00
|
|
|
scope->priv->proportion = proportion;
|
2012-07-08 17:19:38 +00:00
|
|
|
if (diff >= 0)
|
|
|
|
/* we're late, this is a good estimate for next displayable
|
|
|
|
* frame (see part-qos.txt) */
|
2015-10-01 14:27:55 +00:00
|
|
|
scope->priv->earliest_time = timestamp + 2 * diff +
|
|
|
|
scope->priv->frame_duration;
|
2012-07-08 17:19:38 +00:00
|
|
|
else
|
2015-10-01 14:27:55 +00:00
|
|
|
scope->priv->earliest_time = timestamp + diff;
|
2012-07-08 17:19:38 +00:00
|
|
|
GST_OBJECT_UNLOCK (scope);
|
|
|
|
|
2015-10-01 14:27:55 +00:00
|
|
|
res = gst_pad_push_event (scope->priv->sinkpad, event);
|
2012-07-08 17:19:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GST_EVENT_RECONFIGURE:
|
2019-08-29 17:42:39 +00:00
|
|
|
/* don't forward */
|
2012-07-08 17:19:38 +00:00
|
|
|
gst_event_unref (event);
|
|
|
|
res = TRUE;
|
|
|
|
break;
|
|
|
|
default:
|
2012-09-12 10:41:01 +00:00
|
|
|
res = gst_pad_event_default (pad, parent, event);
|
2012-07-08 17:19:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2012-07-16 19:58:23 +00:00
|
|
|
gst_audio_visualizer_sink_event (GstPad * pad, GstObject * parent,
|
2012-07-08 17:19:38 +00:00
|
|
|
GstEvent * event)
|
|
|
|
{
|
|
|
|
gboolean res;
|
2012-07-16 19:58:23 +00:00
|
|
|
GstAudioVisualizer *scope;
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2012-07-16 19:58:23 +00:00
|
|
|
scope = GST_AUDIO_VISUALIZER (parent);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_CAPS:
|
|
|
|
{
|
|
|
|
GstCaps *caps;
|
|
|
|
|
|
|
|
gst_event_parse_caps (event, &caps);
|
2012-07-16 19:58:23 +00:00
|
|
|
res = gst_audio_visualizer_sink_setcaps (scope, caps);
|
2015-01-21 15:22:15 +00:00
|
|
|
gst_event_unref (event);
|
2012-07-08 17:19:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GST_EVENT_FLUSH_STOP:
|
2012-07-16 19:58:23 +00:00
|
|
|
gst_audio_visualizer_reset (scope);
|
2015-06-07 17:23:23 +00:00
|
|
|
res = gst_pad_push_event (scope->priv->srcpad, event);
|
2012-07-08 17:19:38 +00:00
|
|
|
break;
|
|
|
|
case GST_EVENT_SEGMENT:
|
|
|
|
{
|
|
|
|
/* the newsegment values are used to clip the input samples
|
2019-08-29 17:42:39 +00:00
|
|
|
* and to convert the incoming timestamps to running time so
|
2012-07-08 17:19:38 +00:00
|
|
|
* we can do QoS */
|
2015-06-07 17:23:23 +00:00
|
|
|
gst_event_copy_segment (event, &scope->priv->segment);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2015-06-07 17:23:23 +00:00
|
|
|
res = gst_pad_push_event (scope->priv->srcpad, event);
|
2012-07-08 17:19:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2012-09-12 10:41:01 +00:00
|
|
|
res = gst_pad_event_default (pad, parent, event);
|
2012-07-08 17:19:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2012-07-16 19:58:23 +00:00
|
|
|
gst_audio_visualizer_src_query (GstPad * pad, GstObject * parent,
|
2012-07-08 17:19:38 +00:00
|
|
|
GstQuery * query)
|
|
|
|
{
|
|
|
|
gboolean res = FALSE;
|
2012-07-16 19:58:23 +00:00
|
|
|
GstAudioVisualizer *scope;
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2012-07-16 19:58:23 +00:00
|
|
|
scope = GST_AUDIO_VISUALIZER (parent);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
switch (GST_QUERY_TYPE (query)) {
|
|
|
|
case GST_QUERY_LATENCY:
|
|
|
|
{
|
|
|
|
/* We need to send the query upstream and add the returned latency to our
|
|
|
|
* own */
|
|
|
|
GstClockTime min_latency, max_latency;
|
|
|
|
gboolean us_live;
|
|
|
|
GstClockTime our_latency;
|
|
|
|
guint max_samples;
|
|
|
|
gint rate = GST_AUDIO_INFO_RATE (&scope->ainfo);
|
|
|
|
|
|
|
|
if (rate == 0)
|
|
|
|
break;
|
|
|
|
|
2015-06-07 17:23:23 +00:00
|
|
|
if ((res = gst_pad_peer_query (scope->priv->sinkpad, query))) {
|
2012-07-08 17:19:38 +00:00
|
|
|
gst_query_parse_latency (query, &us_live, &min_latency, &max_latency);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (scope, "Peer latency: min %"
|
|
|
|
GST_TIME_FORMAT " max %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (min_latency), GST_TIME_ARGS (max_latency));
|
|
|
|
|
|
|
|
/* the max samples we must buffer buffer */
|
2015-06-07 17:23:23 +00:00
|
|
|
max_samples = MAX (scope->req_spf, scope->priv->spf);
|
2012-07-08 17:19:38 +00:00
|
|
|
our_latency = gst_util_uint64_scale_int (max_samples, GST_SECOND, rate);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (scope, "Our latency: %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (our_latency));
|
|
|
|
|
|
|
|
/* we add some latency but only if we need to buffer more than what
|
|
|
|
* upstream gives us */
|
|
|
|
min_latency += our_latency;
|
|
|
|
if (max_latency != -1)
|
|
|
|
max_latency += our_latency;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (scope, "Calculated total latency : min %"
|
|
|
|
GST_TIME_FORMAT " max %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (min_latency), GST_TIME_ARGS (max_latency));
|
|
|
|
|
|
|
|
gst_query_set_latency (query, TRUE, min_latency, max_latency);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
res = gst_pad_query_default (pad, parent, query);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstStateChangeReturn
|
2012-07-16 19:58:23 +00:00
|
|
|
gst_audio_visualizer_change_state (GstElement * element,
|
2012-07-08 17:19:38 +00:00
|
|
|
GstStateChange transition)
|
|
|
|
{
|
|
|
|
GstStateChangeReturn ret;
|
2012-07-16 19:58:23 +00:00
|
|
|
GstAudioVisualizer *scope;
|
2012-07-08 17:19:38 +00:00
|
|
|
|
2012-07-16 19:58:23 +00:00
|
|
|
scope = GST_AUDIO_VISUALIZER (element);
|
2012-07-08 17:19:38 +00:00
|
|
|
|
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
2012-07-16 19:58:23 +00:00
|
|
|
gst_audio_visualizer_reset (scope);
|
2012-07-08 17:19:38 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
|
|
|
|
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
2013-01-29 09:18:06 +00:00
|
|
|
gst_audio_visualizer_set_allocation (scope, NULL, NULL, NULL, NULL);
|
2012-07-08 17:19:38 +00:00
|
|
|
break;
|
|
|
|
case GST_STATE_CHANGE_READY_TO_NULL:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|