add select all/none, layout shortcuts from all guis, docs tweaks + cv->gg
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / iec61883output.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #ifndef IEC61883OUTPUT_H
23 #define IEC61883OUTPUT_H
24
25
26
27 #ifdef HAVE_FIREWIRE
28
29 #include "audiodevice.inc"
30 #include "condition.inc"
31 #include "libiec61883/iec61883.h"
32 #include "libdv.h"
33 #include "mutex.inc"
34 #include "thread.h"
35 #include "vframe.inc"
36 #include "videodevice.inc"
37
38 // Common 1394 output for audio and video
39
40 // This runs continuously to keep the VTR warm.
41 // Takes encoded DV frames and PCM audio.
42 class IEC61883Output : public Thread
43 {
44 public:
45         IEC61883Output(VideoDevice *vdevice);
46         IEC61883Output(AudioDevice *adevice);
47         ~IEC61883Output();
48
49         void reset();
50         int open(int port,
51                 int channel,
52                 int length,
53                 int channels,
54                 int bits,
55                 int samplerate,
56                 int syt);
57         void start();
58         void run();
59
60
61 // Write frame with timed blocking.
62
63         void write_frame(VFrame *input);
64
65
66 // Write audio with timed blocking.
67
68         void write_samples(char *data, int samples);
69         long get_audio_position();
70         void interrupt();
71         void flush();
72
73
74
75         void increment_counter(int *counter);
76         void decrement_counter(int *counter);
77         int read_frame(unsigned char *data, int n, unsigned int dropped);
78
79
80         char **buffer;
81         int *buffer_size;
82         int *buffer_valid;
83
84         int total_buffers;
85         int current_inbuffer;
86         int current_outbuffer;
87
88         char *audio_buffer;
89         int audio_samples;
90 // Encoder for audio frames
91         dv_t *encoder;
92
93         Mutex *buffer_lock;
94 // Block while waiting for the first buffer to be allocated
95         Condition *start_lock;
96         Mutex *position_lock;
97
98 // Provide timed blocking for writing routines.
99
100         Condition *video_lock;
101         Condition *audio_lock;
102         int done;
103
104
105 // Output
106         int fd;
107         raw1394handle_t handle;
108         iec61883_dv_t frame;
109 // Must break up each frame into 480 byte chunks again.
110         char *out_buffer;
111         int out_size;
112         int out_position;
113
114
115
116
117
118         VFrame *temp_frame, *temp_frame2;
119 // Encoder for making DV frames
120         dv_t *audio_encoder;
121         dv_t *video_encoder;
122         unsigned char *output_buffer;
123         int output_number;
124     unsigned int packet_sizes[321];
125     unsigned char  continuity_counter;
126     int unused_buffers;
127         int avc_id;
128         int channels;
129         int samplerate;
130         int bits;
131         int syt;
132         long audio_position;
133         int interrupted;
134         int have_video;
135         int is_pal;
136         VideoDevice *vdevice;
137         AudioDevice *adevice;
138
139
140
141 };
142
143
144
145
146 #endif
147
148
149
150
151
152 #endif