1 /*
2 * IIDC1394 grab interface (uses libdc1394 and libraw1394)
3 * Copyright (c) 2004 Roman Shaposhnik
4 * Copyright (c) 2008 Alessandro Sappia
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #include <dc1394/dc1394.h>
24
32
36
43 int frame_rate;
/**< frames per 1000 seconds (fps * 1000) */
44 char *
video_size;
/**< String describing video size, set by a private option. */
47
51
62 { 0, 0, 0, 0 } /* gotta be the last one */
63 };
64
69 { 1875, DC1394_FRAMERATE_1_875 },
70 { 3750, DC1394_FRAMERATE_3_75 },
71 { 7500, DC1394_FRAMERATE_7_5 },
72 { 15000, DC1394_FRAMERATE_15 },
73 { 30000, DC1394_FRAMERATE_30 },
74 { 60000, DC1394_FRAMERATE_60 },
75 {120000, DC1394_FRAMERATE_120 },
76 {240000, DC1394_FRAMERATE_240 },
77 { 0, 0 } /* gotta be the last one */
78 };
79
80 #define OFFSET(x) offsetof(dc1394_data, x)
81 #define DEC AV_OPT_FLAG_DECODING_PARAM
83 {
"video_size",
"A string describing frame size, such as 640x480 or hd720.",
OFFSET(video_size),
AV_OPT_TYPE_STRING, {.str =
"qvga"}, 0, 0,
DEC },
87 };
88
95 };
96
97
100 {
109
114 }
115
119 }
123 }
125
128 break;
129
132 break;
133
139 }
140
141 /* create a video stream */
143 if (!vst) {
146 }
154
159
162 *select_fps = fps;
163 *select_fmt = fmt;
166 }
167
169 {
171 dc1394camera_list_t *
list;
175
177 return -1;
178
179 /* Now let us prep the hardware. */
180 dc1394->
d = dc1394_new();
181 if (dc1394_camera_enumerate(dc1394->
d, &
list) != DC1394_SUCCESS || !
list) {
184 }
185
186 if (
list->num == 0) {
188 dc1394_camera_free_list(
list);
190 }
191
192 /* FIXME: To select a specific camera I need to search in list its guid */
193 dc1394->
camera = dc1394_camera_new (dc1394->
d,
list->ids[0].guid);
194
198 dc1394_camera_free_list(
list);
200 }
201
204 }
205
206 /* Freeing list of cameras */
207 dc1394_camera_free_list (
list);
208
209 /* Select MAX Speed possible from the cam */
210 if (dc1394->
camera->bmode_capable>0) {
211 dc1394_video_set_operation_mode(dc1394->
camera, DC1394_OPERATION_MODE_1394B);
212 i = DC1394_ISO_SPEED_800;
213 } else {
214 i = DC1394_ISO_SPEED_400;
215 }
216
217 for (res = DC1394_FAILURE;
i >= DC1394_ISO_SPEED_MIN && res != DC1394_SUCCESS;
i--) {
218 res=dc1394_video_set_iso_speed(dc1394->
camera,
i);
219 }
220 if (res != DC1394_SUCCESS) {
222 goto out_camera;
223 }
224
227 goto out_camera;
228 }
229
232 goto out_camera;
233 }
234 if (dc1394_capture_setup(dc1394->
camera, 10, DC1394_CAPTURE_FLAGS_DEFAULT)!=DC1394_SUCCESS) {
236 goto out_camera;
237 }
238
239 if (dc1394_video_set_transmission(dc1394->
camera, DC1394_ON) !=DC1394_SUCCESS) {
241 goto out_camera;
242 }
243 return 0;
244
245 out_camera:
246 dc1394_capture_stop(dc1394->
camera);
247 dc1394_video_set_transmission(dc1394->
camera, DC1394_OFF);
248 dc1394_camera_free (dc1394->
camera);
250 dc1394_free(dc1394->
d);
251 return -1;
252 }
253
255 {
257 int res;
258
259 /* discard stale frame */
261 if (dc1394_capture_enqueue(dc1394->
camera, dc1394->
frame) != DC1394_SUCCESS)
263 }
264
265 res = dc1394_capture_dequeue(dc1394->
camera, DC1394_CAPTURE_POLICY_WAIT, &dc1394->
frame);
266 if (res == DC1394_SUCCESS) {
272 } else {
275 }
276
278 }
279
281 {
283
284 dc1394_video_set_transmission(dc1394->
camera, DC1394_OFF);
285 dc1394_capture_stop(dc1394->
camera);
286 dc1394_camera_free(dc1394->
camera);
287 dc1394_free(dc1394->
d);
288
289 return 0;
290 }
291
293 .
p.
name =
"libdc1394",
301 };