1 // Based off of the dvcont test app included with libavc1394.
2 // (Originally written by Jason Howard [And based off of gscanbus],
3 // adapted to libavc1394 by Dan Dennedy <dan@dennedy.org>. Released under
6 #include "avc1394control.h"
8 #include "transportque.inc"
10 AVC1394Control::AVC1394Control()
15 void AVC1394Control::initialize()
19 current_command = COMMAND_NONE;
22 device_lock = new Mutex;
25 handle = raw1394_get_handle();
27 handle = raw1394_new_handle();
29 //printf("AVC1394Control::initialize(): 1\n");
32 //printf("AVC1394Control::initialize(): 2\n");
35 //printf("AVC1394Control::initialize(): 3\n");
36 fprintf(stderr, "AVC1394Control::initialize(): Not Compatable!\n");
40 //printf("AVC1394Control::initialize(): 4\n");
41 fprintf(stderr, "AVC1394Control::initialize(): couldn't get handle\n");
46 if(raw1394_set_port(handle, 0) < 0) {
47 //printf("AVC1394Control::initialize(): 5\n");
48 perror("AVC1394Control::initialize(): couldn't set port");
49 // raw1394_destroy_handle(handle);
53 for(i = 0; i < raw1394_get_nodecount(handle); i++)
55 if(rom1394_get_directory(handle, i, &rom_dir) < 0)
57 //printf("AVC1394Control::initialize(): 6\n");
58 fprintf(stderr, "AVC1394Control::initialize(): node %d\n", i);
59 // raw1394_destroy_handle(handle);
63 if((rom1394_get_node_type(&rom_dir) == ROM1394_NODE_TYPE_AVC) &&
64 avc1394_check_subunit_type(handle, i, AVC1394_SUBUNIT_TYPE_VCR))
66 //printf("AVC1394Control::initialize(): 7\n");
74 //printf("AVC1394Control::initialize(): 8\n");
75 fprintf(stderr, "AVC1394Control::initialize(): No AV/C Devices\n");
76 // raw1394_destroy_handle(handle);
82 AVC1394Control::~AVC1394Control()
84 if(handle) raw1394_destroy_handle(handle);
86 if(device_lock) delete device_lock;
90 void AVC1394Control::play()
92 //printf("AVC1394Control::play(): 1\n");
94 avc1394_vcr_play(handle, device);
95 device_lock->unlock();
98 void AVC1394Control::stop()
100 //printf("AVC1394Control::stop(): 1\n");
102 avc1394_vcr_stop(handle, device);
103 device_lock->unlock();
106 void AVC1394Control::reverse()
108 //printf("AVC1394Control::reverse(): 1\n");
110 avc1394_vcr_reverse(handle, device);
111 device_lock->unlock();
114 void AVC1394Control::rewind()
116 //printf("AVC1394Control::rewind(): 1\n");
118 avc1394_vcr_rewind(handle, device);
119 device_lock->unlock();
122 void AVC1394Control::fforward()
124 //printf("AVC1394Control::fforward(): 1\n");
126 avc1394_vcr_forward(handle, device);
127 device_lock->unlock();
130 void AVC1394Control::pause()
132 //printf("AVC1394Control::pause(): 1\n");
134 avc1394_vcr_pause(handle, device);
135 device_lock->unlock();
138 void AVC1394Control::record()
140 //printf("AVC1394Control::record(): 1\n");
142 avc1394_vcr_record(handle, device);
143 device_lock->unlock();
146 void AVC1394Control::eject()
148 //printf("AVC1394Control::eject(): 1\n");
150 avc1394_vcr_eject(handle, device);
151 device_lock->unlock();
154 void AVC1394Control::get_status()
156 //printf("AVC1394Control::get_status(): 1\n");
158 status = avc1394_vcr_status(handle, device);
159 device_lock->unlock();
160 // printf("Status: %s\n", avc1394_vcr_decode_status(status));
163 char *AVC1394Control::timecode()
165 //printf("AVC1394Control::timecode(): 1\n");
167 text = (char *) malloc(12);
169 text = avc1394_vcr_get_timecode(handle, device);
170 device_lock->unlock();
174 void AVC1394Control::seek(char *time)
176 //printf("AVC1394Control::seek(): 1\n");
178 avc1394_vcr_seek_timecode(handle, device, time);
179 device_lock->unlock();