1 | /* |
2 | * 1394-Based Digital Camera Control Library |
3 | * |
4 | * Written by Damien Douxchamps <ddouxchamps@users.sf.net> |
5 | * |
6 | * This library is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU Lesser General Public |
8 | * License as published by the Free Software Foundation; either |
9 | * version 2.1 of the License, or (at your option) any later version. |
10 | * |
11 | * This library 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 GNU |
14 | * Lesser General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU Lesser General Public |
17 | * License along with this library; if not, write to the Free Software |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | */ |
20 | |
21 | |
22 | #include <dc1394/log.h> |
23 | #include <dc1394/video.h> |
24 | |
25 | #ifndef __DC1394_CAPTURE_H__ |
26 | #define __DC1394_CAPTURE_H__ |
27 | |
28 | /*! \file dc1394/capture.h |
29 | \brief Capture functions |
30 | \author Damien Douxchamps: coding |
31 | \author Peter Antoniac: documentation maintainer |
32 | |
33 | More details soon |
34 | */ |
35 | |
36 | /** |
37 | * The capture policy. |
38 | * |
39 | * Can be blocking (wait for a frame forever) or polling (returns if no frames is in the ring buffer) |
40 | */ |
41 | typedef enum { |
42 | DC1394_CAPTURE_POLICY_WAIT=672, |
43 | DC1394_CAPTURE_POLICY_POLL |
44 | } dc1394capture_policy_t; |
45 | #define DC1394_CAPTURE_POLICY_MIN DC1394_CAPTURE_POLICY_WAIT |
46 | #define DC1394_CAPTURE_POLICY_MAX DC1394_CAPTURE_POLICY_POLL |
47 | #define DC1394_CAPTURE_POLICY_NUM (DC1394_CAPTURE_POLICY_MAX - DC1394_CAPTURE_POLICY_MIN + 1) |
48 | |
49 | /** |
50 | * typedef for the callback param for dc1394_capture_set_callback |
51 | */ |
52 | |
53 | typedef void (*dc1394capture_callback_t)(dc1394camera_t *, void *); |
54 | |
55 | |
56 | /** |
57 | * Capture flags. Currently limited to switching automatic functions on/off: channel allocation, bandwidth allocation and automatic |
58 | * starting of ISO transmission |
59 | */ |
60 | #define DC1394_CAPTURE_FLAGS_CHANNEL_ALLOC 0x00000001U |
61 | #define DC1394_CAPTURE_FLAGS_BANDWIDTH_ALLOC 0x00000002U |
62 | #define DC1394_CAPTURE_FLAGS_DEFAULT 0x00000004U /* a reasonable default value: do bandwidth and channel allocation */ |
63 | #define DC1394_CAPTURE_FLAGS_AUTO_ISO 0x00000008U /* automatically start iso before capture and stop it after */ |
64 | |
65 | #ifdef __cplusplus |
66 | extern "C" { |
67 | #endif |
68 | |
69 | /*************************************************************************** |
70 | Capture Functions |
71 | ***************************************************************************/ |
72 | |
73 | /** |
74 | * Setup the capture, using a ring buffer of a certain size (num_dma_buffers) and certain options (flags) |
75 | */ |
76 | dc1394error_t dc1394_capture_setup(dc1394camera_t *camera, uint32_t num_dma_buffers, uint32_t flags); |
77 | |
78 | /** |
79 | * Stop the capture |
80 | */ |
81 | dc1394error_t dc1394_capture_stop(dc1394camera_t *camera); |
82 | |
83 | /** |
84 | * Gets a file descriptor to be used for select(). Must be called after dc1394_capture_setup(). |
85 | */ |
86 | int dc1394_capture_get_fileno (dc1394camera_t * camera); |
87 | |
88 | /** |
89 | * Captures a video frame. The returned struct contains the image buffer, among others. This image buffer SHALL NOT be freed, as it represents an area |
90 | * in the memory that belongs to the system. |
91 | */ |
92 | dc1394error_t dc1394_capture_dequeue(dc1394camera_t * camera, dc1394capture_policy_t policy, dc1394video_frame_t **frame); |
93 | |
94 | /** |
95 | * Returns a frame to the ring buffer once it has been used. |
96 | */ |
97 | dc1394error_t dc1394_capture_enqueue(dc1394camera_t * camera, dc1394video_frame_t * frame); |
98 | |
99 | /** |
100 | * Returns DC1394_TRUE if the given frame (previously dequeued) has been |
101 | * detected to be corrupt (missing data, corrupted data, overrun buffer, etc.). |
102 | * Note that certain types of corruption may go undetected in which case |
103 | * DC1394_FALSE will be returned. The ability to detect corruption also |
104 | * varies between platforms. Note that corrupt frames still need to be |
105 | * enqueued with dc1394_capture_enqueue() when no longer needed by the user. |
106 | */ |
107 | dc1394bool_t dc1394_capture_is_frame_corrupt (dc1394camera_t * camera, |
108 | dc1394video_frame_t * frame); |
109 | |
110 | /** |
111 | * Set a callback if supported by the platform (OS X only for now). |
112 | */ |
113 | void dc1394_capture_set_callback (dc1394camera_t * camera, |
114 | dc1394capture_callback_t callback, void * user_data); |
115 | |
116 | #ifdef __cplusplus |
117 | } |
118 | #endif |
119 | |
120 | #endif |
121 | |