sipxmedialib  Version 3.3
MprDecodeSelectCodecsMsg.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2008-2013 SIPez LLC. All rights reserved.
3 //
4 // Copyright (C) 2008 SIPfoundry Inc.
5 // Licensed by SIPfoundry under the LGPL license.
6 //
7 // $$
9 
10 #ifndef _MprDecodeSelectCodecsMsg_h_
11 #define _MprDecodeSelectCodecsMsg_h_
12 
13 // SYSTEM INCLUDES
14 
15 // APPLICATION INCLUDES
16 #include "os/OsMsg.h"
17 #include "mp/MpResourceMsg.h"
18 
19 // DEFINES
20 // MACROS
21 // EXTERNAL FUNCTIONS
22 // EXTERNAL VARIABLES
23 // CONSTANTS
24 // STRUCTS
25 // TYPEDEFS
26 // FORWARD DECLARATIONS
27 
30 {
31 /* //////////////////////////// PUBLIC //////////////////////////////////// */
32 public:
33 
34 /* ============================ CREATORS ================================== */
36 
37 
39  MprDecodeSelectCodecsMsg(const UtlString& targetResourceName,
40  SdpCodec* codecs[],
41  int numCodecs)
42  : MpResourceMsg(MPRM_DECODE_SELECT_CODECS, targetResourceName)
43  , mpCodecs(NULL)
44  , mNumCodecs(0)
45  {
46  //UtlString codecMediaType;
47 
48  // Allocate new array
49  mpCodecs = new SdpCodec*[numCodecs];
50 
51  // Copy all audio codecs to new array
52  for (int i=0; i<numCodecs; i++)
53  {
54  if (codecs[i] != NULL)
55  {
56  mpCodecs[mNumCodecs] = new SdpCodec(*codecs[i]);
57  mNumCodecs++;
58  }
59  else
60  {
61  mpCodecs[mNumCodecs] = NULL;
62  mNumCodecs++;
63  }
64  }
65  };
66 
69  {
70  clearCodecs();
71  };
72 
75  : MpResourceMsg(resourceMsg)
76  , mpCodecs(NULL)
77  , mNumCodecs(0)
78  {
79  copyCodecs(resourceMsg.mpCodecs, resourceMsg.mNumCodecs);
80  };
81 
83  OsMsg* createCopy(void) const
84  {
85  return new MprDecodeSelectCodecsMsg(*this);
86  }
87 
89 
90 /* ============================ MANIPULATORS ============================== */
92 
93 
96  {
97  if(&rhs == this)
98  {
99  return(*this);
100  }
101 
103  clearCodecs();
104  copyCodecs(rhs.mpCodecs, rhs.mNumCodecs);
105 
106  return *this;
107  }
108 
110 /* ============================ ACCESSORS ================================= */
112 
113 
114  int getNumCodecs() const
115  {
116  return mNumCodecs;
117  }
118 
119  SdpCodec** getCodecs() const
120  {
121  return mpCodecs;
122  }
123 
125 
126 /* ============================ INQUIRY =================================== */
128 
129 
131 
132 /* //////////////////////////// PROTECTED ///////////////////////////////// */
133 protected:
134 
135 /* //////////////////////////// PRIVATE /////////////////////////////////// */
136 private:
137  SdpCodec** mpCodecs;
139 
140  void clearCodecs()
141  {
142  for (int i=0; i<mNumCodecs; i++)
143  {
144  delete mpCodecs[i];
145  }
146  delete[] mpCodecs;
147  }
148 
149  void copyCodecs(SdpCodec* pCodecs[],
150  int numCodecs)
151  {
152  // Allocate new array
153  mpCodecs = new SdpCodec*[numCodecs];
154 
155  // Copy all audio codecs to new array
156  for (int i=0; i<numCodecs; i++) {
157  if (pCodecs[i] != NULL)
158  {
159  mpCodecs[mNumCodecs] = new SdpCodec(*pCodecs[i]);
160  }
161  else
162  {
163  mpCodecs[mNumCodecs] = NULL;
164  }
165  mNumCodecs++;
166  }
167  }
168 };
169 
170 /* ============================ INLINE METHODS ============================ */
171 
172 #endif // _MprDecodeSelectCodecsMsg_h_
MpResourceMsg & operator=(const MpResourceMsg &rhs)
Assignment operator.
Definition: MpResourceMsg.cpp:60
Message object used to communicate with the media processing task.
Definition: MprDecodeSelectCodecsMsg.h:29
Message object used to communicate with the media processing task.
Definition: MpResourceMsg.h:30
void clearCodecs()
Definition: MprDecodeSelectCodecsMsg.h:140
MprDecode/MprEncode: Select codecs.
Definition: MpResourceMsg.h:48
int mNumCodecs
Definition: MprDecodeSelectCodecsMsg.h:138
SdpCodec ** mpCodecs
Definition: MprDecodeSelectCodecsMsg.h:137
MprDecodeSelectCodecsMsg & operator=(const MprDecodeSelectCodecsMsg &rhs)
Assignment operator.
Definition: MprDecodeSelectCodecsMsg.h:95
~MprDecodeSelectCodecsMsg()
Destructor.
Definition: MprDecodeSelectCodecsMsg.h:68
SdpCodec ** getCodecs() const
Definition: MprDecodeSelectCodecsMsg.h:119
int getNumCodecs() const
Definition: MprDecodeSelectCodecsMsg.h:114
OsMsg * createCopy(void) const
Create a copy of this msg object (which may be of a derived type)
Definition: MprDecodeSelectCodecsMsg.h:83
MprDecodeSelectCodecsMsg(const UtlString &targetResourceName, SdpCodec *codecs[], int numCodecs)
Constructor.
Definition: MprDecodeSelectCodecsMsg.h:39
MprDecodeSelectCodecsMsg(const MprDecodeSelectCodecsMsg &resourceMsg)
Copy constructor.
Definition: MprDecodeSelectCodecsMsg.h:74
void copyCodecs(SdpCodec *pCodecs[], int numCodecs)
Definition: MprDecodeSelectCodecsMsg.h:149