spandsp 0.0.6

v42bis.h
1/*
2 * SpanDSP - a series of DSP components for telephony
3 *
4 * v42bis.h
5 *
6 * Written by Steve Underwood <steveu@coppice.org>
7 *
8 * Copyright (C) 2005, 2011 Steve Underwood
9 *
10 * All rights reserved.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 2.1,
14 * as published by the Free Software Foundation.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */
25
26/*! \page v42bis_page V.42bis modem data compression
27\section v42bis_page_sec_1 What does it do?
28 The v.42bis specification defines a data compression scheme, to work in
29 conjunction with the error correction scheme defined in V.42.
30
31\section v42bis_page_sec_2 How does it work?
32*/
33
34#if !defined(_SPANDSP_V42BIS_H_)
35#define _SPANDSP_V42BIS_H_
36
37#define V42BIS_MIN_STRING_SIZE 6
38#define V42BIS_MAX_STRING_SIZE 250
39#define V42BIS_MIN_DICTIONARY_SIZE 512
40#define V42BIS_MAX_BITS 12
41#define V42BIS_MAX_CODEWORDS 4096 /* 2^V42BIS_MAX_BITS */
42#define V42BIS_MAX_OUTPUT_LENGTH 1024
43
44 enum
45{
46 V42BIS_P0_NEITHER_DIRECTION = 0,
47 V42BIS_P0_INITIATOR_RESPONDER,
48 V42BIS_P0_RESPONDER_INITIATOR,
49 V42BIS_P0_BOTH_DIRECTIONS
50};
51
52 enum
53{
54 V42BIS_COMPRESSION_MODE_DYNAMIC = 0,
55 V42BIS_COMPRESSION_MODE_ALWAYS,
56 V42BIS_COMPRESSION_MODE_NEVER
57};
58
59/*!
60 V.42bis compression/decompression descriptor. This defines the working state for a
61 single instance of V.42bis compress/decompression.
62*/
63 typedef struct v42bis_state_s v42bis_state_t;
64
65#if defined(__cplusplus)
66 extern "C"
67{
68#endif
69
70/*! Compress a block of octets.
71 \param s The V.42bis context.
72 \param buf The data to be compressed.
73 \param len The length of the data buffer.
74 \return 0 */
75SPAN_DECLARE(int) v42bis_compress(v42bis_state_t *s, const uint8_t buf[], int len);
76
77/*! Flush out any data remaining in a compression buffer.
78 \param s The V.42bis context.
79 \return 0 */
80SPAN_DECLARE(int) v42bis_compress_flush(v42bis_state_t *s);
81
82/*! Decompress a block of octets.
83 \param s The V.42bis context.
84 \param buf The data to be decompressed.
85 \param len The length of the data buffer.
86 \return 0 */
87SPAN_DECLARE(int) v42bis_decompress(v42bis_state_t *s, const uint8_t buf[], int len);
88
89/*! Flush out any data remaining in the decompression buffer.
90 \param s The V.42bis context.
91 \return 0 */
92SPAN_DECLARE(int) v42bis_decompress_flush(v42bis_state_t *s);
93
94/*! Set the compression mode.
95 \param s The V.42bis context.
96 \param mode One of the V.42bis compression modes -
97 V42BIS_COMPRESSION_MODE_DYNAMIC,
98 V42BIS_COMPRESSION_MODE_ALWAYS,
99 V42BIS_COMPRESSION_MODE_NEVER */
100SPAN_DECLARE(void) v42bis_compression_control(v42bis_state_t *s, int mode);
101
102/*! Initialise a V.42bis context.
103 \param s The V.42bis context.
104 \param negotiated_p0 The negotiated P0 parameter, from the V.42bis spec.
105 \param negotiated_p1 The negotiated P1 parameter, from the V.42bis spec.
106 \param negotiated_p2 The negotiated P2 parameter, from the V.42bis spec.
107 \param encode_handler Encode callback handler.
108 \param encode_user_data An opaque pointer passed to the encode callback handler.
109 \param max_encode_len The maximum length that should be passed to the encode handler.
110 \param decode_handler Decode callback handler.
111 \param decode_user_data An opaque pointer passed to the decode callback handler.
112 \param max_decode_len The maximum length that should be passed to the decode handler.
113 \return The V.42bis context. */
114SPAN_DECLARE(v42bis_state_t *) v42bis_init(v42bis_state_t *s,
115 int negotiated_p0,
116 int negotiated_p1,
117 int negotiated_p2,
118 put_msg_func_t encode_handler,
119 void *encode_user_data,
120 int max_encode_len,
121 put_msg_func_t decode_handler,
122 void *decode_user_data,
123 int max_decode_len);
124
125/*! Release a V.42bis context.
126 \param s The V.42bis context.
127 \return 0 if OK */
128SPAN_DECLARE(int) v42bis_release(v42bis_state_t *s);
129
130/*! Free a V.42bis context.
131 \param s The V.42bis context.
132 \return 0 if OK */
133SPAN_DECLARE(int) v42bis_free(v42bis_state_t *s);
134
135#if defined(__cplusplus)
136}
137#endif
138
139#endif
140/*- End of file ------------------------------------------------------------*/
put_msg_func_t
void(* put_msg_func_t)(void *user_data, const uint8_t *msg, int len)
Definition async.h:93
v42bis_state_s
Definition private/v42bis.h:116