libvisual  0.5.0
lv_morph_c.cpp
1 /* Libvisual - The audio visualisation framework.
2  *
3  * Copyright (C) 2012-2013 ibvisual team
4  *
5  * Authors: Chong Kai Xiong <kaixiong@codeleft.sg>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation; either version 2.1
10  * of the License, or (at your option) any later version.
11  *
12  * This program 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
15  * GNU Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */
21 
22 #include "config.h"
23 #include "lv_morph.h"
24 #include "lv_common.h"
25 #include "lv_plugin_registry.h"
26 
27 namespace {
28 
29  LV::PluginList const&
30  get_morph_plugin_list ()
31  {
32  return LV::PluginRegistry::instance()->get_plugins_by_type (VISUAL_PLUGIN_TYPE_MORPH);
33  }
34 
35 } // anonymous namespace
36 
37 const char *visual_morph_get_next_by_name (const char *name)
38 {
39  return LV::plugin_get_next_by_name (get_morph_plugin_list (), name);
40 }
41 
42 const char *visual_morph_get_prev_by_name (const char *name)
43 {
44  return LV::plugin_get_prev_by_name (get_morph_plugin_list (), name);
45 }
46 
47 VisPluginData *visual_morph_get_plugin (VisMorph *morph)
48 {
49  visual_return_val_if_fail (morph != nullptr, nullptr);
50 
51  return morph->get_plugin ();
52 }
53 
54 VisMorph *visual_morph_new (const char *name)
55 {
56  auto self = LV::Morph::load (name);
57  if (self) {
58  LV::intrusive_ptr_add_ref (self.get ());
59  }
60 
61  return self.get ();
62 }
63 
64 int visual_morph_realize (VisMorph *self)
65 {
66  visual_return_val_if_fail (self != nullptr, FALSE);
67 
68  return self->realize ();
69 }
70 
71 VisVideoDepth visual_morph_get_supported_depths (VisMorph *self)
72 {
73  visual_return_val_if_fail (self != nullptr, VISUAL_VIDEO_DEPTH_NONE);
74 
75  return self->get_supported_depths ();
76 }
77 
78 VisVideoAttrOptions *visual_morph_get_video_attribute_options (VisMorph *self)
79 {
80  visual_return_val_if_fail (self != nullptr, nullptr);
81 
82  return const_cast<VisVideoAttrOptions*> (self->get_video_attribute_options ());
83 }
84 
85 void visual_morph_set_video (VisMorph *self, VisVideo *video)
86 {
87  visual_return_if_fail (self != nullptr);
88 
89  self->set_video (video);
90 }
91 
92 void visual_morph_set_time (VisMorph *self, VisTime *time)
93 {
94  visual_return_if_fail (self != nullptr);
95  visual_return_if_fail (time != nullptr);
96 
97  self->set_time (*time);
98 }
99 
100 void visual_morph_set_progress (VisMorph *self, float progress)
101 {
102  visual_return_if_fail (self != nullptr);
103 
104  self->set_progress (progress);
105 }
106 
107 VisPalette *visual_morph_get_palette (VisMorph *self)
108 {
109  visual_return_val_if_fail (self != nullptr, nullptr);
110 
111  return const_cast<LV::Palette*> (self->get_palette ());
112 }
113 
114 int visual_morph_is_done (VisMorph *self)
115 {
116  visual_return_val_if_fail (self != nullptr, TRUE);
117 
118  return self->is_done ();
119 }
120 
121 int visual_morph_run (VisMorph *self, VisAudio *audio, VisVideo *src1, VisVideo *src2)
122 {
123  visual_return_val_if_fail (self != nullptr, FALSE);
124  visual_return_val_if_fail (audio != nullptr, FALSE);
125  visual_return_val_if_fail (src1 != nullptr, FALSE);
126  visual_return_val_if_fail (src2 != nullptr, FALSE);
127 
128  return self->run (*audio, src1, src2);
129 }