6 #include "audio1394.inc"
7 #include "audiodevice.inc"
8 #include "bccapture.inc"
11 #include "channel.inc"
12 #include "device1394output.inc"
15 #include "mwindow.inc"
17 #include "preferences.inc"
18 #include "recordmonitor.inc"
20 #include "picture.inc"
21 #include "vdevicebase.inc"
22 #include "vdevice1394.inc"
23 #include "vdevicebuz.inc"
24 #include "vdevicelml.inc"
25 #include "vdevicev4l.inc"
26 #include "vdevicex11.inc"
27 #include "videoconfig.inc"
28 #include "videowindow.inc"
31 // The keepalive thread runs continuously during recording.
32 // If the recording thread doesn't reset still_alive, failed is incremented.
33 // Failed is set to 0 if the recording thread resets still_alive.
34 // It calls goose_input in the VideoDevice. The input driver should
35 // trap goose_input and restart itself asynchronous of the recording thread.
37 // Number of seconds for keepalive to freak out
38 #define KEEPALIVE_DELAY 0.5
42 class KeepaliveThread
: public Thread
45 KeepaliveThread(VideoDevice
*device
);
49 int reset_keepalive(); // Call after frame capture to reset counter
51 int start_keepalive();
66 // MWindow is required where picture settings are used, to get the defaults.
67 VideoDevice(MWindow
*mwindow
= 0);
72 // ===================================== Recording
73 int open_input(VideoInConfig
*config
,
81 // Return 1 if the data is compressed.
82 // Called by Record::run to determine if compression option is fixed.
83 // Called by RecordVideo::rewind_file to determine if FileThread should call
84 // write_compressed_frames or write_frames.
85 static int is_compressed(int driver
, int use_file
, int use_fixed
);
86 int is_compressed(int use_file
, int use_fixed
);
90 // Return codec to store on disk if compressed
91 static char* get_vcodec(int driver
);
92 static char* drivertostr(int driver
);
93 // Get the best colormodel for recording given the file format
94 // Must be called between open_input and read_buffer
95 int get_best_colormodel(Asset
*asset
);
97 // Specify the audio device opened concurrently with this video device
98 int set_adevice(AudioDevice
*adevice
);
99 // Return 1 if capturing locked up
101 // Interrupt a crashed DV device
102 int interrupt_crash();
103 // Schedule capture size to be changed.
104 int set_translation(int input_x
, int input_y
);
105 // Change the channel
106 int set_channel(Channel
*channel
);
107 // Set the quality of the JPEG compressor
108 void set_quality(int quality
);
109 // Change field order
110 int set_field_order(int odd_field_first
);
111 // Set frames to clear after translation change.
112 int set_latency_counter(int value
);
113 // Values from -100 to 100
114 int set_picture(PictureConfig
*picture
);
115 int capture_frame(int frame_number
); // Start the frame_number capturing
116 int read_buffer(VFrame
*frame
); // Read the next frame off the device
118 int frame_to_vframe(VFrame
*frame
, unsigned char *input
); // Translate the captured frame to a VFrame
120 ArrayList
<Channel
*>* get_inputs();
121 // Create new input source if it doesn't match device_name.
122 // Otherwise return it.
123 Channel
* new_input_source(char *device_name
);
124 BC_Bitmap
* get_bitmap();
126 // Used by all devices to cause fd's to be not copied in fork operations.
127 int set_cloexec_flag(int desc
, int value
);
129 // ================================== Playback
130 int open_output(VideoOutConfig
*config
,
136 void set_cpus(int cpus
);
137 // Slippery is only used for hardware compression drivers
138 int start_playback();
139 int interrupt_playback();
140 // Get output buffer for playback using colormodel.
141 // colormodel argument should be as close to best_colormodel as possible
142 void new_output_buffers(VFrame
**outputs
, int colormodel
);
143 int wait_for_startup();
144 int wait_for_completion();
145 int output_visible(); // Whether the output is visible or not.
148 long current_position(); // last frame rendered
149 // absolute frame of last frame in buffer.
150 // The EDL parameter is passed to Canvas and can be 0.
151 int write_buffer(VFrame
**outputs
, EDL
*edl
);
159 // Flag when output is interrupted
161 // Compression format in use by the output device
164 // Audio device to share data with
165 AudioDevice
*adevice
;
166 // Reading data from the audio device. This is set by the video device.
168 // Synchronize the close devices
174 // timer for displaying frames in the current buffer
176 // timer for getting frame rate
178 // size of output frame being fed to device during playback
182 // time from start of previous frame to start of next frame in ms
184 // CPU count for MJPEG compression
188 int is_recording
; // status of thread
189 float frame_rate
; // Frame rate to set in device
190 // Location of input frame in captured frame
191 int frame_in_capture_x1
, frame_in_capture_x2
, frame_in_capture_y1
, frame_in_capture_y2
;
192 int capture_in_frame_x1
, capture_in_frame_x2
, capture_in_frame_y1
, capture_in_frame_y2
;
193 // Size of raw captured frame
194 int capture_w
, capture_h
;
195 int input_x
, input_y
;
197 // Captured frame size can only be changed when ready
198 int new_input_x
, new_input_y
;
201 // When the frame is resized, need to clear all the buffer frames.
207 // All the input sources on the device
208 ArrayList
<Channel
*> input_sources
;
210 // Quality for the JPEG compressor
212 // Single frame mode for playback
215 // Copy of the most recent channel set by set_channel
217 // Flag for subdevice to change channels when it has a chance
221 // Copy of the most recent picture controls
223 PictureConfig
*picture
;
227 // Change the capture size when ready
228 int update_translation();
230 VDeviceBase
*input_base
;
231 VDeviceBase
*output_base
;
232 VideoInConfig
*in_config
;
233 VideoOutConfig
*out_config
;
234 KeepaliveThread
*keepalive
;