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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
|
/*
* Copyright 1994-2019 Olivier Girondel
*
* This file is part of lebiniou.
*
* lebiniou is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* lebiniou is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with lebiniou. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __BINIOU_CONTEXT_H
#define __BINIOU_CONTEXT_H
#ifdef WITH_GL
#include <GL/gl.h>
#endif
#include "input.h"
#include "sequencemanager.h"
#include "params3d.h"
#include "particles.h"
#include "imagefader.h"
#include "cmapfader.h"
#include "alarm.h"
#include "brandom.h"
#include "buffer_RGBA.h"
#define NFPS 25 /* to get mean fps */
enum RandomMode { BR_NONE=0, BR_SEQUENCES, BR_SCHEMES, BR_BOTH } RandomMode_e;
/* Random changes delays */
#define DELAY_MIN 15
#define DELAY_MAX 30
enum RandomDelays { BD_COLORMAPS=0, BD_IMAGES=1, BD_SEQUENCES=2
#ifdef WITH_WEBCAM
, BD_WEBCAMS=3
#endif
} RandomDelays_e;
#define ACTIVE_BUFFER 0
#define PASSIVE_BUFFER 1
#define SAVE_BUFFER 2
#ifdef WITH_WEBCAM
#define NSCREENS 6 /* <--- ??? oliv3 */
#else
#define NSCREENS 3
#endif
#define MAX_CAMS 2
/* store the last N frames from the webcam -same as EffectTV */
#define CAM_SAVE 32
typedef struct BKey_s {
uint32_t val;
uint16_t mod;
} BKey_t;
typedef struct Context_s {
u_char running:1;
Plugin_t *input_plugin;
Input_t *input;
/* Buffers */
Buffer8_t *buffers[NSCREENS];
BufferRGBA_t *rgba_buffers[NSCREENS];
/* 0 = active_buffer
* 1 = passive_buffer - for double-buffering
* 2 = save_buffer - push/pop screen for lens effects
*/
#ifdef WITH_WEBCAM
/* webcam */
Buffer8_t *cam_save[MAX_CAMS][CAM_SAVE];
Buffer8_t *cam_ref[MAX_CAMS];
u_char ref_taken[MAX_CAMS];
#endif
/* Faders */
ImageFader_t *imgf;
Alarm_t *a_images;
CmapFader_t *cf;
Alarm_t *a_cmaps;
GSList *outputs;
SequenceManager_t *sm;
/* TODO move this to a global */
Params3d_t params3d;
/* auto-change sequences (user or generated) */
enum RandomMode random_mode;
Alarm_t *a_random;
#ifdef WITH_WEBCAM
/* auto-change webcams */
Shuffler_t *webcams_shuffler;
Alarm_t *a_webcams;
#endif
u_long frames;
GList *events;
u_long nb_events;
BTimer_t *timer;
/* FPS stuff */
u_char sync_fps:1;
u_short max_fps;
float i_max_fps; /* inverse of the maximum frames per second */
int fps[NFPS];
BTimer_t *fps_timer;
u_char fullscreen:1;
u_char display_colormap:1;
u_char take_screenshot:1;
u_char bypass:1;
void (*events_cb)(struct Context_s *, const BKey_t *); /* events callback */
/* Banks */
u_char bank_mode; /* will default to SEQUENCES */
uint32_t banks[3][MAX_BANKS][MAX_BANKS];
u_char bankset[3];
u_char bank[3]; /* the bank used */
#ifdef WITH_WEBCAM
/* Webcam */
pthread_mutex_t cam_mtx[MAX_CAMS];
u_char cam; /* active webcam */
#endif
/* OpenGL */
#ifdef WITH_GL
u_char texture_ready:1;
u_char texture_used:1;
u_char gl_done:1;
GLuint textures[NSCREENS];
GLuint cam_textures[MAX_CAMS];
u_char pulse_3d:1;
u_char force_cube:1;
#endif
/* Target */
Image8_t *target_pic;
Plugin_t *locked; // Locked plugin feature
uint32_t input_size;
uint8_t phase_space_delay;
uint8_t span_size;
} Context_t;
Context_t *Context_new();
void Context_delete(Context_t *);
void Context_set(Context_t *);
void Context_set_colormap(Context_t *);
void Context_set_image(Context_t *);
void Context_run(Context_t *);
void Context_update(Context_t *);
void Context_update_auto(Context_t *);
int Context_add_rand(Sequence_t *, const enum PluginOptions, const int);
void Context_randomize(Context_t *);
void Context_set_max_fps(Context_t *, const u_short);
void Context_set_engine_random_mode(Context_t *, const enum RandomMode);
void Context_insert_plugin(Context_t *, Plugin_t *);
void Context_remove_plugin(Context_t *, Plugin_t *);
void Context_screenshot(const Context_t *);
float Context_fps(const Context_t *);
void Context_previous_sequence(Context_t *);
void Context_next_sequence(Context_t *);
void Context_latest_sequence(Context_t *);
void Context_random_sequence(Context_t *);
void Context_set_sequence(Context_t *, const uint32_t);
/* Events */
int Context_event(Context_t *, const Event_t *); /* TODO void ? */
void Context_process_events(Context_t *);
void Context_add_event(Context_t *, const Event_t *);
void Context_send_event(Context_t *, const enum RcptTo, const enum Command,
const enum Arg);
Buffer8_t *active_buffer(const Context_t *);
Buffer8_t *passive_buffer(const Context_t *);
static inline Buffer8_t *
save_buffer(const Context_t *ctx)
{
return ctx->buffers[SAVE_BUFFER];
}
static inline void
swap_buffers(Context_t *ctx)
{
Buffer8_t *tmp = ctx->buffers[ACTIVE_BUFFER];
ctx->buffers[ACTIVE_BUFFER] = ctx->buffers[PASSIVE_BUFFER];
ctx->buffers[PASSIVE_BUFFER] = tmp;
}
static inline void
push_buffer(const Context_t *ctx)
{
Buffer8_copy(active_buffer(ctx), save_buffer(ctx));
}
static inline void
pop_buffer(const Context_t *ctx)
{
Buffer8_copy(save_buffer(ctx), active_buffer(ctx));
}
/* TODO: deprecate export_RGB*, use export RGBA* */
Pixel_t *export_RGB_buffer(const Context_t *, const u_char, const u_char);
Pixel_t *export_BGR_buffer(const Context_t *, const u_char, const u_char);
Pixel_t *export_RGB_active_buffer(const Context_t *, const u_char);
Pixel_t *export_BGR_active_buffer(const Context_t *, const u_char);
Pixel_t *export_YUV_buffer(const Context_t *, const u_char, const u_char);
Pixel_t *export_YUV_active_buffer(const Context_t *, const u_char);
const RGBA_t *export_RGBA_buffer(const Context_t *, const u_char);
const RGBA_t *export_RGBA_active_buffer(const Context_t *);
void Context_save_banks(const Context_t *);
void Context_load_banks(Context_t *);
void Context_use_sequence_bank(Context_t *, const u_char);
void Context_clear_bank(Context_t *, const u_char);
void Context_store_bank(Context_t *, const u_char);
void Context_use_bankset(Context_t *, const u_char);
void Context_push_webcam(Context_t *, Buffer8_t *, const int);
void Context_make_GL_RGBA_texture(Context_t *ctx, const u_char);
#ifdef WITH_WEBCAM
void Context_make_GL_gray_texture(Context_t *ctx, const u_char);
#endif
void Context_set_delay(const enum RandomDelays, const int, const int);
void Context_set_shuffler_mode(const enum RandomDelays, const enum ShufflerMode);
enum ShufflerMode Context_get_shuffler_mode(const enum RandomDelays);
void Context_set_input_size(Context_t *, const uint32_t);
uint32_t Context_get_input_size(const Context_t *);
void Context_set_phase_space_delay(Context_t *, const uint8_t);
uint8_t Context_get_phase_space_delay(const Context_t *);
uint32_t Context_get_phase_space_samples(const Context_t *);
void Context_set_span_size(Context_t *, const uint8_t);
uint8_t Context_get_span_size(const Context_t *);
#endif /* __BINIOU_CONTEXT_H */
|