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 // Recording constructor
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(Picture
*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
117 int frame_to_vframe(VFrame
*frame
, unsigned char *input
); // Translate the captured frame to a VFrame
119 ArrayList
<Channel
*>* get_inputs();
120 // Create new input source if it doesn't match device_name.
121 // Otherwise return it.
122 Channel
* new_input_source(char *device_name
);
123 BC_Bitmap
* get_bitmap();
125 // Used by all devices to cause fd's to be not copied in fork operations.
126 int set_cloexec_flag(int desc
, int value
);
128 // ================================== Playback
129 int open_output(VideoOutConfig
*config
,
135 void set_cpus(int cpus
);
136 // Slippery is only used for hardware compression drivers
137 int start_playback();
138 int interrupt_playback();
139 // Get output buffer for playback using colormodel.
140 // colormodel argument should be as close to best_colormodel as possible
141 void new_output_buffers(VFrame
**outputs
, int colormodel
);
142 int wait_for_startup();
143 int wait_for_completion();
144 int output_visible(); // Whether the output is visible or not.
147 long current_position(); // last frame rendered
148 // absolute frame of last frame in buffer.
149 // The EDL parameter is passed to Canvas and can be 0.
150 int write_buffer(VFrame
**outputs
, EDL
*edl
);
158 // Flag when output is interrupted
160 // Compression format in use by the output device
163 // Audio device to share data with
164 AudioDevice
*adevice
;
165 // Reading data from the audio device. This is set by the video device.
167 // Synchronize the close devices
173 // timer for displaying frames in the current buffer
175 // timer for getting frame rate
177 // size of output frame being fed to device during playback
181 // time from start of previous frame to start of next frame in ms
183 // CPU count for MJPEG compression
187 int is_recording
; // status of thread
188 float frame_rate
; // Frame rate to set in device
189 // Location of input frame in captured frame
190 int frame_in_capture_x1
, frame_in_capture_x2
, frame_in_capture_y1
, frame_in_capture_y2
;
191 int capture_in_frame_x1
, capture_in_frame_x2
, capture_in_frame_y1
, capture_in_frame_y2
;
192 // Size of raw captured frame
193 int capture_w
, capture_h
;
194 int input_x
, input_y
;
196 // Captured frame size can only be changed when ready
197 int new_input_x
, new_input_y
;
200 // When the frame is resized, need to clear all the buffer frames.
206 // All the input sources on the device
207 ArrayList
<Channel
*> input_sources
;
209 // Quality for the JPEG compressor
211 // Single frame mode for playback
214 // Copy of the most recent channel set by set_channel
216 // Flag for subdevice to change channels when it has a chance
220 // Copy of the most recent picture controls
226 // Change the capture size when ready
227 int update_translation();
229 VDeviceBase
*input_base
;
230 VDeviceBase
*output_base
;
231 VideoInConfig
*in_config
;
232 VideoOutConfig
*out_config
;
233 KeepaliveThread
*keepalive
;