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
23 #include "audio1394.h"
24 #include "audioconfig.h"
25 #include "audiodevice.h"
26 #include "device1394input.h"
27 #include "device1394output.h"
28 #include "iec61883input.h"
29 #include "iec61883output.h"
31 #include "preferences.h"
32 #include "recordconfig.h"
33 #include "vdevice1394.h"
35 #include "playbackconfig.h"
36 #include "videodevice.h"
48 VDevice1394::VDevice1394(VideoDevice *device)
54 VDevice1394::~VDevice1394()
59 int 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_port,
91 device->in_config->firewire_channel,
92 device->in_config->capture_length,
97 device->in_config->h);
106 input_iec = new IEC61883Input;
107 result = input_iec->open(device->in_config->firewire_port,
108 device->in_config->firewire_channel,
109 device->in_config->capture_length,
113 device->in_config->w,
114 device->in_config->h);
125 int VDevice1394::open_output()
127 // Share audio driver. The audio driver takes DV frames from us and
129 if(device->adevice &&
130 (device->adevice->out_config->driver == AUDIO_1394 ||
131 device->adevice->out_config->driver == AUDIO_DV1394 ||
132 device->adevice->out_config->driver == AUDIO_IEC61883))
134 Audio1394 *low_level = (Audio1394*)device->adevice->lowlevel_out;
135 output_thread = low_level->output_thread;
136 output_iec = low_level->output_iec;
140 if(!output_thread && !output_iec)
142 if(device->out_config->driver == PLAYBACK_DV1394)
144 output_thread = new Device1394Output(device);
145 output_thread->open(device->out_config->dv1394_path,
146 device->out_config->dv1394_port,
147 device->out_config->dv1394_channel,
152 device->out_config->dv1394_syt);
155 if(device->out_config->driver == PLAYBACK_FIREWIRE)
157 output_thread = new Device1394Output(device);
158 output_thread->open(device->out_config->firewire_path,
159 device->out_config->firewire_port,
160 device->out_config->firewire_channel,
165 device->out_config->firewire_syt);
169 output_iec = new IEC61883Output(device);
170 output_iec->open(device->out_config->firewire_port,
171 device->out_config->firewire_channel,
176 device->out_config->firewire_syt);
183 int VDevice1394::close_all()
202 delete output_thread;
216 if(user_frame) delete user_frame;
222 int VDevice1394::read_buffer(VFrame *frame)
225 if(!input_thread && !input_iec) return 1;
227 if(input_thread) input_thread->read_video(frame);
229 if(input_iec) input_iec->read_video(frame);
235 void VDevice1394::new_output_buffer(VFrame **output,
240 if(colormodel != user_frame->get_color_model())
252 user_frame = new VFrame;
255 user_frame = new VFrame(0,
265 // user_frame->set_shm_offset(0);
266 *output = user_frame;
269 int VDevice1394::write_buffer(VFrame *frame, EDL *edl)
271 if(output_thread) output_thread->write_frame(frame);
273 if(output_iec) output_iec->write_frame(frame);
280 int VDevice1394::can_copy_from(Asset *asset, int output_w, int output_h)
295 #endif // HAVE_FIREWIRE