|
1 /* |
|
2 * Copyright (c) 2006 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 |
|
22 #ifndef CMESDPCODEC_H |
|
23 #define CMESDPCODEC_H |
|
24 |
|
25 // INCLUDES |
|
26 #include <e32base.h> |
|
27 #include <stringpool.h> |
|
28 #include <sdpattributefield.h> |
|
29 #include <sdpbandwidthfield.h> |
|
30 #include "mcesip.h" |
|
31 #include "mcemmlogs.h" |
|
32 |
|
33 // FORWARD DECLARATIONS |
|
34 class CSdpDocument; |
|
35 class CSdpMediaField; |
|
36 class CMceComSession; |
|
37 class CMceComMediaStream; |
|
38 class CSdpMediaField; |
|
39 class CSdpFmtAttributeField; |
|
40 |
|
41 |
|
42 |
|
43 #define SDP_STRING( stringIndex )\ |
|
44 iStringPool.StringF( stringIndex, *iStringTable ) |
|
45 |
|
46 |
|
47 |
|
48 /** |
|
49 * Class for encoding and decoding media lines and creating server streams |
|
50 * |
|
51 */ |
|
52 class CMceSdpCodec : public CBase |
|
53 { |
|
54 |
|
55 public: |
|
56 |
|
57 /** |
|
58 * destructor |
|
59 */ |
|
60 ~CMceSdpCodec(); |
|
61 |
|
62 /** |
|
63 * returns media(line) which is supported by this SDP codec |
|
64 * @return media(line) which is supported by this SDP codec |
|
65 */ |
|
66 RStringF Media(); |
|
67 |
|
68 /** |
|
69 * returns ETrue, if media is decoded by this codec |
|
70 * @return ETrue, if media is decoded by this codec |
|
71 */ |
|
72 virtual TBool Decodes( const CSdpMediaField& aMedia ) const; |
|
73 |
|
74 /** |
|
75 * Adds capability |
|
76 * @param aCapability capability |
|
77 */ |
|
78 void AddCapabilityL( const TDesC8& aCapability ); |
|
79 |
|
80 /** |
|
81 * Adds capability payload type |
|
82 * @param aPayloadType capability payload type |
|
83 */ |
|
84 void AddCapabilityPayloadTypeL( const TUint aPayloadType ); |
|
85 |
|
86 /** |
|
87 * Returns ETrue, if capability is supported |
|
88 * @param aCapability capability |
|
89 * @return ETrue, if capability is supported |
|
90 */ |
|
91 TBool IsSupported( const TDesC8& aCapability ) const; |
|
92 |
|
93 /** |
|
94 * Returns ETrue, if payload is supported |
|
95 * @param aSdpName SDP name |
|
96 * @param aPayload payload of codec |
|
97 * @return ETrue, if payload is supported |
|
98 */ |
|
99 TBool IsPayloadTypeSupported( const TDesC8& aCapability, const TUint aPayloadType ) const; |
|
100 |
|
101 public: //abstract interface |
|
102 |
|
103 /** |
|
104 * Returns ETrue, if media is encoded by this codec |
|
105 * @return ETrue, if media is encoded by this codec |
|
106 */ |
|
107 virtual TBool Encodes( const CMceComMediaStream& aStream ) const = 0; |
|
108 |
|
109 /** |
|
110 * Encodes a media line. |
|
111 * @param aStream media stream |
|
112 * @param aMediaLine media line |
|
113 * @param aSdpDocument sdp document |
|
114 * @leave system wide error |
|
115 */ |
|
116 virtual void EncodeMediaOfferL( CMceComMediaStream& aStream, |
|
117 CSdpMediaField& aMediaLine, |
|
118 CSdpDocument& aSdpDocument ) = 0; |
|
119 |
|
120 /** |
|
121 * Decodes the media answer. |
|
122 * @param aStream media stream |
|
123 * @param aSdpDocument sdp document |
|
124 * @return warning if any |
|
125 * @leave system wide error |
|
126 */ |
|
127 virtual TMceSipWarningCode DecodeMediaAnswerL( CSdpMediaField& aMediaLine, |
|
128 CMceComMediaStream& aStream, |
|
129 CSdpDocument& aSdpDocument ) = 0; |
|
130 |
|
131 /** |
|
132 * Decodes media offer and creates media stream. The stream is appended |
|
133 * into the media session, if aStream is NULL |
|
134 * @param aMediaLine media line |
|
135 * @param aStream stream added to session |
|
136 * @param aSession media session |
|
137 * @param aSdpDocument sdp document |
|
138 * @param aStream stream to updated, if any |
|
139 * @return warning if any |
|
140 * @leave system wide error |
|
141 */ |
|
142 virtual TMceSipWarningCode DecodeMediaOfferL( CSdpMediaField& aMediaLine, |
|
143 CMceComMediaStream*& aStream, |
|
144 CMceComSession& aSession, |
|
145 CSdpDocument& aSdpDocument ) = 0; |
|
146 |
|
147 /** |
|
148 * Decodes media update by updating media stream |
|
149 * @param aMediaLine media line |
|
150 * @param aStream stream to be updated |
|
151 * @param aSdpDocument sdp document |
|
152 * @return warning if any |
|
153 * @leave system wide error |
|
154 */ |
|
155 virtual TMceSipWarningCode DecodeMediaUpdateL( CSdpMediaField& aMediaLine, |
|
156 CMceComMediaStream& aStream, |
|
157 CSdpDocument& aSdpDocument ) = 0; |
|
158 |
|
159 |
|
160 /** |
|
161 * Creates a encoded media line based on the offer received earlier. |
|
162 * @param aStream media stream |
|
163 * @param aMediaLine media line |
|
164 * @param aSdpDocument sdp document |
|
165 * @leave system wide error |
|
166 */ |
|
167 virtual void EncodeMediaAnswerL( CMceComMediaStream& aStream, |
|
168 CSdpMediaField& aMediaLine, |
|
169 CSdpDocument& aSdpDocument ) = 0; |
|
170 |
|
171 /** |
|
172 * Prepares media line before offer/answer will be decoded |
|
173 * @param aMediaLine media line |
|
174 * @param aStream media stream |
|
175 * @leave system wide error |
|
176 */ |
|
177 virtual void PrepareForDecodeL( CSdpMediaField& aMediaLine, |
|
178 CMceComMediaStream* aStream ) = 0; |
|
179 |
|
180 /** |
|
181 * Clean attributes |
|
182 * @param aMedia Media line |
|
183 */ |
|
184 virtual void CleanAttributes( CSdpMediaField& aMedia ) = 0; |
|
185 |
|
186 |
|
187 public: //interface cont |
|
188 |
|
189 |
|
190 /** |
|
191 * Prepares media line before offer/re-offer will be encoded |
|
192 * @param aStream media stream |
|
193 * @param aMediaLine media line |
|
194 * @leave system wide error |
|
195 */ |
|
196 virtual void PrepareForEncodeL( CMceComMediaStream& aStream, |
|
197 CSdpMediaField& aMediaLine ); |
|
198 |
|
199 |
|
200 |
|
201 public: //common static like API |
|
202 |
|
203 /** |
|
204 * Encodes rtpmap field |
|
205 * @param aPayloadType payload type |
|
206 * @param aEncodingName encoding name |
|
207 * @param aClockRate clock rate |
|
208 * @param aEncodingParam optional encoding paramteter |
|
209 * @return rtpmap |
|
210 * @leave system wide error |
|
211 */ |
|
212 CSdpFmtAttributeField* EncodeRtpMapFieldsL( const TUint8 aPayloadType, |
|
213 const TDesC8& aEncodingName, |
|
214 const TUint aClockRate, |
|
215 const TDesC8& aEncodingParam ) const; |
|
216 |
|
217 /** |
|
218 * Gets the direction attribute |
|
219 * @param aMedia media line |
|
220 * @param aSessionAttributes session attributes |
|
221 * @return Direction attribute. |
|
222 */ |
|
223 TInt Direction( CSdpMediaField& aMedia, |
|
224 RPointerArray<CSdpAttributeField>& aSessionAttributes ) const; |
|
225 |
|
226 |
|
227 |
|
228 /** |
|
229 * Finds attribute from media line |
|
230 * @param aAttribute the attribute as string pool index |
|
231 * @param aMediaLine sdp document |
|
232 * @return attribute or NULL |
|
233 */ |
|
234 CSdpAttributeField* FindAttribute( TInt aAttribute, |
|
235 CSdpMediaField& aMediaLine ) const; |
|
236 |
|
237 /** |
|
238 * Converts Descriptor into TUint |
|
239 * @param aConv descriptor |
|
240 * @return converted value. |
|
241 */ |
|
242 static TUint ConvertDesToUintL( const TDesC8& aConv ); |
|
243 |
|
244 /** |
|
245 * Converts Descriptor into TInt |
|
246 * @param aConv descriptor |
|
247 * @return converted value. |
|
248 */ |
|
249 static TInt ConvertDesToIntL( const TDesC8& aConv ); |
|
250 |
|
251 /** |
|
252 * Converts TReal to HBuf |
|
253 * @param aConv descriptor |
|
254 * @return converted value. |
|
255 */ |
|
256 static HBufC8* ConvertTRealToDesLC( const TReal& aConv ); |
|
257 |
|
258 /** |
|
259 * Converts Descriptor into TReal |
|
260 * @param aConv descriptor |
|
261 * @return converted value. |
|
262 */ |
|
263 static TReal ConvertDesToRealL( const TDesC8& aConv ); |
|
264 |
|
265 |
|
266 /** |
|
267 * Encodes media sdp fields client is willing to insert |
|
268 * @param aClientSdp sdp fields |
|
269 * @param aContainer media line / sdp document |
|
270 */ |
|
271 template <class T> |
|
272 static void EncodeClientSdpFieldsL( const CDesC8Array& aClientSdp, |
|
273 T& aContainer ) |
|
274 { |
|
275 MCEMM_DEBUG("CMceSdpCodec::EncodeClientSdpFieldsL, Entry" ); |
|
276 |
|
277 for ( TInt i = 0; i < aClientSdp.Count(); i++ ) |
|
278 { |
|
279 MCEMM_DEBUG_SVALUE("adding", aClientSdp.MdcaPoint( i ) ); |
|
280 TPtrC8 sdpFieldLine = aClientSdp.MdcaPoint( i ); |
|
281 if ( sdpFieldLine.Find( KMceSdpAttributeLineMarker ) == 0 ) |
|
282 { |
|
283 CSdpAttributeField* attribute = |
|
284 CSdpAttributeField::DecodeLC( sdpFieldLine ); |
|
285 aContainer.AttributeFields().AppendL( attribute ); |
|
286 CleanupStack::Pop( attribute ); |
|
287 } |
|
288 else if ( sdpFieldLine.Find( KMceSdpBandwidthLineMarker ) == 0 ) |
|
289 { |
|
290 CSdpBandwidthField* bandwidth = |
|
291 CSdpBandwidthField::DecodeLC( sdpFieldLine ); |
|
292 aContainer.BandwidthFields().AppendL( bandwidth ); |
|
293 CleanupStack::Pop( bandwidth ); |
|
294 } |
|
295 else |
|
296 { |
|
297 User::Leave( KErrNotSupported ); |
|
298 } |
|
299 } |
|
300 MCEMM_DEBUG("CMceSdpCodec::EncodeClientSdpFieldsL, Exit" ); |
|
301 } |
|
302 |
|
303 |
|
304 protected: |
|
305 |
|
306 |
|
307 CMceSdpCodec( RStringF aMedia ); |
|
308 void ConstructL(); |
|
309 |
|
310 protected://data |
|
311 |
|
312 RStringPool iStringPool; |
|
313 const TStringTable* iStringTable; |
|
314 |
|
315 private: |
|
316 |
|
317 RStringF iMedia; |
|
318 CDesC8Array* iCapabilities; |
|
319 RArray<TUint> iCapabilitiesPT; |
|
320 |
|
321 |
|
322 friend class UT_CMceSdpCodec; |
|
323 friend class UT_CMceMediaManager; |
|
324 friend class UT_CMceSdpSession; |
|
325 |
|
326 |
|
327 }; |
|
328 |
|
329 #endif // CMESDPCODEC_H |
|
330 |
|
331 // End of File |