CGR Localization
 All Classes Namespaces Files Functions Variables Macros Pages
freenect_internal.h
1 /*
2  * This file is part of the OpenKinect Project. http://www.openkinect.org
3  *
4  * Copyright (c) 2010 individual OpenKinect contributors. See the CONTRIB file
5  * for details.
6  *
7  * This code is licensed to you under the terms of the Apache License, version
8  * 2.0, or, at your option, the terms of the GNU General Public License,
9  * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses,
10  * or the following URLs:
11  * http://www.apache.org/licenses/LICENSE-2.0
12  * http://www.gnu.org/licenses/gpl-2.0.txt
13  *
14  * If you redistribute this file in source form, modified or unmodified, you
15  * may:
16  * 1) Leave this header intact and distribute it under the same terms,
17  * accompanying it with the APACHE20 and GPL20 files, or
18  * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or
19  * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file
20  * In all cases you must keep the copyright notice intact and include a copy
21  * of the CONTRIB file.
22  *
23  * Binary distributions must follow the binary distribution requirements of
24  * either License.
25  */
26 
27 #ifndef FREENECT_INTERNAL_H
28 #define FREENECT_INTERNAL_H
29 
30 #include <stdint.h>
31 
32 #include "libfreenect.h"
33 
34 typedef void (*fnusb_iso_cb)(freenect_device *dev, uint8_t *buf, int len);
35 
36 #include "usb_libusb10.h"
37 
39  fnusb_ctx usb;
40 };
41 
42 #ifdef FN_BIGENDIAN
43 static inline uint16_t fn_le16(uint16_t d)
44 {
45  return (d<<8) | (d>>8);
46 }
47 static inline uint32_t fn_le32(uint32_t d)
48 {
49  return (d<<24) | ((d<<8)&0xFF0000) | ((d>>8)&0xFF00) | (d>>24);
50 }
51 #else
52 #define fn_le16(x) (x)
53 #define fn_le32(x) (x)
54 #endif
55 
56 #define DEPTH_RAW_10_BIT_SIZE 384000
57 #define DEPTH_RAW_11_BIT_SIZE 422400
58 #define FRAME_H FREENECT_FRAME_H
59 #define FRAME_W FREENECT_FRAME_W
60 #define FRAME_PIX FREENECT_FRAME_PIX
61 
62 #define DEPTH_PKTSIZE 1760
63 #define RGB_PKTSIZE 1920
64 
65 #define DEPTH_PKTDSIZE (DEPTH_PKTSIZE-12)
66 #define RGB_PKTDSIZE (RGB_PKTSIZE-12)
67 
68 #define DEPTH_PKTS_10_BIT_PER_FRAME ((DEPTH_RAW_10_BIT_SIZE+DEPTH_PKTDSIZE-1)/DEPTH_PKTDSIZE)
69 #define DEPTH_PKTS_11_BIT_PER_FRAME ((DEPTH_RAW_11_BIT_SIZE+DEPTH_PKTDSIZE-1)/DEPTH_PKTDSIZE)
70 #define RGB_PKTS_PER_FRAME ((FRAME_PIX+RGB_PKTDSIZE-1)/RGB_PKTDSIZE)
71 
72 #define MS_MAGIC_VENDOR 0x45e
73 #define MS_MAGIC_CAMERA_PRODUCT 0x02ae
74 #define MS_MAGIC_MOTOR_PRODUCT 0x02b0
75 
76 typedef struct {
77  uint8_t flag;
78  int synced;
79  uint8_t seq;
80  int got_pkts;
81  int pkt_num;
82  int pkts_per_frame;
83  int pkt_size;
84  int valid_pkts;
85  uint32_t last_timestamp;
86  uint32_t timestamp;
87  uint8_t *buf;
89 
91  freenect_context *parent;
92  void *user_data;
93 
94  // Cameras
95  fnusb_dev usb_cam;
96  fnusb_isoc_stream depth_isoc;
97  fnusb_isoc_stream rgb_isoc;
98 
99  freenect_depth_cb depth_cb;
100  freenect_depth_raw_cb depth_raw_cb;
101  freenect_rgb_cb rgb_cb;
102  freenect_rgb_format rgb_format;
103  freenect_depth_format depth_format;
104 
105  int cam_inited;
106 
107  packet_stream depth_stream;
108  uint8_t depth_raw[DEPTH_RAW_11_BIT_SIZE];
109  uint16_t depth_frame[FRAME_PIX];
110 
111  packet_stream rgb_stream;
112  uint8_t rgb_raw[FRAME_PIX];
113  uint8_t rgb_frame[3*FRAME_PIX];
114 
115  // Audio
116  // Motor
117  fnusb_dev usb_motor;
118 
119 };
120 
121 struct caminit {
122  uint16_t command;
123  uint16_t tag;
124  int cmdlen;
125  int replylen;
126  uint8_t cmddata[1024];
127  uint8_t replydata[1024];
128 };
129 
130 
131 
132 
133 
134 #endif