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

avc1394control.C

Go to the documentation of this file.
00001 // Based off of the dvcont test app included with libavc1394.
00002 // (Originally written by Jason Howard [And based off of gscanbus],
00003 // adapted to libavc1394 by Dan Dennedy <dan@dennedy.org>. Released under
00004 // the GPL.)
00005 
00006 #include "avc1394control.h"
00007 #include "mutex.h"
00008 #include "transportque.inc"
00009 
00010 AVC1394Control::AVC1394Control()
00011 {
00012         initialize();
00013 }
00014 
00015 void AVC1394Control::initialize()
00016 {
00017         int i;
00018 
00019         current_command = COMMAND_NONE;
00020         device = -1;
00021 
00022         device_lock = new Mutex("AVC1394Control::device_lock");
00023 
00024 #ifdef RAW1394_V_0_8
00025         handle = raw1394_get_handle();
00026 #else
00027         handle = raw1394_new_handle();
00028 #endif
00029 //printf("AVC1394Control::initialize(): 1\n");
00030         if(!handle)
00031         {
00032 //printf("AVC1394Control::initialize(): 2\n");
00033                 if(!errno)
00034                 {
00035 //printf("AVC1394Control::initialize(): 3\n");
00036                         fprintf(stderr, "AVC1394Control::initialize(): Not Compatable!\n");
00037                 } 
00038                 else 
00039                 {
00040 //printf("AVC1394Control::initialize(): 4\n");
00041                         fprintf(stderr, "AVC1394Control::initialize(): couldn't get handle\n");
00042                 }
00043                 return;
00044         }
00045 
00046         if(raw1394_set_port(handle, 0) < 0) {
00047 //printf("AVC1394Control::initialize(): 5\n");
00048                 perror("AVC1394Control::initialize(): couldn't set port");
00049 //              raw1394_destroy_handle(handle);
00050                 return;
00051         }
00052 
00053         for(i = 0; i < raw1394_get_nodecount(handle); i++)
00054         {
00055                 if(rom1394_get_directory(handle, i, &rom_dir) < 0)
00056                 {
00057 //printf("AVC1394Control::initialize(): 6\n");
00058                         fprintf(stderr, "AVC1394Control::initialize(): node %d\n", i);
00059 //                      raw1394_destroy_handle(handle);
00060                         return;
00061                 }
00062                 
00063                 if((rom1394_get_node_type(&rom_dir) == ROM1394_NODE_TYPE_AVC) &&
00064                         avc1394_check_subunit_type(handle, i, AVC1394_SUBUNIT_TYPE_VCR))
00065                 {
00066 //printf("AVC1394Control::initialize(): 7\n");
00067                         device = i;
00068                         break;
00069                 }
00070         }
00071 
00072         if(device == -1)
00073         {
00074 //printf("AVC1394Control::initialize(): 8\n");
00075                 fprintf(stderr, "AVC1394Control::initialize(): No AV/C Devices\n");
00076 //              raw1394_destroy_handle(handle);
00077                 return;
00078         }
00079 
00080 }
00081 
00082 AVC1394Control::~AVC1394Control()
00083 {
00084         if(handle) raw1394_destroy_handle(handle);
00085 
00086         if(device_lock) delete device_lock;
00087 
00088 }
00089 
00090 void AVC1394Control::play()
00091 {
00092 //printf("AVC1394Control::play(): 1\n");
00093         device_lock->lock("AVC1394Control::play");
00094         avc1394_vcr_play(handle, device);
00095         device_lock->unlock();
00096 }
00097 
00098 void AVC1394Control::stop()
00099 {
00100 //printf("AVC1394Control::stop(): 1\n");
00101         device_lock->lock("AVC1394Control::stop");
00102         avc1394_vcr_stop(handle, device);
00103         device_lock->unlock();
00104 }
00105 
00106 void AVC1394Control::reverse()
00107 {
00108 //printf("AVC1394Control::reverse(): 1\n");
00109         device_lock->lock("AVC1394Control::reverse");
00110         avc1394_vcr_reverse(handle, device);
00111         device_lock->unlock();
00112 }
00113 
00114 void AVC1394Control::rewind()
00115 {
00116 //printf("AVC1394Control::rewind(): 1\n");
00117         device_lock->lock("AVC1394Control::rewind");
00118         avc1394_vcr_rewind(handle, device);
00119         device_lock->unlock();
00120 }
00121 
00122 void AVC1394Control::fforward()
00123 {
00124 //printf("AVC1394Control::fforward(): 1\n");
00125         device_lock->lock("AVC1394Control::fforward");
00126         avc1394_vcr_forward(handle, device);
00127         device_lock->unlock();
00128 }
00129 
00130 void AVC1394Control::pause()
00131 {
00132 //printf("AVC1394Control::pause(): 1\n");
00133         device_lock->lock("AVC1394Control::pause");
00134         avc1394_vcr_pause(handle, device);
00135         device_lock->unlock();
00136 }
00137 
00138 void AVC1394Control::record()
00139 {
00140 //printf("AVC1394Control::record(): 1\n");
00141         device_lock->lock("AVC1394Control::record");
00142         avc1394_vcr_record(handle, device);
00143         device_lock->unlock();
00144 }
00145 
00146 void AVC1394Control::eject()
00147 {
00148 //printf("AVC1394Control::eject(): 1\n");
00149         device_lock->lock("AVC1394Control::eject");
00150         avc1394_vcr_eject(handle, device);
00151         device_lock->unlock();
00152 }
00153 
00154 void AVC1394Control::get_status()
00155 {
00156 //printf("AVC1394Control::get_status(): 1\n");
00157         device_lock->lock("Control::get_status");
00158         status = avc1394_vcr_status(handle, device);
00159         device_lock->unlock();
00160 //      printf("Status: %s\n", avc1394_vcr_decode_status(status));
00161 }
00162 
00163 char *AVC1394Control::timecode()
00164 {
00165         device_lock->lock("AVC1394Control::timecode");
00166         avc1394_vcr_get_timecode2(handle, device, text_return);
00167         device_lock->unlock();
00168         return text_return;
00169 }
00170 
00171 void AVC1394Control::seek(char *time)
00172 {
00173 //printf("AVC1394Control::seek(): 1\n");
00174         device_lock->lock("AVC1394Control::seek");
00175         avc1394_vcr_seek_timecode(handle, device, time);
00176         device_lock->unlock();
00177 }

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