5 #include "audio1394.inc"
6 #include "audiodevice.inc"
8 #include "bccapture.inc"
10 #include "channel.inc"
12 #include "mwindow.inc"
14 #include "preferences.inc"
15 #include "recordmonitor.inc"
18 #include "vdevicebase.inc"
19 #include "vdevice1394.inc"
20 #include "vdevicebuz.inc"
21 #include "vdevicelml.inc"
22 #include "vdevicev4l.inc"
23 #include "vdevicex11.inc"
24 #include "videoconfig.inc"
25 #include "videowindow.inc"
28 // The keepalive thread runs continuously during recording.
29 // If the recording thread doesn't reset still_alive, failed is incremented.
30 // Failed is set to 0 if the recording thread resets still_alive.
31 // It calls goose_input in the VideoDevice. The input driver should
32 // trap goose_input and restart itself asynchronous of the recording thread.
34 // Number of seconds for keepalive to freak out
35 #define KEEPALIVE_DELAY 0.5
39 class KeepaliveThread
: public Thread
42 KeepaliveThread(VideoDevice
*device
);
46 int reset_keepalive(); // Call after frame capture to reset counter
48 int start_keepalive();
63 // Recording constructor
67 friend class VDeviceLML
;
68 friend class VDeviceX11
;
69 friend class VDevice1394
;
70 friend class VDeviceBUZInput
;
71 friend class VDeviceBUZ
;
72 friend class VDeviceBase
;
73 friend class VDeviceV4L
;
74 friend class Audio1394
;
77 // Create a default channeldb, erasing the old one
78 void create_channeldb(ArrayList
<Channel
*> *channeldb
);
80 // ===================================== Recording
81 int open_input(VideoInConfig
*config
,
86 // Return if the data is compressed
87 static int is_compressed(int driver
);
88 // Return codec to store on disk if compressed
89 static char* get_vcodec(int driver
);
90 static char* drivertostr(int driver
);
92 // Get the best colormodel for recording given the file format
93 // Must be called between open_input and read_buffer
94 int get_best_colormodel(Asset
*asset
);
96 // Unlocks the device if being shared with audio
97 // int stop_sharing();
98 // Specify the audio device opened concurrently with this video device
99 int set_adevice(AudioDevice
*adevice
);
100 // Called by the audio device to share a buffer
101 // int get_shared_data(unsigned char *data, long size);
102 // Return 1 if capturing locked up
104 // Interrupt a crashed DV device
105 int interrupt_crash();
106 // Schedule capture size to be changed.
107 int set_translation(int input_x
, int input_y
);
108 // Change the channel
109 int set_channel(Channel
*channel
);
110 // Set the quality of the JPEG compressor
111 void set_quality(int quality
);
112 // Change field order
113 int set_field_order(int odd_field_first
);
114 // Set frames to clear after translation change.
115 int set_latency_counter(int value
);
116 // Values from -100 to 100
117 int set_picture(int brightness
,
122 int capture_frame(int frame_number
); // Start the frame_number capturing
123 int read_buffer(VFrame
*frame
); // Read the next frame off the device
124 int frame_to_vframe(VFrame
*frame
, unsigned char *input
); // Translate the captured frame to a VFrame
126 ArrayList
<char *>* get_inputs();
127 BC_Bitmap
* get_bitmap();
130 // ================================== Playback
131 int open_output(VideoOutConfig
*config
,
137 void set_cpus(int cpus
);
138 // Slippery is only used for hardware compression drivers
139 int start_playback();
140 int interrupt_playback();
141 // Get output buffer for playback using colormodel.
142 // colormodel argument should be as close to best_colormodel as possible
143 void new_output_buffers(VFrame
**outputs
, int colormodel
);
144 int wait_for_startup();
145 int wait_for_completion();
146 int output_visible(); // Whether the output is visible or not.
149 long current_position(); // last frame rendered
150 // absolute frame of last frame in buffer.
151 // The EDL parameter is passed to Canvas and can be 0.
152 int write_buffer(VFrame
**outputs
, EDL
*edl
);
154 // Flag when output is interrupted
156 // Compression format in use by the output device
159 // Audio device to share data with
160 AudioDevice
*adevice
;
161 // Reading data from the audio device. This is set by the video device.
163 // Synchronize the close devices
169 // timer for displaying frames in the current buffer
171 // timer for getting frame rate
173 // size of output frame being fed to device during playback
177 // time from start of previous frame to start of next frame in ms
179 // CPU count for MJPEG compression
183 int is_recording
; // status of thread
184 float frame_rate
; // Frame rate to set in device
185 // Location of input frame in captured frame
186 int frame_in_capture_x1
, frame_in_capture_x2
, frame_in_capture_y1
, frame_in_capture_y2
;
187 int capture_in_frame_x1
, capture_in_frame_x2
, capture_in_frame_y1
, capture_in_frame_y2
;
188 // Size of raw captured frame
189 int capture_w
, capture_h
;
190 int input_x
, input_y
;
192 // Captured frame size can only be changed when ready
193 int new_input_x
, new_input_y
;
196 // When the frame is resized, need to clear all the buffer frames.
200 // All the input sources on the device
201 ArrayList
<char *> input_sources
;
203 // Quality for the JPEG compressor
205 // Single frame mode for playback
209 // Change the capture size when ready
210 int update_translation();
212 VDeviceBase
*input_base
;
213 VDeviceBase
*output_base
;
214 VideoInConfig
*in_config
;
215 VideoOutConfig
*out_config
;
216 KeepaliveThread
*keepalive
;