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
25 #include "audio1394.h"
26 #include "audioconfig.h"
27 #include "audiodevice.h"
28 #include "device1394input.h"
29 #include "device1394output.h"
30 #include "iec61883input.h"
31 #include "iec61883output.h"
33 #include "preferences.h"
34 #include "recordconfig.h"
35 #include "vdevice1394.h"
37 #include "playbackconfig.h"
38 #include "videodevice.h"
49 VDevice1394::VDevice1394(VideoDevice *device)
55 VDevice1394::~VDevice1394()
60 void VDevice1394::initialize()
69 int VDevice1394::open_input()
71 // Share audio driver. The audio driver does the capturing in this case
72 // and fills video frames for us.
75 (device->adevice->in_config->driver == AUDIO_1394 ||
76 device->adevice->in_config->driver == AUDIO_DV1394 ||
77 device->adevice->in_config->driver == AUDIO_IEC61883))
79 Audio1394 *low_level = (Audio1394*)device->adevice->lowlevel_in;
80 input_thread = low_level->input_thread;
81 input_iec = low_level->input_iec;
85 if(!input_thread && !input_iec)
87 if(device->in_config->driver == CAPTURE_FIREWIRE)
89 input_thread = new Device1394Input;
90 result = input_thread->open(device->in_config->firewire_path,
91 device->in_config->firewire_port,
92 device->in_config->firewire_channel,
93 device->in_config->capture_length,
98 device->in_config->h);
107 input_iec = new IEC61883Input;
108 result = input_iec->open(device->in_config->firewire_port,
109 device->in_config->firewire_channel,
110 device->in_config->capture_length,
114 device->in_config->w,
115 device->in_config->h);
126 int VDevice1394::open_output()
128 // Share audio driver. The audio driver takes DV frames from us and
130 if(device->adevice &&
131 (device->adevice->out_config->driver == AUDIO_1394 ||
132 device->adevice->out_config->driver == AUDIO_DV1394 ||
133 device->adevice->out_config->driver == AUDIO_IEC61883))
135 Audio1394 *low_level = (Audio1394*)device->adevice->lowlevel_out;
136 output_thread = low_level->output_thread;
137 output_iec = low_level->output_iec;
141 if(!output_thread && !output_iec)
143 if(device->out_config->driver == PLAYBACK_DV1394)
145 output_thread = new Device1394Output(device);
146 output_thread->open(device->out_config->dv1394_path,
147 device->out_config->dv1394_port,
148 device->out_config->dv1394_channel,
153 device->out_config->dv1394_syt);
156 if(device->out_config->driver == PLAYBACK_FIREWIRE)
158 output_thread = new Device1394Output(device);
159 output_thread->open(device->out_config->firewire_path,
160 device->out_config->firewire_port,
161 device->out_config->firewire_channel,
166 device->out_config->firewire_syt);
170 output_iec = new IEC61883Output(device);
171 output_iec->open(device->out_config->firewire_port,
172 device->out_config->firewire_channel,
177 device->out_config->firewire_syt);
184 int VDevice1394::close_all()
203 delete output_thread;
217 if(user_frame) delete user_frame;
223 int VDevice1394::read_buffer(VFrame *frame)
226 if(!input_thread && !input_iec) return 1;
228 if(input_thread) input_thread->read_video(frame);
230 if(input_iec) input_iec->read_video(frame);
236 void VDevice1394::new_output_buffer(VFrame **output,
242 if(colormodel != user_frame->get_color_model())
254 user_frame = new VFrame;
257 user_frame = new VFrame(device->out_w, device->out_h, colormodel);
262 // user_frame->set_shm_offset(0);
263 *output = user_frame;
266 int VDevice1394::write_buffer(VFrame *frame, EDL *edl)
268 if(output_thread) output_thread->write_frame(frame);
270 if(output_iec) output_iec->write_frame(frame);
277 int VDevice1394::can_copy_from(Asset *asset, int output_w, int output_h)