2011-05-27 08:14:19 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <2011> Stefan Kost <ensonic@users.sf.net>
|
|
|
|
*
|
2011-06-04 11:33:29 +00:00
|
|
|
* gstbaseaudiovisualizer.c: base class for audio visualisation elements
|
2011-05-27 08:14:19 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2011-06-04 11:33:29 +00:00
|
|
|
#ifndef __GST_BASE_AUDIO_VISUALIZER_H__
|
|
|
|
#define __GST_BASE_AUDIO_VISUALIZER_H__
|
2011-05-27 08:14:19 +00:00
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <gst/base/gstbasetransform.h>
|
|
|
|
|
|
|
|
#include <gst/video/video.h>
|
|
|
|
#include <gst/audio/audio.h>
|
|
|
|
#include <gst/base/gstadapter.h>
|
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
2011-06-04 11:33:29 +00:00
|
|
|
#define GST_TYPE_BASE_AUDIO_VISUALIZER (gst_base_audio_visualizer_get_type())
|
|
|
|
#define GST_BASE_AUDIO_VISUALIZER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_AUDIO_VISUALIZER,GstBaseAudioVisualizer))
|
|
|
|
#define GST_BASE_AUDIO_VISUALIZER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_AUDIO_VISUALIZER,GstBaseAudioVisualizerClass))
|
|
|
|
#define GST_IS_SYNAESTHESIA(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_AUDIO_VISUALIZER))
|
|
|
|
#define GST_IS_SYNAESTHESIA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_AUDIO_VISUALIZER))
|
|
|
|
typedef struct _GstBaseAudioVisualizer GstBaseAudioVisualizer;
|
|
|
|
typedef struct _GstBaseAudioVisualizerClass GstBaseAudioVisualizerClass;
|
2011-05-27 08:14:19 +00:00
|
|
|
|
2011-06-04 11:33:29 +00:00
|
|
|
typedef void (*GstBaseAudioVisualizerShaderFunc)(GstBaseAudioVisualizer *scope, const guint8 *s, guint8 *d);
|
2011-05-27 20:25:00 +00:00
|
|
|
|
|
|
|
/**
|
2011-06-04 11:33:29 +00:00
|
|
|
* GstBaseAudioVisualizerShader:
|
|
|
|
* @GST_BASE_AUDIO_VISUALIZER_SHADER_NONE: no shading
|
|
|
|
* @GST_BASE_AUDIO_VISUALIZER_SHADER_FADE: plain fading
|
|
|
|
* @GST_BASE_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_UP: fade and move up
|
|
|
|
* @GST_BASE_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_DOWN: fade and move down
|
2011-08-12 20:39:53 +00:00
|
|
|
* @GST_BASE_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_LEFT: fade and move left
|
|
|
|
* @GST_BASE_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_RIGHT: fade and move right
|
|
|
|
* @GST_BASE_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_HORIZ_OUT: fade and move horizontally out
|
|
|
|
* @GST_BASE_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_HORIZ_IN: fade and move horizontally in
|
|
|
|
* @GST_BASE_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_VERT_OUT: fade and move vertically out
|
|
|
|
* @GST_BASE_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_VERT_IN: fade and move vertically in
|
2011-05-27 20:25:00 +00:00
|
|
|
*
|
|
|
|
* Different types of supported background shading functions.
|
|
|
|
*/
|
|
|
|
typedef enum {
|
2011-06-04 11:33:29 +00:00
|
|
|
GST_BASE_AUDIO_VISUALIZER_SHADER_NONE,
|
|
|
|
GST_BASE_AUDIO_VISUALIZER_SHADER_FADE,
|
|
|
|
GST_BASE_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_UP,
|
|
|
|
GST_BASE_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_DOWN,
|
2011-08-12 20:39:53 +00:00
|
|
|
GST_BASE_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_LEFT,
|
|
|
|
GST_BASE_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_RIGHT,
|
|
|
|
GST_BASE_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_HORIZ_OUT,
|
|
|
|
GST_BASE_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_HORIZ_IN,
|
|
|
|
GST_BASE_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_VERT_OUT,
|
|
|
|
GST_BASE_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_VERT_IN
|
2011-06-04 11:33:29 +00:00
|
|
|
} GstBaseAudioVisualizerShader;
|
|
|
|
|
|
|
|
struct _GstBaseAudioVisualizer
|
2011-05-27 08:14:19 +00:00
|
|
|
{
|
|
|
|
GstElement parent;
|
|
|
|
|
|
|
|
/* pads */
|
|
|
|
GstPad *srcpad, *sinkpad;
|
|
|
|
|
|
|
|
GstAdapter *adapter;
|
|
|
|
GstBuffer *inbuf;
|
2011-05-27 20:25:00 +00:00
|
|
|
guint8 *pixelbuf;
|
|
|
|
|
2011-06-04 11:33:29 +00:00
|
|
|
GstBaseAudioVisualizerShader shader_type;
|
|
|
|
GstBaseAudioVisualizerShaderFunc shader;
|
2011-05-28 11:08:05 +00:00
|
|
|
guint32 shade_amount;
|
2011-05-27 08:14:19 +00:00
|
|
|
|
|
|
|
guint64 next_ts; /* the timestamp of the next frame */
|
|
|
|
guint64 frame_duration;
|
2011-05-27 20:25:00 +00:00
|
|
|
guint bpf; /* bytes per frame */
|
|
|
|
guint bps; /* bytes per sample */
|
2011-05-27 08:14:19 +00:00
|
|
|
guint spf; /* samples per video frame */
|
2011-05-27 20:12:00 +00:00
|
|
|
guint req_spf; /* min samples per frame wanted by the subclass */
|
2011-05-27 08:14:19 +00:00
|
|
|
|
|
|
|
/* video state */
|
|
|
|
GstVideoFormat video_format;
|
|
|
|
gint fps_n, fps_d;
|
|
|
|
gint width;
|
|
|
|
gint height;
|
|
|
|
gint channels;
|
|
|
|
|
|
|
|
/* audio state */
|
|
|
|
gint sample_rate;
|
|
|
|
gint rate;
|
2011-08-12 19:18:44 +00:00
|
|
|
|
|
|
|
/* configuration mutex */
|
|
|
|
GMutex *config_lock;
|
2011-05-27 08:14:19 +00:00
|
|
|
};
|
|
|
|
|
2011-06-04 11:33:29 +00:00
|
|
|
struct _GstBaseAudioVisualizerClass
|
2011-05-27 08:14:19 +00:00
|
|
|
{
|
|
|
|
GstElementClass parent_class;
|
|
|
|
|
|
|
|
/* virtual function, called whenever the format changes */
|
2011-06-04 11:33:29 +00:00
|
|
|
gboolean (*setup) (GstBaseAudioVisualizer * scope);
|
2011-05-27 08:14:19 +00:00
|
|
|
|
|
|
|
/* virtual function for rendering a frame */
|
2011-06-04 11:33:29 +00:00
|
|
|
gboolean (*render) (GstBaseAudioVisualizer * scope, GstBuffer * audio, GstBuffer * video);
|
2011-05-27 08:14:19 +00:00
|
|
|
};
|
|
|
|
|
2011-06-04 11:33:29 +00:00
|
|
|
GType gst_base_audio_visualizer_get_type (void);
|
2011-05-27 08:14:19 +00:00
|
|
|
|
|
|
|
G_END_DECLS
|
2011-06-04 11:33:29 +00:00
|
|
|
#endif /* __GST_BASE_AUDIO_VISUALIZER_H__ */
|