|
1 /* |
|
2 * Copyright (c) 2002-2003 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDES |
|
22 #include <rtpdef.h> |
|
23 |
|
24 #include "rtputil.h" |
|
25 #include "rtpsdes.h" |
|
26 |
|
27 // ================= MEMBER FUNCTIONS ======================= |
|
28 |
|
29 // --------------------------------------------------------------------------- |
|
30 // C++ default constructor can NOT contain any code, that |
|
31 // might leave. |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 CRtpSDES::CRtpSDES() |
|
35 { |
|
36 } |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // Symbian 2nd phase constructor can leave. |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 void CRtpSDES::ConstructL() |
|
43 { |
|
44 for ( TInt k = 0; k < ERTCP_NUM_OF_SDES_ITEMS; k++ ) |
|
45 { |
|
46 iSDESBuf[k] = HBufC8::NewL( KMaxSdesItemSize ); |
|
47 iSDESItems[k] = const_cast<TUint8*>( iSDESBuf[k]->Des().Ptr() ); |
|
48 Mem::FillZ( iSDESItems[k], KMaxSdesItemSize ); |
|
49 iSDESItemsSize[k] = 0; |
|
50 } |
|
51 |
|
52 iSndSSRCArray = new ( ELeave ) CArrayFixFlat<TRtpSSRC>( 4 ); |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // Two-phased constructor. |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 CRtpSDES* CRtpSDES::NewL() |
|
60 { |
|
61 CRtpSDES* self = new ( ELeave ) CRtpSDES(); |
|
62 CleanupStack::PushL( self ); |
|
63 self->ConstructL(); |
|
64 CleanupStack::Pop(); // self |
|
65 return self; |
|
66 } |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // Two-phased constructor. |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 CRtpSDES* CRtpSDES::NewL( const TRtpSdesParams& aSDES ) |
|
73 { |
|
74 CRtpSDES* self = new ( ELeave ) CRtpSDES(); |
|
75 CleanupStack::PushL( self ); |
|
76 self->ConstructL(); |
|
77 self->SetSDES( aSDES ); |
|
78 CleanupStack::Pop(); // self |
|
79 return self; |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // Destructor |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 CRtpSDES::~CRtpSDES() |
|
87 { |
|
88 for ( TInt k = 0; k < ERTCP_NUM_OF_SDES_ITEMS; k++ ) |
|
89 { |
|
90 delete iSDESBuf[k]; |
|
91 iSDESItemsSize[k] = 0; |
|
92 } |
|
93 if (iSndSSRCArray) |
|
94 { |
|
95 iSndSSRCArray->Reset(); |
|
96 delete iSndSSRCArray; |
|
97 } |
|
98 } |
|
99 |
|
100 // --------------------------------------------------------------------------- |
|
101 // CRtpSDES::SetSDES() |
|
102 // |
|
103 // --------------------------------------------------------------------------- |
|
104 // |
|
105 void CRtpSDES::SetSDES( const TRtpSdesParams& aSDES ) |
|
106 { |
|
107 |
|
108 iSDESItemsSize[ERTCP_SDES_CNAME] = ( aSDES.iCName ).Length(); |
|
109 Mem::Copy( iSDESItems[ERTCP_SDES_CNAME], ( aSDES.iCName ).Ptr(), |
|
110 iSDESItemsSize[ERTCP_SDES_CNAME] ); |
|
111 *( iSDESItems[ERTCP_SDES_CNAME] + iSDESItemsSize[ERTCP_SDES_CNAME] ) = '\0'; |
|
112 |
|
113 iSDESItemsSize[ERTCP_SDES_NAME] = ( aSDES.iUserName ).Length(); |
|
114 Mem::Copy( iSDESItems[ERTCP_SDES_NAME], ( aSDES.iUserName ).Ptr(), |
|
115 iSDESItemsSize[ERTCP_SDES_NAME] ); |
|
116 *( iSDESItems[ERTCP_SDES_NAME] + iSDESItemsSize[ERTCP_SDES_NAME] ) = '\0'; |
|
117 |
|
118 iSDESItemsSize[ERTCP_SDES_EMAIL] = ( aSDES.iEmail ).Length(); |
|
119 Mem::Copy( iSDESItems[ERTCP_SDES_EMAIL], ( aSDES.iEmail ).Ptr(), |
|
120 iSDESItemsSize[ERTCP_SDES_EMAIL] ); |
|
121 *( iSDESItems[ERTCP_SDES_EMAIL] + iSDESItemsSize[ERTCP_SDES_EMAIL] ) = '\0'; |
|
122 |
|
123 iSDESItemsSize[ERTCP_SDES_PHONE] = ( aSDES.iPhoneNumber ).Length(); |
|
124 Mem::Copy( iSDESItems[ERTCP_SDES_PHONE], ( aSDES.iPhoneNumber ).Ptr(), |
|
125 iSDESItemsSize[ERTCP_SDES_PHONE] ); |
|
126 *( iSDESItems[ERTCP_SDES_PHONE] + iSDESItemsSize[ERTCP_SDES_PHONE] ) = '\0'; |
|
127 |
|
128 iSDESItemsSize[ERTCP_SDES_LOC] = ( aSDES.iLocation ).Length(); |
|
129 Mem::Copy( iSDESItems[ERTCP_SDES_LOC], ( aSDES.iLocation ).Ptr(), |
|
130 iSDESItemsSize[ERTCP_SDES_LOC] ); |
|
131 *( iSDESItems[ERTCP_SDES_LOC] + iSDESItemsSize[ERTCP_SDES_LOC] ) = '\0'; |
|
132 |
|
133 iSDESItemsSize[ERTCP_SDES_TOOL] = ( aSDES.iSwToolName ).Length(); |
|
134 Mem::Copy( iSDESItems[ERTCP_SDES_TOOL], ( aSDES.iSwToolName ).Ptr(), |
|
135 iSDESItemsSize[ERTCP_SDES_TOOL] ); |
|
136 *( iSDESItems[ERTCP_SDES_TOOL] + iSDESItemsSize[ERTCP_SDES_TOOL] ) = '\0'; |
|
137 |
|
138 iSDESItemsSize[ERTCP_SDES_NOTE] = ( aSDES.iNoticeStatus ).Length(); |
|
139 Mem::Copy( iSDESItems[ERTCP_SDES_NOTE], ( aSDES.iNoticeStatus ).Ptr(), |
|
140 iSDESItemsSize[ERTCP_SDES_NOTE] ); |
|
141 *( iSDESItems[ERTCP_SDES_NOTE] + iSDESItemsSize[ERTCP_SDES_NOTE] ) = '\0'; |
|
142 |
|
143 iSDESItemsSize[ERTCP_SDES_PRIV] = ( aSDES.iPrivate ).Length(); |
|
144 Mem::Copy( iSDESItems[ERTCP_SDES_PRIV], ( aSDES.iPrivate ).Ptr(), |
|
145 iSDESItemsSize[ERTCP_SDES_PRIV] ); |
|
146 *( iSDESItems[ERTCP_SDES_PRIV] + iSDESItemsSize[ERTCP_SDES_PRIV] ) = '\0'; |
|
147 |
|
148 } |
|
149 |
|
150 |
|
151 // --------------------------------------------------------------------------- |
|
152 // CRtpSDES::GetSDES() |
|
153 // |
|
154 // --------------------------------------------------------------------------- |
|
155 // |
|
156 void CRtpSDES::GetSDES( TRtpSdesParams& aSDES ) |
|
157 { |
|
158 ( aSDES.iCName ).Set( iSDESItems[ERTCP_SDES_CNAME], |
|
159 iSDESItemsSize[ERTCP_SDES_CNAME] ); |
|
160 |
|
161 ( aSDES.iUserName ).Set( iSDESItems[ERTCP_SDES_NAME], |
|
162 iSDESItemsSize[ERTCP_SDES_NAME] ); |
|
163 |
|
164 ( aSDES.iEmail ).Set( iSDESItems[ERTCP_SDES_EMAIL], |
|
165 iSDESItemsSize[ERTCP_SDES_EMAIL] ); |
|
166 |
|
167 ( aSDES.iPhoneNumber).Set( iSDESItems[ERTCP_SDES_PHONE], |
|
168 iSDESItemsSize[ERTCP_SDES_PHONE] ); |
|
169 |
|
170 ( aSDES.iLocation ).Set( iSDESItems[ERTCP_SDES_LOC], |
|
171 iSDESItemsSize[ERTCP_SDES_LOC] ); |
|
172 |
|
173 ( aSDES.iSwToolName ).Set( iSDESItems[ERTCP_SDES_TOOL], |
|
174 iSDESItemsSize[ERTCP_SDES_TOOL] ); |
|
175 |
|
176 ( aSDES.iNoticeStatus ).Set( iSDESItems[ERTCP_SDES_NOTE], iSDESItemsSize[ERTCP_SDES_NOTE] ); |
|
177 |
|
178 ( aSDES.iPrivate ).Set( iSDESItems[ERTCP_SDES_PRIV], iSDESItemsSize[ERTCP_SDES_PRIV] ); |
|
179 } |
|
180 |
|
181 // --------------------------------------------------------------------------- |
|
182 // CRtpSDES::AddSsrcToSdesL() |
|
183 // |
|
184 // --------------------------------------------------------------------------- |
|
185 // |
|
186 void CRtpSDES::AddSsrcToSdesL( const TRtpSSRC aSSRC ) |
|
187 { |
|
188 TInt index = 0; |
|
189 TBool fFoundSSRC = EFalse; |
|
190 TInt totalSSRC = iSndSSRCArray->Count(); |
|
191 |
|
192 if ( totalSSRC > 0 ) |
|
193 { |
|
194 for ( index = 0; index < totalSSRC; index++ ) |
|
195 { |
|
196 if ( iSndSSRCArray->At( index ) == aSSRC ) |
|
197 { |
|
198 fFoundSSRC = ETrue; |
|
199 } |
|
200 } |
|
201 if ( !fFoundSSRC ) |
|
202 { |
|
203 iSndSSRCArray->AppendL( aSSRC ); |
|
204 } |
|
205 } |
|
206 else //first SSRC, added to array |
|
207 { |
|
208 iSndSSRCArray->AppendL( aSSRC ); |
|
209 } |
|
210 } |
|
211 |
|
212 // --------------------------------------------------------------------------- |
|
213 // TBool CRtpSDES::GetSdesSsrc() |
|
214 // |
|
215 // --------------------------------------------------------------------------- |
|
216 // |
|
217 TBool CRtpSDES::GetSdesSsrc( TRtpSSRC aSSRC ) |
|
218 { |
|
219 TInt totalSSRC = iSndSSRCArray->Count(); |
|
220 |
|
221 for ( TInt index = 0; index < totalSSRC; index++ ) |
|
222 { |
|
223 if ( iSndSSRCArray->At( index ) == aSSRC ) |
|
224 { |
|
225 return ETrue; |
|
226 } |
|
227 } |
|
228 return EFalse; |
|
229 } |
|
230 |
|
231 |
|
232 // End of File |