Mercurial > hg > audiostuff
comparison spandsp-0.0.6pre17/src/spandsp/v42bis.h @ 4:26cd8f1ef0b1
import spandsp-0.0.6pre17
| author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
|---|---|
| date | Fri, 25 Jun 2010 15:50:58 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 3:c6c5a16ce2f2 | 4:26cd8f1ef0b1 |
|---|---|
| 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 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 * $Id: v42bis.h,v 1.27 2009/04/11 18:11:19 steveu Exp $ | |
| 26 */ | |
| 27 | |
| 28 /*! \page v42bis_page V.42bis modem data compression | |
| 29 \section v42bis_page_sec_1 What does it do? | |
| 30 The v.42bis specification defines a data compression scheme, to work in | |
| 31 conjunction with the error correction scheme defined in V.42. | |
| 32 | |
| 33 \section v42bis_page_sec_2 How does it work? | |
| 34 */ | |
| 35 | |
| 36 #if !defined(_SPANDSP_V42BIS_H_) | |
| 37 #define _SPANDSP_V42BIS_H_ | |
| 38 | |
| 39 #define V42BIS_MAX_BITS 12 | |
| 40 #define V42BIS_MAX_CODEWORDS 4096 /* 2^V42BIS_MAX_BITS */ | |
| 41 #define V42BIS_TABLE_SIZE 5021 /* This should be a prime >(2^V42BIS_MAX_BITS) */ | |
| 42 #define V42BIS_MAX_STRING_SIZE 250 | |
| 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 typedef void (*v42bis_frame_handler_t)(void *user_data, const uint8_t *pkt, int len); | |
| 60 typedef void (*v42bis_data_handler_t)(void *user_data, const uint8_t *buf, int len); | |
| 61 | |
| 62 /*! | |
| 63 V.42bis compression/decompression descriptor. This defines the working state for a | |
| 64 single instance of V.42bis compress/decompression. | |
| 65 */ | |
| 66 typedef struct v42bis_state_s v42bis_state_t; | |
| 67 | |
| 68 #if defined(__cplusplus) | |
| 69 extern "C" | |
| 70 { | |
| 71 #endif | |
| 72 | |
| 73 /*! Compress a block of octets. | |
| 74 \param s The V.42bis context. | |
| 75 \param buf The data to be compressed. | |
| 76 \param len The length of the data buffer. | |
| 77 \return 0 */ | |
| 78 SPAN_DECLARE(int) v42bis_compress(v42bis_state_t *s, const uint8_t *buf, int len); | |
| 79 | |
| 80 /*! Flush out any data remaining in a compression buffer. | |
| 81 \param s The V.42bis context. | |
| 82 \return 0 */ | |
| 83 SPAN_DECLARE(int) v42bis_compress_flush(v42bis_state_t *s); | |
| 84 | |
| 85 /*! Decompress a block of octets. | |
| 86 \param s The V.42bis context. | |
| 87 \param buf The data to be decompressed. | |
| 88 \param len The length of the data buffer. | |
| 89 \return 0 */ | |
| 90 SPAN_DECLARE(int) v42bis_decompress(v42bis_state_t *s, const uint8_t *buf, int len); | |
| 91 | |
| 92 /*! Flush out any data remaining in the decompression buffer. | |
| 93 \param s The V.42bis context. | |
| 94 \return 0 */ | |
| 95 SPAN_DECLARE(int) v42bis_decompress_flush(v42bis_state_t *s); | |
| 96 | |
| 97 /*! Set the compression mode. | |
| 98 \param s The V.42bis context. | |
| 99 \param mode One of the V.42bis compression modes - | |
| 100 V42BIS_COMPRESSION_MODE_DYNAMIC, | |
| 101 V42BIS_COMPRESSION_MODE_ALWAYS, | |
| 102 V42BIS_COMPRESSION_MODE_NEVER */ | |
| 103 SPAN_DECLARE(void) v42bis_compression_control(v42bis_state_t *s, int mode); | |
| 104 | |
| 105 /*! Initialise a V.42bis context. | |
| 106 \param s The V.42bis context. | |
| 107 \param negotiated_p0 The negotiated P0 parameter, from the V.42bis spec. | |
| 108 \param negotiated_p1 The negotiated P1 parameter, from the V.42bis spec. | |
| 109 \param negotiated_p2 The negotiated P2 parameter, from the V.42bis spec. | |
| 110 \param frame_handler Frame callback handler. | |
| 111 \param frame_user_data An opaque pointer passed to the frame callback handler. | |
| 112 \param max_frame_len The maximum length that should be passed to the frame handler. | |
| 113 \param data_handler data callback handler. | |
| 114 \param data_user_data An opaque pointer passed to the data callback handler. | |
| 115 \param max_data_len The maximum length that should be passed to the data handler. | |
| 116 \return The V.42bis context. */ | |
| 117 SPAN_DECLARE(v42bis_state_t *) v42bis_init(v42bis_state_t *s, | |
| 118 int negotiated_p0, | |
| 119 int negotiated_p1, | |
| 120 int negotiated_p2, | |
| 121 v42bis_frame_handler_t frame_handler, | |
| 122 void *frame_user_data, | |
| 123 int max_frame_len, | |
| 124 v42bis_data_handler_t data_handler, | |
| 125 void *data_user_data, | |
| 126 int max_data_len); | |
| 127 | |
| 128 /*! Release a V.42bis context. | |
| 129 \param s The V.42bis context. | |
| 130 \return 0 if OK */ | |
| 131 SPAN_DECLARE(int) v42bis_release(v42bis_state_t *s); | |
| 132 | |
| 133 /*! Free a V.42bis context. | |
| 134 \param s The V.42bis context. | |
| 135 \return 0 if OK */ | |
| 136 SPAN_DECLARE(int) v42bis_free(v42bis_state_t *s); | |
| 137 | |
| 138 #if defined(__cplusplus) | |
| 139 } | |
| 140 #endif | |
| 141 | |
| 142 #endif | |
| 143 /*- End of file ------------------------------------------------------------*/ |
