aboutsummaryrefslogtreecommitdiffstats
path: root/src/v4l.h
blob: 1d4fa1f033c1356bb04d4b106e8627c76ff08921 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#ifndef CAMORAMA_V4L_H
#define CAMORAMA_V4L_H

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <gio/gio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <linux/types.h>
#include <linux/videodev2.h>
#include <libv4l2.h>
#include <signal.h>
#include <png.h>
#include <gconf/gconf-client.h>

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-prototypes"
#include <gtk/gtk.h>
#pragma GCC diagnostic pop

#include "camorama-filter-chain.h"

typedef enum {
    PICMAX = 0,
    PICMIN = 1,
    PICHALF = 2
} CamoImageSize;

enum {
    JPEG = 0,
    PNG = 1,
    PPM = 2
};

struct buffer_start_len {
    void *start;
    size_t length;
};

struct resolutions {
    unsigned int x, y;
};

typedef struct camera {
    int dev;
    unsigned int width, height;
    int bpp;
    CamoImageSize size;
    char name[32];
    int contrast, brightness, whiteness, colour, hue, bytesperline;
    unsigned int pixformat;
    int frame_number;

    unsigned int min_width, min_height, max_width, max_height;

    unsigned int n_res;
    struct resolutions *res;

    char *video_dev;
    unsigned char *image;
    gchar *capturefile, *rcapturefile;
    gchar *pixdir, *host, *proto, *rdir, *uri;
    int savetype, rsavetype;
    gchar *ts_string;
    gchar *date_format;
    gboolean debug, read, hidden;
    gboolean cap, rcap, acap, show_adjustments, show_effects;
    gboolean timestamp, rtimestamp, usedate, usestring;
    gboolean rtimefn, timefn;
    GtkWidget *da, *tray_tooltip, *status;
    unsigned char *pic_buf, *tmp;
    guint timeout_id, idle_id;
    guint32 timeout_interval;
    GConfClient *gc;
    GtkBuilder *xml;
    GdkPixbuf *pb;
    GtkStatusIcon *tray_icon;

    CamoramaFilterChain *filter_chain;

    gboolean rdir_ok;
    GFile *rdir_file;
    GMountOperation *rdir_mop;

    /* Buffer handling - should be used only inside v4l.c */
    struct v4l2_requestbuffers req;
    unsigned int n_buffers;
    struct {
        void *start;
        size_t length;
    } *buffers;
} cam_t;

void camera_cap(cam_t *);
void print_cam(cam_t *);
void try_set_win_info(cam_t *cam, unsigned int *x, unsigned int *y);
void set_win_info(cam_t *cam);
void get_pic_info(cam_t *);
void get_win_info(cam_t *);
void get_supported_resolutions(cam_t *cam);
void start_streaming(cam_t *cam);
void capture_buffers(cam_t *cam, unsigned char *outbuf, unsigned int len);
void stop_streaming(cam_t *cam);

#endif                          /* !CAMORAMA_V4L_H */

Privacy Policy