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

device1394output.h

Go to the documentation of this file.
00001 #ifndef DEVICE1394OUTPUT_H
00002 #define DEVICE1394OUTPUT_H
00003 
00004 
00005 
00006 #ifdef HAVE_FIREWIRE
00007 
00008 #include "audiodevice.inc"
00009 #include "condition.inc"
00010 #include "libdv.h"
00011 #include "dv1394.h"
00012 #include "ieee1394-ioctl.h"
00013 #include "mutex.inc"
00014 #include "thread.h"
00015 #include "vframe.inc"
00016 #include "video1394.h"
00017 #include "videodevice.inc"
00018 
00019 // Common 1394 output for audio and video
00020 
00021 // This runs continuously to keep the VTR warm.
00022 // Takes encoded DV frames and PCM audio.  Does the 1394 encryption on the fly.
00023 class Device1394Output : public Thread
00024 {
00025 public:
00026         Device1394Output(VideoDevice *vdevice);
00027         Device1394Output(AudioDevice *adevice);
00028         ~Device1394Output();
00029 
00030         void reset();
00031         int open(char *path,
00032                 int port,
00033                 int channel,
00034                 int length,
00035                 int channels, 
00036                 int bits, 
00037                 int samplerate,
00038                 int syt);
00039         void start();
00040         void run();
00041 
00042 
00043 // Write frame with timed blocking.
00044 
00045         void write_frame(VFrame *input);
00046 
00047 
00048 // Write audio with timed blocking.
00049 
00050         void write_samples(char *data, int samples);
00051         long get_audio_position();
00052         void interrupt();
00053         void flush();
00054 
00055 // This object is shared between audio and video.  Return what the driver is
00056 // based on whether vdevice or adevice exists.
00057         int get_dv1394();
00058 
00059 // Set IOCTL numbers based on kernel version
00060         void set_ioctls();
00061 
00062         void encrypt(unsigned char *output, 
00063                 unsigned char *data, 
00064                 int data_size);
00065 
00066 
00067         void increment_counter(int *counter);
00068         void decrement_counter(int *counter);
00069 
00070 
00071         char **buffer;
00072         int *buffer_size;
00073         int *buffer_valid;
00074 
00075         int total_buffers;
00076         int current_inbuffer;
00077         int current_outbuffer;
00078 
00079         char *audio_buffer;
00080         int audio_samples;
00081 // Encoder for audio frames
00082         dv_t *encoder;
00083 
00084         Mutex *buffer_lock;
00085 // Block while waiting for the first buffer to be allocated
00086         Condition *start_lock;
00087         Mutex *position_lock;
00088 
00089 // Provide timed blocking for writing routines.
00090 
00091         Condition *video_lock;
00092         Condition *audio_lock;
00093         int done;
00094         struct dv1394_status status;
00095 
00096 
00097 // Output
00098         int output_fd;
00099         struct video1394_mmap output_mmap;
00100         struct video1394_queue_variable output_queue;
00101 //      raw1394handle_t avc_handle;
00102         VFrame *temp_frame, *temp_frame2;
00103 // Encoder for making DV frames
00104         dv_t *audio_encoder;
00105         dv_t *video_encoder;
00106         unsigned int cip_n, cip_d;
00107     unsigned int cip_counter;
00108         unsigned char f50_60;
00109         unsigned char *output_buffer;
00110         int output_number;
00111     unsigned int packet_sizes[321];
00112     unsigned char  continuity_counter;
00113     int unused_buffers;
00114         int avc_id;
00115         int channels;
00116         int samplerate;
00117         int bits;
00118         int syt;
00119         long audio_position;
00120         int interrupted;
00121         int have_video;
00122         int is_pal;
00123         VideoDevice *vdevice;
00124         AudioDevice *adevice;
00125 
00126         // IOCTL # variables
00127    // video1394
00128    int video1394_listen_channel;
00129    int video1394_unlisten_channel;
00130    int video1394_listen_queue_buffer;
00131    int video1394_listen_wait_buffer;
00132    int video1394_talk_channel;
00133    int video1394_untalk_channel;
00134    int video1394_talk_queue_buffer;
00135    int video1394_talk_wait_buffer;
00136    int video1394_listen_poll_buffer;
00137 
00138 
00139 };
00140 
00141 
00142 
00143 
00144 #endif
00145 
00146 
00147 
00148 
00149 
00150 #endif

Generated on Sun Jan 8 13:38:53 2006 for Cinelerra-svn by  doxygen 1.4.4