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
22 #include "avc1394transport.h"
23 #include "bcsignals.h"
26 #include "recordmonitor.h"
30 #define POLL_INTERVAL 20000
32 AVC1394TransportThread::AVC1394TransportThread(BC_Title *label,
41 AVC1394TransportThread::~AVC1394TransportThread()
48 void AVC1394TransportThread::run()
54 Thread::disable_cancel();
55 text = avc->timecode();
56 label->lock_window("AVC1394TransportThread::run 1");
57 // Sometimes text is set to NULL for some reason...
59 label->update("Unknown");
62 label->unlock_window();
63 Thread::enable_cancel();
64 usleep(POLL_INTERVAL);
74 AVC1394Transport::AVC1394Transport(MWindow *mwindow,
76 BC_WindowBase *window,
80 this->mwindow = mwindow;
82 this->window = window;
87 AVC1394Transport::~AVC1394Transport()
92 void AVC1394Transport::create_objects()
94 int x = this->x, y = this->y;
96 window->add_subwindow(start_button = new AVC1394GUISeekStart(mwindow, avc, x, y));
97 x += start_button->get_w();
98 window->add_subwindow(rewind_button = new AVC1394GUIRewind(mwindow, avc, x, y));
99 x += rewind_button->get_w();
100 window->add_subwindow(reverse_button = new AVC1394GUIReverse(mwindow, avc, x, y));
101 x += reverse_button->get_w();
102 window->add_subwindow(stop_button = new AVC1394GUIStop(mwindow, avc, x, y));
103 x += stop_button->get_w();
104 window->add_subwindow(pause_button = new AVC1394GUIPause(mwindow, avc, x, y));
105 x += pause_button->get_w();
106 window->add_subwindow(play_button = new AVC1394GUIPlay(mwindow, avc, x, y));
107 x += play_button->get_w();
108 window->add_subwindow(fforward_button = new AVC1394GUIFForward(mwindow, avc, x, y));
109 x += fforward_button->get_w();
110 window->add_subwindow(end_button = new AVC1394GUISeekEnd(mwindow, avc, x, y));
111 x += end_button->get_w();
117 int AVC1394Transport::keypress_event(int keypress)
122 if(avc->current_command == PAUSE)
124 avc->current_command = NORMAL_FWD;
129 avc->current_command = PAUSE;
137 void AVC1394Transport::reposition_window(int x, int y)
142 start_button->reposition_window(x, y);
143 x += start_button->get_w();
144 rewind_button->reposition_window(x, y);
145 x += rewind_button->get_w();
146 reverse_button->reposition_window(x, y);
147 x += reverse_button->get_w();
148 stop_button->reposition_window(x, y);
149 x += stop_button->get_w();
150 pause_button->reposition_window(x, y);
151 x += pause_button->get_w();
152 play_button->reposition_window(x, y);
153 x += play_button->get_w();
154 fforward_button->reposition_window(x, y);
155 x += fforward_button->get_w();
156 end_button->reposition_window(x, y);
170 AVC1394GUISeekStart::AVC1394GUISeekStart(MWindow *mwindow, AVC1394Control *avc, int x, int y)
171 : BC_Button(x, y, mwindow->theme->get_image_set("rewind"))
174 set_tooltip(_("Rewind ( Home )"));
177 AVC1394GUISeekStart::~AVC1394GUISeekStart()
181 int AVC1394GUISeekStart::handle_event()
183 avc->current_command = COMMAND_NONE;
184 avc->seek("00:00:00:00");
188 int AVC1394GUISeekStart::keypress_event()
190 if(get_keypress() == HOME) return handle_event();
195 AVC1394GUIRewind::AVC1394GUIRewind(MWindow *mwindow, AVC1394Control *avc, int x, int y)
196 : BC_Button(x, y, mwindow->theme->get_image_set("fastrev"))
199 set_tooltip(_("Fast Reverse ( + )"));
202 AVC1394GUIRewind::~AVC1394GUIRewind()
206 int AVC1394GUIRewind::handle_event()
208 avc->current_command = FAST_REWIND;
213 int AVC1394GUIRewind::keypress_event()
215 if(get_keypress() == KPPLUS) return handle_event();
219 AVC1394GUIReverse::AVC1394GUIReverse(MWindow *mwindow, AVC1394Control *avc, int x, int y)
220 : BC_Button(x, y, mwindow->theme->get_image_set("reverse"))
223 set_tooltip(_("Reverse Play ( 6 )"));
226 AVC1394GUIReverse::~AVC1394GUIReverse()
230 int AVC1394GUIReverse::handle_event()
232 if(avc->current_command == NORMAL_REWIND)
234 avc->current_command = PAUSE;
239 avc->current_command = NORMAL_REWIND;
245 int AVC1394GUIReverse::keypress_event()
247 if(get_keypress() == KP6) return handle_event();
251 AVC1394GUIStop::AVC1394GUIStop(MWindow *mwindow, AVC1394Control *avc, int x, int y)
252 : BC_Button(x, y, mwindow->theme->get_image_set("stop"))
255 set_tooltip(_("Stop ( 0 )"));
258 AVC1394GUIStop::~AVC1394GUIStop()
262 int AVC1394GUIStop::handle_event()
264 avc->current_command = COMMAND_NONE;
269 int AVC1394GUIStop::keypress_event()
271 if(get_keypress() == KPINS) return handle_event();
275 AVC1394GUIPlay::AVC1394GUIPlay(MWindow *mwindow, AVC1394Control *avc, int x, int y)
276 : BC_Button(x, y, mwindow->theme->get_image_set("play"))
280 set_tooltip(_("Play ( 3 )"));
283 AVC1394GUIPlay::~AVC1394GUIPlay()
287 int AVC1394GUIPlay::handle_event()
289 if(avc->current_command == NORMAL_FWD)
291 avc->current_command = PAUSE;
296 avc->current_command = NORMAL_FWD;
302 int AVC1394GUIPlay::keypress_event()
304 if(get_keypress() == KP3) return handle_event();
308 AVC1394GUIPause::AVC1394GUIPause(MWindow *mwindow, AVC1394Control *avc, int x,
310 : BC_Button(x, y, mwindow->theme->get_image_set("pause"))
313 set_tooltip(_("Pause"));
316 AVC1394GUIPause::~AVC1394GUIPause()
320 int AVC1394GUIPause::handle_event()
322 avc->current_command = PAUSE;
327 int AVC1394GUIPause::keypress_event()
332 AVC1394GUIFForward::AVC1394GUIFForward(MWindow *mwindow, AVC1394Control *avc, int x, int y)
333 : BC_Button(x, y, mwindow->theme->get_image_set("fastfwd"))
336 set_tooltip(_("Fast Forward ( Enter )"));
339 AVC1394GUIFForward::~AVC1394GUIFForward()
343 int AVC1394GUIFForward::handle_event()
345 avc->current_command = FAST_FWD;
350 int AVC1394GUIFForward::keypress_event()
352 if(get_keypress() == KPENTER) return handle_event();
357 AVC1394GUISeekEnd::AVC1394GUISeekEnd(MWindow *mwindow,
361 : BC_Button(x, y, mwindow->theme->get_image_set("end"))
364 set_tooltip(_("Jump to end ( End )"));
367 AVC1394GUISeekEnd::~AVC1394GUISeekEnd()
371 int AVC1394GUISeekEnd::handle_event()
373 avc->current_command = COMMAND_NONE;
374 avc->seek("ff:ff:ff:ff");
378 int AVC1394GUISeekEnd::keypress_event()
380 if(get_keypress() == END) return handle_event();