4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "avc1394transport.h"
24 #include "bcsignals.h"
27 #include "recordmonitor.h"
31 #define POLL_INTERVAL 20000
33 AVC1394TransportThread::AVC1394TransportThread(BC_Title *label,
42 AVC1394TransportThread::~AVC1394TransportThread()
49 void AVC1394TransportThread::run()
55 Thread::disable_cancel();
56 text = avc->timecode();
57 label->lock_window("AVC1394TransportThread::run 1");
58 // Sometimes text is set to NULL for some reason...
60 label->update("Unknown");
63 label->unlock_window();
64 Thread::enable_cancel();
65 usleep(POLL_INTERVAL);
75 AVC1394Transport::AVC1394Transport(MWindow *mwindow,
77 BC_WindowBase *window,
81 this->mwindow = mwindow;
83 this->window = window;
88 AVC1394Transport::~AVC1394Transport()
93 void AVC1394Transport::create_objects()
95 int x = this->x, y = this->y;
97 window->add_subwindow(start_button = new AVC1394GUISeekStart(mwindow, avc, x, y));
98 x += start_button->get_w();
99 window->add_subwindow(rewind_button = new AVC1394GUIRewind(mwindow, avc, x, y));
100 x += rewind_button->get_w();
101 window->add_subwindow(reverse_button = new AVC1394GUIReverse(mwindow, avc, x, y));
102 x += reverse_button->get_w();
103 window->add_subwindow(stop_button = new AVC1394GUIStop(mwindow, avc, x, y));
104 x += stop_button->get_w();
105 window->add_subwindow(pause_button = new AVC1394GUIPause(mwindow, avc, x, y));
106 x += pause_button->get_w();
107 window->add_subwindow(play_button = new AVC1394GUIPlay(mwindow, avc, x, y));
108 x += play_button->get_w();
109 window->add_subwindow(fforward_button = new AVC1394GUIFForward(mwindow, avc, x, y));
110 x += fforward_button->get_w();
111 window->add_subwindow(end_button = new AVC1394GUISeekEnd(mwindow, avc, x, y));
112 x += end_button->get_w();
118 int AVC1394Transport::keypress_event(int keypress)
123 if(avc->current_command == PAUSE)
125 avc->current_command = NORMAL_FWD;
130 avc->current_command = PAUSE;
138 void AVC1394Transport::reposition_window(int x, int y)
143 start_button->reposition_window(x, y);
144 x += start_button->get_w();
145 rewind_button->reposition_window(x, y);
146 x += rewind_button->get_w();
147 reverse_button->reposition_window(x, y);
148 x += reverse_button->get_w();
149 stop_button->reposition_window(x, y);
150 x += stop_button->get_w();
151 pause_button->reposition_window(x, y);
152 x += pause_button->get_w();
153 play_button->reposition_window(x, y);
154 x += play_button->get_w();
155 fforward_button->reposition_window(x, y);
156 x += fforward_button->get_w();
157 end_button->reposition_window(x, y);
171 AVC1394GUISeekStart::AVC1394GUISeekStart(MWindow *mwindow, AVC1394Control *avc, int x, int y)
172 : BC_Button(x, y, mwindow->theme->get_image_set("rewind"))
175 set_tooltip(_("Rewind ( Home )"));
178 AVC1394GUISeekStart::~AVC1394GUISeekStart()
182 int AVC1394GUISeekStart::handle_event()
184 avc->current_command = COMMAND_NONE;
185 avc->seek("00:00:00:00");
189 int AVC1394GUISeekStart::keypress_event()
191 if(get_keypress() == HOME) return handle_event();
192 return context_help_check_and_show();
196 AVC1394GUIRewind::AVC1394GUIRewind(MWindow *mwindow, AVC1394Control *avc, int x, int y)
197 : BC_Button(x, y, mwindow->theme->get_image_set("fastrev"))
200 set_tooltip(_("Fast Reverse ( + )"));
203 AVC1394GUIRewind::~AVC1394GUIRewind()
207 int AVC1394GUIRewind::handle_event()
209 avc->current_command = FAST_REWIND;
214 int AVC1394GUIRewind::keypress_event()
216 if(get_keypress() == KPPLUS) return handle_event();
217 return context_help_check_and_show();
220 AVC1394GUIReverse::AVC1394GUIReverse(MWindow *mwindow, AVC1394Control *avc, int x, int y)
221 : BC_Button(x, y, mwindow->theme->get_image_set("reverse"))
224 set_tooltip(_("Reverse Play ( 6 )"));
227 AVC1394GUIReverse::~AVC1394GUIReverse()
231 int AVC1394GUIReverse::handle_event()
233 if(avc->current_command == NORMAL_REWIND)
235 avc->current_command = PAUSE;
240 avc->current_command = NORMAL_REWIND;
246 int AVC1394GUIReverse::keypress_event()
248 if(get_keypress() == KP6) return handle_event();
249 return context_help_check_and_show();
252 AVC1394GUIStop::AVC1394GUIStop(MWindow *mwindow, AVC1394Control *avc, int x, int y)
253 : BC_Button(x, y, mwindow->theme->get_image_set("stop"))
256 set_tooltip(_("Stop ( 0 )"));
259 AVC1394GUIStop::~AVC1394GUIStop()
263 int AVC1394GUIStop::handle_event()
265 avc->current_command = COMMAND_NONE;
270 int AVC1394GUIStop::keypress_event()
272 if(get_keypress() == KPINS) return handle_event();
273 return context_help_check_and_show();
276 AVC1394GUIPlay::AVC1394GUIPlay(MWindow *mwindow, AVC1394Control *avc, int x, int y)
277 : BC_Button(x, y, mwindow->theme->get_image_set("play"))
281 set_tooltip(_("Play ( 3 )"));
284 AVC1394GUIPlay::~AVC1394GUIPlay()
288 int AVC1394GUIPlay::handle_event()
290 if(avc->current_command == NORMAL_FWD)
292 avc->current_command = PAUSE;
297 avc->current_command = NORMAL_FWD;
303 int AVC1394GUIPlay::keypress_event()
305 if(get_keypress() == KP3) return handle_event();
306 return context_help_check_and_show();
309 AVC1394GUIPause::AVC1394GUIPause(MWindow *mwindow, AVC1394Control *avc, int x,
311 : BC_Button(x, y, mwindow->theme->get_image_set("pause"))
314 set_tooltip(_("Pause"));
317 AVC1394GUIPause::~AVC1394GUIPause()
321 int AVC1394GUIPause::handle_event()
323 avc->current_command = PAUSE;
328 int AVC1394GUIPause::keypress_event()
330 return context_help_check_and_show();
333 AVC1394GUIFForward::AVC1394GUIFForward(MWindow *mwindow, AVC1394Control *avc, int x, int y)
334 : BC_Button(x, y, mwindow->theme->get_image_set("fastfwd"))
337 set_tooltip(_("Fast Forward ( Enter )"));
340 AVC1394GUIFForward::~AVC1394GUIFForward()
344 int AVC1394GUIFForward::handle_event()
346 avc->current_command = FAST_FWD;
351 int AVC1394GUIFForward::keypress_event()
353 if(get_keypress() == KPENTER) return handle_event();
354 return context_help_check_and_show();
358 AVC1394GUISeekEnd::AVC1394GUISeekEnd(MWindow *mwindow,
362 : BC_Button(x, y, mwindow->theme->get_image_set("end"))
365 set_tooltip(_("Jump to end ( End )"));
368 AVC1394GUISeekEnd::~AVC1394GUISeekEnd()
372 int AVC1394GUISeekEnd::handle_event()
374 avc->current_command = COMMAND_NONE;
375 avc->seek("ff:ff:ff:ff");
379 int AVC1394GUISeekEnd::keypress_event()
381 if(get_keypress() == END) return handle_event();
382 return context_help_check_and_show();