1 #include "bcdisplayinfo.h"
6 #include "pluginvclient.h"
7 #include "transportque.h"
13 class ReverseVideoConfig
21 class ReverseVideoEnabled : public BC_CheckBox
24 ReverseVideoEnabled(ReverseVideo *plugin,
31 class ReverseVideoWindow : public BC_Window
34 ReverseVideoWindow(ReverseVideo *plugin, int x, int y);
35 ~ReverseVideoWindow();
36 void create_objects();
39 ReverseVideoEnabled *enabled;
42 PLUGIN_THREAD_HEADER(ReverseVideo, ReverseVideoThread, ReverseVideoWindow)
44 class ReverseVideo : public PluginVClient
47 ReverseVideo(PluginServer *server);
50 PLUGIN_CLASS_MEMBERS(ReverseVideoConfig, ReverseVideoThread)
54 void save_data(KeyFrame *keyframe);
55 void read_data(KeyFrame *keyframe);
58 int process_buffer(VFrame *frame,
59 int64_t start_position,
62 int64_t input_position;
71 REGISTER_PLUGIN(ReverseVideo);
75 ReverseVideoConfig::ReverseVideoConfig()
84 ReverseVideoWindow::ReverseVideoWindow(ReverseVideo *plugin, int x, int y)
85 : BC_Window(plugin->gui_string,
96 this->plugin = plugin;
99 ReverseVideoWindow::~ReverseVideoWindow()
103 void ReverseVideoWindow::create_objects()
107 add_subwindow(enabled = new ReverseVideoEnabled(plugin,
114 WINDOW_CLOSE_EVENT(ReverseVideoWindow)
117 PLUGIN_THREAD_OBJECT(ReverseVideo, ReverseVideoThread, ReverseVideoWindow)
124 ReverseVideoEnabled::ReverseVideoEnabled(ReverseVideo *plugin,
129 plugin->config.enabled,
132 this->plugin = plugin;
135 int ReverseVideoEnabled::handle_event()
137 plugin->config.enabled = get_value();
138 plugin->send_configure_change();
150 ReverseVideo::ReverseVideo(PluginServer *server)
151 : PluginVClient(server)
153 PLUGIN_CONSTRUCTOR_MACRO
157 ReverseVideo::~ReverseVideo()
159 PLUGIN_DESTRUCTOR_MACRO
162 char* ReverseVideo::plugin_title() { return N_("Reverse video"); }
163 int ReverseVideo::is_realtime() { return 1; }
165 #include "picon_png.h"
166 NEW_PICON_MACRO(ReverseVideo)
168 SHOW_GUI_MACRO(ReverseVideo, ReverseVideoThread)
170 RAISE_WINDOW_MACRO(ReverseVideo)
172 SET_STRING_MACRO(ReverseVideo);
175 int ReverseVideo::process_buffer(VFrame *frame,
176 int64_t start_position,
179 load_configuration();
197 int ReverseVideo::load_configuration()
199 KeyFrame *prev_keyframe, *next_keyframe;
200 next_keyframe = get_next_keyframe(get_source_position());
201 prev_keyframe = get_prev_keyframe(get_source_position());
202 // Previous keyframe stays in config object.
203 read_data(prev_keyframe);
205 int64_t prev_position = edl_to_local(prev_keyframe->position);
206 int64_t next_position = edl_to_local(next_keyframe->position);
208 if(prev_position == 0 && next_position == 0)
210 next_position = prev_position = get_source_start();
213 // Get range to flip in requested rate
214 int64_t range_start = prev_position;
215 int64_t range_end = next_position;
217 // Between keyframe and edge of range or no keyframes
218 if(range_start == range_end)
220 // Between first keyframe and start of effect
221 if(get_source_position() >= get_source_start() &&
222 get_source_position() < range_start)
224 range_start = get_source_start();
227 // Between last keyframe and end of effect
228 if(get_source_position() >= range_start &&
229 get_source_position() < get_source_start() + get_total_len())
231 range_end = get_source_start() + get_total_len();
235 // Should never get here
241 // Convert start position to new direction
242 if(get_direction() == PLAY_FORWARD)
244 input_position = get_source_position() - range_start;
245 input_position = range_end - input_position - 1;
249 input_position = range_end - get_source_position();
250 input_position = range_start + input_position + 1;
252 // printf("ReverseVideo::load_configuration 2 start=%lld end=%lld current=%lld input=%lld\n",
255 // get_source_position(),
261 int ReverseVideo::load_defaults()
263 char directory[BCTEXTLEN];
264 // set the default directory
265 sprintf(directory, "%sreversevideo.rc", BCASTDIR);
268 defaults = new BC_Hash(directory);
271 config.enabled = defaults->get("ENABLED", config.enabled);
275 int ReverseVideo::save_defaults()
277 defaults->update("ENABLED", config.enabled);
282 void ReverseVideo::save_data(KeyFrame *keyframe)
286 // cause data to be stored directly in text
287 output.set_shared_string(keyframe->data, MESSAGESIZE);
288 output.tag.set_title("REVERSEVIDEO");
289 output.tag.set_property("ENABLED", config.enabled);
291 output.terminate_string();
294 void ReverseVideo::read_data(KeyFrame *keyframe)
298 input.set_shared_string(keyframe->data, strlen(keyframe->data));
302 while(!input.read_tag())
304 if(input.tag.title_is("REVERSEVIDEO"))
306 config.enabled = input.tag.get_property("ENABLED", config.enabled);
311 void ReverseVideo::update_gui()
315 load_configuration();
316 thread->window->lock_window();
317 thread->window->enabled->update(config.enabled);
318 thread->window->unlock_window();