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 // Based off of the dvcont test app included with libavc1394.
23 // (Originally written by Jason Howard [And based off of gscanbus],
24 // adapted to libavc1394 by Dan Dennedy <dan@dennedy.org>. Released under
27 #include "avc1394control.h"
29 #include "transportque.inc"
31 AVC1394Control::AVC1394Control()
36 void AVC1394Control::initialize()
40 current_command = COMMAND_NONE;
43 device_lock = new Mutex("AVC1394Control::device_lock");
46 handle = raw1394_get_handle();
48 handle = raw1394_new_handle();
50 //printf("AVC1394Control::initialize(): 1\n");
53 //printf("AVC1394Control::initialize(): 2\n");
56 //printf("AVC1394Control::initialize(): 3\n");
57 fprintf(stderr, "AVC1394Control::initialize(): Not Compatable!\n");
61 //printf("AVC1394Control::initialize(): 4\n");
62 fprintf(stderr, "AVC1394Control::initialize(): couldn't get handle\n");
67 if(raw1394_set_port(handle, 0) < 0) {
68 //printf("AVC1394Control::initialize(): 5\n");
69 perror("AVC1394Control::initialize(): couldn't set port");
70 // raw1394_destroy_handle(handle);
74 for(i = 0; i < raw1394_get_nodecount(handle); i++)
76 if(rom1394_get_directory(handle, i, &rom_dir) < 0)
78 //printf("AVC1394Control::initialize(): 6\n");
79 fprintf(stderr, "AVC1394Control::initialize(): node %d\n", i);
80 // raw1394_destroy_handle(handle);
84 if((rom1394_get_node_type(&rom_dir) == ROM1394_NODE_TYPE_AVC) &&
85 avc1394_check_subunit_type(handle, i, AVC1394_SUBUNIT_TYPE_VCR))
87 //printf("AVC1394Control::initialize(): 7\n");
95 //printf("AVC1394Control::initialize(): 8\n");
96 fprintf(stderr, "AVC1394Control::initialize(): No AV/C Devices\n");
97 // raw1394_destroy_handle(handle);
103 AVC1394Control::~AVC1394Control()
105 if(handle) raw1394_destroy_handle(handle);
107 if(device_lock) delete device_lock;
111 void AVC1394Control::play()
113 //printf("AVC1394Control::play(): 1\n");
114 device_lock->lock("AVC1394Control::play");
115 avc1394_vcr_play(handle, device);
116 device_lock->unlock();
119 void AVC1394Control::stop()
121 //printf("AVC1394Control::stop(): 1\n");
122 device_lock->lock("AVC1394Control::stop");
123 avc1394_vcr_stop(handle, device);
124 device_lock->unlock();
127 void AVC1394Control::reverse()
129 //printf("AVC1394Control::reverse(): 1\n");
130 device_lock->lock("AVC1394Control::reverse");
131 avc1394_vcr_reverse(handle, device);
132 device_lock->unlock();
135 void AVC1394Control::rewind()
137 //printf("AVC1394Control::rewind(): 1\n");
138 device_lock->lock("AVC1394Control::rewind");
139 avc1394_vcr_rewind(handle, device);
140 device_lock->unlock();
143 void AVC1394Control::fforward()
145 //printf("AVC1394Control::fforward(): 1\n");
146 device_lock->lock("AVC1394Control::fforward");
147 avc1394_vcr_forward(handle, device);
148 device_lock->unlock();
151 void AVC1394Control::pause()
153 //printf("AVC1394Control::pause(): 1\n");
154 device_lock->lock("AVC1394Control::pause");
155 avc1394_vcr_pause(handle, device);
156 device_lock->unlock();
159 void AVC1394Control::record()
161 //printf("AVC1394Control::record(): 1\n");
162 device_lock->lock("AVC1394Control::record");
163 avc1394_vcr_record(handle, device);
164 device_lock->unlock();
167 void AVC1394Control::eject()
169 //printf("AVC1394Control::eject(): 1\n");
170 device_lock->lock("AVC1394Control::eject");
171 avc1394_vcr_eject(handle, device);
172 device_lock->unlock();
175 void AVC1394Control::get_status()
177 //printf("AVC1394Control::get_status(): 1\n");
178 device_lock->lock("Control::get_status");
179 status = avc1394_vcr_status(handle, device);
180 device_lock->unlock();
181 // printf("Status: %s\n", avc1394_vcr_decode_status(status));
184 char *AVC1394Control::timecode()
186 device_lock->lock("AVC1394Control::timecode");
187 avc1394_vcr_get_timecode2(handle, device, text_return);
188 device_lock->unlock();
192 void AVC1394Control::seek(const char *time)
194 //printf("AVC1394Control::seek(): 1\n");
195 device_lock->lock("AVC1394Control::seek");
196 avc1394_vcr_seek_timecode(handle, device, (char*)time);
197 device_lock->unlock();