1/*
2 * Routines exported to the interface file
3 */
4
5
6#include <stdlib.h>
7#include <pthread.h>
8#include <linux/videodev.h>
9
10
11/* Our preference for the next image to capture
12   (or the next series of images */
13
14enum ECaptureSize {
15	ECS_TINY = 0,  // 160 x 120
16	ECS_QVGA = 1,  // 320 x 240
17	ECS_VGA  = 2   // 640 x 480
18};
19
20struct PrefData {
21	pthread_mutex_t    lock;     /* Prevent modification of params during a grab */
22	pthread_cond_t     cond;
23	unsigned short     brightness;
24	unsigned short     fps;
25	unsigned short     power;
26	unsigned short     gain;
27	unsigned short     power_mgmt;
28	unsigned short     special_modes;
29	unsigned char      flip;
30	enum ECaptureSize  capture_size;
31
32	gboolean           pause;  // Set to TRUE to pause capture
33	gboolean           dirty;
34};
35
36/* A single captured image */
37struct ImageData {
38	pthread_mutex_t    lock;
39	struct video_mmap  vmap;   // Copied over at capture time
40#ifdef WL600
41	int				   size;
42	char               data[2][640*480*3/2];
43#else
44	char			   data[2][640*480*3];
45#endif
46  	int cur;
47};
48
49#define SMALL_IMAGE 0
50#define LARGE_IMAGE 1
51
52struct CaptureData {
53	struct PrefData   desired;   /* Change these when you want to reset the image capture */
54
55	// V4L stuff
56	int                                video_fd;
57	struct video_capability            vcap;
58	struct video_picture               vpic;
59	struct video_window                vwin;
60	struct video_mbuf                  vmbuf;
61	struct video_mmap                  vmap[2];
62	unsigned char *                    videoBuffer;
63	int                                grab_frame; // Which vmap[] we're grabbing
64
65	// The most recently captured image
66	struct ImageData    image;
67	int                 current_display;
68  //struct DisplayArea  displayarea[2];
69
70	GTimer        *timer;
71	guint          context_id;
72};
73
74typedef struct _clientdata {
75  int sockfd;
76  char *address;
77#ifdef WL600
78  int written;
79  int errcount;
80#endif
81} clientdata;
82
83static char *unknown_address = "unknown";
84
85int server(void);
86int sender(unsigned char *yuvcap, int size);
87unsigned int compare_images(unsigned char *last, unsigned char *current,
88				   int width, int height);
89
90