1 /* @(#) definition of packet-io functions for udpxy
3 * Copyright 2008-2011 Pavel V. Cherenkov (pcherenkov@gmail.com)
5 * This file is part of udpxy.
7 * udpxy 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 3 of the License, or
10 * (at your option) any later version.
12 * udpxy 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 udpxy. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef UDPXY_DPKTH_02182008
22 #define UDPXY_DPKTH_02182008
27 /* data-stream format type */
31 DT_UNKNOWN
, /* no assumptions */
33 DT_RTP_TS
, /* RTP over MPEG-TS */
34 DT_UDS
, /* UDS file format */
35 DT_RAW
, /* read AS-IS */
41 /* data stream context
53 /* data-stream context flags
55 static const int32_t F_DROP_PACKET
= (1 << 1);
56 static const int32_t F_CHECK_FMT
= (1 << 2);
57 static const int32_t F_SCATTERED
= (1 << 3);
58 static const int32_t F_FILE_INPUT
= (1 << 4);
65 /* return human-readable name of file/stream format
67 const char* fmt2str( upxfmt_t fmt
);
70 /* determine type of stream saved in file
73 get_fstream_type( int fd
, FILE* log
);
75 /* determine type of stream in memory
78 get_mstream_type( const char* data
, size_t len
, FILE* log
);
81 /* read record of one of the supported types from file
84 read_frecord( int fd
, char* data
, const size_t len
,
85 upxfmt_t
* stream_type
, FILE* log
);
88 /* write record after converting it from source into destination
92 write_frecord( int fd
, const char* data
, size_t len
,
93 upxfmt_t sfmt
, upxfmt_t dfmt
, FILE* log
);
96 /* reset packet-buffer registry in stream context
99 reset_pkt_registry( struct dstream_ctx
* ds
);
102 /* release resources allocated for stream context
105 free_dstream_ctx( struct dstream_ctx
* ds
);
108 /* initialize incoming-stream context:
109 * set data type (if possible) and flags
112 init_dstream_ctx( struct dstream_ctx
* ds
, const char* cmd
, const char* fname
,
116 /* read data from source of specified type (UDP socket or otherwise);
117 * read as many fragments as specified (max_frgs) into the buffer
120 int max_frgs
; /* max fragments to read in */
121 time_t buf_tmout
; /* max time (sec) to hold data in buffer */
125 read_data( struct dstream_ctx
* spc
, int fd
, char* data
,
126 const ssize_t data_len
, const struct rdata_opt
* opt
);
129 /* write data to destination(s)
132 write_data( const struct dstream_ctx
* spc
,
141 #endif /* UDPXY_DPKTH_02182008 */