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"
47 VDevice1394::VDevice1394(VideoDevice *device)
53 VDevice1394::~VDevice1394()
58 void VDevice1394::initialize()
67 int VDevice1394::open_input()
69 // Share audio driver. The audio driver does the capturing in this case
70 // and fills video frames for us.
73 (device->adevice->in_config->driver == AUDIO_1394 ||
74 device->adevice->in_config->driver == AUDIO_DV1394 ||
75 device->adevice->in_config->driver == AUDIO_IEC61883))
77 Audio1394 *low_level = (Audio1394*)device->adevice->lowlevel_in;
78 input_thread = low_level->input_thread;
79 input_iec = low_level->input_iec;
83 if(!input_thread && !input_iec)
85 if(device->in_config->driver == CAPTURE_FIREWIRE)
87 input_thread = new Device1394Input;
88 result = input_thread->open(device->in_config->firewire_path,
89 device->in_config->firewire_port,
90 device->in_config->firewire_channel,
91 device->in_config->capture_length,
96 device->in_config->h);
105 input_iec = new IEC61883Input;
106 result = input_iec->open(device->in_config->firewire_port,
107 device->in_config->firewire_channel,
108 device->in_config->capture_length,
112 device->in_config->w,
113 device->in_config->h);
124 int VDevice1394::open_output()
126 // Share audio driver. The audio driver takes DV frames from us and
128 if(device->adevice &&
129 (device->adevice->out_config->driver == AUDIO_1394 ||
130 device->adevice->out_config->driver == AUDIO_DV1394 ||
131 device->adevice->out_config->driver == AUDIO_IEC61883))
133 Audio1394 *low_level = (Audio1394*)device->adevice->lowlevel_out;
134 output_thread = low_level->output_thread;
135 output_iec = low_level->output_iec;
139 if(!output_thread && !output_iec)
141 if(device->out_config->driver == PLAYBACK_DV1394)
143 output_thread = new Device1394Output(device);
144 output_thread->open(device->out_config->dv1394_path,
145 device->out_config->dv1394_port,
146 device->out_config->dv1394_channel,
151 device->out_config->dv1394_syt);
154 if(device->out_config->driver == PLAYBACK_FIREWIRE)
156 output_thread = new Device1394Output(device);
157 output_thread->open(device->out_config->firewire_path,
158 device->out_config->firewire_port,
159 device->out_config->firewire_channel,
164 device->out_config->firewire_syt);
168 output_iec = new IEC61883Output(device);
169 output_iec->open(device->out_config->firewire_port,
170 device->out_config->firewire_channel,
175 device->out_config->firewire_syt);
182 int VDevice1394::close_all()
201 delete output_thread;
215 if(user_frame) delete user_frame;
221 int VDevice1394::read_buffer(VFrame *frame)
224 if(!input_thread && !input_iec) return 1;
226 if(input_thread) input_thread->read_video(frame);
228 if(input_iec) input_iec->read_video(frame);
234 void VDevice1394::new_output_buffer(VFrame **output,
239 if(colormodel != user_frame->get_color_model())
251 user_frame = new VFrame;
254 user_frame = new VFrame(0,
264 // user_frame->set_shm_offset(0);
265 *output = user_frame;
268 int VDevice1394::write_buffer(VFrame *frame, EDL *edl)
270 if(output_thread) output_thread->write_frame(frame);
272 if(output_iec) output_iec->write_frame(frame);
279 int VDevice1394::can_copy_from(Asset *asset, int output_w, int output_h)