reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
MediaResourceCache.hxx
Go to the documentation of this file.
1#if !defined(MediaResourceCache_hxx)
2#define MediaResourceCache_hxx
3
4#include <map>
5#include <rutil/Mutex.hxx>
6
7namespace recon
8{
9
18{
19 public:
21 virtual ~MediaResourceCache();
22 void addToCache(const resip::Data& name, const resip::Data& buffer, int type);
23 bool getFromCache(const resip::Data& name, resip::Data** buffer, int* type);
24
25 private:
26 class CacheItem
27 {
28 public:
29 CacheItem(const resip::Data& buffer, int type) :
30 mBuffer(buffer), mType(type) {}
31 resip::Data mBuffer;
32 int mType;
33 };
34
35 typedef std::map<resip::Data,CacheItem*> CacheMap;
36 CacheMap mCacheMap;
37 resip::Mutex mMutex;
38};
39
40}
41
42#endif
43
44
45/* ====================================================================
46
47 Copyright (c) 2021, SIP Spectrum, Inc. www.sipspectrum.com
48 Copyright (c) 2021, Daniel Pocock https://danielpocock.com
49 Copyright (c) 2007-2008, Plantronics, Inc.
50 All rights reserved.
51
52 Redistribution and use in source and binary forms, with or without
53 modification, are permitted provided that the following conditions are
54 met:
55
56 1. Redistributions of source code must retain the above copyright
57 notice, this list of conditions and the following disclaimer.
58
59 2. Redistributions in binary form must reproduce the above copyright
60 notice, this list of conditions and the following disclaimer in the
61 documentation and/or other materials provided with the distribution.
62
63 3. Neither the name of Plantronics nor the names of its contributors
64 may be used to endorse or promote products derived from this
65 software without specific prior written permission.
66
67 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
68 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
69 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
70 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
71 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
72 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
73 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
74 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
75 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
76 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
77 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
78
79 ==================================================================== */
This class is responsible for caching media resource buffers.
bool getFromCache(const resip::Data &name, resip::Data **buffer, int *type)
void addToCache(const resip::Data &name, const resip::Data &buffer, int type)
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
std::mutex Mutex
A semaphore that can be locked by only one thread at a time.
Definition Mutex.hxx:37