r286: Heroine Virutal's official release 1.2.0
[cinelerra_cv/ct.git] / hvirtual / cinelerra / device1394output.h
blob47102ba5983e3260598605ca06544832932f78c7
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 "libdv/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 // dv1394
128 int dv1394_init;
129 int dv1394_shutdown;
130 int dv1394_submit_frames;
131 int dv1394_wait_frames;
132 int dv1394_receive_frames;
133 int dv1394_start_receive;
134 int dv1394_get_status;
136 // video1394
137 int video1394_listen_channel;
138 int video1394_unlisten_channel;
139 int video1394_listen_queue_buffer;
140 int video1394_listen_wait_buffer;
141 int video1394_talk_channel;
142 int video1394_untalk_channel;
143 int video1394_talk_queue_buffer;
144 int video1394_talk_wait_buffer;
145 int video1394_listen_poll_buffer;
153 #endif
159 #endif