33 #include <dc1394/dc1394.h>
34 #elif HAVE_LIBDC1394_1
35 #include <libraw1394/raw1394.h>
36 #include <libdc1394/dc1394_control.h>
38 #define DC1394_VIDEO_MODE_320x240_YUV422 MODE_320x240_YUV422
39 #define DC1394_VIDEO_MODE_640x480_YUV411 MODE_640x480_YUV411
40 #define DC1394_VIDEO_MODE_640x480_YUV422 MODE_640x480_YUV422
41 #define DC1394_FRAMERATE_1_875 FRAMERATE_1_875
42 #define DC1394_FRAMERATE_3_75 FRAMERATE_3_75
43 #define DC1394_FRAMERATE_7_5 FRAMERATE_7_5
44 #define DC1394_FRAMERATE_15 FRAMERATE_15
45 #define DC1394_FRAMERATE_30 FRAMERATE_30
46 #define DC1394_FRAMERATE_60 FRAMERATE_60
47 #define DC1394_FRAMERATE_120 FRAMERATE_120
48 #define DC1394_FRAMERATE_240 FRAMERATE_240
54 raw1394handle_t handle;
55 dc1394_cameracapture camera;
57 #elif HAVE_LIBDC1394_2
59 dc1394camera_t *camera;
60 dc1394video_frame_t *
frame;
87 { 1875, DC1394_FRAMERATE_1_875 },
88 { 3750, DC1394_FRAMERATE_3_75 },
89 { 7500, DC1394_FRAMERATE_7_5 },
90 { 15000, DC1394_FRAMERATE_15 },
91 { 30000, DC1394_FRAMERATE_30 },
92 { 60000, DC1394_FRAMERATE_60 },
93 {120000, DC1394_FRAMERATE_120 },
94 {240000, DC1394_FRAMERATE_240 },
98 #define OFFSET(x) offsetof(dc1394_data, x)
99 #define DEC AV_OPT_FLAG_DECODING_PARAM
104 {
"video_size",
"A string describing frame size, such as 640x480 or hd720.",
OFFSET(video_size),
AV_OPT_TYPE_STRING, {.str =
"qvga"}, 0, 0,
DEC },
197 nodeid_t* camera_nodes;
206 dc1394->handle = dc1394_create_handle(0);
207 if (!dc1394->handle) {
211 camera_nodes = dc1394_get_camera_nodes(dc1394->handle, &res, 1);
212 if (!camera_nodes || camera_nodes[dc1394->channel] == DC1394_NO_CAMERA) {
213 av_log(c,
AV_LOG_ERROR,
"There's no IIDC camera on the channel %d\n", dc1394->channel);
216 res = dc1394_dma_setup_capture(dc1394->handle, camera_nodes[dc1394->channel],
218 FORMAT_VGA_NONCOMPRESSED,
224 dc1394_free_camera_nodes(camera_nodes);
225 if (res != DC1394_SUCCESS) {
230 res = dc1394_start_iso_transmission(dc1394->handle, dc1394->camera.node);
231 if (res != DC1394_SUCCESS) {
239 dc1394_dma_unlisten(dc1394->handle, &dc1394->camera);
240 dc1394_dma_release_camera(dc1394->handle, &dc1394->camera);
242 dc1394_destroy_handle(dc1394->handle);
254 if (dc1394_dma_done_with_buffer(&dc1394->camera) != DC1394_SUCCESS)
258 res = dc1394_dma_single_capture(&dc1394->camera);
260 if (res == DC1394_SUCCESS) {
278 dc1394_stop_iso_transmission(dc1394->handle, dc1394->camera.node);
279 dc1394_dma_unlisten(dc1394->handle, &dc1394->camera);
280 dc1394_dma_release_camera(dc1394->handle, &dc1394->camera);
281 dc1394_destroy_handle(dc1394->handle);
286 #elif HAVE_LIBDC1394_2
290 dc1394camera_list_t *list;
299 dc1394->d = dc1394_new();
300 dc1394_camera_enumerate (dc1394->d, &list);
301 if ( !list || list->num == 0) {
307 dc1394->camera = dc1394_camera_new (dc1394->d, list->ids[0].guid);
313 dc1394_camera_free_list (list);
316 if (dc1394->camera->bmode_capable>0) {
317 dc1394_video_set_operation_mode(dc1394->camera, DC1394_OPERATION_MODE_1394B);
318 i = DC1394_ISO_SPEED_800;
320 i = DC1394_ISO_SPEED_400;
323 for (res = DC1394_FAILURE; i >= DC1394_ISO_SPEED_MIN && res != DC1394_SUCCESS; i--) {
324 res=dc1394_video_set_iso_speed(dc1394->camera, i);
326 if (res != DC1394_SUCCESS) {
331 if (dc1394_video_set_mode(dc1394->camera, fmt->
frame_size_id) != DC1394_SUCCESS) {
336 if (dc1394_video_set_framerate(dc1394->camera,fps->
frame_rate_id) != DC1394_SUCCESS) {
340 if (dc1394_capture_setup(dc1394->camera, 10, DC1394_CAPTURE_FLAGS_DEFAULT)!=DC1394_SUCCESS) {
345 if (dc1394_video_set_transmission(dc1394->camera, DC1394_ON) !=DC1394_SUCCESS) {
352 dc1394_capture_stop(dc1394->camera);
353 dc1394_video_set_transmission(dc1394->camera, DC1394_OFF);
354 dc1394_camera_free (dc1394->camera);
356 dc1394_free(dc1394->d);
367 if (dc1394_capture_enqueue(dc1394->camera, dc1394->frame) != DC1394_SUCCESS)
371 res = dc1394_capture_dequeue(dc1394->camera, DC1394_CAPTURE_POLICY_WAIT, &dc1394->frame);
372 if (res == DC1394_SUCCESS) {
375 res = dc1394->frame->image_bytes;
390 dc1394_video_set_transmission(dc1394->camera, DC1394_OFF);
391 dc1394_capture_stop(dc1394->camera);
392 dc1394_camera_free(dc1394->camera);
393 dc1394_free(dc1394->d);
403 .read_packet = dc1394_v2_read_packet,
404 .read_close = dc1394_v2_close,
416 .read_packet = dc1394_v1_read_packet,
417 .read_close = dc1394_v1_close,