libvisual  0.5.0
lv_actor.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_ACTOR_H
24 #define _LV_ACTOR_H
25 
26 #include <libvisual/lv_defines.h>
27 #include <libvisual/lv_types.h>
28 #include <libvisual/lv_video.h>
29 #include <libvisual/lv_plugin.h>
30 #include <libvisual/lv_audio.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 
46  class Actor;
47 
48  typedef LV::IntrusivePtr<Actor> ActorPtr;
49 
51  class LV_API Actor
52  {
53  public:
54 
64  static ActorPtr load (std::string const& name);
65 
66  Actor (Actor const&) = delete;
67 
68  ~Actor ();
69 
70  Actor& operator= (Actor const&) = delete;
71 
77  VisPluginData* get_plugin ();
78 
84  bool realize ();
85 
91  SongInfo const* get_songinfo ();
92 
100  Palette const* get_palette ();
101 
115  bool video_negotiate (VisVideoDepth run_depth, bool noevent, bool forced);
116 
122  VisVideoDepth get_supported_depths ();
123 
124  VisVideoAttrOptions const* get_video_attribute_options ();
125 
133  void set_video (VideoPtr const& video);
134 
135  VideoPtr const& get_video ();
136 
147  void run (Audio const& audio);
148 
149  private:
150 
151  friend void intrusive_ptr_add_ref (Actor const* actor);
152  friend void intrusive_ptr_release (Actor const* actor);
153 
154  class Impl;
155  const std::unique_ptr<Impl> m_impl;
156 
157  mutable unsigned int m_ref_count;
158 
159  explicit Actor (std::string const& name);
160  };
161 
162  inline void intrusive_ptr_add_ref (Actor const* actor)
163  {
164  actor->m_ref_count++;
165  }
166 
167  inline void intrusive_ptr_release (Actor const* actor)
168  {
169  if (--actor->m_ref_count == 0) {
170  delete actor;
171  }
172  }
173 
174 } // LV namespace
175 
176 typedef LV::Actor VisActor;
177 
178 #else
179 
180 typedef struct _VisActor VisActor;
181 struct _VisActor;
182 
183 #endif /* __cplusplus */
184 
194 typedef void (*VisPluginActorRequisitionFunc)(VisPluginData *plugin, int *width, int *height);
195 
205 typedef VisPalette *(*VisPluginActorPaletteFunc)(VisPluginData *plugin);
206 
216 typedef void (*VisPluginActorRenderFunc)(VisPluginData *plugin, VisVideo *video, VisAudio *audio);
217 
221 typedef struct _VisActorPlugin VisActorPlugin;
228  VisVideoAttrOptions vidoptions;
229 };
230 
231 LV_BEGIN_DECLS
232 
233 LV_API VisPluginData *visual_actor_get_plugin (VisActor *actor);
234 
235 LV_API const char *visual_actor_get_prev_by_name_gl (const char *name);
236 LV_API const char *visual_actor_get_next_by_name_gl (const char *name);
237 LV_API const char *visual_actor_get_prev_by_name_nogl (const char *name);
238 LV_API const char *visual_actor_get_next_by_name_nogl (const char *name);
239 LV_API const char *visual_actor_get_prev_by_name (const char *name);
240 LV_API const char *visual_actor_get_next_by_name (const char *name);
241 
242 LV_API VisActor *visual_actor_new (const char *name);
243 LV_API int visual_actor_realize (VisActor *actor);
244 LV_API void visual_actor_run (VisActor *actor, VisAudio *audio);
245 LV_API void visual_actor_ref (VisActor *actor);
246 LV_API void visual_actor_unref (VisActor *actor);
247 
248 LV_API VisSongInfo *visual_actor_get_songinfo (VisActor *actor);
249 LV_API VisPalette *visual_actor_get_palette (VisActor *actor);
250 
251 LV_API VisVideoDepth visual_actor_get_supported_depths (VisActor *actor);
252 LV_API VisVideoAttrOptions *visual_actor_get_video_attribute_options (VisActor *actor);
253 
254 LV_API void visual_actor_set_video (VisActor *actor, VisVideo *video);
255 LV_API VisVideo *visual_actor_get_video (VisActor *actor);
256 
257 LV_API int visual_actor_video_negotiate (VisActor *actor, VisVideoDepth run_depth, int noevent, int forced);
258 
259 LV_END_DECLS
260 
265 #endif /* _LV_ACTOR_H */