improve delays created by vicon drawing locks, reset_cache segv fix, gang track toolt...
[goodguy/cinelerra.git] / cinelerra-5.1 / guicast / bccapture.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program 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
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #ifndef BCCAPTURE_H
23 #define BCCAPTURE_H
24
25 #include <sys/ipc.h>
26 #include <sys/shm.h>
27 #include <X11/Xlib.h>
28 #include <X11/extensions/XShm.h>
29
30 #include "sizes.h"
31 #include "vframe.inc"
32
33
34 class BC_Capture
35 {
36 public:
37         BC_Capture(int w, int h, const char *display_path = "");
38         virtual ~BC_Capture();
39
40         int init_window(const char *display_path);
41 // x1 and y1 are automatically adjusted if out of bounds
42         int capture_frame(VFrame *frame, int &x1, int &y1, 
43                 int do_cursor=0); // the scale of the cursor if nonzero
44         int get_w();
45         int get_h();
46
47         Window border[4];
48         int bar_w, bar_color;
49         Window bar(int x, int y, int w, int h, int color);
50         void bars_on(int bw, int color, int x, int y, int w, int h);
51         void bars_off();
52         void bars_reposition(int x, int y, int w, int h);
53
54         int w, h, default_depth;
55         unsigned char **row_data;
56
57 private:
58         int allocate_data();
59         int delete_data();
60         int get_top_w();
61         int get_top_h();
62
63         inline void import_RGB565_to_RGB888(unsigned char* &output, unsigned char* &input)
64         {
65                 *output++ = (*input & 0xf800) >> 8;
66                 *output++ = (*input & 0x7e0) >> 3;
67                 *output++ = (*input & 0x1f) << 3;
68
69                 input += 2;
70                 output += 3;
71         };
72
73         inline void import_BGR888_to_RGB888(unsigned char* &output, unsigned char* &input)
74         {
75                 *output++ = input[2];
76                 *output++ = input[1];
77                 *output++ = input[0];
78
79                 input += 3;
80                 output += 3;
81         };
82
83         inline void import_BGR8888_to_RGB888(unsigned char* &output, unsigned char* &input)
84         {
85                 *output++ = input[2];
86                 *output++ = input[1];
87                 *output++ = input[0];
88
89                 input += 4;
90                 output += 3;
91         };
92
93         int use_shm;
94         int bitmap_color_model;
95         unsigned char *data;
96         XImage *ximage;
97         XShmSegmentInfo shm_info;
98         Display* display;
99         Window rootwin;
100         Visual *vis;
101         int bits_per_pixel;
102         int screen;
103         long shm_event_type;
104         int client_byte_order, server_byte_order;
105 };
106
107 #endif