libvisual  0.5.0
lv_morph.h
1 /* Libvisual - The audio visualisation framework.
2  *
3  * Copyright (C) 2012 Libvisual team
4  * 2004-2006 Dennis Smit
5  *
6  * Authors: Dennis Smit <ds@nerds-incorporated.org>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as
10  * published by the Free Software Foundation; either version 2.1
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  */
22 
23 #ifndef _LV_MORPH_H
24 #define _LV_MORPH_H
25 
26 #include <libvisual/lv_audio.h>
27 #include <libvisual/lv_palette.h>
28 #include <libvisual/lv_plugin.h>
29 #include <libvisual/lv_video.h>
30 #include <libvisual/lv_time.h>
31 
37 #ifdef __cplusplus
38 
39 #include <libvisual/lv_intrusive_ptr.hpp>
40 #include <string>
41 #include <memory>
42 
43 namespace LV {
44 
45  class Morph;
46 
47  typedef LV::IntrusivePtr<Morph> MorphPtr;
48 
50  class LV_API Morph
51  {
52  public:
53 
63  static MorphPtr load (std::string const& name);
64 
65  Morph (Morph const& morph) = delete;
66 
67  ~Morph ();
68 
69  Morph& operator= (Morph const&) = delete;
70 
76  VisPluginData* get_plugin ();
77 
85  bool realize ();
86 
92  VisVideoDepth get_supported_depths ();
93 
94  VisVideoAttrOptions const* get_video_attribute_options ();
95 
101  void set_video (VideoPtr const& video);
102 
108  void set_time (Time const& time);
109 
115  void set_progress (float progress);
116 
124  Palette const* get_palette ();
125 
131  bool is_done ();
132 
144  bool run (Audio const& audio, VideoPtr const& src1, VideoPtr const& src2);
145 
146 private:
147 
148  friend void intrusive_ptr_add_ref (Morph const* morph);
149  friend void intrusive_ptr_release (Morph const* morph);
150 
151  class Impl;
152  const std::unique_ptr<Impl> m_impl;
153 
154  mutable unsigned int m_ref_count;
155 
156  explicit Morph (std::string const& name);
157  };
158 
159  inline void intrusive_ptr_add_ref (Morph const* morph)
160  {
161  morph->m_ref_count++;
162  }
163 
164  inline void intrusive_ptr_release (Morph const* morph)
165  {
166  if (--morph->m_ref_count == 0) {
167  delete morph;
168  }
169  }
170 
171 } // LV namespace
172 
173 typedef LV::Morph VisMorph;
174 
175 #else
176 
177 typedef struct _VisMorph VisMorph;
178 struct _VisMorph;
179 
180 #endif
181 
182 typedef struct _VisMorphPlugin VisMorphPlugin;
183 
196 typedef void (*VisPluginMorphPaletteFunc) (VisPluginData *plugin,
197  float progress,
198  VisAudio *audio,
200  VisVideo *src1,
201  VisVideo *src2);
202 
214 typedef void (*VisPluginMorphApplyFunc) (VisPluginData *plugin,
215  float progress,
216  VisAudio *audio,
217  VisVideo *dest,
218  VisVideo *src1,
219  VisVideo *src2);
220 
228  VisVideoAttrOptions vidoptions;
229 };
230 
231 LV_BEGIN_DECLS
232 
242 LV_API const char *visual_morph_get_next_by_name (const char *name);
243 
253 LV_API const char *visual_morph_get_prev_by_name (const char *name);
254 
255 LV_API VisMorph *visual_morph_new (const char *name);
256 LV_API void visual_morph_ref (VisMorph *morph);
257 LV_API void visual_morph_unref (VisMorph *morph);
258 
259 LV_API VisPluginData *visual_morph_get_plugin (VisMorph *morph);
260 LV_API VisVideoDepth visual_morph_get_supported_depths (VisMorph *morph);
261 LV_API VisVideoAttrOptions *visual_morph_get_video_attribute_options (VisMorph *morph);
262 LV_API int visual_morph_requests_audio (VisMorph *morph);
263 
264 LV_API void visual_morph_set_video (VisMorph *morph, VisVideo *video);
265 LV_API void visual_morph_set_time (VisMorph *morph, VisTime *time);
266 LV_API void visual_morph_set_progress (VisMorph *morph, float progress);
267 
268 LV_API int visual_morph_realize (VisMorph *morph);
269 LV_API int visual_morph_run (VisMorph *morph, VisAudio *audio, VisVideo *src1, VisVideo *src2);
270 LV_API int visual_morph_is_done (VisMorph *morph);
271 
272 LV_API VisPalette *visual_morph_get_palette (VisMorph *morph);
273 
274 LV_END_DECLS
275 
280 #endif /* _LV_MORPH_H */