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

iec61883output.h

Go to the documentation of this file.
00001 #ifndef IEC61883OUTPUT_H
00002 #define IEC61883OUTPUT_H
00003 
00004 
00005 
00006 #ifdef HAVE_FIREWIRE
00007 
00008 #include "audiodevice.inc"
00009 #include "condition.inc"
00010 #include <libiec61883/iec61883.h>
00011 #include "libdv.h"
00012 #include "mutex.inc"
00013 #include "thread.h"
00014 #include "vframe.inc"
00015 #include "videodevice.inc"
00016 
00017 // Common 1394 output for audio and video
00018 
00019 // This runs continuously to keep the VTR warm.
00020 // Takes encoded DV frames and PCM audio.
00021 class IEC61883Output : public Thread
00022 {
00023 public:
00024         IEC61883Output(VideoDevice *vdevice);
00025         IEC61883Output(AudioDevice *adevice);
00026         ~IEC61883Output();
00027 
00028         void reset();
00029         int open(int port,
00030                 int channel,
00031                 int length,
00032                 int channels, 
00033                 int bits, 
00034                 int samplerate,
00035                 int syt);
00036         void start();
00037         void run();
00038 
00039 
00040 // Write frame with timed blocking.
00041 
00042         void write_frame(VFrame *input);
00043 
00044 
00045 // Write audio with timed blocking.
00046 
00047         void write_samples(char *data, int samples);
00048         long get_audio_position();
00049         void interrupt();
00050         void flush();
00051 
00052 
00053 
00054         void increment_counter(int *counter);
00055         void decrement_counter(int *counter);
00056         int read_frame(unsigned char *data, int n, unsigned int dropped);
00057 
00058 
00059         char **buffer;
00060         int *buffer_size;
00061         int *buffer_valid;
00062 
00063         int total_buffers;
00064         int current_inbuffer;
00065         int current_outbuffer;
00066 
00067         char *audio_buffer;
00068         int audio_samples;
00069 // Encoder for audio frames
00070         dv_t *encoder;
00071 
00072         Mutex *buffer_lock;
00073 // Block while waiting for the first buffer to be allocated
00074         Condition *start_lock;
00075         Mutex *position_lock;
00076 
00077 // Provide timed blocking for writing routines.
00078 
00079         Condition *video_lock;
00080         Condition *audio_lock;
00081         int done;
00082 
00083 
00084 // Output
00085         int fd;
00086         raw1394handle_t handle;
00087         iec61883_dv_t frame;
00088 // Must break up each frame into 480 byte chunks again.
00089         char *out_buffer;
00090         int out_size;
00091         int out_position;
00092 
00093 
00094         
00095         
00096         
00097         VFrame *temp_frame, *temp_frame2;
00098 // Encoder for making DV frames
00099         dv_t *audio_encoder;
00100         dv_t *video_encoder;
00101         unsigned char *output_buffer;
00102         int output_number;
00103     unsigned int packet_sizes[321];
00104     unsigned char  continuity_counter;
00105     int unused_buffers;
00106         int avc_id;
00107         int channels;
00108         int samplerate;
00109         int bits;
00110         int syt;
00111         long audio_position;
00112         int interrupted;
00113         int have_video;
00114         int is_pal;
00115         VideoDevice *vdevice;
00116         AudioDevice *adevice;
00117 
00118 
00119 
00120 };
00121 
00122 
00123 
00124 
00125 #endif
00126 
00127 
00128 
00129 
00130 
00131 #endif

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