4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
25 #ifdef HAVE_VIDEO4LINUX
29 #include "channel.inc"
30 #include "condition.inc"
35 #include "vdevicebase.h"
36 #include "vdevicebuz.inc"
40 #define INPUT_BUFFER_SIZE 0x40000
42 // Let's get real. The Buz driver doesn't work. If the buffers overflow
43 // for enough time it locks up and can't be recovered except by a
44 // SIGINT and restart. We need to cascade the buffer reading in another
45 // ring buffer thread, have it read continuously, and cancel it if it
46 // dies. How about if we do this in SCHED_RR and wait for it to die before
47 // implementing cancellation?
50 class VDeviceBUZInput : public Thread
53 VDeviceBUZInput(VDeviceBUZ *device);
57 void get_buffer(char **ptr, int *size);
59 void increment_counter(int *counter);
60 void decrement_counter(int *counter);
67 int current_outbuffer;
68 Condition *output_lock;
74 class VDeviceBUZ : public VDeviceBase
77 VDeviceBUZ(VideoDevice *device);
80 friend class VDeviceBUZInput;
85 int read_buffer(VFrame *frame);
86 int write_buffer(VFrame *frames, EDL *edl);
87 int reset_parameters();
88 ArrayList<int>* get_render_strategies();
89 int set_channel(Channel *channel);
90 int get_norm(int norm);
91 static void get_inputs(ArrayList<Channel*> *input_sources);
92 int set_picture(PictureConfig *picture);
93 int get_best_colormodel(int colormodel);
94 int create_channeldb(ArrayList<Channel*> *channeldb);
95 void new_output_buffer(VFrame *output, int colormodel);
99 int open_input_core(Channel *channel);
100 int close_input_core();
101 int open_output_core(Channel *channel);
102 int close_output_core();
105 char *input_buffer, *frame_buffer, *output_buffer;
106 long frame_size, frame_allocated;
108 // quicktime_mjpeg_hdr jpeg_header;
110 ArrayList<int> render_strategies;
111 // Temporary frame for compressing output data
113 // Frame given to user to acquire data
117 VDeviceBUZInput *input_thread;
119 struct buz_params bparm;
120 struct buz_requestbuffers breq;
121 // Can't CSYNC the first loop
123 // Number of output frame to load
134 #endif // HAVE_VIDEO4LINUX