r1026: Videoscope layout tweaks.
[cinelerra_cv/ct.git] / cinelerra / device1394output.h
blob06cf726daf6c079559a0950e1e46336e017719dc
1 #ifndef DEVICE1394OUTPUT_H
2 #define DEVICE1394OUTPUT_H
6 #ifdef HAVE_FIREWIRE
8 #include "audiodevice.inc"
9 #include "condition.inc"
10 #include "libdv.h"
11 #include "dv1394.h"
12 #include "ieee1394-ioctl.h"
13 #include "mutex.inc"
14 #include "thread.h"
15 #include "vframe.inc"
16 #include "video1394.h"
17 #include "videodevice.inc"
19 // Common 1394 output for audio and video
21 // This runs continuously to keep the VTR warm.
22 // Takes encoded DV frames and PCM audio. Does the 1394 encryption on the fly.
23 class Device1394Output : public Thread
25 public:
26 Device1394Output(VideoDevice *vdevice);
27 Device1394Output(AudioDevice *adevice);
28 ~Device1394Output();
30 void reset();
31 int open(char *path,
32 int port,
33 int channel,
34 int length,
35 int channels,
36 int bits,
37 int samplerate,
38 int syt);
39 void start();
40 void run();
43 // Write frame with timed blocking.
45 void write_frame(VFrame *input);
48 // Write audio with timed blocking.
50 void write_samples(char *data, int samples);
51 long get_audio_position();
52 void interrupt();
53 void flush();
55 // This object is shared between audio and video. Return what the driver is
56 // based on whether vdevice or adevice exists.
57 int get_dv1394();
59 // Set IOCTL numbers based on kernel version
60 void set_ioctls();
62 void encrypt(unsigned char *output,
63 unsigned char *data,
64 int data_size);
67 void increment_counter(int *counter);
68 void decrement_counter(int *counter);
71 char **buffer;
72 int *buffer_size;
73 int *buffer_valid;
75 int total_buffers;
76 int current_inbuffer;
77 int current_outbuffer;
79 char *audio_buffer;
80 int audio_samples;
81 // Encoder for audio frames
82 dv_t *encoder;
84 Mutex *buffer_lock;
85 // Block while waiting for the first buffer to be allocated
86 Condition *start_lock;
87 Mutex *position_lock;
89 // Provide timed blocking for writing routines.
91 Condition *video_lock;
92 Condition *audio_lock;
93 int done;
94 struct dv1394_status status;
97 // Output
98 int output_fd;
99 struct video1394_mmap output_mmap;
100 struct video1394_queue_variable output_queue;
101 // raw1394handle_t avc_handle;
102 VFrame *temp_frame, *temp_frame2;
103 // Encoder for making DV frames
104 dv_t *audio_encoder;
105 dv_t *video_encoder;
106 unsigned int cip_n, cip_d;
107 unsigned int cip_counter;
108 unsigned char f50_60;
109 unsigned char *output_buffer;
110 int output_number;
111 unsigned int packet_sizes[321];
112 unsigned char continuity_counter;
113 int unused_buffers;
114 int avc_id;
115 int channels;
116 int samplerate;
117 int bits;
118 int syt;
119 long audio_position;
120 int interrupted;
121 int have_video;
122 int is_pal;
123 VideoDevice *vdevice;
124 AudioDevice *adevice;
126 // IOCTL # variables
127 // video1394
128 int video1394_listen_channel;
129 int video1394_unlisten_channel;
130 int video1394_listen_queue_buffer;
131 int video1394_listen_wait_buffer;
132 int video1394_talk_channel;
133 int video1394_untalk_channel;
134 int video1394_talk_queue_buffer;
135 int video1394_talk_wait_buffer;
136 int video1394_listen_poll_buffer;
138 // To keep track of the delay between putting the audio in the buffer
139 // and when it is actually presented on the DV device
140 long *position_presented;
147 #endif
153 #endif