Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

videodevice.h

Go to the documentation of this file.
00001 #ifndef VIDEODEVICE_H
00002 #define VIDEODEVICE_H
00003 
00004 #include "asset.inc"
00005 #include "assets.inc"
00006 #include "audio1394.inc"
00007 #include "audiodevice.inc"
00008 #include "bccapture.inc"
00009 #include "bctimer.h"
00010 #include "canvas.inc"
00011 #include "channel.inc"
00012 #include "device1394output.inc"
00013 #include "edl.inc"
00014 #include "guicast.h"
00015 #include "mwindow.inc"
00016 #include "mutex.inc"
00017 #include "preferences.inc"
00018 #include "recordmonitor.inc"
00019 #include "thread.h"
00020 #include "picture.inc"
00021 #include "vdevicebase.inc"
00022 #include "vdevice1394.inc"
00023 #include "vdevicebuz.inc"
00024 #include "vdevicelml.inc"
00025 #include "vdevicev4l.inc"
00026 #include "vdevicex11.inc"
00027 #include "videoconfig.inc"
00028 #include "videowindow.inc"
00029 
00030 
00031 // The keepalive thread runs continuously during recording.
00032 // If the recording thread doesn't reset still_alive, failed is incremented.
00033 // Failed is set to 0 if the recording thread resets still_alive.
00034 // It calls goose_input in the VideoDevice.  The input driver should
00035 // trap goose_input and restart itself asynchronous of the recording thread.
00036 
00037 // Number of seconds for keepalive to freak out
00038 #define KEEPALIVE_DELAY 0.5
00039 
00040 class VideoDevice;
00041 
00042 class KeepaliveThread : public Thread
00043 {
00044 public:
00045         KeepaliveThread(VideoDevice *device);
00046         ~KeepaliveThread();
00047 
00048         void run();
00049         int reset_keepalive();   // Call after frame capture to reset counter
00050         int get_failed();
00051         int start_keepalive();
00052         int stop();
00053 
00054         Timer timer;
00055         int still_alive;
00056         int failed;
00057         int interrupted;
00058         VideoDevice *device;
00059         Mutex *startup_lock;
00060         int capturing;
00061 };
00062 
00063 class VideoDevice
00064 {
00065 public:
00066 // MWindow is required where picture settings are used, to get the defaults.
00067         VideoDevice(MWindow *mwindow = 0);
00068         ~VideoDevice();
00069 
00070         int close_all();
00071 
00072 // ===================================== Recording
00073         int open_input(VideoInConfig *config, 
00074                 int input_x, 
00075                 int input_y, 
00076                 float input_z,
00077                 float frame_rate);
00078 
00079 
00080 
00081 // Return 1 if the data is compressed.
00082 // Called by Record::run to determine if compression option is fixed.
00083 // Called by RecordVideo::rewind_file to determine if FileThread should call
00084 // write_compressed_frames or write_frames.
00085         static int is_compressed(int driver, int use_file, int use_fixed);
00086         int is_compressed(int use_file, int use_fixed);
00087 
00088 
00089 
00090 // Return codec to store on disk if compressed
00091         static char* get_vcodec(int driver);
00092         static char* drivertostr(int driver);
00093 // Get the best colormodel for recording given the file format
00094 // Must be called between open_input and read_buffer
00095         int get_best_colormodel(Asset *asset);
00096 
00097 // Specify the audio device opened concurrently with this video device
00098         int set_adevice(AudioDevice *adevice);
00099 // Return 1 if capturing locked up
00100         int get_failed();  
00101 // Interrupt a crashed DV device
00102         int interrupt_crash();
00103 // Schedule capture size to be changed.
00104         int set_translation(int input_x, int input_y);
00105 // Change the channel
00106         int set_channel(Channel *channel);
00107 // Set the quality of the JPEG compressor
00108         void set_quality(int quality);
00109 // Change field order
00110         int set_field_order(int odd_field_first);
00111 // Set frames to clear after translation change.
00112         int set_latency_counter(int value);
00113 // Values from -100 to 100
00114         int set_picture(PictureConfig *picture);
00115         int capture_frame(int frame_number);  // Start the frame_number capturing
00116         int read_buffer(VFrame *frame);  // Read the next frame off the device
00117         int has_signal();
00118         int frame_to_vframe(VFrame *frame, unsigned char *input); // Translate the captured frame to a VFrame
00119         int initialize();
00120         ArrayList<Channel*>* get_inputs();
00121 // Create new input source if it doesn't match device_name.  
00122 // Otherwise return it.
00123         Channel* new_input_source(char *device_name);
00124         BC_Bitmap* get_bitmap();
00125 
00126 // Used by all devices to cause fd's to be not copied in fork operations.
00127         int set_cloexec_flag(int desc, int value);
00128 
00129 // ================================== Playback
00130         int open_output(VideoOutConfig *config, 
00131                                         float rate, 
00132                                         int out_w, 
00133                                         int out_h,
00134                                         Canvas *output,
00135                                         int single_frame);
00136         void set_cpus(int cpus);
00137 // Slippery is only used for hardware compression drivers
00138         int start_playback();
00139         int interrupt_playback();
00140 // Get output buffer for playback using colormodel.
00141 // colormodel argument should be as close to best_colormodel as possible
00142         void new_output_buffers(VFrame **outputs, int colormodel);
00143         int wait_for_startup();
00144         int wait_for_completion();
00145         int output_visible();     // Whether the output is visible or not.
00146         int stop_playback();
00147         void goose_input();
00148         long current_position();     // last frame rendered
00149 // absolute frame of last frame in buffer.
00150 // The EDL parameter is passed to Canvas and can be 0.
00151         int write_buffer(VFrame **outputs, EDL *edl);   
00152 
00153 
00154 
00155 
00156 
00157 
00158 
00159 // Flag when output is interrupted
00160         int interrupt;
00161 // Compression format in use by the output device
00162         int output_format;   
00163         int is_playing_back;
00164 // Audio device to share data with
00165         AudioDevice *adevice;
00166 // Reading data from the audio device.  This is set by the video device.
00167         int sharing;
00168 // Synchronize the close devices
00169         int done_sharing;
00170         Mutex *sharing_lock;
00171 
00172 // frame rates
00173         float orate, irate;               
00174 // timer for displaying frames in the current buffer
00175         Timer buffer_timer;               
00176 // timer for getting frame rate
00177         Timer rate_timer;                 
00178 // size of output frame being fed to device during playback
00179         int out_w, out_h;                 
00180 // modes
00181         int r, w;                         
00182 // time from start of previous frame to start of next frame in ms
00183         long frame_delay;
00184 // CPU count for MJPEG compression
00185         int cpus;
00186 
00187 
00188         int is_recording; // status of thread
00189         float frame_rate; // Frame rate to set in device
00190 // Location of input frame in captured frame
00191         int frame_in_capture_x1, frame_in_capture_x2, frame_in_capture_y1, frame_in_capture_y2;
00192         int capture_in_frame_x1, capture_in_frame_x2, capture_in_frame_y1, capture_in_frame_y2;
00193 // Size of raw captured frame
00194         int capture_w, capture_h;
00195         int input_x, input_y;
00196         float input_z;
00197 // Captured frame size can only be changed when ready
00198         int new_input_x, new_input_y;
00199         float new_input_z;
00200         int frame_resized;
00201 // When the frame is resized, need to clear all the buffer frames.
00202         int latency_counter;
00203         int capturing;
00204         int swap_bytes;
00205 
00206 
00207 // All the input sources on the device
00208         ArrayList<Channel*> input_sources;
00209         int odd_field_first;
00210 // Quality for the JPEG compressor
00211         int quality;
00212 // Single frame mode for playback
00213         int single_frame;
00214 
00215 // Copy of the most recent channel set by set_channel
00216         Channel *channel;
00217 // Flag for subdevice to change channels when it has a chance
00218         int channel_changed;
00219         Mutex *channel_lock;
00220 
00221 // Copy of the most recent picture controls
00222         int picture_changed;
00223         PictureConfig *picture;
00224         Mutex *picture_lock;
00225 
00226 
00227 // Change the capture size when ready
00228         int update_translation();  
00229 
00230         VDeviceBase *input_base;
00231         VDeviceBase *output_base;
00232         VideoInConfig *in_config;
00233         VideoOutConfig *out_config;
00234         KeepaliveThread *keepalive;
00235         MWindow *mwindow;
00236 };
00237 
00238 
00239 
00240 #endif

Generated on Sun Jan 8 13:39:02 2006 for Cinelerra-svn by  doxygen 1.4.4