sipXtapi home page


SdpCodecList.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2007-2013 SIPez LLC. All rights reserved.
3 //
4 // Copyright (C) 2004-2008 SIPfoundry Inc.
5 // Licensed by SIPfoundry under the LGPL license.
6 //
7 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
8 // Licensed to SIPfoundry under a Contributor Agreement.
9 //
10 // $$
12 
13 #ifndef _SdpCodecList_h_
14 #define _SdpCodecList_h_
15 
16 // SYSTEM INCLUDES
17 // APPLICATION INCLUDES
18 #include <sdp/SdpCodec.h>
19 #include <utl/UtlDList.h>
20 #include <os/OsRWMutex.h>
21 
22 // DEFINES
23 // MACROS
24 // EXTERNAL FUNCTIONS
25 // EXTERNAL VARIABLES
26 // CONSTANTS
27 // STRUCTS
28 // TYPEDEFS
29 // FORWARD DECLARATIONS
30 
33 {
34 /* //////////////////////////// PUBLIC //////////////////////////////////// */
35 public:
36 
37 /* =============================== CREATORS =============================== */
39 
40 
42  SdpCodecList(int numCodecs = 0,
43  SdpCodec* codecArray[] = NULL);
44 
46  SdpCodecList(const SdpCodecList& rSdpCodecFactory);
47 
49  SdpCodecList& operator=(const SdpCodecList& rhs);
50 
52  virtual
53  ~SdpCodecList();
54 
56 
57 /* ============================= MANIPULATORS ============================= */
59 
60 
62  void addCodec(const SdpCodec& newCodec);
63 
65  void addCodecs(int numCodecs, SdpCodec* newCodecs[]);
66 
68  int addCodecs(const UtlString &codecList);
73  int addCodecs(UtlSList& codecNameList);
78  int addCodecs(int numTokens, const char* codecTokens[], int payloadIds[]);
80 
82  int addCodecs(int codecCount, SdpCodec::SdpCodecTypes codecTypes[]);
87  void bindPayloadTypes();
89 
91  int unbindPayloadType(int payloadId);
92  /*
93  * @param payloadId - no op if not a dynamic payload ID (> SDP_CODEC_MAXIMUM_STATIC_CODEC),
94  * codec payload ID to unbind (set to SDP_CODEC_UNKNOWN)
95  *
96  * @returns number of codecs unbound
97  */
98 
101  void copyPayloadType(const SdpCodec& codec);
102 
105  void copyPayloadTypes(int numCodecs, const SdpCodec* codecArray[]);
106 
109  void copyPayloadTypes(const SdpCodecList& codecList);
110 
112  void limitCodecs(const SdpCodecList& includeOnlyCodecList);
113 
115  void clearCodecs(void);
116 
118  void setCodecCPULimit(int iLimit);
127 
128 /* ============================== ACCESSORS =============================== */
130 
131 
133  const SdpCodec* getCodec(SdpCodec::SdpCodecTypes internalCodecId) const;
134 
136  const SdpCodec* getCodecByType(int payloadTypeId, UtlBoolean shouldLock = TRUE) const;
137 
139  const SdpCodec* getCodec(const char* MIMEType,
140  const char* MIMESubType,
141  int sampleRate,
142  int numChannels,
143  const UtlString &fmtp) const;
144 
146  int getCodecCount() const;
147 
149  int getCodecCount(const char* MIMEType) const;
150 
152  void getCodecs(int& numCodecs,
153  SdpCodec**& codecArray) const;
154 
157  void getCodecs(int& numCodecs,
158  SdpCodec**& codecArray,
159  const char* MIMEType) const;
160 
162  void getCodecs(int& numCodecs,
163  SdpCodec**& codecArray,
164  const char* MIMEType,
165  const char* subMimeType) const;
166 
168  static void freeArray(int arraySize, SdpCodec**& codecArray);
169  /*
170  * getCodecs allocates a codec pointer array and codecs. This frees them.
171  */
172 
174  void toString(UtlString& serializedFactory) const;
175 
177  int getCodecCPULimit() const;
178 
180 
181 /* =============================== INQUIRY ================================ */
183 
184 
186  UtlBoolean containsCodec(const SdpCodec& codec, UtlBoolean exeact = FALSE) const;
187 
189 
190 /* //////////////////////////// PROTECTED ///////////////////////////////// */
191 protected:
192 
193 /* //////////////////////////// PRIVATE /////////////////////////////////// */
194 private:
195 
197  void addCodecNoLock(const SdpCodec& newCodec);
198 
199  UtlDList mCodecs;
200  OsRWMutex mReadWriteMutex;
202 
203 };
204 
205 /* ============================ INLINE METHODS ============================ */
206 
207 #endif // _SdpCodecList_h_
SdpCodecTypes
Unique identifier used for each supported codec.
Definition: SdpCodec.h:133
virtual ~SdpCodecList()
Destructor.
Definition: SdpCodecList.cpp:58
int getCodecCount() const
Get the number of codecs.
Definition: SdpCodecList.cpp:657
void limitCodecs(const SdpCodecList &includeOnlyCodecList)
Remove any codecs in this list that are not equivalent to those in the given list.
Definition: SdpCodecList.cpp:401
const SdpCodec * getCodecByType(int payloadTypeId, UtlBoolean shouldLock=TRUE) const
Get a codec given the payload type id.
Definition: SdpCodecList.cpp:467
static void freeArray(int arraySize, SdpCodec **&codecArray)
Frees up codecs and codec pointer array.
Definition: SdpCodecList.cpp:785
OsRWMutex mReadWriteMutex
Definition: SdpCodecList.h:200
int mCodecCPULimit
Definition: SdpCodecList.h:201
List of codecs, used for storing supported codecs and for codec negotiation.
Definition: SdpCodecList.h:32
void clearCodecs(void)
Clear the list.
Definition: SdpCodecList.cpp:425
Container for SDP/RTP codec specification.
Definition: SdpCodec.h:123
void addCodecs(int numCodecs, SdpCodec *newCodecs[])
Add copies of the array of codecs.
Definition: SdpCodecList.cpp:93
void setCodecCPULimit(int iLimit)
Limits the advertised codec by CPU limit level.
Definition: SdpCodecList.cpp:432
void bindPayloadTypes()
Assign any unset payload type ids.
Definition: SdpCodecList.cpp:277
SdpCodecList(int numCodecs=0, SdpCodec *codecArray[]=NULL)
Constructor.
Definition: SdpCodecList.cpp:43
void toString(UtlString &serializedFactory) const
String representation of factory and codecs.
Definition: SdpCodecList.cpp:797
void copyPayloadTypes(int numCodecs, const SdpCodec *codecArray[])
For all matching codecs, copy the payload type from the codecArray to the matching codec in this fact...
Definition: SdpCodecList.cpp:381
UtlBoolean containsCodec(const SdpCodec &codec, UtlBoolean exeact=FALSE) const
Query if equivalent codec is in the list.
Definition: SdpCodecList.cpp:827
void copyPayloadType(const SdpCodec &codec)
If there is a matching codec in this factory, set its payload type to that of the given codec...
Definition: SdpCodecList.cpp:329
void getCodecs(int &numCodecs, SdpCodec **&codecArray) const
Get codecs from this list, taking into account maximum CPU cost.
Definition: SdpCodecList.cpp:701
int unbindPayloadType(int payloadId)
unbind any codec with the given dynamic payload type
Definition: SdpCodecList.cpp:311
SdpCodecList & operator=(const SdpCodecList &rhs)
Assignment operator.
Definition: SdpCodecList.cpp:66
void addCodec(const SdpCodec &newCodec)
Add a new codec type to the list of known codecs.
Definition: SdpCodecList.cpp:87
void addCodecNoLock(const SdpCodec &newCodec)
Add a new codec type to the list of known codecs (without locking).
Definition: SdpCodecList.cpp:860
int getCodecCPULimit() const
Gets the codec CPU limit level.
Definition: SdpCodecList.cpp:819
const SdpCodec * getCodec(SdpCodec::SdpCodecTypes internalCodecId) const
Get a codec given an internal codec id.
Definition: SdpCodecList.cpp:441
UtlDList mCodecs
Definition: SdpCodecList.h:199