reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
Compression.cxx
Go to the documentation of this file.
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#endif
4
5#include "rutil/Logger.hxx"
6#include "rutil/Random.hxx"
8
9#ifdef USE_SIGCOMP
10#include <osc/StateHandler.h>
11#include <osc/Stack.h>
12#include <osc/DeflateCompressor.h>
13#endif
14
15#define RESIPROCATE_SUBSYSTEM Subsystem::SIP
16
18
21 int cyclesPerBit,
23 Data sigcompId)
24 : mAlgorithm(algorithm), mStateHandler(0), mSigcompId(sigcompId)
25{
26#ifdef USE_SIGCOMP
27 if (algorithm != NONE)
28 {
29 mStateHandler = new osc::StateHandler(stateMemorySize,
30 cyclesPerBit,
31 decompressionMemorySize);
32 mStateHandler->useSipDictionary();
33
34 if (sigcompId == Data::Empty)
35 {
36 mSigcompId = "<";
37 mSigcompId += Random::getVersion4UuidUrn();
38 mSigcompId += ">";
39 }
40 }
41 DebugLog (<< "Set SigcompId to " << mSigcompId);
42#else
43 mAlgorithm = NONE;
44 DebugLog (<< "COMPRESSION SUPPORT NOT COMPILED IN");
45#endif
46 DebugLog (<< "Compression configuration object created; algorithm = "
47 << static_cast<int>(mAlgorithm) );
48}
49
51{
52#ifdef USE_SIGCOMP
53 delete mStateHandler;
54#endif
55}
56
57void
59{
60#ifdef USE_SIGCOMP
61 switch(getAlgorithm())
62 {
63 case DEFLATE:
64 DebugLog (<< "Adding Deflate Compressor");
65 stack->addCompressor(new osc::DeflateCompressor(getStateHandler()));
66 break;
67
68 default:
69 WarningLog (<< "Invalid compressor specified! Using deflate Compressor");
70 stack->addCompressor(new osc::DeflateCompressor(getStateHandler()));
71
72 case NONE:
73 DebugLog (<< "Compression disabled: not adding any compressors");
74 break;
75
76 }
77#else
78 DebugLog (<< "Compression not compiled in: not adding any compressors");
79#endif
80}
81
82/* ====================================================================
83* The Vovida Software License, Version 1.0
84*
85* Copyright (c) 2002-2005 Vovida Networks, Inc. All rights reserved.
86*
87* Redistribution and use in source and binary forms, with or without
88* modification, are permitted provided that the following conditions
89* are met:
90*
91* 1. Redistributions of source code must retain the above copyright
92* notice, this list of conditions and the following disclaimer.
93*
94* 2. Redistributions in binary form must reproduce the above copyright
95* notice, this list of conditions and the following disclaimer in
96* the documentation and/or other materials provided with the
97* distribution.
98*
99* 3. The names "VOCAL", "Vovida Open Communication Application Library",
100* and "Vovida Open Communication Application Library (VOCAL)" must
101* not be used to endorse or promote products derived from this
102* software without prior written permission. For written
103* permission, please contact vocal@vovida.org.
104*
105* 4. Products derived from this software may not be called "VOCAL", nor
106* may "VOCAL" appear in their name, without prior written
107* permission of Vovida Networks, Inc.
108*
109* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
110* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
111* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
112* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
113* NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
114* IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
115* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
116* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
117* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
118* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
119* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
120* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
121* DAMAGE.
122*
123* ====================================================================
124*
125* This software consists of voluntary contributions made by Vovida
126* Networks, Inc. and many individuals on behalf of Vovida Networks,
127* Inc. For more information on Vovida Networks, Inc., please see
128* <http://www.vovida.org/>.
129*
130*/
#define DebugLog(args_)
Definition Logger.hxx:128
#define WarningLog(args_)
Definition Logger.hxx:134
static Compression Disabled
Represents a compression configuration object with compression disabled.
void addCompressorsToStack(osc::Stack *)
Compression(Algorithm algorithm=DEFLATE, int stateMemorySize=8192, int cyclesPerBit=64, int decompressionMemorySize=8192, Data sigcompId=Data::Empty)
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
static const Data Empty
Constant that represents a zero-length data.
Definition Data.hxx:882
static Data getVersion4UuidUrn()
Returns a version 4 (random) UUID as defined in RFC 4122.
Definition Random.cxx:436
void list()
Definition userAdmin.cxx:66