4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5 * Copyright (C) 2003-2016 Cinelerra CV contributors
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #ifndef DEVICE1394OUTPUT_H
24 #define DEVICE1394OUTPUT_H
30 #include "audiodevice.inc"
31 #include "condition.inc"
34 #include "ieee1394-ioctl.h"
38 #include "video1394.h"
39 #include "videodevice.inc"
41 // Common 1394 output for audio and video
43 // This runs continuously to keep the VTR warm.
44 // Takes encoded DV frames and PCM audio. Does the 1394 encryption on the fly.
45 class Device1394Output : public Thread
48 Device1394Output(VideoDevice *vdevice);
49 Device1394Output(AudioDevice *adevice);
65 // Write frame with timed blocking.
67 void write_frame(VFrame *input);
70 // Write audio with timed blocking.
72 void write_samples(char *data, int samples);
73 long get_audio_position();
77 // This object is shared between audio and video. Return what the driver is
78 // based on whether vdevice or adevice exists.
81 // Set IOCTL numbers based on kernel version
84 void encrypt(unsigned char *output,
89 void increment_counter(int *counter);
90 void decrement_counter(int *counter);
99 int current_outbuffer;
103 // Encoder for audio frames
107 // Block while waiting for the first buffer to be allocated
108 Condition *start_lock;
109 Mutex *position_lock;
111 // Provide timed blocking for writing routines.
113 Condition *video_lock;
114 Condition *audio_lock;
116 struct dv1394_status status;
121 struct video1394_mmap output_mmap;
122 struct video1394_queue_variable output_queue;
123 // raw1394handle_t avc_handle;
124 VFrame *temp_frame, *temp_frame2;
125 // Encoder for making DV frames
128 unsigned int cip_n, cip_d;
129 unsigned int cip_counter;
130 unsigned char f50_60;
131 unsigned char *output_buffer;
133 unsigned int packet_sizes[321];
134 unsigned char continuity_counter;
145 VideoDevice *vdevice;
146 AudioDevice *adevice;
150 int video1394_listen_channel;
151 int video1394_unlisten_channel;
152 int video1394_listen_queue_buffer;
153 int video1394_listen_wait_buffer;
154 int video1394_talk_channel;
155 int video1394_untalk_channel;
156 int video1394_talk_queue_buffer;
157 int video1394_talk_wait_buffer;
158 int video1394_listen_poll_buffer;
160 // To keep track of the delay between putting the audio in the buffer
161 // and when it is actually presented on the DV device
162 long *position_presented;