spandsp 3.0.0
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?
28The v.42bis specification defines a data compression scheme, to work in
29conjunction 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
44enum
45{
46 V42BIS_P0_NEITHER_DIRECTION = 0,
47 V42BIS_P0_INITIATOR_RESPONDER,
48 V42BIS_P0_RESPONDER_INITIATOR,
49 V42BIS_P0_BOTH_DIRECTIONS
50};
51
52enum
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*/
63typedef struct v42bis_state_s v42bis_state_t;
64
65#if defined(__cplusplus)
66extern "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/*! Get the logging context associated with a V.42bis context.
103 \brief Get the logging context associated with a V.42bis context.
104 \param s The V.42bis context.
105 \return A pointer to the logging context */
106SPAN_DECLARE(logging_state_t *) v42bis_get_logging_state(v42bis_state_t *s);
107
108/*! Initialise a V.42bis context.
109 \param s The V.42bis context.
110 \param negotiated_p0 The negotiated P0 parameter, from the V.42bis spec.
111 \param negotiated_p1 The negotiated P1 parameter, from the V.42bis spec.
112 \param negotiated_p2 The negotiated P2 parameter, from the V.42bis spec.
113 \param encode_handler Encode callback handler.
114 \param encode_user_data An opaque pointer passed to the encode callback handler.
115 \param max_encode_len The maximum length that should be passed to the encode handler.
116 \param decode_handler Decode callback handler.
117 \param decode_user_data An opaque pointer passed to the decode callback handler.
118 \param max_decode_len The maximum length that should be passed to the decode handler.
119 \return The V.42bis context. */
120SPAN_DECLARE(v42bis_state_t *) v42bis_init(v42bis_state_t *s,
121 int negotiated_p0,
122 int negotiated_p1,
123 int negotiated_p2,
124 put_msg_func_t encode_handler,
125 void *encode_user_data,
126 int max_encode_len,
127 put_msg_func_t decode_handler,
128 void *decode_user_data,
129 int max_decode_len);
130
131/*! Release a V.42bis context.
132 \param s The V.42bis context.
133 \return 0 if OK */
134SPAN_DECLARE(int) v42bis_release(v42bis_state_t *s);
135
136/*! Free a V.42bis context.
137 \param s The V.42bis context.
138 \return 0 if OK */
139SPAN_DECLARE(int) v42bis_free(v42bis_state_t *s);
140
141#if defined(__cplusplus)
142}
143#endif
144
145#endif
146/*- End of file ------------------------------------------------------------*/
void(* put_msg_func_t)(void *user_data, const uint8_t *msg, int len)
Definition async.h:95
Definition private/logging.h:34
Definition private/v42bis.h:116