00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * v42bis.h 00005 * 00006 * Written by Steve Underwood <steveu@coppice.org> 00007 * 00008 * Copyright (C) 2005, 2011 Steve Underwood 00009 * 00010 * All rights reserved. 00011 * 00012 * This program is free software; you can redistribute it and/or modify 00013 * it under the terms of the GNU Lesser General Public License version 2.1, 00014 * as published by the Free Software Foundation. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Lesser General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Lesser General Public 00022 * License along with this program; if not, write to the Free Software 00023 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00024 */ 00025 00026 /*! \page v42bis_page V.42bis modem data compression 00027 \section v42bis_page_sec_1 What does it do? 00028 The v.42bis specification defines a data compression scheme, to work in 00029 conjunction with the error correction scheme defined in V.42. 00030 00031 \section v42bis_page_sec_2 How does it work? 00032 */ 00033 00034 #if !defined(_SPANDSP_V42BIS_H_) 00035 #define _SPANDSP_V42BIS_H_ 00036 00037 #define V42BIS_MIN_STRING_SIZE 6 00038 #define V42BIS_MAX_STRING_SIZE 250 00039 #define V42BIS_MIN_DICTIONARY_SIZE 512 00040 #define V42BIS_MAX_BITS 12 00041 #define V42BIS_MAX_CODEWORDS 4096 /* 2^V42BIS_MAX_BITS */ 00042 #define V42BIS_MAX_OUTPUT_LENGTH 1024 00043 00044 enum 00045 { 00046 V42BIS_P0_NEITHER_DIRECTION = 0, 00047 V42BIS_P0_INITIATOR_RESPONDER, 00048 V42BIS_P0_RESPONDER_INITIATOR, 00049 V42BIS_P0_BOTH_DIRECTIONS 00050 }; 00051 00052 enum 00053 { 00054 V42BIS_COMPRESSION_MODE_DYNAMIC = 0, 00055 V42BIS_COMPRESSION_MODE_ALWAYS, 00056 V42BIS_COMPRESSION_MODE_NEVER 00057 }; 00058 00059 /*! 00060 V.42bis compression/decompression descriptor. This defines the working state for a 00061 single instance of V.42bis compress/decompression. 00062 */ 00063 typedef struct v42bis_state_s v42bis_state_t; 00064 00065 #if defined(__cplusplus) 00066 extern "C" 00067 { 00068 #endif 00069 00070 /*! Compress a block of octets. 00071 \param s The V.42bis context. 00072 \param buf The data to be compressed. 00073 \param len The length of the data buffer. 00074 \return 0 */ 00075 SPAN_DECLARE(int) v42bis_compress(v42bis_state_t *s, const uint8_t buf[], int len); 00076 00077 /*! Flush out any data remaining in a compression buffer. 00078 \param s The V.42bis context. 00079 \return 0 */ 00080 SPAN_DECLARE(int) v42bis_compress_flush(v42bis_state_t *s); 00081 00082 /*! Decompress a block of octets. 00083 \param s The V.42bis context. 00084 \param buf The data to be decompressed. 00085 \param len The length of the data buffer. 00086 \return 0 */ 00087 SPAN_DECLARE(int) v42bis_decompress(v42bis_state_t *s, const uint8_t buf[], int len); 00088 00089 /*! Flush out any data remaining in the decompression buffer. 00090 \param s The V.42bis context. 00091 \return 0 */ 00092 SPAN_DECLARE(int) v42bis_decompress_flush(v42bis_state_t *s); 00093 00094 /*! Set the compression mode. 00095 \param s The V.42bis context. 00096 \param mode One of the V.42bis compression modes - 00097 V42BIS_COMPRESSION_MODE_DYNAMIC, 00098 V42BIS_COMPRESSION_MODE_ALWAYS, 00099 V42BIS_COMPRESSION_MODE_NEVER */ 00100 SPAN_DECLARE(void) v42bis_compression_control(v42bis_state_t *s, int mode); 00101 00102 /*! Initialise a V.42bis context. 00103 \param s The V.42bis context. 00104 \param negotiated_p0 The negotiated P0 parameter, from the V.42bis spec. 00105 \param negotiated_p1 The negotiated P1 parameter, from the V.42bis spec. 00106 \param negotiated_p2 The negotiated P2 parameter, from the V.42bis spec. 00107 \param encode_handler Encode callback handler. 00108 \param encode_user_data An opaque pointer passed to the encode callback handler. 00109 \param max_encode_len The maximum length that should be passed to the encode handler. 00110 \param decode_handler Decode callback handler. 00111 \param decode_user_data An opaque pointer passed to the decode callback handler. 00112 \param max_decode_len The maximum length that should be passed to the decode handler. 00113 \return The V.42bis context. */ 00114 SPAN_DECLARE(v42bis_state_t *) v42bis_init(v42bis_state_t *s, 00115 int negotiated_p0, 00116 int negotiated_p1, 00117 int negotiated_p2, 00118 put_msg_func_t encode_handler, 00119 void *encode_user_data, 00120 int max_encode_len, 00121 put_msg_func_t decode_handler, 00122 void *decode_user_data, 00123 int max_decode_len); 00124 00125 /*! Release a V.42bis context. 00126 \param s The V.42bis context. 00127 \return 0 if OK */ 00128 SPAN_DECLARE(int) v42bis_release(v42bis_state_t *s); 00129 00130 /*! Free a V.42bis context. 00131 \param s The V.42bis context. 00132 \return 0 if OK */ 00133 SPAN_DECLARE(int) v42bis_free(v42bis_state_t *s); 00134 00135 #if defined(__cplusplus) 00136 } 00137 #endif 00138 00139 #endif 00140 /*- End of file ------------------------------------------------------------*/
1.6.1