6 #include "audiodevice.inc"
7 #include "bccapture.inc"
10 #include "channel.inc"
13 #include "mwindow.inc"
15 #include "preferences.inc"
16 #include "recordmonitor.inc"
18 #include "picture.inc"
19 #include "vdevicebase.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"
27 #include "audio1394.inc"
28 #include "device1394output.inc"
29 #include "vdevice1394.inc"
33 // The keepalive thread runs continuously during recording.
34 // If the recording thread doesn't reset still_alive, failed is incremented.
35 // Failed is set to 0 if the recording thread resets still_alive.
36 // It calls goose_input in the VideoDevice. The input driver should
37 // trap goose_input and restart itself asynchronous of the recording thread.
39 // Number of seconds for keepalive to freak out
40 #define KEEPALIVE_DELAY 0.5
44 class KeepaliveThread
: public Thread
47 KeepaliveThread(VideoDevice
*device
);
51 int reset_keepalive(); // Call after frame capture to reset counter
53 int start_keepalive();
68 // MWindow is required where picture settings are used, to get the defaults.
69 VideoDevice(MWindow
*mwindow
= 0);
74 // ===================================== Recording
75 int open_input(VideoInConfig
*config
,
83 // Return 1 if the data is compressed.
84 // Called by Record::run to determine if compression option is fixed.
85 // Called by RecordVideo::rewind_file to determine if FileThread should call
86 // write_compressed_frames or write_frames.
87 static int is_compressed(int driver
, int use_file
, int use_fixed
);
88 int is_compressed(int use_file
, int use_fixed
);
92 // Return codec to store on disk if compressed
93 static char* get_vcodec(int driver
);
94 static char* drivertostr(int driver
);
95 // Get the best colormodel for recording given the file format
96 // Must be called between open_input and read_buffer
97 int get_best_colormodel(Asset
*asset
);
99 // Specify the audio device opened concurrently with this video device
100 int set_adevice(AudioDevice
*adevice
);
101 // Return 1 if capturing locked up
103 // Interrupt a crashed DV device
104 int interrupt_crash();
105 // Schedule capture size to be changed.
106 int set_translation(int input_x
, int input_y
);
107 // Change the channel
108 int set_channel(Channel
*channel
);
109 // Set the quality of the JPEG compressor
110 void set_quality(int quality
);
111 // Change field order
112 int set_field_order(int odd_field_first
);
113 // Set frames to clear after translation change.
114 int set_latency_counter(int value
);
115 // Values from -100 to 100
116 int set_picture(PictureConfig
*picture
);
117 int capture_frame(int frame_number
); // Start the frame_number capturing
118 int read_buffer(VFrame
*frame
); // Read the next frame off the device
120 int frame_to_vframe(VFrame
*frame
, unsigned char *input
); // Translate the captured frame to a VFrame
122 ArrayList
<Channel
*>* get_inputs();
123 // Create new input source if it doesn't match device_name.
124 // Otherwise return it.
125 Channel
* new_input_source(char *device_name
);
126 BC_Bitmap
* get_bitmap();
128 // Used by all devices to cause fd's to be not copied in fork operations.
129 int set_cloexec_flag(int desc
, int value
);
131 // ================================== Playback
132 int open_output(VideoOutConfig
*config
,
138 void set_cpus(int cpus
);
139 // Slippery is only used for hardware compression drivers
140 int start_playback();
141 int interrupt_playback();
142 // Get output buffer for playback using colormodel.
143 // colormodel argument should be as close to best_colormodel as possible
144 void new_output_buffers(VFrame
**outputs
, int colormodel
);
145 int wait_for_startup();
146 int wait_for_completion();
147 int output_visible(); // Whether the output is visible or not.
150 long current_position(); // last frame rendered
151 // absolute frame of last frame in buffer.
152 // The EDL parameter is passed to Canvas and can be 0.
153 int write_buffer(VFrame
**outputs
, EDL
*edl
);
161 // Flag when output is interrupted
163 // Compression format in use by the output device
166 // Audio device to share data with
167 AudioDevice
*adevice
;
168 // Reading data from the audio device. This is set by the video device.
170 // Synchronize the close devices
176 // timer for displaying frames in the current buffer
178 // timer for getting frame rate
180 // size of output frame being fed to device during playback
184 // time from start of previous frame to start of next frame in ms
186 // CPU count for MJPEG compression
190 int is_recording
; // status of thread
191 float frame_rate
; // Frame rate to set in device
192 // Location of input frame in captured frame
193 int frame_in_capture_x1
, frame_in_capture_x2
, frame_in_capture_y1
, frame_in_capture_y2
;
194 int capture_in_frame_x1
, capture_in_frame_x2
, capture_in_frame_y1
, capture_in_frame_y2
;
195 // Size of raw captured frame
196 int capture_w
, capture_h
;
197 int input_x
, input_y
;
199 // Captured frame size can only be changed when ready
200 int new_input_x
, new_input_y
;
203 // When the frame is resized, need to clear all the buffer frames.
209 // All the input sources on the device
210 ArrayList
<Channel
*> input_sources
;
212 // Quality for the JPEG compressor
214 // Single frame mode for playback
217 // Copy of the most recent channel set by set_channel
219 // Flag for subdevice to change channels when it has a chance
223 // Copy of the most recent picture controls
225 PictureConfig
*picture
;
229 // Change the capture size when ready
230 int update_translation();
232 VDeviceBase
*input_base
;
233 VDeviceBase
*output_base
;
234 VideoInConfig
*in_config
;
235 VideoOutConfig
*out_config
;
236 KeepaliveThread
*keepalive
;