/[resiprocate]/main/resip/stack/Compression.cxx
ViewVC logotype

Contents of /main/resip/stack/Compression.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9493 - (show annotations) (download)
Sat Apr 7 10:56:50 2012 UTC (7 years, 9 months ago) by dpocock
File MIME type: text/plain
File size: 4467 byte(s)
Include config.h from even more places where it may be needed
1 #ifdef HAVE_CONFIG_H
2 #include "config.h"
3 #endif
4
5 #include "rutil/Logger.hxx"
6 #include "rutil/Random.hxx"
7 #include "resip/stack/Compression.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
17 resip::Compression resip::Compression::Disabled(resip::Compression::NONE);
18
19 resip::Compression::Compression(resip::Compression::Algorithm algorithm,
20 int stateMemorySize,
21 int cyclesPerBit,
22 int decompressionMemorySize,
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
50 resip::Compression::~Compression()
51 {
52 #ifdef USE_SIGCOMP
53 delete mStateHandler;
54 #endif
55 }
56
57 void
58 resip::Compression::addCompressorsToStack(osc::Stack *stack)
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 */

Properties

Name Value
svn:eol-style native
svn:mime-type text/plain

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27