2 * Copyright (C) <2011> Stefan Kost <ensonic@users.sf.net>
4 * gstaudiobasevisualizer.c: base class for audio visualisation elements
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #ifndef __GST_AUDIO_BASE_VISUALIZER_H__
22 #define __GST_AUDIO_BASE_VISUALIZER_H__
25 #include <gst/base/gstbasetransform.h>
27 #include <gst/video/video.h>
28 #include <gst/audio/audio.h>
29 #include <gst/base/gstadapter.h>
32 #define GST_TYPE_AUDIO_BASE_VISUALIZER (gst_audio_base_visualizer_get_type())
33 #define GST_AUDIO_BASE_VISUALIZER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_BASE_VISUALIZER,GstAudioBaseVisualizer))
34 #define GST_AUDIO_BASE_VISUALIZER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_BASE_VISUALIZER,GstAudioBaseVisualizerClass))
35 #define GST_IS_SYNAESTHESIA(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_BASE_VISUALIZER))
36 #define GST_IS_SYNAESTHESIA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_BASE_VISUALIZER))
37 typedef struct _GstAudioBaseVisualizer GstAudioBaseVisualizer;
38 typedef struct _GstAudioBaseVisualizerClass GstAudioBaseVisualizerClass;
40 typedef void (*GstAudioBaseVisualizerShaderFunc)(GstAudioBaseVisualizer *scope, const guint8 *s, guint8 *d);
43 * GstAudioBaseVisualizerShader:
44 * @GST_AUDIO_BASE_VISUALIZER_SHADER_NONE: no shading
45 * @GST_AUDIO_BASE_VISUALIZER_SHADER_FADE: plain fading
46 * @GST_AUDIO_BASE_VISUALIZER_SHADER_FADE_AND_MOVE_UP: fade and move up
47 * @GST_AUDIO_BASE_VISUALIZER_SHADER_FADE_AND_MOVE_DOWN: fade and move down
48 * @GST_AUDIO_BASE_VISUALIZER_SHADER_FADE_AND_MOVE_LEFT: fade and move left
49 * @GST_AUDIO_BASE_VISUALIZER_SHADER_FADE_AND_MOVE_RIGHT: fade and move right
50 * @GST_AUDIO_BASE_VISUALIZER_SHADER_FADE_AND_MOVE_HORIZ_OUT: fade and move horizontally out
51 * @GST_AUDIO_BASE_VISUALIZER_SHADER_FADE_AND_MOVE_HORIZ_IN: fade and move horizontally in
52 * @GST_AUDIO_BASE_VISUALIZER_SHADER_FADE_AND_MOVE_VERT_OUT: fade and move vertically out
53 * @GST_AUDIO_BASE_VISUALIZER_SHADER_FADE_AND_MOVE_VERT_IN: fade and move vertically in
55 * Different types of supported background shading functions.
58 GST_AUDIO_BASE_VISUALIZER_SHADER_NONE,
59 GST_AUDIO_BASE_VISUALIZER_SHADER_FADE,
60 GST_AUDIO_BASE_VISUALIZER_SHADER_FADE_AND_MOVE_UP,
61 GST_AUDIO_BASE_VISUALIZER_SHADER_FADE_AND_MOVE_DOWN,
62 GST_AUDIO_BASE_VISUALIZER_SHADER_FADE_AND_MOVE_LEFT,
63 GST_AUDIO_BASE_VISUALIZER_SHADER_FADE_AND_MOVE_RIGHT,
64 GST_AUDIO_BASE_VISUALIZER_SHADER_FADE_AND_MOVE_HORIZ_OUT,
65 GST_AUDIO_BASE_VISUALIZER_SHADER_FADE_AND_MOVE_HORIZ_IN,
66 GST_AUDIO_BASE_VISUALIZER_SHADER_FADE_AND_MOVE_VERT_OUT,
67 GST_AUDIO_BASE_VISUALIZER_SHADER_FADE_AND_MOVE_VERT_IN
68 } GstAudioBaseVisualizerShader;
70 struct _GstAudioBaseVisualizer
75 GstPad *srcpad, *sinkpad;
82 GstAudioBaseVisualizerShader shader_type;
83 GstAudioBaseVisualizerShaderFunc shader;
86 guint spf; /* samples per video frame */
87 guint req_spf; /* min samples per frame wanted by the subclass */
91 GstVideoFormat video_format;
95 guint64 frame_duration;
96 guint bpf; /* bytes per frame */
101 /* configuration mutex */
104 /* QoS stuff *//* with LOCK */
106 GstClockTime earliest_time;
111 struct _GstAudioBaseVisualizerClass
113 GstElementClass parent_class;
115 /* virtual function, called whenever the format changes */
116 gboolean (*setup) (GstAudioBaseVisualizer * scope);
118 /* virtual function for rendering a frame */
119 gboolean (*render) (GstAudioBaseVisualizer * scope, GstBuffer * audio, GstBuffer * video);
122 GType gst_audio_base_visualizer_get_type (void);
125 #endif /* __GST_AUDIO_BASE_VISUALIZER_H__ */