r1053: Add Russian translation.
[cinelerra_cv.git] / cinelerra / avc1394transport.C
blob6db50433584c59bf484264ea19aa23b3c0f5ab10
1 #include "avc1394transport.h"
2 #include "bcsignals.h"
3 #include "keys.h"
4 #include "language.h"
5 #include "recordmonitor.h"
7 #include <unistd.h>
9 #define POLL_INTERVAL 20000
11 AVC1394TransportThread::AVC1394TransportThread(BC_Title *label, 
12         AVC1394Control *avc)
13  : Thread(1, 0, 0)
15         this->label = label;
16         this->avc = avc;
17         done = 0;
20 AVC1394TransportThread::~AVC1394TransportThread()
22         done = 1;
23         end();
24         join();
27 void AVC1394TransportThread::run()
29         char *text;
30         sleep(5);
31         while(!done)
32         {
33                 Thread::disable_cancel();
34                 text = avc->timecode();
35                 label->lock_window("AVC1394TransportThread::run 1");
36 // Sometimes text is set to NULL for some reason...
37                 if(text == NULL)
38                         label->update("Unknown");
39                 else
40                         label->update(text);
41                 label->unlock_window();
42                 Thread::enable_cancel();
43                 usleep(POLL_INTERVAL);
44         }
53 AVC1394Transport::AVC1394Transport(MWindow *mwindow,
54                 AVC1394Control *avc,
55                 BC_WindowBase *window,
56                 int x,
57                 int y)
59         this->mwindow = mwindow;
60         this->avc = avc;
61         this->window = window;
62         this->x = x;
63         this->y = y;
66 AVC1394Transport::~AVC1394Transport()
71 int AVC1394Transport::create_objects()
73         int x = this->x, y = this->y;
75         window->add_subwindow(start_button = new AVC1394GUISeekStart(mwindow, avc, x, y));
76         x += start_button->get_w();
77         window->add_subwindow(rewind_button = new AVC1394GUIRewind(mwindow, avc, x, y));
78         x += rewind_button->get_w();
79         window->add_subwindow(reverse_button = new  AVC1394GUIReverse(mwindow, avc, x, y));
80         x += reverse_button->get_w();
81         window->add_subwindow(stop_button = new  AVC1394GUIStop(mwindow, avc, x, y));
82     x += stop_button->get_w();
83         window->add_subwindow(pause_button = new AVC1394GUIPause(mwindow, avc, x, y));
84         x += pause_button->get_w();
85         window->add_subwindow(play_button = new  AVC1394GUIPlay(mwindow, avc, x, y));
86     x += play_button->get_w();
87         window->add_subwindow(fforward_button = new  AVC1394GUIFForward(mwindow, avc, x, y));
88         x += fforward_button->get_w();
89         window->add_subwindow(end_button = new AVC1394GUISeekEnd(mwindow, avc, x, y));
90         x += end_button->get_w();
92         x_end = x + 10;
94         return 0;
97 int AVC1394Transport::keypress_event(int keypress)
99         switch(keypress)
100         {
101                 case ' ':
102                         if(avc->current_command == PAUSE)
103                         {
104                                 avc->current_command = NORMAL_FWD;
105                                 avc->play();
106                         }
107                         else
108                         {
109                                 avc->current_command = PAUSE;
110                                 avc->pause();
111                         }
112                         break;
113         }
114         return 0;
117 void AVC1394Transport::reposition_window(int x, int y)
119         this->x = x;
120         this->y = y;
122         start_button->reposition_window(x, y);
123         x += start_button->get_w();
124         rewind_button->reposition_window(x, y);
125    x += rewind_button->get_w();
126         reverse_button->reposition_window(x, y);
127    x += reverse_button->get_w();
128         stop_button->reposition_window(x, y);
129    x += stop_button->get_w();
130         pause_button->reposition_window(x, y);
131         x += pause_button->get_w();
132         play_button->reposition_window(x, y);
133    x += play_button->get_w();
134         fforward_button->reposition_window(x, y);
135         x += fforward_button->get_w();
136         end_button->reposition_window(x, y);
138         x_end = x + 10;
150 AVC1394GUISeekStart::AVC1394GUISeekStart(MWindow *mwindow, AVC1394Control *avc, int x, int y)
151  : BC_Button(x, y, mwindow->theme->get_image_set("rewind"))
153    this->avc = avc;
154    set_tooltip(_("Rewind ( Home )"));
157 AVC1394GUISeekStart::~AVC1394GUISeekStart()
161 int AVC1394GUISeekStart::handle_event()
163         avc->current_command = COMMAND_NONE;
164     avc->seek("00:00:00:00");
165     return 1;
168 int  AVC1394GUISeekStart::keypress_event()
170         if(get_keypress() == HOME) return handle_event();
171         return 0;
175 AVC1394GUIRewind::AVC1394GUIRewind(MWindow *mwindow, AVC1394Control *avc, int x, int y)
176  : BC_Button(x, y, mwindow->theme->get_image_set("fastrev"))
178         this->avc = avc;
179         set_tooltip(_("Fast Reverse ( + )"));
182 AVC1394GUIRewind::~AVC1394GUIRewind()
186 int AVC1394GUIRewind::handle_event()
188         avc->current_command = FAST_REWIND;
189         avc->rewind();
190         return 1;
193 int  AVC1394GUIRewind::keypress_event()
195         if(get_keypress() == KPPLUS) return handle_event();
196         return 0;
199 AVC1394GUIReverse::AVC1394GUIReverse(MWindow *mwindow, AVC1394Control *avc, int x, int y)
200  : BC_Button(x, y, mwindow->theme->get_image_set("reverse"))
202         this->avc = avc;
203         set_tooltip(_("Reverse Play ( 6 )"));
206 AVC1394GUIReverse::~AVC1394GUIReverse()
210 int AVC1394GUIReverse::handle_event()
212         if(avc->current_command == NORMAL_REWIND)
213         {
214                 avc->current_command = PAUSE;
215                 avc->pause();
216         }
217         else
218         {
219                 avc->current_command = NORMAL_REWIND;
220                 avc->reverse();
221         }
222         return 1;
225 int AVC1394GUIReverse::keypress_event()
227         if(get_keypress() == KP6) return handle_event();
228         return 0;
231 AVC1394GUIStop::AVC1394GUIStop(MWindow *mwindow, AVC1394Control *avc, int x, int y)
232  : BC_Button(x, y, mwindow->theme->get_image_set("stop"))
234         this->avc = avc;
235         set_tooltip(_("Stop ( 0 )"));
238 AVC1394GUIStop::~AVC1394GUIStop()
242 int AVC1394GUIStop::handle_event()
244         avc->current_command = COMMAND_NONE;
245         avc->stop();
246         return 1;
249 int AVC1394GUIStop::keypress_event()
251         if(get_keypress() == KPINS) return handle_event();
252         return 0;
255 AVC1394GUIPlay::AVC1394GUIPlay(MWindow *mwindow, AVC1394Control *avc, int x, int y)
256  : BC_Button(x, y, mwindow->theme->get_image_set("play"))
258         this->avc = avc;
259         mode = 0;
260         set_tooltip(_("Play ( 3 )"));
263 AVC1394GUIPlay::~AVC1394GUIPlay()
267 int AVC1394GUIPlay::handle_event()
269         if(avc->current_command == NORMAL_FWD)
270         {
271                 avc->current_command = PAUSE;
272                 avc->pause();
273         }
274         else
275         {
276                 avc->current_command = NORMAL_FWD;
277                 avc->play();
278         }
279         return 1;
282 int AVC1394GUIPlay::keypress_event()
284         if(get_keypress() == KP3) return handle_event();
285         return 0;
288 AVC1394GUIPause::AVC1394GUIPause(MWindow *mwindow, AVC1394Control *avc, int x,
289 int y)
290  : BC_Button(x, y, mwindow->theme->get_image_set("pause"))
292         this->avc = avc;
293         set_tooltip(_("Pause"));
296 AVC1394GUIPause::~AVC1394GUIPause()
300 int AVC1394GUIPause::handle_event()
302         avc->current_command = PAUSE;
303     avc->pause();
304     return 1;
307 int AVC1394GUIPause::keypress_event()
309     return 0;
312 AVC1394GUIFForward::AVC1394GUIFForward(MWindow *mwindow, AVC1394Control *avc, int x, int y)
313  : BC_Button(x, y, mwindow->theme->get_image_set("fastfwd"))
315    this->avc = avc;
316    set_tooltip(_("Fast Forward ( Enter )"));
319 AVC1394GUIFForward::~AVC1394GUIFForward()
323 int AVC1394GUIFForward::handle_event()
325         avc->current_command = FAST_FWD;
326     avc->fforward();
327     return 1;
330 int AVC1394GUIFForward::keypress_event()
332         if(get_keypress() == KPENTER) return handle_event();
333     return 0;
337 AVC1394GUISeekEnd::AVC1394GUISeekEnd(MWindow *mwindow, 
338         AVC1394Control *avc, 
339         int x, 
340         int y)
341  : BC_Button(x, y, mwindow->theme->get_image_set("end"))
343    this->avc = avc;
344    set_tooltip(_("Jump to end ( End )"));
347 AVC1394GUISeekEnd::~AVC1394GUISeekEnd()
351 int AVC1394GUISeekEnd::handle_event()
353    avc->current_command = COMMAND_NONE;
354    avc->seek("ff:ff:ff:ff");
355    return 1;
358 int AVC1394GUISeekEnd::keypress_event()
360         if(get_keypress() == END) return handle_event();
361      return 0;