| 1 | /* GStreamer | 
| 2 |  * Copyright (C) <2011> Stefan Kost <ensonic@users.sf.net> | 
| 3 |  * Copyright (C) <2015> Luis de Bethencourt <luis@debethencourt.com> | 
| 4 |  * | 
| 5 |  * gstaudiovisualizer.c: base class for audio visualisation elements | 
| 6 |  * | 
| 7 |  * This library is free software; you can redistribute it and/or | 
| 8 |  * modify it under the terms of the GNU Library General Public | 
| 9 |  * License as published by the Free Software Foundation; either | 
| 10 |  * version 2 of the License, or (at your option) any later version. | 
| 11 |  * | 
| 12 |  * This library is distributed in the hope that it will be useful, | 
| 13 |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| 14 |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
| 15 |  * Library General Public License for more details. | 
| 16 |  * | 
| 17 |  * You should have received a copy of the GNU Library General Public | 
| 18 |  * License along with this library; if not, write to the | 
| 19 |  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, | 
| 20 |  * Boston, MA 02110-1301, USA. | 
| 21 |  */ | 
| 22 |  | 
| 23 | #ifndef __GST_AUDIO_VISUALIZER_H__ | 
| 24 | #define __GST_AUDIO_VISUALIZER_H__ | 
| 25 |  | 
| 26 | #include <gst/gst.h> | 
| 27 | #include <gst/base/gstbasetransform.h> | 
| 28 |  | 
| 29 | #include <gst/video/video.h> | 
| 30 | #include <gst/audio/audio.h> | 
| 31 | #include <gst/base/gstadapter.h> | 
| 32 | #include <gst/pbutils/pbutils-prelude.h> | 
| 33 |  | 
| 34 | G_BEGIN_DECLS | 
| 35 | #define GST_TYPE_AUDIO_VISUALIZER            (gst_audio_visualizer_get_type()) | 
| 36 | #define GST_AUDIO_VISUALIZER(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_VISUALIZER,GstAudioVisualizer)) | 
| 37 | #define GST_AUDIO_VISUALIZER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_VISUALIZER,GstAudioVisualizerClass)) | 
| 38 | #define GST_AUDIO_VISUALIZER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_AUDIO_VISUALIZER,GstAudioVisualizerClass)) | 
| 39 | #define GST_IS_SYNAESTHESIA(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_VISUALIZER)) | 
| 40 | #define GST_IS_SYNAESTHESIA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_VISUALIZER)) | 
| 41 | typedef struct _GstAudioVisualizer GstAudioVisualizer; | 
| 42 | typedef struct _GstAudioVisualizerClass GstAudioVisualizerClass; | 
| 43 | typedef struct _GstAudioVisualizerPrivate GstAudioVisualizerPrivate; | 
| 44 |  | 
| 45 | typedef void (*GstAudioVisualizerShaderFunc)(GstAudioVisualizer *scope, const GstVideoFrame *s, GstVideoFrame *d); | 
| 46 |  | 
| 47 | /** | 
| 48 |  * GstAudioVisualizerShader: | 
| 49 |  * @GST_AUDIO_VISUALIZER_SHADER_NONE: no shading | 
| 50 |  * @GST_AUDIO_VISUALIZER_SHADER_FADE: plain fading | 
| 51 |  * @GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_UP: fade and move up | 
| 52 |  * @GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_DOWN: fade and move down | 
| 53 |  * @GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_LEFT: fade and move left | 
| 54 |  * @GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_RIGHT: fade and move right | 
| 55 |  * @GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_HORIZ_OUT: fade and move horizontally out | 
| 56 |  * @GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_HORIZ_IN: fade and move horizontally in | 
| 57 |  * @GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_VERT_OUT: fade and move vertically out | 
| 58 |  * @GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_VERT_IN: fade and move vertically in | 
| 59 |  * | 
| 60 |  * Different types of supported background shading functions. | 
| 61 |  */ | 
| 62 | typedef enum { | 
| 63 |   GST_AUDIO_VISUALIZER_SHADER_NONE, | 
| 64 |   GST_AUDIO_VISUALIZER_SHADER_FADE, | 
| 65 |   GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_UP, | 
| 66 |   GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_DOWN, | 
| 67 |   GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_LEFT, | 
| 68 |   GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_RIGHT, | 
| 69 |   GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_HORIZ_OUT, | 
| 70 |   GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_HORIZ_IN, | 
| 71 |   GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_VERT_OUT, | 
| 72 |   GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_VERT_IN | 
| 73 | } GstAudioVisualizerShader; | 
| 74 |  | 
| 75 | struct _GstAudioVisualizer | 
| 76 | { | 
| 77 |   GstElement parent; | 
| 78 |  | 
| 79 |   guint req_spf;                /* min samples per frame wanted by the subclass */ | 
| 80 |  | 
| 81 |   /* video state */ | 
| 82 |   GstVideoInfo vinfo; | 
| 83 |  | 
| 84 |   /* audio state */ | 
| 85 |   GstAudioInfo ainfo; | 
| 86 |  | 
| 87 |   /*< private >*/ | 
| 88 |   GstAudioVisualizerPrivate *priv; | 
| 89 | }; | 
| 90 |  | 
| 91 | struct _GstAudioVisualizerClass | 
| 92 | { | 
| 93 |   /*< private >*/ | 
| 94 |   GstElementClass parent_class; | 
| 95 |  | 
| 96 |   /*< public >*/ | 
| 97 |   /* virtual function, called whenever the format changes */ | 
| 98 |   gboolean (*setup) (GstAudioVisualizer * scope); | 
| 99 |  | 
| 100 |   /* virtual function for rendering a frame */ | 
| 101 |   gboolean (*render) (GstAudioVisualizer * scope, GstBuffer * audio, GstVideoFrame * video); | 
| 102 |  | 
| 103 |   gboolean (*decide_allocation)   (GstAudioVisualizer * scope, GstQuery *query); | 
| 104 | }; | 
| 105 |  | 
| 106 | GST_PBUTILS_API | 
| 107 | GType gst_audio_visualizer_get_type (void); | 
| 108 |  | 
| 109 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (GstAudioVisualizer, gst_object_unref) | 
| 110 |  | 
| 111 | G_END_DECLS | 
| 112 | #endif /* __GST_AUDIO_VISUALIZER_H__ */ | 
| 113 |  |