Mercurial > pygame
annotate src/camera.h @ 3194:9fcb7abf3185 default tip
Remove some gcc 4.7.2 compiler warnings
| author | Lenard Lindstrom <len-l@telus.net> |
|---|---|
| date | Tue, 23 Apr 2013 19:53:36 -0700 |
| parents | 531a7f35798d |
| children |
| rev | line source |
|---|---|
|
1323
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
1 /* |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
2 pygame - Python Game Library |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
3 |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
4 This library is free software; you can redistribute it and/or |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
5 modify it under the terms of the GNU Library General Public |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
6 License as published by the Free Software Foundation; either |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
7 version 2 of the License, or (at your option) any later version. |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
8 |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
9 This library is distributed in the hope that it will be useful, |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
12 Library General Public License for more details. |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
13 |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
14 You should have received a copy of the GNU Library General Public |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
15 License along with this library; if not, write to the Free |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
17 |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
18 */ |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
19 |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
20 #include "pygame.h" |
| 1937 | 21 #include "doc/camera_doc.h" |
|
1323
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
22 |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
23 #if defined(__unix__) |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
24 #include <structmember.h> |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
25 #include <stdio.h> |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
26 #include <stdlib.h> |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
27 #include <string.h> |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
28 #include <assert.h> |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
29 |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
30 #include <fcntl.h> /* low-level i/o */ |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
31 #include <unistd.h> |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
32 #include <errno.h> |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
33 #include <sys/stat.h> |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
34 #include <sys/types.h> |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
35 #include <sys/time.h> |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
36 #include <sys/mman.h> |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
37 #include <sys/ioctl.h> |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
38 |
|
3034
dd6752f761be
refers to #92. Only include asm/types.h on linux
Rene Dudfield <renesd@gmail.com>
parents:
2174
diff
changeset
|
39 /* on freebsd there is no asm/types */ |
|
dd6752f761be
refers to #92. Only include asm/types.h on linux
Rene Dudfield <renesd@gmail.com>
parents:
2174
diff
changeset
|
40 #ifdef linux |
|
dd6752f761be
refers to #92. Only include asm/types.h on linux
Rene Dudfield <renesd@gmail.com>
parents:
2174
diff
changeset
|
41 #include <asm/types.h> /* for videodev2.h */ |
|
dd6752f761be
refers to #92. Only include asm/types.h on linux
Rene Dudfield <renesd@gmail.com>
parents:
2174
diff
changeset
|
42 #endif |
|
1323
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
43 |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
44 #include <linux/videodev2.h> |
| 1937 | 45 #elif defined(__APPLE__) |
|
3073
1c265998cf59
Disable camera_mac if OS X is above version 10.6.
Rene Dudfield <renesd@gmail.com>
parents:
3034
diff
changeset
|
46 #include <AvailabilityMacros.h> |
|
1c265998cf59
Disable camera_mac if OS X is above version 10.6.
Rene Dudfield <renesd@gmail.com>
parents:
3034
diff
changeset
|
47 /* We support OSX 10.6 and below. */ |
|
1c265998cf59
Disable camera_mac if OS X is above version 10.6.
Rene Dudfield <renesd@gmail.com>
parents:
3034
diff
changeset
|
48 #if __MAC_OS_X_VERSION_MAX_ALLOWED <= 1060 |
| 3104 | 49 #define PYGAME_MAC_CAMERA_OLD 1 |
|
3073
1c265998cf59
Disable camera_mac if OS X is above version 10.6.
Rene Dudfield <renesd@gmail.com>
parents:
3034
diff
changeset
|
50 #endif |
|
1c265998cf59
Disable camera_mac if OS X is above version 10.6.
Rene Dudfield <renesd@gmail.com>
parents:
3034
diff
changeset
|
51 #endif |
|
1c265998cf59
Disable camera_mac if OS X is above version 10.6.
Rene Dudfield <renesd@gmail.com>
parents:
3034
diff
changeset
|
52 |
|
1c265998cf59
Disable camera_mac if OS X is above version 10.6.
Rene Dudfield <renesd@gmail.com>
parents:
3034
diff
changeset
|
53 #if defined(PYGAME_MAC_CAMERA_OLD) |
|
1c265998cf59
Disable camera_mac if OS X is above version 10.6.
Rene Dudfield <renesd@gmail.com>
parents:
3034
diff
changeset
|
54 #include <QuickTime/QuickTime.h> |
|
1c265998cf59
Disable camera_mac if OS X is above version 10.6.
Rene Dudfield <renesd@gmail.com>
parents:
3034
diff
changeset
|
55 #include <QuickTime/Movies.h> |
|
1c265998cf59
Disable camera_mac if OS X is above version 10.6.
Rene Dudfield <renesd@gmail.com>
parents:
3034
diff
changeset
|
56 #include <QuickTime/ImageCompression.h> |
|
1988
71a7d433cd5e
defined some constants used which are not defined on non-v4l machines
Rene Dudfield <renesd@gmail.com>
parents:
1986
diff
changeset
|
57 #endif |
|
71a7d433cd5e
defined some constants used which are not defined on non-v4l machines
Rene Dudfield <renesd@gmail.com>
parents:
1986
diff
changeset
|
58 |
|
71a7d433cd5e
defined some constants used which are not defined on non-v4l machines
Rene Dudfield <renesd@gmail.com>
parents:
1986
diff
changeset
|
59 /* some constants used which are not defined on non-v4l machines. */ |
|
71a7d433cd5e
defined some constants used which are not defined on non-v4l machines
Rene Dudfield <renesd@gmail.com>
parents:
1986
diff
changeset
|
60 #ifndef V4L2_PIX_FMT_RGB24 |
|
1976
4b67c00bb2b3
camera building again, fixed a few warnings and errors. got camera.h from the git branch of Werner.
Rene Dudfield <renesd@gmail.com>
parents:
1937
diff
changeset
|
61 #define V4L2_PIX_FMT_RGB24 'RGB3' |
|
3119
531a7f35798d
If V4L2_PIX_FMT_RGB444 not defined, we define it. Fixes #116
Rene Dudfield <renesd@gmail.com>
parents:
3104
diff
changeset
|
62 #endif |
|
531a7f35798d
If V4L2_PIX_FMT_RGB444 not defined, we define it. Fixes #116
Rene Dudfield <renesd@gmail.com>
parents:
3104
diff
changeset
|
63 #ifndef V4L2_PIX_FMT_RGB444 |
|
1976
4b67c00bb2b3
camera building again, fixed a few warnings and errors. got camera.h from the git branch of Werner.
Rene Dudfield <renesd@gmail.com>
parents:
1937
diff
changeset
|
64 #define V4L2_PIX_FMT_RGB444 'R444' |
|
3119
531a7f35798d
If V4L2_PIX_FMT_RGB444 not defined, we define it. Fixes #116
Rene Dudfield <renesd@gmail.com>
parents:
3104
diff
changeset
|
65 #endif |
|
531a7f35798d
If V4L2_PIX_FMT_RGB444 not defined, we define it. Fixes #116
Rene Dudfield <renesd@gmail.com>
parents:
3104
diff
changeset
|
66 #ifndef V4L2_PIX_FMT_YUYV |
|
1976
4b67c00bb2b3
camera building again, fixed a few warnings and errors. got camera.h from the git branch of Werner.
Rene Dudfield <renesd@gmail.com>
parents:
1937
diff
changeset
|
67 #define V4L2_PIX_FMT_YUYV 'YUYV' |
|
1323
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
68 #endif |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
69 |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
70 #define CLEAR(x) memset (&(x), 0, sizeof (x)) |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
71 #define SAT(c) if (c & (~255)) { if (c < 0) c = 0; else c = 255; } |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
72 #define SAT2(c) ((c) & (~255) ? ((c) < 0 ? 0 : 255) : (c)) |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
73 #define DEFAULT_WIDTH 640 |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
74 #define DEFAULT_HEIGHT 480 |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
75 #define RGB_OUT 1 |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
76 #define YUV_OUT 2 |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
77 #define HSV_OUT 4 |
|
2174
8296cad31717
Patch from Martijn Schmidt. Remove V4L support.
Nirav Patel <nrp@eclecti.cc>
parents:
2143
diff
changeset
|
78 #define CAM_V4L 1 /* deprecated. the incomplete support in pygame was removed */ |
|
1323
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
79 #define CAM_V4L2 2 |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
80 |
|
1976
4b67c00bb2b3
camera building again, fixed a few warnings and errors. got camera.h from the git branch of Werner.
Rene Dudfield <renesd@gmail.com>
parents:
1937
diff
changeset
|
81 struct buffer { |
|
1323
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
82 void * start; |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
83 size_t length; |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
84 }; |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
85 |
|
1976
4b67c00bb2b3
camera building again, fixed a few warnings and errors. got camera.h from the git branch of Werner.
Rene Dudfield <renesd@gmail.com>
parents:
1937
diff
changeset
|
86 #if defined(__unix__) |
|
1986
1bb73f52b0aa
some fixups for non apple/unix builds
Rene Dudfield <renesd@gmail.com>
parents:
1976
diff
changeset
|
87 typedef struct PyCameraObject { |
|
1323
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
88 PyObject_HEAD |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
89 char* device_name; |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
90 int camera_type; |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
91 unsigned long pixelformat; |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
92 unsigned int color_out; |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
93 struct buffer* buffers; |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
94 unsigned int n_buffers; |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
95 int width; |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
96 int height; |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
97 int size; |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
98 int hflip; |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
99 int vflip; |
| 1327 | 100 int brightness; |
|
1323
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
101 int fd; |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
102 } PyCameraObject; |
|
3073
1c265998cf59
Disable camera_mac if OS X is above version 10.6.
Rene Dudfield <renesd@gmail.com>
parents:
3034
diff
changeset
|
103 #elif defined(PYGAME_MAC_CAMERA_OLD) |
|
1986
1bb73f52b0aa
some fixups for non apple/unix builds
Rene Dudfield <renesd@gmail.com>
parents:
1976
diff
changeset
|
104 typedef struct PyCameraObject { |
|
1976
4b67c00bb2b3
camera building again, fixed a few warnings and errors. got camera.h from the git branch of Werner.
Rene Dudfield <renesd@gmail.com>
parents:
1937
diff
changeset
|
105 PyObject_HEAD |
|
1986
1bb73f52b0aa
some fixups for non apple/unix builds
Rene Dudfield <renesd@gmail.com>
parents:
1976
diff
changeset
|
106 char* device_name; /* unieke name of the device */ |
|
1976
4b67c00bb2b3
camera building again, fixed a few warnings and errors. got camera.h from the git branch of Werner.
Rene Dudfield <renesd@gmail.com>
parents:
1937
diff
changeset
|
107 OSType pixelformat; |
|
4b67c00bb2b3
camera building again, fixed a few warnings and errors. got camera.h from the git branch of Werner.
Rene Dudfield <renesd@gmail.com>
parents:
1937
diff
changeset
|
108 unsigned int color_out; |
|
1986
1bb73f52b0aa
some fixups for non apple/unix builds
Rene Dudfield <renesd@gmail.com>
parents:
1976
diff
changeset
|
109 SeqGrabComponent component; /* A type used by the Sequence Grabber API */ |
|
1bb73f52b0aa
some fixups for non apple/unix builds
Rene Dudfield <renesd@gmail.com>
parents:
1976
diff
changeset
|
110 SGChannel channel; /* Channel of the Sequence Grabber */ |
|
1bb73f52b0aa
some fixups for non apple/unix builds
Rene Dudfield <renesd@gmail.com>
parents:
1976
diff
changeset
|
111 GWorldPtr gworld; /* Pointer to the struct that holds the data of the captured image */ |
|
1bb73f52b0aa
some fixups for non apple/unix builds
Rene Dudfield <renesd@gmail.com>
parents:
1976
diff
changeset
|
112 Rect boundsRect; /* bounds of the image frame */ |
|
1bb73f52b0aa
some fixups for non apple/unix builds
Rene Dudfield <renesd@gmail.com>
parents:
1976
diff
changeset
|
113 long size; /* size of the image in our buffer to draw */ |
|
1976
4b67c00bb2b3
camera building again, fixed a few warnings and errors. got camera.h from the git branch of Werner.
Rene Dudfield <renesd@gmail.com>
parents:
1937
diff
changeset
|
114 int hflip; |
|
4b67c00bb2b3
camera building again, fixed a few warnings and errors. got camera.h from the git branch of Werner.
Rene Dudfield <renesd@gmail.com>
parents:
1937
diff
changeset
|
115 int vflip; |
|
1986
1bb73f52b0aa
some fixups for non apple/unix builds
Rene Dudfield <renesd@gmail.com>
parents:
1976
diff
changeset
|
116 short depth; |
|
1bb73f52b0aa
some fixups for non apple/unix builds
Rene Dudfield <renesd@gmail.com>
parents:
1976
diff
changeset
|
117 struct buffer pixels; |
|
1bb73f52b0aa
some fixups for non apple/unix builds
Rene Dudfield <renesd@gmail.com>
parents:
1976
diff
changeset
|
118 //struct buffer tmp_pixels /* place where the flipped image in temporarly stored if hflip or vflip is true.*/ |
|
1bb73f52b0aa
some fixups for non apple/unix builds
Rene Dudfield <renesd@gmail.com>
parents:
1976
diff
changeset
|
119 } PyCameraObject; |
|
1bb73f52b0aa
some fixups for non apple/unix builds
Rene Dudfield <renesd@gmail.com>
parents:
1976
diff
changeset
|
120 |
|
1bb73f52b0aa
some fixups for non apple/unix builds
Rene Dudfield <renesd@gmail.com>
parents:
1976
diff
changeset
|
121 #else |
|
1bb73f52b0aa
some fixups for non apple/unix builds
Rene Dudfield <renesd@gmail.com>
parents:
1976
diff
changeset
|
122 /* generic definition. |
|
1bb73f52b0aa
some fixups for non apple/unix builds
Rene Dudfield <renesd@gmail.com>
parents:
1976
diff
changeset
|
123 */ |
|
1bb73f52b0aa
some fixups for non apple/unix builds
Rene Dudfield <renesd@gmail.com>
parents:
1976
diff
changeset
|
124 |
|
1bb73f52b0aa
some fixups for non apple/unix builds
Rene Dudfield <renesd@gmail.com>
parents:
1976
diff
changeset
|
125 typedef struct PyCameraObject { |
|
1bb73f52b0aa
some fixups for non apple/unix builds
Rene Dudfield <renesd@gmail.com>
parents:
1976
diff
changeset
|
126 PyObject_HEAD |
|
1990
ad835522ab82
added some things back to generic implementation
Rene Dudfield <renesd@gmail.com>
parents:
1989
diff
changeset
|
127 char* device_name; |
|
ad835522ab82
added some things back to generic implementation
Rene Dudfield <renesd@gmail.com>
parents:
1989
diff
changeset
|
128 int camera_type; |
|
ad835522ab82
added some things back to generic implementation
Rene Dudfield <renesd@gmail.com>
parents:
1989
diff
changeset
|
129 unsigned long pixelformat; |
|
ad835522ab82
added some things back to generic implementation
Rene Dudfield <renesd@gmail.com>
parents:
1989
diff
changeset
|
130 unsigned int color_out; |
|
ad835522ab82
added some things back to generic implementation
Rene Dudfield <renesd@gmail.com>
parents:
1989
diff
changeset
|
131 struct buffer* buffers; |
|
ad835522ab82
added some things back to generic implementation
Rene Dudfield <renesd@gmail.com>
parents:
1989
diff
changeset
|
132 unsigned int n_buffers; |
|
ad835522ab82
added some things back to generic implementation
Rene Dudfield <renesd@gmail.com>
parents:
1989
diff
changeset
|
133 int width; |
|
ad835522ab82
added some things back to generic implementation
Rene Dudfield <renesd@gmail.com>
parents:
1989
diff
changeset
|
134 int height; |
|
ad835522ab82
added some things back to generic implementation
Rene Dudfield <renesd@gmail.com>
parents:
1989
diff
changeset
|
135 int size; |
|
ad835522ab82
added some things back to generic implementation
Rene Dudfield <renesd@gmail.com>
parents:
1989
diff
changeset
|
136 int hflip; |
|
ad835522ab82
added some things back to generic implementation
Rene Dudfield <renesd@gmail.com>
parents:
1989
diff
changeset
|
137 int vflip; |
|
ad835522ab82
added some things back to generic implementation
Rene Dudfield <renesd@gmail.com>
parents:
1989
diff
changeset
|
138 int brightness; |
|
ad835522ab82
added some things back to generic implementation
Rene Dudfield <renesd@gmail.com>
parents:
1989
diff
changeset
|
139 int fd; |
|
1976
4b67c00bb2b3
camera building again, fixed a few warnings and errors. got camera.h from the git branch of Werner.
Rene Dudfield <renesd@gmail.com>
parents:
1937
diff
changeset
|
140 } PyCameraObject; |
|
4b67c00bb2b3
camera building again, fixed a few warnings and errors. got camera.h from the git branch of Werner.
Rene Dudfield <renesd@gmail.com>
parents:
1937
diff
changeset
|
141 #endif |
|
1323
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
142 |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
143 /* internal functions for colorspace conversion */ |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
144 void colorspace (SDL_Surface *src, SDL_Surface *dst, int cspace); |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
145 void rgb24_to_rgb (const void* src, void* dst, int length, SDL_PixelFormat* format); |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
146 void rgb444_to_rgb (const void* src, void* dst, int length, SDL_PixelFormat* format); |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
147 void rgb_to_yuv (const void* src, void* dst, int length, |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
148 unsigned long source, SDL_PixelFormat* format); |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
149 void rgb_to_hsv (const void* src, void* dst, int length, |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
150 unsigned long source, SDL_PixelFormat* format); |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
151 void yuyv_to_rgb (const void* src, void* dst, int length, SDL_PixelFormat* format); |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
152 void yuyv_to_yuv (const void* src, void* dst, int length, SDL_PixelFormat* format); |
|
1976
4b67c00bb2b3
camera building again, fixed a few warnings and errors. got camera.h from the git branch of Werner.
Rene Dudfield <renesd@gmail.com>
parents:
1937
diff
changeset
|
153 void sbggr8_to_rgb (const void* src, void* dst, int width, int height, |
|
4b67c00bb2b3
camera building again, fixed a few warnings and errors. got camera.h from the git branch of Werner.
Rene Dudfield <renesd@gmail.com>
parents:
1937
diff
changeset
|
154 SDL_PixelFormat* format); |
|
4b67c00bb2b3
camera building again, fixed a few warnings and errors. got camera.h from the git branch of Werner.
Rene Dudfield <renesd@gmail.com>
parents:
1937
diff
changeset
|
155 void yuv420_to_rgb (const void* src, void* dst, int width, int height, |
|
4b67c00bb2b3
camera building again, fixed a few warnings and errors. got camera.h from the git branch of Werner.
Rene Dudfield <renesd@gmail.com>
parents:
1937
diff
changeset
|
156 SDL_PixelFormat* format); |
|
4b67c00bb2b3
camera building again, fixed a few warnings and errors. got camera.h from the git branch of Werner.
Rene Dudfield <renesd@gmail.com>
parents:
1937
diff
changeset
|
157 void yuv420_to_yuv (const void* src, void* dst, int width, int height, |
|
4b67c00bb2b3
camera building again, fixed a few warnings and errors. got camera.h from the git branch of Werner.
Rene Dudfield <renesd@gmail.com>
parents:
1937
diff
changeset
|
158 SDL_PixelFormat* format); |
|
1323
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
159 |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
160 #if defined(__unix__) |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
161 /* internal functions specific to v4l2 */ |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
162 char** v4l2_list_cameras (int* num_devices); |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
163 int v4l2_get_control (int fd, int id, int *value); |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
164 int v4l2_set_control (int fd, int id, int value); |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
165 PyObject* v4l2_read_raw (PyCameraObject* self); |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
166 int v4l2_xioctl (int fd, int request, void *arg); |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
167 int v4l2_process_image (PyCameraObject* self, const void *image, |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
168 unsigned int buffer_size, SDL_Surface* surf); |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
169 int v4l2_query_buffer (PyCameraObject* self); |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
170 int v4l2_read_frame (PyCameraObject* self, SDL_Surface* surf); |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
171 int v4l2_stop_capturing (PyCameraObject* self); |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
172 int v4l2_start_capturing (PyCameraObject* self); |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
173 int v4l2_uninit_device (PyCameraObject* self); |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
174 int v4l2_init_mmap (PyCameraObject* self); |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
175 int v4l2_init_device (PyCameraObject* self); |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
176 int v4l2_close_device (PyCameraObject* self); |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
177 int v4l2_open_device (PyCameraObject* self); |
|
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
178 |
|
3073
1c265998cf59
Disable camera_mac if OS X is above version 10.6.
Rene Dudfield <renesd@gmail.com>
parents:
3034
diff
changeset
|
179 #elif defined(PYGAME_MAC_CAMERA_OLD) |
|
1976
4b67c00bb2b3
camera building again, fixed a few warnings and errors. got camera.h from the git branch of Werner.
Rene Dudfield <renesd@gmail.com>
parents:
1937
diff
changeset
|
180 /* internal functions specific to mac */ |
| 1933 | 181 char** mac_list_cameras(int* num_devices); |
| 182 int mac_open_device (PyCameraObject* self); | |
| 183 int mac_init_device(PyCameraObject* self); | |
| 184 int mac_close_device (PyCameraObject* self); | |
| 185 int mac_start_capturing(PyCameraObject* self); | |
| 186 int mac_stop_capturing (PyCameraObject* self); | |
|
1976
4b67c00bb2b3
camera building again, fixed a few warnings and errors. got camera.h from the git branch of Werner.
Rene Dudfield <renesd@gmail.com>
parents:
1937
diff
changeset
|
187 |
|
4b67c00bb2b3
camera building again, fixed a few warnings and errors. got camera.h from the git branch of Werner.
Rene Dudfield <renesd@gmail.com>
parents:
1937
diff
changeset
|
188 int mac_get_control(PyCameraObject* self, int id, int* value); |
|
4b67c00bb2b3
camera building again, fixed a few warnings and errors. got camera.h from the git branch of Werner.
Rene Dudfield <renesd@gmail.com>
parents:
1937
diff
changeset
|
189 int mac_set_control(PyCameraObject* self, int id, int value); |
|
4b67c00bb2b3
camera building again, fixed a few warnings and errors. got camera.h from the git branch of Werner.
Rene Dudfield <renesd@gmail.com>
parents:
1937
diff
changeset
|
190 |
|
4b67c00bb2b3
camera building again, fixed a few warnings and errors. got camera.h from the git branch of Werner.
Rene Dudfield <renesd@gmail.com>
parents:
1937
diff
changeset
|
191 PyObject* mac_read_raw(PyCameraObject *self); |
|
4b67c00bb2b3
camera building again, fixed a few warnings and errors. got camera.h from the git branch of Werner.
Rene Dudfield <renesd@gmail.com>
parents:
1937
diff
changeset
|
192 int mac_read_frame(PyCameraObject* self, SDL_Surface* surf); |
|
4b67c00bb2b3
camera building again, fixed a few warnings and errors. got camera.h from the git branch of Werner.
Rene Dudfield <renesd@gmail.com>
parents:
1937
diff
changeset
|
193 int mac_camera_idle(PyCameraObject* self); |
|
4b67c00bb2b3
camera building again, fixed a few warnings and errors. got camera.h from the git branch of Werner.
Rene Dudfield <renesd@gmail.com>
parents:
1937
diff
changeset
|
194 int mac_copy_gworld_to_surface(PyCameraObject* self, SDL_Surface* surf); |
|
1989
b8611a14022c
moved flip_image into camera_mac since it is only used there and fails to build x platform.
Rene Dudfield <renesd@gmail.com>
parents:
1988
diff
changeset
|
195 |
|
b8611a14022c
moved flip_image into camera_mac since it is only used there and fails to build x platform.
Rene Dudfield <renesd@gmail.com>
parents:
1988
diff
changeset
|
196 void flip_image(const void* image, void* flipped_image, int width, int height, |
|
b8611a14022c
moved flip_image into camera_mac since it is only used there and fails to build x platform.
Rene Dudfield <renesd@gmail.com>
parents:
1988
diff
changeset
|
197 short depth, int hflip, int vflip); |
|
b8611a14022c
moved flip_image into camera_mac since it is only used there and fails to build x platform.
Rene Dudfield <renesd@gmail.com>
parents:
1988
diff
changeset
|
198 |
|
1323
1ca45b50f8ea
camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents:
diff
changeset
|
199 #endif |
