6 #include "audiodevice.inc"
7 #include "bccapture.inc"
10 #include "channel.inc"
11 #include "channeldb.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 "vdevicebuz.inc"
23 #include "vdevicelml.inc"
24 #include "vdevicev4l.inc"
25 #include "vdevicex11.inc"
26 #include "videoconfig.inc"
27 #include "videowindow.inc"
29 #include "audio1394.inc"
30 #include "device1394output.inc"
31 #include "vdevice1394.inc"
35 // The keepalive thread runs continuously during recording.
36 // If the recording thread doesn't reset still_alive, failed is incremented.
37 // Failed is set to 0 if the recording thread resets still_alive.
38 // It calls goose_input in the VideoDevice. The input driver should
39 // trap goose_input and restart itself asynchronous of the recording thread.
41 // Number of seconds for keepalive to freak out
42 #define KEEPALIVE_DELAY 0.5
46 class KeepaliveThread
: public Thread
49 KeepaliveThread(VideoDevice
*device
);
53 int reset_keepalive(); // Call after frame capture to reset counter
55 int start_keepalive();
70 // MWindow is required where picture settings are used, to get the defaults.
71 VideoDevice(MWindow
*mwindow
= 0);
76 // ===================================== Recording
77 int open_input(VideoInConfig
*config
,
83 // Call the constructor of the desired device.
84 // Used by fix_asset and open_input
85 VDeviceBase
* new_device_base();
88 // Used for calling OpenGL functions
89 VDeviceBase
* get_output_base();
91 // Return 1 if the data is compressed.
92 // Called by Record::run to determine if compression option is fixed.
93 // Called by RecordVideo::rewind_file to determine if FileThread should call
94 // write_compressed_frames or write_frames.
95 static int is_compressed(int driver
, int use_file
, int use_fixed
);
96 int is_compressed(int use_file
, int use_fixed
);
98 // Load the specific channeldb for the device type
99 static void load_channeldb(ChannelDB
*channeldb
, VideoInConfig
*vconfig_in
);
100 static void save_channeldb(ChannelDB
*channeldb
, VideoInConfig
*vconfig_in
);
103 // Return codec to store on disk if compressed
104 void fix_asset(Asset
*asset
, int driver
);
105 static char* drivertostr(int driver
);
106 // Get the best colormodel for recording given the file format.
107 // Must be called between open_input and read_buffer.
108 int get_best_colormodel(Asset
*asset
);
110 // Specify the audio device opened concurrently with this video device
111 int set_adevice(AudioDevice
*adevice
);
112 // Return 1 if capturing locked up
114 // Interrupt a crashed DV device
115 int interrupt_crash();
116 // Schedule capture size to be changed.
117 int set_translation(int input_x
, int input_y
);
118 // Change the channel
119 int set_channel(Channel
*channel
);
120 // Set the quality of the JPEG compressor
121 void set_quality(int quality
);
122 // Change field order
123 int set_field_order(int odd_field_first
);
124 // Set frames to clear after translation change.
125 int set_latency_counter(int value
);
126 // Values from -100 to 100
127 int set_picture(PictureConfig
*picture
);
128 int capture_frame(int frame_number
); // Start the frame_number capturing
129 int read_buffer(VFrame
*frame
); // Read the next frame off the device
131 int frame_to_vframe(VFrame
*frame
, unsigned char *input
); // Translate the captured frame to a VFrame
133 ArrayList
<Channel
*>* get_inputs();
134 // Create new input source if it doesn't match device_name.
135 // Otherwise return it.
136 Channel
* new_input_source(char *device_name
);
137 BC_Bitmap
* get_bitmap();
139 // Used by all devices to cause fd's to be not copied in fork operations.
140 int set_cloexec_flag(int desc
, int value
);
142 // ================================== Playback
143 int open_output(VideoOutConfig
*config
,
149 void set_cpus(int cpus
);
150 // Slippery is only used for hardware compression drivers
151 int start_playback();
152 int interrupt_playback();
153 // Get output buffer for playback using colormodel.
154 // colormodel argument should be as close to best_colormodel as possible
155 void new_output_buffer(VFrame
**output
, int colormodel
);
156 int wait_for_startup();
157 int wait_for_completion();
158 int output_visible(); // Whether the output is visible or not.
161 long current_position(); // last frame rendered
162 // absolute frame of last frame in buffer.
163 // The EDL parameter is passed to Canvas and can be 0.
164 int write_buffer(VFrame
*output
, EDL
*edl
);
172 // Flag when output is interrupted
174 // Compression format in use by the output device
177 // Audio device to share data with
178 AudioDevice
*adevice
;
179 // Reading data from the audio device. This is set by the video device.
181 // Synchronize the close devices
187 // timer for displaying frames in the current buffer
189 // timer for getting frame rate
191 // size of output frame being fed to device during playback
195 // time from start of previous frame to start of next frame in ms
197 // CPU count for MJPEG compression
201 int is_recording
; // status of thread
202 double frame_rate
; // Frame rate to set in device
203 // Location of input frame in captured frame
204 int frame_in_capture_x1
, frame_in_capture_x2
, frame_in_capture_y1
, frame_in_capture_y2
;
205 int capture_in_frame_x1
, capture_in_frame_x2
, capture_in_frame_y1
, capture_in_frame_y2
;
206 // Size of raw captured frame
207 int capture_w
, capture_h
;
208 int input_x
, input_y
;
210 // Captured frame size can only be changed when ready
211 int new_input_x
, new_input_y
;
214 // When the frame is resized, need to clear all the buffer frames.
220 // All the input sources on the device
221 ArrayList
<Channel
*> input_sources
;
223 // Quality for the JPEG compressor
225 // Single frame mode for playback
228 // Copy of the most recent channel set by set_channel
230 // Flag for subdevice to change channels when it has a chance
234 // Copy of the most recent picture controls
236 PictureConfig
*picture
;
240 // Change the capture size when ready
241 int update_translation();
243 VDeviceBase
*input_base
;
244 VDeviceBase
*output_base
;
245 VideoInConfig
*in_config
;
246 VideoOutConfig
*out_config
;
247 KeepaliveThread
*keepalive
;