Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

avc1394transport.C

Go to the documentation of this file.
00001 #include "avc1394transport.h"
00002 #include "bcsignals.h"
00003 #include "keys.h"
00004 #include "language.h"
00005 #include "recordmonitor.h"
00006 
00007 #include <unistd.h>
00008 
00009 #define POLL_INTERVAL 20000
00010 
00011 AVC1394TransportThread::AVC1394TransportThread(BC_Title *label, 
00012         AVC1394Control *avc)
00013  : Thread(1, 0, 0)
00014 {
00015         this->label = label;
00016         this->avc = avc;
00017         done = 0;
00018 }
00019 
00020 AVC1394TransportThread::~AVC1394TransportThread()
00021 {
00022         done = 1;
00023         end();
00024         join();
00025 }
00026 
00027 void AVC1394TransportThread::run()
00028 {
00029         char *text;
00030         while(!done)
00031         {
00032                 Thread::disable_cancel();
00033 SET_TRACE
00034                 text = avc->timecode();
00035 SET_TRACE
00036                 label->lock_window("AVC1394TransportThread::run 1");
00037 SET_TRACE
00038 // Sometimes text is set to NULL for some reason...
00039                 if(text == NULL)
00040                         label->update("Unknown");
00041                 else
00042                         label->update(text);
00043 SET_TRACE
00044                 label->unlock_window();
00045 SET_TRACE
00046                 Thread::enable_cancel();
00047                 usleep(POLL_INTERVAL);
00048         }
00049 }
00050 
00051 
00052 
00053 
00054 
00055 
00056 
00057 AVC1394Transport::AVC1394Transport(MWindow *mwindow,
00058                 AVC1394Control *avc,
00059                 BC_WindowBase *window,
00060                 int x,
00061                 int y)
00062 {
00063         this->mwindow = mwindow;
00064         this->avc = avc;
00065         this->window = window;
00066         this->x = x;
00067         this->y = y;
00068 }
00069 
00070 AVC1394Transport::~AVC1394Transport()
00071 {
00072 
00073 }
00074 
00075 int AVC1394Transport::create_objects()
00076 {
00077         int x = this->x, y = this->y;
00078 
00079         window->add_subwindow(start_button = new AVC1394GUISeekStart(mwindow, avc, x, y));
00080         x += start_button->get_w();
00081         window->add_subwindow(rewind_button = new AVC1394GUIRewind(mwindow, avc, x, y));
00082         x += rewind_button->get_w();
00083         window->add_subwindow(reverse_button = new  AVC1394GUIReverse(mwindow, avc, x, y));
00084         x += reverse_button->get_w();
00085         window->add_subwindow(stop_button = new  AVC1394GUIStop(mwindow, avc, x, y));
00086     x += stop_button->get_w();
00087         window->add_subwindow(pause_button = new AVC1394GUIPause(mwindow, avc, x, y));
00088         x += pause_button->get_w();
00089         window->add_subwindow(play_button = new  AVC1394GUIPlay(mwindow, avc, x, y));
00090     x += play_button->get_w();
00091         window->add_subwindow(fforward_button = new  AVC1394GUIFForward(mwindow, avc, x, y));
00092         x += fforward_button->get_w();
00093         window->add_subwindow(end_button = new AVC1394GUISeekEnd(mwindow, avc, x, y));
00094         x += end_button->get_w();
00095 
00096         x_end = x + 10;
00097 
00098         return 0;
00099 }
00100 
00101 int AVC1394Transport::keypress_event(int keypress)
00102 {
00103         switch(keypress)
00104         {
00105                 case ' ':
00106                         if(avc->current_command == PAUSE)
00107                         {
00108                                 avc->current_command = NORMAL_FWD;
00109                                 avc->play();
00110                         }
00111                         else
00112                         {
00113                                 avc->current_command = PAUSE;
00114                                 avc->pause();
00115                         }
00116                         break;
00117         }
00118         return 0;
00119 }
00120 
00121 void AVC1394Transport::reposition_window(int x, int y)
00122 {
00123         this->x = x;
00124         this->y = y;
00125 
00126         start_button->reposition_window(x, y);
00127         x += start_button->get_w();
00128         rewind_button->reposition_window(x, y);
00129    x += rewind_button->get_w();
00130         reverse_button->reposition_window(x, y);
00131    x += reverse_button->get_w();
00132         stop_button->reposition_window(x, y);
00133    x += stop_button->get_w();
00134         pause_button->reposition_window(x, y);
00135         x += pause_button->get_w();
00136         play_button->reposition_window(x, y);
00137    x += play_button->get_w();
00138         fforward_button->reposition_window(x, y);
00139         x += fforward_button->get_w();
00140         end_button->reposition_window(x, y);
00141 
00142         x_end = x + 10;
00143 }
00144 
00145 
00146 
00147 
00148 
00149 
00150 
00151 
00152 
00153 
00154 AVC1394GUISeekStart::AVC1394GUISeekStart(MWindow *mwindow, AVC1394Control *avc, int x, int y)
00155  : BC_Button(x, y, mwindow->theme->get_image_set("rewind"))
00156 {
00157    this->avc = avc;
00158    set_tooltip(_("Rewind ( Home )"));
00159 }
00160 
00161 AVC1394GUISeekStart::~AVC1394GUISeekStart()
00162 {
00163 }
00164 
00165 int AVC1394GUISeekStart::handle_event()
00166 {
00167         avc->current_command = COMMAND_NONE;
00168     avc->seek("00:00:00:00");
00169     return 1;
00170 }
00171 
00172 int  AVC1394GUISeekStart::keypress_event()
00173 {
00174         if(get_keypress() == HOME) return handle_event();
00175         return 0;
00176 }
00177 
00178 
00179 AVC1394GUIRewind::AVC1394GUIRewind(MWindow *mwindow, AVC1394Control *avc, int x, int y)
00180  : BC_Button(x, y, mwindow->theme->get_image_set("fastrev"))
00181 {
00182         this->avc = avc;
00183         set_tooltip(_("Fast Reverse ( + )"));
00184 }
00185 
00186 AVC1394GUIRewind::~AVC1394GUIRewind()
00187 {
00188 }
00189 
00190 int AVC1394GUIRewind::handle_event()
00191 {
00192         avc->current_command = FAST_REWIND;
00193         avc->rewind();
00194         return 1;
00195 }
00196 
00197 int  AVC1394GUIRewind::keypress_event()
00198 {
00199         if(get_keypress() == KPPLUS) return handle_event();
00200         return 0;
00201 }
00202 
00203 AVC1394GUIReverse::AVC1394GUIReverse(MWindow *mwindow, AVC1394Control *avc, int x, int y)
00204  : BC_Button(x, y, mwindow->theme->get_image_set("reverse"))
00205 {
00206         this->avc = avc;
00207         set_tooltip(_("Reverse Play ( 6 )"));
00208 }
00209 
00210 AVC1394GUIReverse::~AVC1394GUIReverse()
00211 {
00212 }
00213 
00214 int AVC1394GUIReverse::handle_event()
00215 {
00216         if(avc->current_command == NORMAL_REWIND)
00217         {
00218                 avc->current_command = PAUSE;
00219                 avc->pause();
00220         }
00221         else
00222         {
00223                 avc->current_command = NORMAL_REWIND;
00224                 avc->reverse();
00225         }
00226         return 1;
00227 }
00228 
00229 int AVC1394GUIReverse::keypress_event()
00230 {
00231         if(get_keypress() == KP6) return handle_event();
00232         return 0;
00233 }
00234 
00235 AVC1394GUIStop::AVC1394GUIStop(MWindow *mwindow, AVC1394Control *avc, int x, int y)
00236  : BC_Button(x, y, mwindow->theme->get_image_set("stop"))
00237 {
00238         this->avc = avc;
00239         set_tooltip(_("Stop ( 0 )"));
00240 }
00241 
00242 AVC1394GUIStop::~AVC1394GUIStop()
00243 {
00244 }
00245 
00246 int AVC1394GUIStop::handle_event()
00247 {
00248         avc->current_command = COMMAND_NONE;
00249         avc->stop();
00250         return 1;
00251 }
00252 
00253 int AVC1394GUIStop::keypress_event()
00254 {
00255         if(get_keypress() == KPINS) return handle_event();
00256         return 0;
00257 }
00258 
00259 AVC1394GUIPlay::AVC1394GUIPlay(MWindow *mwindow, AVC1394Control *avc, int x, int y)
00260  : BC_Button(x, y, mwindow->theme->get_image_set("play"))
00261 {
00262         this->avc = avc;
00263         mode = 0;
00264         set_tooltip(_("Play ( 3 )"));
00265 }
00266 
00267 AVC1394GUIPlay::~AVC1394GUIPlay()
00268 {
00269 }
00270 
00271 int AVC1394GUIPlay::handle_event()
00272 {
00273         if(avc->current_command == NORMAL_FWD)
00274         {
00275                 avc->current_command = PAUSE;
00276                 avc->pause();
00277         }
00278         else
00279         {
00280                 avc->current_command = NORMAL_FWD;
00281                 avc->play();
00282         }
00283         return 1;
00284 }
00285 
00286 int AVC1394GUIPlay::keypress_event()
00287 {
00288         if(get_keypress() == KP3) return handle_event();
00289         return 0;
00290 }
00291 
00292 AVC1394GUIPause::AVC1394GUIPause(MWindow *mwindow, AVC1394Control *avc, int x,
00293 int y)
00294  : BC_Button(x, y, mwindow->theme->get_image_set("pause"))
00295 {
00296         this->avc = avc;
00297         set_tooltip(_("Pause"));
00298 }
00299 
00300 AVC1394GUIPause::~AVC1394GUIPause()
00301 {
00302 }
00303 
00304 int AVC1394GUIPause::handle_event()
00305 {
00306         avc->current_command = PAUSE;
00307     avc->pause();
00308     return 1;
00309 }
00310 
00311 int AVC1394GUIPause::keypress_event()
00312 {
00313     return 0;
00314 }
00315 
00316 AVC1394GUIFForward::AVC1394GUIFForward(MWindow *mwindow, AVC1394Control *avc, int x, int y)
00317  : BC_Button(x, y, mwindow->theme->get_image_set("fastfwd"))
00318 {
00319    this->avc = avc;
00320    set_tooltip(_("Fast Forward ( Enter )"));
00321 }
00322 
00323 AVC1394GUIFForward::~AVC1394GUIFForward()
00324 {
00325 }
00326 
00327 int AVC1394GUIFForward::handle_event()
00328 {
00329         avc->current_command = FAST_FWD;
00330     avc->fforward();
00331     return 1;
00332 }
00333 
00334 int AVC1394GUIFForward::keypress_event()
00335 {
00336         if(get_keypress() == KPENTER) return handle_event();
00337     return 0;
00338 }
00339 
00340 
00341 AVC1394GUISeekEnd::AVC1394GUISeekEnd(MWindow *mwindow, 
00342         AVC1394Control *avc, 
00343         int x, 
00344         int y)
00345  : BC_Button(x, y, mwindow->theme->get_image_set("end"))
00346 {
00347    this->avc = avc;
00348    set_tooltip(_("Jump to end ( End )"));
00349 }
00350 
00351 AVC1394GUISeekEnd::~AVC1394GUISeekEnd()
00352 {
00353 }
00354 
00355 int AVC1394GUISeekEnd::handle_event()
00356 {
00357    avc->current_command = COMMAND_NONE;
00358    avc->seek("ff:ff:ff:ff");
00359    return 1;
00360 }
00361 
00362 int AVC1394GUISeekEnd::keypress_event()
00363 {
00364         if(get_keypress() == END) return handle_event();
00365      return 0;
00366 }
00367 

Generated on Sun Jan 8 13:38:50 2006 for Cinelerra-svn by  doxygen 1.4.4