| 1 |
/* |
| 2 |
* dvconnect.c |
| 3 |
* |
| 4 |
* Copyright (C) Peter Schlaile - May 2001 |
| 5 |
* |
| 6 |
* This file is part of libdv, a free DV (IEC 61834/SMPTE 314M) |
| 7 |
* codec. |
| 8 |
* |
| 9 |
* libdv is free software; you can redistribute it and/or modify it |
| 10 |
* under the terms of the GNU Lesser Public License as published by |
| 11 |
* the Free Software Foundation; either version 2.1, or (at your |
| 12 |
* option) any later version. |
| 13 |
* |
| 14 |
* libdv is distributed in the hope that it will be useful, but |
| 15 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 |
* Lesser Public License for more details. |
| 18 |
* |
| 19 |
* You should have received a copy of the GNU Lesser Public License |
| 20 |
* along with libdv; see the file COPYING. If not, write to |
| 21 |
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
| 22 |
* |
| 23 |
* The libdv homepage is http://libdv.sourceforge.net/. |
| 24 |
*/ |
| 25 |
|
| 26 |
#ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:412:9`! |
| 27 |
#include <config.h>cxx . . $ `<file>/config.h`/ |
| 28 |
#endif // HAVE_CONFIG_H |
| 29 |
|
| 30 |
#define _FILE_OFFSET_BITScxx . . $ `encodedv/dvconnect.c:30:9`! 64 |
| 31 |
|
| 32 |
#include <stdio.h> |
| 33 |
#include <sys/ioctl.h> |
| 34 |
#include <sys/mman.h> |
| 35 |
#include <sys/time.h> |
| 36 |
#include <unistd.h> |
| 37 |
#include <fcntl.h> |
| 38 |
#include <sched.h> |
| 39 |
#include <sys/resource.h> |
| 40 |
#include <string.h> |
| 41 |
#include <pthread.h> |
| 42 |
#include <signal.h> |
| 43 |
|
| 44 |
#if HAVE_LIBPOPTcxx . . $ `config.h:38:9`! |
| 45 |
#include <popt.h> |
| 46 |
#endif |
| 47 |
|
| 48 |
#include <stdlib.h> |
| 49 |
|
| 50 |
static long cip_n_ntsccxx . . $ cip_n_ntsc. = 2436; |
| 51 |
static long cip_d_ntsccxx . . $ cip_d_ntsc. = 38400; |
| 52 |
static long cip_n_palcxx . . $ cip_n_pal. = 1; |
| 53 |
static long cip_d_palcxx . . $ cip_d_pal. = 16; |
| 54 |
static long syt_offsetcxx . . $ syt_offset. = 11000; |
| 55 |
|
| 56 |
#define TARGETBUFSIZEcxx . . $ `encodedv/dvconnect.c:56:9`! 320 |
| 57 |
#define MAX_PACKET_SIZEcxx . . $ `encodedv/dvconnect.c:57:9`! 512 |
| 58 |
#define VBUF_SIZEcxx . . $ `encodedv/dvconnect.c:58:9`! (320*512) |
| 59 |
|
| 60 |
#define VIDEO1394_MAX_SIZEcxx . . $ `encodedv/dvconnect.c:60:9`! 0x4000000 |
| 61 |
|
| 62 |
enumcxx . . $ $anonymous_type_18d3f5e09e42d993_0# { |
| 63 |
VIDEO1394_BUFFER_FREEcxx . . $ VIDEO1394_BUFFER_FREE. = 0, |
| 64 |
VIDEO1394_BUFFER_QUEUEDcxx . . $ VIDEO1394_BUFFER_QUEUED., |
| 65 |
VIDEO1394_BUFFER_READYcxx . . $ VIDEO1394_BUFFER_READY. |
| 66 |
}; |
| 67 |
|
| 68 |
#define VIDEO1394_SYNC_FRAMEScxx . . $ `encodedv/dvconnect.c:68:9`! 0x00000001 |
| 69 |
#define VIDEO1394_INCLUDE_ISO_HEADERScxx . . $ `encodedv/dvconnect.c:69:9`! 0x00000002 |
| 70 |
#define VIDEO1394_VARIABLE_PACKET_SIZEcxx . . $ `encodedv/dvconnect.c:70:9`! 0x00000004 |
| 71 |
|
| 72 |
struct video1394_mmapcxx . . $ video1394_mmap# |
| 73 |
{ |
| 74 |
int channelcxx . . $ video1394_mmap#channel.; |
| 75 |
unsigned int sync_tagcxx . . $ video1394_mmap#sync_tag.; |
| 76 |
unsigned int nb_bufferscxx . . $ video1394_mmap#nb_buffers.; |
| 77 |
unsigned int buf_sizecxx . . $ video1394_mmap#buf_size.; |
| 78 |
/* For VARIABLE_PACKET_SIZE: Maximum packet size */ |
| 79 |
unsigned int packet_sizecxx . . $ video1394_mmap#packet_size.; |
| 80 |
unsigned int fpscxx . . $ video1394_mmap#fps.; |
| 81 |
unsigned int syt_offsetcxx . . $ video1394_mmap#syt_offset.; |
| 82 |
unsigned int flagscxx . . $ video1394_mmap#flags.; |
| 83 |
}; |
| 84 |
|
| 85 |
|
| 86 |
/* For TALK_QUEUE_BUFFER with VIDEO1394_VARIABLE_PACKET_SIZE use */ |
| 87 |
struct video1394_queue_variablecxx . . $ video1394_queue_variable# |
| 88 |
{ |
| 89 |
unsigned int channelcxx . . $ video1394_queue_variable#channel.; |
| 90 |
unsigned int buffercxx . . $ video1394_queue_variable#buffer.; |
| 91 |
unsigned int* packet_sizescxx . . $ video1394_queue_variable#packet_sizes.; /* Buffer of size: buf_size / packet_size*/ |
| 92 |
}; |
| 93 |
|
| 94 |
struct video1394_waitcxx . . $ video1394_wait# |
| 95 |
{ |
| 96 |
unsigned int channelcxx . . $ video1394_wait#channel.; |
| 97 |
unsigned int buffercxx . . $ video1394_wait#buffer.; |
| 98 |
struct timevalcxx . . $ timeval# filltimecxx . . $ video1394_wait#filltime.; /* time of buffer full */ |
| 99 |
}; |
| 100 |
|
| 101 |
#define VIDEO1394_LISTEN_CHANNELcxx . . $ `encodedv/dvconnect.c:101:9`! \ |
| 102 |
_IOWRcxx . . $ `<external>/9493957431124703620/ioctl.h:86:9`!('#', 0x10, struct video1394_mmap) |
| 103 |
#define VIDEO1394_UNLISTEN_CHANNELcxx . . $ `encodedv/dvconnect.c:103:9`! \ |
| 104 |
_IOWcxx . . $ `<external>/9493957431124703620/ioctl.h:85:9`! ('#', 0x11, int) |
| 105 |
#define VIDEO1394_LISTEN_QUEUE_BUFFERcxx . . $ `encodedv/dvconnect.c:105:9`! \ |
| 106 |
_IOWcxx . . $ `<external>/9493957431124703620/ioctl.h:85:9`! ('#', 0x12, struct video1394_wait) |
| 107 |
#define VIDEO1394_LISTEN_WAIT_BUFFERcxx . . $ `encodedv/dvconnect.c:107:9`! \ |
| 108 |
_IOWRcxx . . $ `<external>/9493957431124703620/ioctl.h:86:9`!('#', 0x13, struct video1394_wait) |
| 109 |
#define VIDEO1394_TALK_CHANNELcxx . . $ `encodedv/dvconnect.c:109:9`! \ |
| 110 |
_IOWRcxx . . $ `<external>/9493957431124703620/ioctl.h:86:9`!('#', 0x14, struct video1394_mmap) |
| 111 |
#define VIDEO1394_UNTALK_CHANNELcxx . . $ `encodedv/dvconnect.c:111:9`! \ |
| 112 |
_IOWcxx . . $ `<external>/9493957431124703620/ioctl.h:85:9`! ('#', 0x15, int) |
| 113 |
#define VIDEO1394_TALK_QUEUE_BUFFERcxx . . $ `encodedv/dvconnect.c:113:9`! \ |
| 114 |
_IOWcxx . . $ `<external>/9493957431124703620/ioctl.h:85:9`! ('#', 0x16, size_t) |
| 115 |
#define VIDEO1394_TALK_WAIT_BUFFERcxx . . $ `encodedv/dvconnect.c:115:9`! \ |
| 116 |
_IOWcxx . . $ `<external>/9493957431124703620/ioctl.h:85:9`! ('#', 0x17, struct video1394_wait) |
| 117 |
#define VIDEO1394_LISTEN_POLL_BUFFERcxx . . $ `encodedv/dvconnect.c:117:9`! \ |
| 118 |
_IOWR('#', 0x18, struct video1394_wait) |
| 119 |
|
| •120 |
#ifdef __GNU__ |
| 121 |
#define _IOT_video1394_mmap \ |
| 122 |
_IOT(_IOTS(int), 1, _IOTS(unsigned int), 7, 0, 0) |
| 123 |
#define _IOT_video1394_wait \ |
| 124 |
_IOT(_IOTS(unsigned int), 2, _IOTS(struct timeval), 1, 0, 0) |
| 125 |
#endif |
| 126 |
|
| 127 |
static int cap_start_framecxx . . $ cap_start_frame. = 0; |
| 128 |
static int cap_num_framescxx . . $ cap_num_frames. = 0xfffffff; |
| 129 |
static int cap_verbose_modecxx . . $ cap_verbose_mode.; |
| 130 |
static int frames_capturedcxx . . $ frames_captured. = 0; |
| 131 |
static int broken_framescxx . . $ broken_frames. = 0; |
| 132 |
|
| 133 |
/* ------------------------------------------------------------------------ |
| 134 |
- buffer management |
| 135 |
------------------------------------------------------------------------ */ |
| 136 |
|
| 137 |
static int max_buffer_blockscxx . . $ max_buffer_blocks. = 25*10; |
| 138 |
static int ceil_buffer_blockscxx . . $ ceil_buffer_blocks. = 0; |
| 139 |
|
| 140 |
struct buf_nodecxx . . $ buf_node# { |
| 141 |
unsigned char datacxx . . $ buf_node#data.[144000]; /* FIXME: We are wasting space on NTSC! */ |
| 142 |
int usagecxx . . $ buf_node#usage.; |
| 143 |
struct buf_nodecxx . . $ buf_node#* nextcxx . . $ buf_node#next.; |
| 144 |
}; |
| 145 |
|
| 146 |
struct buf_listcxx . . $ buf_list# { |
| 147 |
struct buf_nodecxx . . $ buf_node# * firstcxx . . $ buf_list#first.; |
| 148 |
struct buf_nodecxx . . $ buf_node# * lastcxx . . $ buf_list#last.; |
| 149 |
int usagecxx . . $ buf_list#usage.; |
| 150 |
}; |
| 151 |
|
| 152 |
static struct buf_listcxx . . $ buf_list# free_listcxx . . $ free_list. = { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, 0 }; |
| 153 |
static struct buf_listcxx . . $ buf_list# buf_queuecxx . . $ buf_queue. = { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, 0 }; |
| 154 |
|
| 155 |
static pthread_mutex_tcxx . . $ pthread_mutex_t# queue_mutexcxx . . $ queue_mutex.; |
| 156 |
static pthread_mutex_tcxx . . $ pthread_mutex_t# wakeup_mutexcxx . . $ wakeup_mutex.; |
| 157 |
static pthread_cond_tcxx . . $ pthread_cond_t# wakeup_condcxx . . $ wakeup_cond.; |
| 158 |
static pthread_tcxx . . $ pthread_t# file_io_threadcxx . . $ file_io_thread.; |
| 159 |
|
| 160 |
void push_backcxx . . $ push_back(7223fee24e770583).(struct buf_listcxx . . $ buf_list# * l, struct buf_nodecxx . . $ buf_node# * elem) |
| 161 |
{ |
| 162 |
pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(&queue_mutexcxx . . $ queue_mutex.); |
| 163 |
if (l->lastcxx . . $ buf_list#last.) { |
| 164 |
l->lastcxx . . $ buf_list#last.->nextcxx . . $ buf_node#next. = elem; |
| 165 |
} else { |
| 166 |
l->firstcxx . . $ buf_list#first. = elem; |
| 167 |
} |
| 168 |
elem->nextcxx . . $ buf_node#next. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 169 |
l->lastcxx . . $ buf_list#last. = elem; |
| 170 |
l->usagecxx . . $ buf_list#usage.++; |
| 171 |
pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&queue_mutexcxx . . $ queue_mutex.); |
| 172 |
} |
| 173 |
|
| 174 |
struct buf_nodecxx . . $ buf_node# * pop_frontcxx . . $ pop_front(fa03ca384d2af08a).(struct buf_listcxx . . $ buf_list# * l) |
| 175 |
{ |
| 176 |
struct buf_nodecxx . . $ buf_node# * rval; |
| 177 |
|
| 178 |
pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(&queue_mutexcxx . . $ queue_mutex.); |
| 179 |
rval = l->firstcxx . . $ buf_list#first.; |
| 180 |
|
| 181 |
if (l->firstcxx . . $ buf_list#first. == l->lastcxx . . $ buf_list#last.) { |
| 182 |
l->lastcxx . . $ buf_list#last. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 183 |
} |
| 184 |
if (rval) { |
| 185 |
l->firstcxx . . $ buf_list#first. = rval->nextcxx . . $ buf_node#next.; |
| 186 |
l->usagecxx . . $ buf_list#usage.--; |
| 187 |
} else { |
| 188 |
l->firstcxx . . $ buf_list#first. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 189 |
} |
| 190 |
|
| 191 |
pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&queue_mutexcxx . . $ queue_mutex.); |
| 192 |
return rval; |
| 193 |
} |
| 194 |
|
| 195 |
struct buf_nodecxx . . $ buf_node# * get_free_blockcxx . . $ get_free_block(6ab0ada7a6b212ed).() |
| 196 |
{ |
| 197 |
struct buf_nodecxx . . $ buf_node# * f = pop_frontcxx . . $ pop_front(fa03ca384d2af08a).(&free_listcxx . . $ free_list.); |
| 198 |
if (!f) { |
| 199 |
if (buf_queuecxx . . $ buf_queue..usagecxx . . $ buf_list#usage. >= max_buffer_blockscxx . . $ max_buffer_blocks.) { |
| 200 |
return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 201 |
} |
| 202 |
f = (struct buf_nodecxx . . $ buf_node#*) malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(struct buf_nodecxx . . $ buf_node#)); |
| 203 |
} |
| 204 |
return f; |
| 205 |
} |
| 206 |
|
| 207 |
/* ------------------------------------------------------------------------ |
| 208 |
- receiver |
| 209 |
------------------------------------------------------------------------ */ |
| 210 |
|
| 211 |
static FILEcxx . . $ FILE#* dst_fpcxx . . $ dst_fp.; |
| 212 |
|
| 213 |
void handle_packetcxx . . $ handle_packet(fc0f0e1646c32816).(unsigned char* data, int len) |
| 214 |
{ |
| 215 |
int start_of_frame = 0; |
| 216 |
static int frame_size = 0; |
| 217 |
static int isPAL = 0; |
| 218 |
static int found_first_block = 0; |
| 219 |
static unsigned char* p_out = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 220 |
static struct buf_nodecxx . . $ buf_node# * f = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 221 |
|
| 222 |
switch (len) { |
| 223 |
case 488: |
| 224 |
if (data[12] == 0x1f && data[13] == 0x07) { |
| 225 |
start_of_frame = 1; |
| 226 |
} |
| 227 |
|
| 228 |
if (start_of_frame) { |
| 229 |
int frame_broken = 0; |
| 230 |
if (!found_first_block) { |
| 231 |
if (!cap_start_framecxx . . $ cap_start_frame.) { |
| 232 |
found_first_block = 1; |
| 233 |
} else { |
| 234 |
cap_start_framecxx . . $ cap_start_frame.--; |
| 235 |
if (cap_verbose_modecxx . . $ cap_verbose_mode.) { |
| 236 |
fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, |
| 237 |
"Skipped frame %8d\r", |
| 238 |
cap_start_framecxx . . $ cap_start_frame.); |
| 239 |
} |
| 240 |
return; |
| 241 |
} |
| 242 |
frame_size = 0; |
| 243 |
} |
| 244 |
if (!cap_num_framescxx . . $ cap_num_frames.) { |
| 245 |
return; |
| 246 |
} |
| 247 |
cap_num_framescxx . . $ cap_num_frames.--; |
| 248 |
|
| 249 |
if (frame_size) { |
| 250 |
if ((isPAL && frame_size != 144000) |
| 251 |
|| (!isPAL && frame_size != 120000)) { |
| 252 |
fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, |
| 253 |
"Broken frame %8d " |
| 254 |
"(size = %d)!\n", |
| 255 |
frames_capturedcxx . . $ frames_captured., frame_size); |
| 256 |
broken_framescxx . . $ broken_frames.++; |
| 257 |
frame_broken = 1; |
| 258 |
} |
| 259 |
if (cap_verbose_modecxx . . $ cap_verbose_mode.) { |
| 260 |
fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, |
| 261 |
"Captured frame %8d\r", |
| 262 |
frames_capturedcxx . . $ frames_captured.); |
| 263 |
} |
| 264 |
frames_capturedcxx . . $ frames_captured.++; |
| 265 |
} |
| 266 |
isPAL = (data[15] & 0x80); |
| 267 |
|
| 268 |
if (f && !frame_broken) { |
| 269 |
f->usagecxx . . $ buf_node#usage. = frame_size; |
| 270 |
push_backcxx . . $ push_back(7223fee24e770583).(&buf_queuecxx . . $ buf_queue., f); |
| 271 |
pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(&wakeup_mutexcxx . . $ wakeup_mutex.); |
| 272 |
pthread_cond_signalcxx . . $ pthread_cond_signal(98095c34a2b0149d).(&wakeup_condcxx . . $ wakeup_cond.); |
| 273 |
pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&wakeup_mutexcxx . . $ wakeup_mutex.); |
| 274 |
f = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 275 |
} |
| 276 |
|
| 277 |
if (!f) { |
| 278 |
f = get_free_blockcxx . . $ get_free_block(6ab0ada7a6b212ed).(); |
| 279 |
if (!f) { |
| 280 |
fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, |
| 281 |
"Buffer overrun: " |
| 282 |
"Frame discarded!\n"); |
| 283 |
broken_framescxx . . $ broken_frames.++; |
| 284 |
} |
| 285 |
} |
| 286 |
if (f) { |
| 287 |
p_out = f->datacxx . . $ buf_node#data.; |
| 288 |
} |
| 289 |
frame_size = 0; |
| 290 |
} |
| 291 |
|
| 292 |
if (found_first_block && cap_num_framescxx . . $ cap_num_frames. != 0 && f) { |
| 293 |
if (frame_size < 144000) { |
| 294 |
memcpycxx . . $ memcpy(cc817cb175f282d).(p_out, data + 12, 480); |
| 295 |
p_out += 480; |
| 296 |
frame_size += 480; |
| 297 |
} else { |
| 298 |
fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Frame buffer overrun: " |
| 299 |
"Frame discarded!\n"); |
| 300 |
broken_framescxx . . $ broken_frames.++; |
| 301 |
p_out = f->datacxx . . $ buf_node#data.; |
| 302 |
frame_size = 0; |
| 303 |
} |
| 304 |
} |
| 305 |
|
| 306 |
break; |
| 307 |
case 8: |
| 308 |
break; |
| 309 |
default: |
| 310 |
fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Penguin on the bus? (packet size = %d!)\n", |
| 311 |
len); |
| 312 |
break; |
| 313 |
} |
| 314 |
} |
| 315 |
|
| 316 |
void* write_out_threadcxx . . $ write_out_thread(9f162e79bfc6c74).(void * arg) |
| 317 |
{ |
| 318 |
while (cap_num_framescxx . . $ cap_num_frames. != 0) { |
| 319 |
struct buf_nodecxx . . $ buf_node# * f; |
| 320 |
pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(&wakeup_mutexcxx . . $ wakeup_mutex.); |
| 321 |
pthread_cond_waitcxx . . $ pthread_cond_wait(6145be15a5d9db5d).(&wakeup_condcxx . . $ wakeup_cond., &wakeup_mutexcxx . . $ wakeup_mutex.); |
| 322 |
pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&wakeup_mutexcxx . . $ wakeup_mutex.); |
| 323 |
|
| 324 |
while ((f = pop_frontcxx . . $ pop_front(fa03ca384d2af08a).(&buf_queuecxx . . $ buf_queue.)) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 325 |
fwritecxx . . $ fwrite(ab0609fa07c47d6e).(f->datacxx . . $ buf_node#data., 1, f->usagecxx . . $ buf_node#usage., dst_fpcxx . . $ dst_fp.); |
| 326 |
push_backcxx . . $ push_back(7223fee24e770583).(&free_listcxx . . $ free_list., f); |
| 327 |
} |
| 328 |
} |
| 329 |
return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 330 |
} |
| 331 |
|
| 332 |
void sig_int_recv_handlercxx . . $ sig_int_recv_handler(d4f767463ce0a6b3).(int signum) |
| 333 |
{ |
| 334 |
char t [] = "Terminating on user's request...\n"; |
| 335 |
writecxx . . $ write(41184a59d38b4f65).(2, t, sizeof(t)); |
| 336 |
|
| 337 |
cap_num_framescxx . . $ cap_num_frames. = 0; |
| 338 |
} |
| 339 |
|
| 340 |
int capture_rawcxx . . $ capture_raw(7aeb29e642a729f0).(const char* filename, int channel, int nbuffers, |
| 341 |
int start_frame, int end_frame, int verbose_mode, |
| 342 |
char *device) |
| 343 |
{ |
| 344 |
int viddev; |
| 345 |
unsigned char *recv_buf; |
| 346 |
struct video1394_mmapcxx . . $ video1394_mmap# v; |
| 347 |
struct video1394_waitcxx . . $ video1394_wait# w; |
| 348 |
int unused_buffers; |
| 349 |
unsigned char outbuf[2*65536]; |
| 350 |
int outbuf_used = 0; |
| 351 |
|
| 352 |
cap_start_framecxx . . $ cap_start_frame. = start_frame; |
| 353 |
cap_num_framescxx . . $ cap_num_frames. = end_frame - start_frame; |
| 354 |
cap_verbose_modecxx . . $ cap_verbose_mode. = verbose_mode; |
| 355 |
|
| 356 |
if (!filename || strcmpcxx . . $ strcmp(5ae29d726ae57f88).(filename, "-") == 0) { |
| 357 |
dst_fpcxx . . $ dst_fp. = stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!; |
| 358 |
} else { |
| 359 |
dst_fpcxx . . $ dst_fp. = fopencxx . . $ fopen(82ec0787cd37e0a3).(filename, "wb"); |
| 360 |
if (!dst_fpcxx . . $ dst_fp.) { |
| 361 |
perrorcxx . . $ perror(85c52e162fed56f9).("fopen input file"); |
| 362 |
return(-1); |
| 363 |
} |
| 364 |
} |
| 365 |
|
| 366 |
if ((viddev = opencxx . . $ open(e156e3aa1e5c4ad1).(device, O_RDWRcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:45:9`!)) < 0) { |
| 367 |
perrorcxx . . $ perror(85c52e162fed56f9).("open video1394 device"); |
| 368 |
return -1; |
| 369 |
} |
| 370 |
|
| 371 |
v.channelcxx . . $ video1394_mmap#channel. = channel; |
| 372 |
v.sync_tagcxx . . $ video1394_mmap#sync_tag. = 0; |
| 373 |
v.nb_bufferscxx . . $ video1394_mmap#nb_buffers. = nbuffers; |
| 374 |
v.buf_sizecxx . . $ video1394_mmap#buf_size. = VBUF_SIZEcxx . . $ `encodedv/dvconnect.c:58:9`!; |
| 375 |
v.packet_sizecxx . . $ video1394_mmap#packet_size. = MAX_PACKET_SIZEcxx . . $ `encodedv/dvconnect.c:57:9`!; |
| 376 |
v.syt_offsetcxx . . $ video1394_mmap#syt_offset. = syt_offsetcxx . . $ syt_offset.; |
| 377 |
v.flagscxx . . $ video1394_mmap#flags. = VIDEO1394_INCLUDE_ISO_HEADERScxx . . $ `encodedv/dvconnect.c:69:9`!; |
| 378 |
w.channelcxx . . $ video1394_wait#channel. = v.channelcxx . . $ video1394_mmap#channel.; |
| 379 |
|
| 380 |
if (ioctlcxx . . $ ioctl(67fa1c773b05068c).(viddev, VIDEO1394_LISTEN_CHANNELcxx . . $ `encodedv/dvconnect.c:101:9`!, &v) < 0) { |
| 381 |
perrorcxx . . $ perror(85c52e162fed56f9).("VIDEO1394_LISTEN_CHANNEL"); |
| 382 |
return -1; |
| 383 |
} |
| 384 |
|
| 385 |
if ((recv_buf = (unsigned char *) mmapcxx . . $ mmap(ff06c1c904cdf0e2).( |
| 386 |
0, v.nb_bufferscxx . . $ video1394_mmap#nb_buffers.*v.buf_sizecxx . . $ video1394_mmap#buf_size., PROT_READcxx . . $ `<external>/17226767460805440860/mman-linux.h:32:9`!|PROT_WRITEcxx . . $ `<external>/17226767460805440860/mman-linux.h:33:9`!, |
| 387 |
MAP_SHAREDcxx . . $ `<external>/17226767460805440860/mman-linux.h:42:9`!, viddev, 0)) == (unsigned char *)-1) { |
| 388 |
perrorcxx . . $ perror(85c52e162fed56f9).("mmap videobuffer"); |
| 389 |
return -1; |
| 390 |
} |
| 391 |
|
| 392 |
pthread_mutex_initcxx . . $ pthread_mutex_init(db9d29dab44ea1aa).(&queue_mutexcxx . . $ queue_mutex., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 393 |
pthread_mutex_initcxx . . $ pthread_mutex_init(db9d29dab44ea1aa).(&wakeup_mutexcxx . . $ wakeup_mutex., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 394 |
pthread_cond_initcxx . . $ pthread_cond_init(fc876bc1ec1249fc).(&wakeup_condcxx . . $ wakeup_cond., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 395 |
|
| 396 |
pthread_createcxx . . $ pthread_create(2141a84bcac899e5).(&file_io_threadcxx . . $ file_io_thread., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, write_out_threadcxx . . $ write_out_thread(9f162e79bfc6c74)., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 397 |
|
| 398 |
/* signal(SIGTERM, sig_int_recv_handler); |
| 399 |
signal(SIGINT, sig_int_recv_handler); */ |
| 400 |
|
| 401 |
unused_buffers = v.nb_bufferscxx . . $ video1394_mmap#nb_buffers.; |
| 402 |
w.buffercxx . . $ video1394_wait#buffer. = 0; |
| 403 |
|
| 404 |
while (cap_num_framescxx . . $ cap_num_frames. != 0) { |
| 405 |
struct video1394_waitcxx . . $ video1394_wait# wcopy; |
| 406 |
unsigned char * curr; |
| 407 |
int ofs; |
| 408 |
|
| 409 |
while (unused_buffers--) { |
| 410 |
unsigned char * curr = recv_buf+ v.buf_sizecxx . . $ video1394_mmap#buf_size. * w.buffercxx . . $ video1394_wait#buffer.; |
| 411 |
|
| 412 |
memsetcxx . . $ memset(d1de1e4fb215f1c6).(curr, 0, v.buf_sizecxx . . $ video1394_mmap#buf_size.); |
| 413 |
|
| 414 |
wcopy = w; |
| 415 |
|
| 416 |
if (ioctlcxx . . $ ioctl(67fa1c773b05068c).(viddev,VIDEO1394_LISTEN_QUEUE_BUFFERcxx . . $ `encodedv/dvconnect.c:105:9`!, &wcopy) < 0) { |
| 417 |
perrorcxx . . $ perror(85c52e162fed56f9).("VIDEO1394_LISTEN_QUEUE_BUFFER"); |
| 418 |
} |
| 419 |
w.buffercxx . . $ video1394_wait#buffer.++; |
| 420 |
w.buffercxx . . $ video1394_wait#buffer. %= v.nb_bufferscxx . . $ video1394_mmap#nb_buffers.; |
| 421 |
} |
| 422 |
wcopy = w; |
| 423 |
if (ioctlcxx . . $ ioctl(67fa1c773b05068c).(viddev, VIDEO1394_LISTEN_WAIT_BUFFERcxx . . $ `encodedv/dvconnect.c:107:9`!, &wcopy) < 0) { |
| 424 |
perrorcxx . . $ perror(85c52e162fed56f9).("VIDEO1394_LISTEN_WAIT_BUFFER"); |
| 425 |
} |
| 426 |
curr = recv_buf + v.buf_sizecxx . . $ video1394_mmap#buf_size. * w.buffercxx . . $ video1394_wait#buffer.; |
| 427 |
ofs = 0; |
| 428 |
|
| 429 |
while (ofs < VBUF_SIZEcxx . . $ `encodedv/dvconnect.c:58:9`!) { |
| 430 |
while (outbuf_used < 4 && ofs < VBUF_SIZEcxx . . $ `encodedv/dvconnect.c:58:9`!) { |
| 431 |
outbuf[outbuf_used++] = curr[ofs++]; |
| 432 |
} |
| 433 |
if (ofs != VBUF_SIZEcxx . . $ `encodedv/dvconnect.c:58:9`!) { |
| 434 |
int len = outbuf[2] + (outbuf[3] << 8) + 8; |
| 435 |
if (ofs + len - outbuf_used > VBUF_SIZEcxx . . $ `encodedv/dvconnect.c:58:9`!) { |
| 436 |
memcpycxx . . $ memcpy(cc817cb175f282d).(outbuf + outbuf_used, curr+ofs, |
| 437 |
VBUF_SIZEcxx . . $ `encodedv/dvconnect.c:58:9`! - ofs); |
| 438 |
outbuf_used += VBUF_SIZEcxx . . $ `encodedv/dvconnect.c:58:9`! - ofs; |
| 439 |
ofs = VBUF_SIZEcxx . . $ `encodedv/dvconnect.c:58:9`!; |
| 440 |
} else { |
| 441 |
memcpycxx . . $ memcpy(cc817cb175f282d).(outbuf + outbuf_used, |
| 442 |
curr + ofs, len - outbuf_used); |
| 443 |
ofs += len - outbuf_used; |
| 444 |
outbuf_used = 0; |
| 445 |
handle_packetcxx . . $ handle_packet(fc0f0e1646c32816).(outbuf, len - 8); |
| 446 |
} |
| 447 |
} |
| 448 |
} |
| 449 |
unused_buffers = 1; |
| 450 |
} |
| 451 |
|
| 452 |
if (broken_framescxx . . $ broken_frames.) { |
| 453 |
fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\nCaptured %d broken frames!\n", broken_framescxx . . $ broken_frames.); |
| 454 |
} |
| 455 |
|
| 456 |
munmapcxx . . $ munmap(c0a5f96701d3f89).(recv_buf, v.nb_bufferscxx . . $ video1394_mmap#nb_buffers. * v.buf_sizecxx . . $ video1394_mmap#buf_size.); |
| 457 |
|
| 458 |
if (ioctlcxx . . $ ioctl(67fa1c773b05068c).(viddev, VIDEO1394_UNLISTEN_CHANNELcxx . . $ `encodedv/dvconnect.c:103:9`!, &v.channelcxx . . $ video1394_mmap#channel.)<0) { |
| 459 |
perrorcxx . . $ perror(85c52e162fed56f9).("VIDEO1394_UNLISTEN_CHANNEL"); |
| 460 |
} |
| 461 |
|
| 462 |
closecxx . . $ close(7864480464b09eea).(viddev); |
| 463 |
|
| 464 |
pthread_joincxx . . $ pthread_join(269902cf949f12c5).(file_io_threadcxx . . $ file_io_thread., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 465 |
|
| 466 |
if (dst_fpcxx . . $ dst_fp. != stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!) { |
| 467 |
fclosecxx . . $ fclose(89bc1efcdac0ca22).(dst_fpcxx . . $ dst_fp.); |
| 468 |
} |
| 469 |
|
| 470 |
return 0; |
| 471 |
} |
| 472 |
|
| 473 |
/* ------------------------------------------------------------------------ |
| 474 |
- sender |
| 475 |
------------------------------------------------------------------------ */ |
| 476 |
|
| 477 |
static const char*const* src_filenamescxx . . $ src_filenames.; |
| 478 |
static FILEcxx . . $ FILE#* src_fpcxx . . $ src_fp.; |
| 479 |
static int is_eofcxx . . $ is_eof. = 0; |
| 480 |
static unsigned char * underrun_data_framecxx . . $ underrun_data_frame. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 481 |
static int underrun_frame_ispalcxx . . $ underrun_frame_ispal. = 0; |
| 482 |
static unsigned char *devicecxx . . $ device. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 483 |
|
| 484 |
static pthread_mutex_tcxx . . $ pthread_mutex_t# wakeup_rev_mutexcxx . . $ wakeup_rev_mutex.; |
| 485 |
static pthread_cond_tcxx . . $ pthread_cond_t# wakeup_rev_condcxx . . $ wakeup_rev_cond.; |
| 486 |
|
| 487 |
int read_framecxx . . $ read_frame(319757e74fda37e9).(FILEcxx . . $ FILE#* fp, unsigned char* frame, int* isPAL) |
| 488 |
{ |
| 489 |
if (is_eofcxx . . $ is_eof.) { |
| 490 |
return -1; |
| 491 |
} |
| 492 |
if (freadcxx . . $ fread(738fc8ac1d711e58).(frame, 1, 120000, fp) != 120000) { |
| 493 |
return -1; |
| 494 |
} |
| 495 |
*isPAL = (frame[3] & 0x80); |
| 496 |
|
| 497 |
if (*isPAL) { |
| 498 |
if (freadcxx . . $ fread(738fc8ac1d711e58).(frame + 120000, 1, 144000 - 120000, fp) |
| 499 |
!= 144000 - 120000) { |
| 500 |
return -1; |
| 501 |
} |
| 502 |
} |
| 503 |
return 0; |
| 504 |
} |
| 505 |
|
| 506 |
void sig_int_send_handlercxx . . $ sig_int_send_handler(d4f767463ce0a6b3).(int signum) |
| 507 |
{ |
| 508 |
char t [] = "Terminating on user's request...\n"; |
| 509 |
writecxx . . $ write(41184a59d38b4f65).(2, t, sizeof(t)); |
| 510 |
|
| 511 |
is_eofcxx . . $ is_eof. = 1; |
| 512 |
} |
| 513 |
|
| 514 |
static int |
| 515 |
open_next_inputcxx . . $ open_next_input(b126dc7c1de90089).(void) |
| 516 |
{ |
| 517 |
if (src_fpcxx . . $ src_fp. && src_fpcxx . . $ src_fp. != stdincxx . . $ `<external>/232824719582829767/stdio.h:157:9`!) { |
| 518 |
fclosecxx . . $ fclose(89bc1efcdac0ca22). (src_fpcxx . . $ src_fp.); |
| 519 |
src_fpcxx . . $ src_fp. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 520 |
} |
| 521 |
if (!src_filenamescxx . . $ src_filenames. || !*src_filenamescxx . . $ src_filenames.) |
| 522 |
return 1; |
| 523 |
if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88). (*src_filenamescxx . . $ src_filenames.++, "-")) |
| 524 |
src_fpcxx . . $ src_fp. = stdincxx . . $ `<external>/232824719582829767/stdio.h:157:9`!; |
| 525 |
else { |
| 526 |
src_fpcxx . . $ src_fp. = fopencxx . . $ fopen(82ec0787cd37e0a3).(src_filenamescxx . . $ src_filenames.[-1], "rb"); |
| 527 |
if (!src_fpcxx . . $ src_fp.) { |
| 528 |
perrorcxx . . $ perror(85c52e162fed56f9).("fopen input file"); |
| 529 |
return 1; |
| 530 |
} |
| 531 |
} |
| 532 |
return 0; |
| 533 |
} |
| 534 |
|
| 535 |
|
| 536 |
void fill_buf_queuecxx . . $ fill_buf_queue(d4f767463ce0a6b3).(int fire) |
| 537 |
{ |
| 538 |
struct buf_nodecxx . . $ buf_node# * f; |
| 539 |
|
| 540 |
while ((f = get_free_blockcxx . . $ get_free_block(6ab0ada7a6b212ed).()) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 541 |
int isPAL; |
| 542 |
again: |
| 543 |
if (read_framecxx . . $ read_frame(319757e74fda37e9).(src_fpcxx . . $ src_fp., f->datacxx . . $ buf_node#data., &isPAL) < 0) { |
| 544 |
is_eofcxx . . $ is_eof. = open_next_inputcxx . . $ open_next_input(b126dc7c1de90089). (); |
| 545 |
if (!is_eofcxx . . $ is_eof.) |
| 546 |
goto again; |
| 547 |
push_backcxx . . $ push_back(7223fee24e770583).(&free_listcxx . . $ free_list., f); |
| 548 |
return; |
| 549 |
} |
| 550 |
if (isPAL) { |
| 551 |
f->usagecxx . . $ buf_node#usage. = 144000; |
| 552 |
} else { |
| 553 |
f->usagecxx . . $ buf_node#usage. = 120000; |
| 554 |
} |
| 555 |
push_backcxx . . $ push_back(7223fee24e770583).(&buf_queuecxx . . $ buf_queue., f); |
| 556 |
if (fire) { |
| 557 |
pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(&wakeup_rev_mutexcxx . . $ wakeup_rev_mutex.); |
| 558 |
pthread_cond_signalcxx . . $ pthread_cond_signal(98095c34a2b0149d).(&wakeup_rev_condcxx . . $ wakeup_rev_cond.); |
| 559 |
pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&wakeup_rev_mutexcxx . . $ wakeup_rev_mutex.); |
| 560 |
} |
| 561 |
} |
| 562 |
} |
| 563 |
|
| 564 |
void* read_in_threadcxx . . $ read_in_thread(9f162e79bfc6c74).(void * arg) |
| 565 |
{ |
| 566 |
fill_buf_queuecxx . . $ fill_buf_queue(d4f767463ce0a6b3).(0); |
| 567 |
|
| 568 |
pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(&wakeup_rev_mutexcxx . . $ wakeup_rev_mutex.); |
| 569 |
pthread_cond_signalcxx . . $ pthread_cond_signal(98095c34a2b0149d).(&wakeup_rev_condcxx . . $ wakeup_rev_cond.); |
| 570 |
pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&wakeup_rev_mutexcxx . . $ wakeup_rev_mutex.); |
| 571 |
|
| 572 |
while (!is_eofcxx . . $ is_eof.) { |
| 573 |
pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(&wakeup_mutexcxx . . $ wakeup_mutex.); |
| 574 |
pthread_cond_waitcxx . . $ pthread_cond_wait(6145be15a5d9db5d).(&wakeup_condcxx . . $ wakeup_cond., &wakeup_mutexcxx . . $ wakeup_mutex.); |
| 575 |
pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&wakeup_mutexcxx . . $ wakeup_mutex.); |
| 576 |
|
| 577 |
fill_buf_queuecxx . . $ fill_buf_queue(d4f767463ce0a6b3).(1); |
| 578 |
} |
| 579 |
return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 580 |
} |
| 581 |
|
| 582 |
static int fill_buffercxx . . $ fill_buffer(9f597e2150cf6e22).(unsigned char* targetbuf, unsigned int * packet_sizes) |
| 583 |
{ |
| 584 |
unsigned char* frame; |
| 585 |
struct buf_nodecxx . . $ buf_node# * f_node; |
| 586 |
int isPAL; |
| 587 |
int frame_size; |
| 588 |
unsigned long vdata = 0; |
| 589 |
int i; |
| 590 |
static unsigned char continuity_counter = 0; |
| 591 |
static unsigned int cip_counter = 0; |
| 592 |
static unsigned int cip_n = 0; |
| 593 |
static unsigned int cip_d = 0; |
| 594 |
|
| 595 |
f_node = pop_frontcxx . . $ pop_front(fa03ca384d2af08a).(&buf_queuecxx . . $ buf_queue.); |
| 596 |
if (!f_node) { |
| 597 |
if (!is_eofcxx . . $ is_eof.) { |
| 598 |
if (!underrun_data_framecxx . . $ underrun_data_frame.) { |
| 599 |
fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Buffer underrun "); |
| 600 |
if (ceil_buffer_blockscxx . . $ ceil_buffer_blocks. > 0 && |
| 601 |
max_buffer_blockscxx . . $ max_buffer_blocks. < ceil_buffer_blockscxx . . $ ceil_buffer_blocks.) { |
| 602 |
max_buffer_blockscxx . . $ max_buffer_blocks. += 25; |
| 603 |
fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, |
| 604 |
"(raising buffer limit +25 => %d)!\n", |
| 605 |
max_buffer_blockscxx . . $ max_buffer_blocks.); |
| 606 |
} else { |
| 607 |
fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, |
| 608 |
"(not raising buffer space, " |
| 609 |
"hard limit reached)\n"); |
| 610 |
} |
| 611 |
|
| 612 |
|
| 613 |
pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(&wakeup_rev_mutexcxx . . $ wakeup_rev_mutex.); |
| 614 |
pthread_cond_waitcxx . . $ pthread_cond_wait(6145be15a5d9db5d).(&wakeup_rev_condcxx . . $ wakeup_rev_cond., |
| 615 |
&wakeup_rev_mutexcxx . . $ wakeup_rev_mutex.); |
| 616 |
pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&wakeup_rev_mutexcxx . . $ wakeup_rev_mutex.); |
| 617 |
f_node = pop_frontcxx . . $ pop_front(fa03ca384d2af08a).(&buf_queuecxx . . $ buf_queue.); |
| 618 |
} else { |
| 619 |
f_node = get_free_blockcxx . . $ get_free_block(6ab0ada7a6b212ed).(); |
| 620 |
|
| 621 |
if (underrun_frame_ispalcxx . . $ underrun_frame_ispal.) { |
| 622 |
f_node->usagecxx . . $ buf_node#usage. = 144000; |
| 623 |
} else { |
| 624 |
f_node->usagecxx . . $ buf_node#usage. = 120000; |
| 625 |
} |
| 626 |
memcpycxx . . $ memcpy(cc817cb175f282d).(f_node->datacxx . . $ buf_node#data., underrun_data_framecxx . . $ underrun_data_frame., |
| 627 |
f_node->usagecxx . . $ buf_node#usage.); |
| 628 |
} |
| 629 |
|
| 630 |
} else { |
| 631 |
return -1; |
| 632 |
} |
| 633 |
} |
| 634 |
|
| 635 |
frame = f_node->datacxx . . $ buf_node#data.; |
| 636 |
frame_size = f_node->usagecxx . . $ buf_node#usage.; |
| 637 |
|
| 638 |
isPAL = (frame_size == 144000); |
| 639 |
|
| 640 |
if (cip_counter == 0) { |
| 641 |
if (!isPAL) { |
| 642 |
cip_n = cip_n_ntsccxx . . $ cip_n_ntsc.; |
| 643 |
cip_d = cip_d_ntsccxx . . $ cip_d_ntsc.; |
| 644 |
} else { |
| 645 |
cip_n = cip_n_palcxx . . $ cip_n_pal.; |
| 646 |
cip_d = cip_d_palcxx . . $ cip_d_pal.; |
| 647 |
} |
| 648 |
cip_counter = cip_n; |
| 649 |
} |
| 650 |
|
| 651 |
for (i = 0; i < TARGETBUFSIZEcxx . . $ `encodedv/dvconnect.c:56:9`! && vdata < frame_size; i++) { |
| 652 |
unsigned char* p = targetbuf; |
| 653 |
int want_sync = 0; |
| 654 |
cip_counter += cip_n; |
| 655 |
|
| 656 |
if (cip_counter > cip_d) { |
| 657 |
want_sync = 1; |
| 658 |
cip_counter -= cip_d; |
| 659 |
} |
| 660 |
|
| 661 |
*p++ = 0x01; /* Source node ID ! */ |
| 662 |
*p++ = 0x78; /* Packet size in quadlets (480 / 4) */ |
| 663 |
*p++ = 0x00; |
| 664 |
*p++ = continuity_counter; |
| 665 |
|
| 666 |
*p++ = 0x80; /* const */ |
| 667 |
*p++ = isPAL ? 0x80 : 0x00; |
| 668 |
*p++ = 0xff; /* timestamp */ |
| 669 |
*p++ = 0xff; /* timestamp */ |
| 670 |
|
| 671 |
/* Timestamping is now done in the kernel driver! */ |
| 672 |
if (!want_sync) { /* video data */ |
| 673 |
continuity_counter++; |
| 674 |
|
| 675 |
memcpycxx . . $ memcpy(cc817cb175f282d).(p, frame + vdata, 480); |
| 676 |
p += 480; |
| 677 |
vdata += 480; |
| 678 |
} |
| 679 |
|
| 680 |
*packet_sizes++ = p - targetbuf; |
| 681 |
targetbuf += MAX_PACKET_SIZEcxx . . $ `encodedv/dvconnect.c:57:9`!; |
| 682 |
} |
| 683 |
*packet_sizes++ = 0; |
| 684 |
|
| 685 |
push_backcxx . . $ push_back(7223fee24e770583).(&free_listcxx . . $ free_list., f_node); |
| 686 |
|
| 687 |
pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(&wakeup_mutexcxx . . $ wakeup_mutex.); |
| 688 |
pthread_cond_signalcxx . . $ pthread_cond_signal(98095c34a2b0149d).(&wakeup_condcxx . . $ wakeup_cond.); |
| 689 |
pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&wakeup_mutexcxx . . $ wakeup_mutex.); |
| 690 |
|
| 691 |
return 0; |
| 692 |
} |
| 693 |
|
| 694 |
int send_rawcxx . . $ send_raw(5f01636f8fae20d6).(const char*const* filenames, int channel, int nbuffers, |
| 695 |
int start_frame, int end_frame, int verbose_mode, |
| 696 |
const char * underrun_data_filename, char *device) |
| 697 |
{ |
| 698 |
int viddev; |
| 699 |
unsigned char *send_buf; |
| 700 |
struct video1394_mmapcxx . . $ video1394_mmap# v; |
| 701 |
struct video1394_queue_variablecxx . . $ video1394_queue_variable# w; |
| 702 |
int unused_buffers; |
| 703 |
int got_frame; |
| 704 |
unsigned int packet_sizes[321]; |
| 705 |
|
| 706 |
if ( filenames == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! ) |
| 707 |
return -1; |
| 708 |
|
| 709 |
src_filenamescxx . . $ src_filenames. = filenames; |
| 710 |
if (!*src_filenamescxx . . $ src_filenames.) { |
| 711 |
src_filenamescxx . . $ src_filenames. = 0; |
| 712 |
src_fpcxx . . $ src_fp. = stdincxx . . $ `<external>/232824719582829767/stdio.h:157:9`!; |
| 713 |
} |
| 714 |
else if (open_next_inputcxx . . $ open_next_input(b126dc7c1de90089). ()) |
| 715 |
return -1; |
| 716 |
|
| 717 |
if (underrun_data_filename) { |
| 718 |
FILEcxx . . $ FILE# * fp = fopencxx . . $ fopen(82ec0787cd37e0a3).(underrun_data_filename, "rb"); |
| 719 |
if (!fp) { |
| 720 |
perrorcxx . . $ perror(85c52e162fed56f9).("fopen underrun data file"); |
| 721 |
return -1; |
| 722 |
} |
| 723 |
underrun_data_framecxx . . $ underrun_data_frame. = (unsigned char*) malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(144000); |
| 724 |
if (read_framecxx . . $ read_frame(319757e74fda37e9).(fp, underrun_data_framecxx . . $ underrun_data_frame., |
| 725 |
&underrun_frame_ispalcxx . . $ underrun_frame_ispal.) < 0) { |
| 726 |
fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Short read on reading underrun data " |
| 727 |
"frame...\n"); |
| 728 |
fclosecxx . . $ fclose(89bc1efcdac0ca22).(fp); |
| 729 |
return -1; |
| 730 |
} |
| 731 |
fclosecxx . . $ fclose(89bc1efcdac0ca22).(fp); |
| 732 |
} |
| 733 |
|
| 734 |
while (start_frame > 0) { |
| 735 |
int isPAL,i; |
| 736 |
unsigned char frame[144000]; /* PAL is large enough... */ |
| 737 |
|
| 738 |
for (i = 0; i < start_frame; i++) { |
| 739 |
if (verbose_mode) { |
| 740 |
fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Skipped frame %8d\r", |
| 741 |
start_frame - i); |
| 742 |
} |
| 743 |
if (read_framecxx . . $ read_frame(319757e74fda37e9).(src_fpcxx . . $ src_fp., frame, &isPAL) < 0) { |
| 744 |
break; |
| 745 |
} |
| 746 |
} |
| 747 |
start_frame -= i; |
| 748 |
if (!start_frame) |
| 749 |
break; |
| 750 |
if (open_next_inputcxx . . $ open_next_input(b126dc7c1de90089). ()) |
| 751 |
return -1; |
| 752 |
} |
| 753 |
|
| 754 |
if ((viddev = opencxx . . $ open(e156e3aa1e5c4ad1).(device,O_RDWRcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:45:9`!)) < 0) { |
| 755 |
perrorcxx . . $ perror(85c52e162fed56f9).("open video1394 device"); |
| 756 |
if (src_fpcxx . . $ src_fp. && src_fpcxx . . $ src_fp. != stdincxx . . $ `<external>/232824719582829767/stdio.h:157:9`!) |
| 757 |
fclosecxx . . $ fclose(89bc1efcdac0ca22). (src_fpcxx . . $ src_fp.); |
| 758 |
return -1; |
| 759 |
} |
| 760 |
|
| 761 |
v.channelcxx . . $ video1394_mmap#channel. = channel; |
| 762 |
v.sync_tagcxx . . $ video1394_mmap#sync_tag. = 0; |
| 763 |
v.nb_bufferscxx . . $ video1394_mmap#nb_buffers. = nbuffers; |
| 764 |
v.buf_sizecxx . . $ video1394_mmap#buf_size. = TARGETBUFSIZEcxx . . $ `encodedv/dvconnect.c:56:9`! * MAX_PACKET_SIZEcxx . . $ `encodedv/dvconnect.c:57:9`!; |
| 765 |
v.packet_sizecxx . . $ video1394_mmap#packet_size. = MAX_PACKET_SIZEcxx . . $ `encodedv/dvconnect.c:57:9`!; |
| 766 |
v.flagscxx . . $ video1394_mmap#flags. = VIDEO1394_VARIABLE_PACKET_SIZEcxx . . $ `encodedv/dvconnect.c:70:9`!; |
| 767 |
v.syt_offsetcxx . . $ video1394_mmap#syt_offset. = syt_offsetcxx . . $ syt_offset.; |
| 768 |
w.channelcxx . . $ video1394_queue_variable#channel. = v.channelcxx . . $ video1394_mmap#channel.; |
| 769 |
|
| 770 |
if (ioctlcxx . . $ ioctl(67fa1c773b05068c).(viddev, VIDEO1394_TALK_CHANNELcxx . . $ `encodedv/dvconnect.c:109:9`!, &v) < 0) { |
| 771 |
perrorcxx . . $ perror(85c52e162fed56f9).("VIDEO1394_TALK_CHANNEL"); |
| 772 |
closecxx . . $ close(7864480464b09eea). (viddev); |
| 773 |
if (src_fpcxx . . $ src_fp. && src_fpcxx . . $ src_fp. != stdincxx . . $ `<external>/232824719582829767/stdio.h:157:9`!) |
| 774 |
fclosecxx . . $ fclose(89bc1efcdac0ca22). (src_fpcxx . . $ src_fp.); |
| 775 |
return -1; |
| 776 |
} |
| 777 |
|
| 778 |
if ((send_buf = (unsigned char *) mmapcxx . . $ mmap(ff06c1c904cdf0e2).( |
| 779 |
0, v.nb_bufferscxx . . $ video1394_mmap#nb_buffers. * v.buf_sizecxx . . $ video1394_mmap#buf_size., PROT_READcxx . . $ `<external>/17226767460805440860/mman-linux.h:32:9`!|PROT_WRITEcxx . . $ `<external>/17226767460805440860/mman-linux.h:33:9`!, |
| 780 |
MAP_SHAREDcxx . . $ `<external>/17226767460805440860/mman-linux.h:42:9`!, viddev, 0)) == (unsigned char *)-1) { |
| 781 |
perrorcxx . . $ perror(85c52e162fed56f9).("mmap videobuffer"); |
| 782 |
closecxx . . $ close(7864480464b09eea). (viddev); |
| 783 |
if (src_fpcxx . . $ src_fp. && src_fpcxx . . $ src_fp. != stdincxx . . $ `<external>/232824719582829767/stdio.h:157:9`!) |
| 784 |
fclosecxx . . $ fclose(89bc1efcdac0ca22). (src_fpcxx . . $ src_fp.); |
| 785 |
return -1; |
| 786 |
} |
| 787 |
|
| 788 |
if (verbose_mode) { |
| 789 |
fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Filling buffers...\r"); |
| 790 |
} |
| 791 |
|
| 792 |
/* signal(SIGTERM, sig_int_send_handler); |
| 793 |
signal(SIGINT, sig_int_send_handler); */ |
| 794 |
|
| 795 |
pthread_mutex_initcxx . . $ pthread_mutex_init(db9d29dab44ea1aa).(&queue_mutexcxx . . $ queue_mutex., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 796 |
pthread_mutex_initcxx . . $ pthread_mutex_init(db9d29dab44ea1aa).(&wakeup_mutexcxx . . $ wakeup_mutex., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 797 |
pthread_cond_initcxx . . $ pthread_cond_init(fc876bc1ec1249fc).(&wakeup_condcxx . . $ wakeup_cond., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 798 |
pthread_mutex_initcxx . . $ pthread_mutex_init(db9d29dab44ea1aa).(&wakeup_rev_mutexcxx . . $ wakeup_rev_mutex., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 799 |
pthread_cond_initcxx . . $ pthread_cond_init(fc876bc1ec1249fc).(&wakeup_rev_condcxx . . $ wakeup_rev_cond., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 800 |
|
| 801 |
pthread_createcxx . . $ pthread_create(2141a84bcac899e5).(&file_io_threadcxx . . $ file_io_thread., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, read_in_threadcxx . . $ read_in_thread(9f162e79bfc6c74)., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 802 |
|
| 803 |
pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(&wakeup_rev_mutexcxx . . $ wakeup_rev_mutex.); |
| 804 |
pthread_cond_waitcxx . . $ pthread_cond_wait(6145be15a5d9db5d).(&wakeup_rev_condcxx . . $ wakeup_rev_cond., &wakeup_rev_mutexcxx . . $ wakeup_rev_mutex.); |
| 805 |
pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&wakeup_rev_mutexcxx . . $ wakeup_rev_mutex.); |
| 806 |
|
| 807 |
if (verbose_mode) { |
| 808 |
fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Transmitting...\r"); |
| 809 |
} |
| 810 |
|
| 811 |
unused_buffers = v.nb_bufferscxx . . $ video1394_mmap#nb_buffers.; |
| 812 |
w.buffercxx . . $ video1394_queue_variable#buffer. = 0; |
| 813 |
got_frame = 1; |
| 814 |
w.packet_sizescxx . . $ video1394_queue_variable#packet_sizes. = packet_sizes; |
| 815 |
memsetcxx . . $ memset(d1de1e4fb215f1c6).(packet_sizes, 0, sizeof(packet_sizes)); |
| 816 |
|
| 817 |
for (;start_frame < end_frame;) { |
| 818 |
while (unused_buffers--) { |
| 819 |
got_frame = (fill_buffercxx . . $ fill_buffer(9f597e2150cf6e22).( |
| 820 |
send_buf + w.buffercxx . . $ video1394_queue_variable#buffer. * v.buf_sizecxx . . $ video1394_mmap#buf_size., |
| 821 |
packet_sizes) < 0) ? 0 : 1; |
| 822 |
|
| 823 |
if (!got_frame) { |
| 824 |
break; |
| 825 |
} |
| 826 |
if (ioctlcxx . . $ ioctl(67fa1c773b05068c).(viddev, VIDEO1394_TALK_QUEUE_BUFFERcxx . . $ `encodedv/dvconnect.c:113:9`!, &w)<0) { |
| 827 |
perrorcxx . . $ perror(85c52e162fed56f9).("VIDEO1394_TALK_QUEUE_BUFFER"); |
| 828 |
} |
| 829 |
if (verbose_mode) { |
| 830 |
fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Sent frame %8d\r", |
| 831 |
start_frame); |
| 832 |
} |
| 833 |
w.buffercxx . . $ video1394_queue_variable#buffer. ++; |
| 834 |
w.buffercxx . . $ video1394_queue_variable#buffer. %= v.nb_bufferscxx . . $ video1394_mmap#nb_buffers.; |
| 835 |
start_frame++; |
| 836 |
} |
| 837 |
if (!got_frame) { |
| 838 |
break; |
| 839 |
} |
| 840 |
if (ioctlcxx . . $ ioctl(67fa1c773b05068c).(viddev, VIDEO1394_TALK_WAIT_BUFFERcxx . . $ `encodedv/dvconnect.c:115:9`!, &w) < 0) { |
| 841 |
perrorcxx . . $ perror(85c52e162fed56f9).("VIDEO1394_TALK_WAIT_BUFFER"); |
| 842 |
} |
| 843 |
unused_buffers = 1; |
| 844 |
} |
| 845 |
|
| 846 |
w.buffercxx . . $ video1394_queue_variable#buffer. = (v.nb_bufferscxx . . $ video1394_mmap#nb_buffers. + w.buffercxx . . $ video1394_queue_variable#buffer. - 1) % v.nb_bufferscxx . . $ video1394_mmap#nb_buffers.; |
| 847 |
|
| 848 |
if (ioctlcxx . . $ ioctl(67fa1c773b05068c).(viddev, VIDEO1394_TALK_WAIT_BUFFERcxx . . $ `encodedv/dvconnect.c:115:9`!, &w) < 0) { |
| 849 |
perrorcxx . . $ perror(85c52e162fed56f9).("VIDEO1394_TALK_WAIT_BUFFER"); |
| 850 |
} |
| 851 |
|
| 852 |
munmapcxx . . $ munmap(c0a5f96701d3f89).(send_buf, v.nb_bufferscxx . . $ video1394_mmap#nb_buffers. * v.buf_sizecxx . . $ video1394_mmap#buf_size.); |
| 853 |
|
| 854 |
if (ioctlcxx . . $ ioctl(67fa1c773b05068c).(viddev, VIDEO1394_UNTALK_CHANNELcxx . . $ `encodedv/dvconnect.c:111:9`!, &v.channelcxx . . $ video1394_mmap#channel.)<0) { |
| 855 |
perrorcxx . . $ perror(85c52e162fed56f9).("VIDEO1394_UNTALK_CHANNEL"); |
| 856 |
} |
| 857 |
|
| 858 |
closecxx . . $ close(7864480464b09eea).(viddev); |
| 859 |
|
| 860 |
pthread_joincxx . . $ pthread_join(269902cf949f12c5).(file_io_threadcxx . . $ file_io_thread., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 861 |
|
| 862 |
return 0; |
| 863 |
} |
| 864 |
|
| 865 |
int rt_raisepricxx . . $ rt_raisepri(7864480464b09eea). (int pri) |
| 866 |
{ |
| 867 |
#ifdef _SC_PRIORITY_SCHEDULINGcxx . . $ `<external>/6393649343499073842/confname.h:94:9`! |
| 868 |
struct sched_paramcxx . . $ sched_param# scp; |
| 869 |
|
| 870 |
/* |
| 871 |
* Verify that scheduling is available |
| 872 |
*/ |
| 873 |
if (sysconfcxx . . $ sysconf(dc1f09c09fbff20f). (_SC_PRIORITY_SCHEDULINGcxx . . $ `<external>/6393649343499073842/confname.h:94:9`!) == -1) { |
| 874 |
fprintfcxx . . $ fprintf(bc216f8e5b1ebeac). (stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "WARNING: RR-scheduler not available, " |
| 875 |
"disabling.\n"); |
| 876 |
return (-1); |
| 877 |
} else { |
| 878 |
memsetcxx . . $ memset(d1de1e4fb215f1c6). (&scp, '\0', sizeof (scp)); |
| 879 |
scp.sched_prioritycxx . . $ `<external>/17522079545615609418/sched.h:47:9`! = sched_get_priority_maxcxx . . $ sched_get_priority_max(7864480464b09eea). (SCHED_RRcxx . . $ `<external>/4872883757279652994/sched.h:30:9`!) - pri; |
| 880 |
if (sched_setschedulercxx . . $ sched_setscheduler(b99e0841b006542f). (0, SCHED_RRcxx . . $ `<external>/4872883757279652994/sched.h:30:9`!, &scp) < 0) { |
| 881 |
fprintfcxx . . $ fprintf(bc216f8e5b1ebeac). (stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "WARNING: Cannot set RR-scheduler\n"); |
| 882 |
return (-1); |
| 883 |
} |
| 884 |
} |
| 885 |
#endif |
| 886 |
return (0); |
| 887 |
} |
| 888 |
|
| 889 |
/* ------------------------------------------------------------------------ |
| 890 |
- main() |
| 891 |
------------------------------------------------------------------------ */ |
| 892 |
|
| 893 |
#define DV_CONNECT_OPT_VERSIONcxx . . $ `encodedv/dvconnect.c:893:9`! 0 |
| 894 |
#define DV_CONNECT_OPT_SENDcxx . . $ `encodedv/dvconnect.c:894:9`! 1 |
| 895 |
#define DV_CONNECT_OPT_VERBOSEcxx . . $ `encodedv/dvconnect.c:895:9`! 2 |
| 896 |
#define DV_CONNECT_OPT_CHANNELcxx . . $ `encodedv/dvconnect.c:896:9`! 3 |
| 897 |
#define DV_CONNECT_OPT_KBUFFERScxx . . $ `encodedv/dvconnect.c:897:9`! 4 |
| 898 |
#define DV_CONNECT_OPT_START_FRAMEcxx . . $ `encodedv/dvconnect.c:898:9`! 5 |
| 899 |
#define DV_CONNECT_OPT_END_FRAMEcxx . . $ `encodedv/dvconnect.c:899:9`! 6 |
| 900 |
#define DV_CONNECT_OPT_CIP_N_NTSCcxx . . $ `encodedv/dvconnect.c:900:9`! 7 |
| 901 |
#define DV_CONNECT_OPT_CIP_D_NTSCcxx . . $ `encodedv/dvconnect.c:901:9`! 8 |
| 902 |
#define DV_CONNECT_OPT_SYT_OFFSETcxx . . $ `encodedv/dvconnect.c:902:9`! 9 |
| 903 |
#define DV_CONNECT_OPT_MAX_BUFFERScxx . . $ `encodedv/dvconnect.c:903:9`! 10 |
| 904 |
#define DV_CONNECT_OPT_UNDERRUN_DATAcxx . . $ `encodedv/dvconnect.c:904:9`! 11 |
| 905 |
#define DV_CONNECT_OPT_AUTOHELPcxx . . $ `encodedv/dvconnect.c:905:9`! 12 |
| 906 |
#define DV_CONNECT_OPT_DEVICEcxx . . $ `encodedv/dvconnect.c:906:9`! 13 |
| 907 |
#define DV_CONNECT_NUM_OPTScxx . . $ `encodedv/dvconnect.c:907:9`! 14 |
| 908 |
|
| 909 |
|
| 910 |
int maincxx . . $ main(d8e43b79a186046c).(int argc, const char** argv) |
| 911 |
{ |
| 912 |
#if HAVE_LIBPOPTcxx . . $ `config.h:38:9`! |
| 913 |
int verbose_mode = 0; |
| 914 |
int send_mode = 0; |
| 915 |
int channel = 63; |
| 916 |
int buffers = 8; |
| 917 |
int start = 0; |
| 918 |
int end = 0xfffffff; |
| 919 |
const char* underrun_data = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 920 |
|
| 921 |
struct poptOptioncxx . . $ poptOption# option_table[DV_CONNECT_NUM_OPTScxx . . $ `encodedv/dvconnect.c:907:9`!+1]; |
| 922 |
int rc; /* return code from popt */ |
| 923 |
poptContextcxx . . $ poptContext# optCon; /* context for parsing command-line options */ |
| 924 |
|
| 925 |
option_table[DV_CONNECT_OPT_VERSIONcxx . . $ `encodedv/dvconnect.c:893:9`!] = (struct poptOptioncxx . . $ poptOption#) { |
| 926 |
longName: "version", |
| 927 |
val: 'v', |
| 928 |
descrip: "show dvconnect version number" |
| 929 |
}; /* version */ |
| 930 |
|
| 931 |
option_table[DV_CONNECT_OPT_SENDcxx . . $ `encodedv/dvconnect.c:894:9`!] = (struct poptOptioncxx . . $ poptOption#) { |
| 932 |
longName: "send", |
| 933 |
shortName: 's', |
| 934 |
arg: &send_mode, |
| 935 |
descrip: "send data instead of capturing" |
| 936 |
}; /* send mode */ |
| 937 |
|
| 938 |
option_table[DV_CONNECT_OPT_VERBOSEcxx . . $ `encodedv/dvconnect.c:895:9`!] = (struct poptOptioncxx . . $ poptOption#) { |
| 939 |
longName: "verbose", |
| 940 |
shortName: 'v', |
| 941 |
arg: &verbose_mode, |
| 942 |
descrip: "show status information while receiving / sending" |
| 943 |
}; /* verbose mode */ |
| 944 |
|
| 945 |
option_table[DV_CONNECT_OPT_CHANNELcxx . . $ `encodedv/dvconnect.c:896:9`!] = (struct poptOptioncxx . . $ poptOption#) { |
| 946 |
longName: "channel", |
| 947 |
shortName: 'c', |
| 948 |
argInfo: POPT_ARG_INTcxx . . $ `<external>/16232926639102580118/popt.h:20:9`!, |
| 949 |
arg: &channel, |
| 950 |
argDescrip: "number", |
| 951 |
descrip: "channel to send / receive on " |
| 952 |
"(range: 0 - 63, default = 63)" |
| 953 |
}; /* channel */ |
| 954 |
|
| 955 |
option_table[DV_CONNECT_OPT_KBUFFERScxx . . $ `encodedv/dvconnect.c:897:9`!] = (struct poptOptioncxx . . $ poptOption#) { |
| 956 |
longName: "kbuffers", |
| 957 |
shortName: 'k', |
| 958 |
argInfo: POPT_ARG_INTcxx . . $ `<external>/16232926639102580118/popt.h:20:9`!, |
| 959 |
arg: &buffers, |
| 960 |
argDescrip: "number", |
| 961 |
descrip: "number of kernel video frame buffers to use. " |
| 962 |
"default = 8" |
| 963 |
}; /* buffers */ |
| 964 |
|
| 965 |
option_table[DV_CONNECT_OPT_START_FRAMEcxx . . $ `encodedv/dvconnect.c:898:9`!] = (struct poptOptioncxx . . $ poptOption#) { |
| 966 |
longName: "start-frame", |
| 967 |
argInfo: POPT_ARG_INTcxx . . $ `<external>/16232926639102580118/popt.h:20:9`!, |
| 968 |
arg: &start, |
| 969 |
argDescrip: "count", |
| 970 |
descrip: "start at <count> frame (defaults to 0)" |
| 971 |
}; /* start-frame */ |
| 972 |
|
| 973 |
option_table[DV_CONNECT_OPT_END_FRAMEcxx . . $ `encodedv/dvconnect.c:899:9`!] = (struct poptOptioncxx . . $ poptOption#) { |
| 974 |
longName: "end-frame", |
| 975 |
shortName: 'e', |
| 976 |
argInfo: POPT_ARG_INTcxx . . $ `<external>/16232926639102580118/popt.h:20:9`!, |
| 977 |
arg: &end, |
| 978 |
argDescrip: "count", |
| 979 |
descrip: "end at <count> frame (defaults to unlimited)" |
| 980 |
}; /* end-frames */ |
| 981 |
|
| 982 |
option_table[DV_CONNECT_OPT_CIP_N_NTSCcxx . . $ `encodedv/dvconnect.c:900:9`!] = (struct poptOptioncxx . . $ poptOption#) { |
| 983 |
longName: "cip-n-ntsc", |
| 984 |
argInfo: POPT_ARG_INTcxx . . $ `<external>/16232926639102580118/popt.h:20:9`!, |
| 985 |
arg: &cip_n_ntsccxx . . $ cip_n_ntsc., |
| 986 |
descrip: "cip n ntsc timing counter (default: 2436)" |
| 987 |
}; /* cip_n_ntsc */ |
| 988 |
|
| 989 |
option_table[DV_CONNECT_OPT_CIP_D_NTSCcxx . . $ `encodedv/dvconnect.c:901:9`!] = (struct poptOptioncxx . . $ poptOption#) { |
| 990 |
longName: "cip-d-ntsc", |
| 991 |
argInfo: POPT_ARG_INTcxx . . $ `<external>/16232926639102580118/popt.h:20:9`!, |
| 992 |
arg: &cip_d_ntsccxx . . $ cip_d_ntsc., |
| 993 |
descrip: "cip d ntsc timing counter (default: 38400)" |
| 994 |
}; /* cip_d_ntsc */ |
| 995 |
|
| 996 |
option_table[DV_CONNECT_OPT_SYT_OFFSETcxx . . $ `encodedv/dvconnect.c:902:9`!] = (struct poptOptioncxx . . $ poptOption#) { |
| 997 |
longName: "syt-offset", |
| 998 |
argInfo: POPT_ARG_INTcxx . . $ `<external>/16232926639102580118/popt.h:20:9`!, |
| 999 |
arg: &syt_offsetcxx . . $ syt_offset., |
| 1000 |
descrip: "syt offset (default: 10000 range: 10000-26000)" |
| 1001 |
}; /* syt offset */ |
| 1002 |
|
| 1003 |
option_table[DV_CONNECT_OPT_MAX_BUFFERScxx . . $ `encodedv/dvconnect.c:903:9`!] = (struct poptOptioncxx . . $ poptOption#) { |
| 1004 |
longName: "buffers", |
| 1005 |
shortName: 'b', |
| 1006 |
argInfo: POPT_ARG_INTcxx . . $ `<external>/16232926639102580118/popt.h:20:9`!, |
| 1007 |
arg: &max_buffer_blockscxx . . $ max_buffer_blocks., |
| 1008 |
argDescrip: "number", |
| 1009 |
descrip: "max number of file io thread buffers to use. " |
| 1010 |
"default = 250" |
| 1011 |
}; /* buffers */ |
| 1012 |
|
| 1013 |
option_table[DV_CONNECT_OPT_UNDERRUN_DATAcxx . . $ `encodedv/dvconnect.c:904:9`!] = (struct poptOptioncxx . . $ poptOption#) { |
| 1014 |
longName: "underrun-data", |
| 1015 |
shortName: 'u', |
| 1016 |
argInfo: POPT_ARG_STRINGcxx . . $ `<external>/16232926639102580118/popt.h:19:9`!, |
| 1017 |
arg: &underrun_data, |
| 1018 |
argDescrip: "filename", |
| 1019 |
descrip: "file with the frame to send in case of underruns" |
| 1020 |
}; /* underrun-data */ |
| 1021 |
|
| 1022 |
option_table[DV_CONNECT_OPT_AUTOHELPcxx . . $ `encodedv/dvconnect.c:905:9`!] = (struct poptOptioncxx . . $ poptOption#) { |
| 1023 |
argInfo: POPT_ARG_INCLUDE_TABLEcxx . . $ `<external>/16232926639102580118/popt.h:22:9`!, |
| 1024 |
arg: poptHelpOptionscxx . . $ poptHelpOptions., |
| 1025 |
descrip: "Help options", |
| 1026 |
}; /* autohelp */ |
| 1027 |
|
| 1028 |
option_table[DV_CONNECT_OPT_DEVICEcxx . . $ `encodedv/dvconnect.c:906:9`!] = (struct poptOptioncxx . . $ poptOption#) { |
| 1029 |
longName: "device", |
| 1030 |
shortName: 'd', |
| 1031 |
argInfo: POPT_ARG_STRINGcxx . . $ `<external>/16232926639102580118/popt.h:19:9`!, |
| 1032 |
arg: &devicecxx . . $ device., |
| 1033 |
descrip: "Specify the video1394 device (default /dev/video1394/0)", |
| 1034 |
}; /* device */ |
| 1035 |
|
| 1036 |
option_table[DV_CONNECT_NUM_OPTScxx . . $ `encodedv/dvconnect.c:907:9`!] = (struct poptOptioncxx . . $ poptOption#) { |
| 1037 |
NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, 0, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, 0 }; |
| 1038 |
|
| 1039 |
optCon = poptGetContextcxx . . $ poptGetContext(69e83c0752e8078).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, argc, |
| 1040 |
(const char **)argv, option_table, 0); |
| 1041 |
poptSetOtherOptionHelpcxx . . $ poptSetOtherOptionHelp(fc627e009555550b).(optCon, "<raw dv files or '-- -' for stdin/stdout>"); |
| 1042 |
|
| 1043 |
while ((rc = poptGetNextOptcxx . . $ poptGetNextOpt(8c14591e39307bbe).(optCon)) > 0) { |
| 1044 |
switch (rc) { |
| 1045 |
case 'v': |
| 1046 |
fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!,"dvconnect: version %s, " |
| 1047 |
"http://libdv.sourceforge.net/\n", |
| 1048 |
"CVS 05/06/2001"); |
| 1049 |
return 0; |
| 1050 |
break; |
| 1051 |
default: |
| 1052 |
break; |
| 1053 |
} |
| 1054 |
} |
| 1055 |
|
| 1056 |
if (rc < -1) { |
| 1057 |
/* an error occurred during option processing */ |
| 1058 |
fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "%s: %s\n", |
| 1059 |
poptBadOptioncxx . . $ poptBadOption(abdebb552147fd6f).(optCon, POPT_BADOPTION_NOALIAScxx . . $ `<external>/16232926639102580118/popt.h:99:9`!), |
| 1060 |
poptStrerrorcxx . . $ poptStrerror(f7ae7e56280f18ae).(rc)); |
| 1061 |
return -1; |
| 1062 |
} |
| 1063 |
|
| 1064 |
if (channel < 0 || channel > 63) { |
| 1065 |
fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Invalid channel chosen: %d\n" |
| 1066 |
"Should be in the range 0 - 63\n", channel); |
| 1067 |
return -1; |
| 1068 |
} |
| 1069 |
if (buffers < 0) { |
| 1070 |
fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Number of buffers should be > 0!\n"); |
| 1071 |
return -1; |
| 1072 |
} |
| 1073 |
|
| 1074 |
setprioritycxx . . $ setpriority(1b61798b465b7f9). (PRIO_PROCESScxx . . $ `<external>/1890803886155400780/resource.h:190:9`!, 0, -20); |
| 1075 |
if (rt_raisepricxx . . $ rt_raisepri(7864480464b09eea). (1) != 0) { |
| 1076 |
setprioritycxx . . $ setpriority(1b61798b465b7f9). (PRIO_PROCESScxx . . $ `<external>/1890803886155400780/resource.h:190:9`!, 0, -20); |
| 1077 |
} |
| 1078 |
|
| 1079 |
#if _POSIX_MEMLOCKcxx . . $ `<external>/4533468968537266721/posix_opt.h:44:9`! > 0 |
| 1080 |
if (mlockallcxx . . $ mlockall(7864480464b09eea).(MCL_CURRENTcxx . . $ `<external>/17226767460805440860/mman-linux.h:131:10`! | MCL_FUTUREcxx . . $ `<external>/17226767460805440860/mman-linux.h:132:10`!) == -1) |
| 1081 |
{ |
| 1082 |
if (verbose_mode) |
| 1083 |
fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Cannot disable swapping\n"); |
| 1084 |
} |
| 1085 |
else |
| 1086 |
#endif |
| 1087 |
{ |
| 1088 |
/* Prevent excessive underruns from locking down all mem. */ |
| 1089 |
ceil_buffer_blockscxx . . $ ceil_buffer_blocks. = 10*max_buffer_blockscxx . . $ max_buffer_blocks.; |
| 1090 |
} |
| 1091 |
|
| 1092 |
if ( devicecxx . . $ device. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! ) |
| 1093 |
devicecxx . . $ device. = "/dev/video1394/0"; |
| 1094 |
|
| 1095 |
if (send_mode) { |
| 1096 |
send_rawcxx . . $ send_raw(5f01636f8fae20d6).(poptGetArgscxx . . $ poptGetArgs(a29d6e5da170a4c3).(optCon), channel, buffers, start, end, |
| 1097 |
verbose_mode, underrun_data, devicecxx . . $ device.); |
| 1098 |
} else { |
| 1099 |
capture_rawcxx . . $ capture_raw(7aeb29e642a729f0).(poptGetArgcxx . . $ poptGetArg(86c70cf25448eb00).(optCon), channel, buffers, start, end, |
| 1100 |
verbose_mode, devicecxx . . $ device.); |
| 1101 |
} |
| 1102 |
return 0; |
| 1103 |
#else |
| 1104 |
#warning dvconnect can not work without libpopt! |
| 1105 |
|
| 1106 |
#endif |
| 1107 |
} |
| 1108 |
|