|
reSIProcate/stack
9694
|
00001 #ifdef HAVE_CONFIG_H 00002 #include "config.h" 00003 #endif 00004 00005 #include "rutil/Logger.hxx" 00006 #include "rutil/Random.hxx" 00007 #include "resip/stack/Compression.hxx" 00008 00009 #ifdef USE_SIGCOMP 00010 #include <osc/StateHandler.h> 00011 #include <osc/Stack.h> 00012 #include <osc/DeflateCompressor.h> 00013 #endif 00014 00015 #define RESIPROCATE_SUBSYSTEM Subsystem::SIP 00016 00017 resip::Compression resip::Compression::Disabled(resip::Compression::NONE); 00018 00019 resip::Compression::Compression(resip::Compression::Algorithm algorithm, 00020 int stateMemorySize, 00021 int cyclesPerBit, 00022 int decompressionMemorySize, 00023 Data sigcompId) 00024 : mAlgorithm(algorithm), mStateHandler(0), mSigcompId(sigcompId) 00025 { 00026 #ifdef USE_SIGCOMP 00027 if (algorithm != NONE) 00028 { 00029 mStateHandler = new osc::StateHandler(stateMemorySize, 00030 cyclesPerBit, 00031 decompressionMemorySize); 00032 mStateHandler->useSipDictionary(); 00033 00034 if (sigcompId == Data::Empty) 00035 { 00036 mSigcompId = "<"; 00037 mSigcompId += Random::getVersion4UuidUrn(); 00038 mSigcompId += ">"; 00039 } 00040 } 00041 DebugLog (<< "Set SigcompId to " << mSigcompId); 00042 #else 00043 mAlgorithm = NONE; 00044 DebugLog (<< "COMPRESSION SUPPORT NOT COMPILED IN"); 00045 #endif 00046 DebugLog (<< "Compression configuration object created; algorithm = " 00047 << static_cast<int>(mAlgorithm) ); 00048 } 00049 00050 resip::Compression::~Compression() 00051 { 00052 #ifdef USE_SIGCOMP 00053 delete mStateHandler; 00054 #endif 00055 } 00056 00057 void 00058 resip::Compression::addCompressorsToStack(osc::Stack *stack) 00059 { 00060 #ifdef USE_SIGCOMP 00061 switch(getAlgorithm()) 00062 { 00063 case DEFLATE: 00064 DebugLog (<< "Adding Deflate Compressor"); 00065 stack->addCompressor(new osc::DeflateCompressor(getStateHandler())); 00066 break; 00067 00068 default: 00069 WarningLog (<< "Invalid compressor specified! Using deflate Compressor"); 00070 stack->addCompressor(new osc::DeflateCompressor(getStateHandler())); 00071 00072 case NONE: 00073 DebugLog (<< "Compression disabled: not adding any compressors"); 00074 break; 00075 00076 } 00077 #else 00078 DebugLog (<< "Compression not compiled in: not adding any compressors"); 00079 #endif 00080 } 00081 00082 /* ==================================================================== 00083 * The Vovida Software License, Version 1.0 00084 * 00085 * Copyright (c) 2002-2005 Vovida Networks, Inc. All rights reserved. 00086 * 00087 * Redistribution and use in source and binary forms, with or without 00088 * modification, are permitted provided that the following conditions 00089 * are met: 00090 * 00091 * 1. Redistributions of source code must retain the above copyright 00092 * notice, this list of conditions and the following disclaimer. 00093 * 00094 * 2. Redistributions in binary form must reproduce the above copyright 00095 * notice, this list of conditions and the following disclaimer in 00096 * the documentation and/or other materials provided with the 00097 * distribution. 00098 * 00099 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00100 * and "Vovida Open Communication Application Library (VOCAL)" must 00101 * not be used to endorse or promote products derived from this 00102 * software without prior written permission. For written 00103 * permission, please contact vocal@vovida.org. 00104 * 00105 * 4. Products derived from this software may not be called "VOCAL", nor 00106 * may "VOCAL" appear in their name, without prior written 00107 * permission of Vovida Networks, Inc. 00108 * 00109 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00110 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00111 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00112 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00113 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00114 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00115 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00116 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00117 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00118 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00119 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00120 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00121 * DAMAGE. 00122 * 00123 * ==================================================================== 00124 * 00125 * This software consists of voluntary contributions made by Vovida 00126 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00127 * Inc. For more information on Vovida Networks, Inc., please see 00128 * <http://www.vovida.org/>. 00129 * 00130 */
1.7.5.1