|
1 /* |
|
2 * Copyright (c) 2005 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 #include "mcecommessagecodec.h" |
|
22 #include "mcemsrpcodec.h" |
|
23 |
|
24 #include "mceserial.h" |
|
25 #include "mceevents.h" |
|
26 |
|
27 #include "mcecomrtpsource.h" |
|
28 #include "mcertpsource.h" |
|
29 #include "mcecommsrpsource.h" |
|
30 |
|
31 #ifdef MCE_COMMON_SERVER_SIDE |
|
32 |
|
33 #include <MmccCodecInformation.h> |
|
34 #include "mcesrvstream.h" |
|
35 #include "mcesrvsource.h" |
|
36 #include "mcemsrpsource.h" |
|
37 #include "mcecommsrpsource.h" |
|
38 #include "mcemsrpsink.h" |
|
39 #include "mcecommsrpsink.h" |
|
40 |
|
41 #endif//MCE_COMMON_SERVER_SIDE |
|
42 |
|
43 |
|
44 // ============================ MEMBER FUNCTIONS =============================== |
|
45 |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CMceComMessageCodec::NewL |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 CMceComMessageCodec* CMceComMessageCodec::NewL( TBuf8<KMceMaxSdpNameLength> aSdpName ) |
|
52 { |
|
53 CMceComMessageCodec* self = NewLC( aSdpName ); |
|
54 CleanupStack::Pop( self ); |
|
55 return self; |
|
56 |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CMceComMessageCodec::NewLC |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 CMceComMessageCodec* CMceComMessageCodec::NewLC( TBuf8<KMceMaxSdpNameLength> aSdpName ) |
|
64 { |
|
65 CMceComMessageCodec* self = new (ELeave) CMceComMessageCodec(); |
|
66 CleanupStack::PushL( self ); |
|
67 self->ConstructL( aSdpName ); |
|
68 return self; |
|
69 } |
|
70 |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CMceComMessageCodec::~CMceComMessageCodec |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 CMceComMessageCodec::~CMceComMessageCodec() |
|
77 { |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CMceComMessageCodec::CMceComMessageCodec |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 CMceComMessageCodec::CMceComMessageCodec() |
|
85 : CMceComCodec(), |
|
86 iEnableVAD( EFalse ), |
|
87 iSamplingFreq( 0 ), |
|
88 iPTime( 0 ), |
|
89 iMaxPTime( 0 ) |
|
90 { |
|
91 } |
|
92 |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CMceComMessageCodec::ConstructL |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 CMceComMessageCodec* CMceComMessageCodec::CloneL() |
|
99 { |
|
100 CMceComMessageCodec* copy = new (ELeave) CMceComMessageCodec(); |
|
101 CleanupStack::PushL( copy ); |
|
102 copy->ConstructL( *this ); |
|
103 CleanupStack::Pop( copy ); |
|
104 return copy; |
|
105 |
|
106 } |
|
107 |
|
108 |
|
109 // ----------------------------------------------------------------------------- |
|
110 // CMceComMessageCodec::ConstructL |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 void CMceComMessageCodec::ConstructL( TBuf8<KMceMaxSdpNameLength> aSdpName ) |
|
114 { |
|
115 CMceComCodec::ConstructL( aSdpName ); |
|
116 } |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // CMceComMessageCodec::ConstructL |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 void CMceComMessageCodec::ConstructL( CMceComMessageCodec& aCodec ) |
|
123 { |
|
124 CMceComCodec::ConstructL( aCodec ); |
|
125 |
|
126 iEnableVAD = aCodec.iEnableVAD; |
|
127 iSamplingFreq = aCodec.iSamplingFreq; |
|
128 iPTime = aCodec.iPTime; |
|
129 iMaxPTime = aCodec.iMaxPTime; |
|
130 |
|
131 } |
|
132 |
|
133 |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // CMceComMessageCodec::InternalizeFlatL |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 void CMceComMessageCodec::InternalizeFlatL( RReadStream& aReadStream ) |
|
140 { |
|
141 CMceComCodec::InternalizeFlatL( aReadStream ); |
|
142 |
|
143 iEnableVAD = static_cast<TBool>( aReadStream.ReadUint8L() ); |
|
144 iSamplingFreq = aReadStream.ReadUint16L(); |
|
145 iPTime = aReadStream.ReadUint16L(); |
|
146 iMaxPTime = aReadStream.ReadUint16L(); |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // CMceComMessageCodec::ExternalizeFlatL |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 void CMceComMessageCodec::ExternalizeFlatL( RWriteStream& aWriteStream ) |
|
154 { |
|
155 CMceComCodec::ExternalizeFlatL( aWriteStream ); |
|
156 |
|
157 aWriteStream.WriteUint8L( iEnableVAD ); |
|
158 aWriteStream.WriteUint16L( iSamplingFreq ); |
|
159 aWriteStream.WriteUint16L( iPTime ); |
|
160 aWriteStream.WriteUint16L( iMaxPTime ); |
|
161 } |
|
162 |
|
163 |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // CMceComMessageCodec::UpdateL |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 void CMceComMessageCodec::UpdateL( CMceComCodec& aUpdate ) |
|
170 { |
|
171 CMceComCodec::UpdateL( aUpdate ); |
|
172 |
|
173 CMceComMessageCodec& update = static_cast<CMceComMessageCodec&>( aUpdate ); |
|
174 |
|
175 iEnableVAD = update.iEnableVAD; |
|
176 iSamplingFreq = update.iSamplingFreq; |
|
177 |
|
178 |
|
179 if ( IS_RECEIVESTREAM( iStream ) ) |
|
180 { |
|
181 iPTime = update.iPTime; |
|
182 iMaxPTime = update.iMaxPTime; |
|
183 } |
|
184 } |
|
185 |
|
186 |
|
187 // ----------------------------------------------------------------------------- |
|
188 // CMceComMessageCodec::Factory |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 TMceComMessageCodecFactory CMceComMessageCodec::Factory() |
|
192 { |
|
193 return TMceComMessageCodecFactory(); |
|
194 } |
|
195 |
|
196 |
|
197 // ----------------------------------------------------------------------------- |
|
198 // CMceComMessageCodec::CompareSdpIndex |
|
199 // ----------------------------------------------------------------------------- |
|
200 // |
|
201 TInt CMceComMessageCodec::CompareSdpIndex( |
|
202 const CMceComMessageCodec& aIndex1, const CMceComMessageCodec& aIndex2 ) |
|
203 { |
|
204 // NOTE: if zero (equals) is returned from here, order is strangely anyway |
|
205 // changed. Returning positive value if indexes are equal is for avoiding |
|
206 // this quirk. |
|
207 |
|
208 if ( aIndex1.iCodecSdpIndex >= aIndex2.iCodecSdpIndex ) |
|
209 { |
|
210 return (1); |
|
211 } |
|
212 else if ( aIndex1.iCodecSdpIndex < aIndex2.iCodecSdpIndex ) |
|
213 { |
|
214 return (-1); |
|
215 } |
|
216 else |
|
217 { |
|
218 return (0); |
|
219 } |
|
220 } |
|
221 |
|
222 #ifdef MCE_COMMON_SERVER_SIDE |
|
223 |
|
224 |
|
225 // ----------------------------------------------------------------------------- |
|
226 // CMceComMessageCodec::operator= |
|
227 // ----------------------------------------------------------------------------- |
|
228 // |
|
229 CMceComCodec& CMceComMessageCodec::operator=( CMccCodecInformation& aMccCodec ) |
|
230 { |
|
231 |
|
232 iPayloadType = aMccCodec.PayloadType(); |
|
233 iBitrate = aMccCodec.Bitrate(); |
|
234 iAllowedBitrates = aMccCodec.AllowedBitrates(); |
|
235 iCodecMode = aMccCodec.CodecMode(); |
|
236 iFourCC = aMccCodec.FourCC(); |
|
237 iFrameSize = aMccCodec.FrameSize(); |
|
238 |
|
239 iEnableVAD = aMccCodec.VAD(); |
|
240 iSamplingFreq = aMccCodec.SamplingFreq(); |
|
241 iPTime = aMccCodec.PTime(); |
|
242 iMaxPTime = aMccCodec.MaxPTime(); |
|
243 |
|
244 return *this; |
|
245 |
|
246 } |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // CMceComMessageCodec::DoMccDecodeL |
|
250 // ----------------------------------------------------------------------------- |
|
251 // |
|
252 void CMceComMessageCodec::DoMccDecodeL( CMccCodecInformation& aMccCodec ) |
|
253 { |
|
254 //copy values, which are not explicitely in SDP, from mcc codec |
|
255 iSamplingFreq = aMccCodec.SamplingFreq(); |
|
256 |
|
257 iBitrate = aMccCodec.Bitrate(); |
|
258 } |
|
259 |
|
260 // ----------------------------------------------------------------------------- |
|
261 // CMceComMessageCodec::DoMccEncodeL |
|
262 // ----------------------------------------------------------------------------- |
|
263 // |
|
264 void CMceComMessageCodec::DoMccEncodeL( CMccCodecInformation& aMccCodec, |
|
265 CMceSrvStream& /*aStream*/ ) |
|
266 { |
|
267 User::LeaveIfError( aMccCodec.SetSamplingFreq( iSamplingFreq ) ); |
|
268 User::LeaveIfError( aMccCodec.SetBitrate( iBitrate ) ); |
|
269 } |
|
270 |
|
271 |
|
272 // ----------------------------------------------------------------------------- |
|
273 // CMceComMessageCodec::DoMccValidateL |
|
274 // ----------------------------------------------------------------------------- |
|
275 // |
|
276 CMceComCodec* CMceComMessageCodec::DoMccValidateL( CMccCodecInformation& aMccCodec, |
|
277 CMceSrvStream& /*aStream*/, |
|
278 TMceNegotiationRole aRole ) |
|
279 { |
|
280 //if answerer mcc codec represents the received offer and codec the answer |
|
281 //if offerer codec represents the sent offer and mcc codec the answer |
|
282 TBool notValid = aRole == EMceRoleAnswerer ? |
|
283 ( iAllowedBitrates && aMccCodec.AllowedBitrates() == 0 || |
|
284 iAllowedBitrates > aMccCodec.AllowedBitrates() ) : |
|
285 ( iAllowedBitrates && aMccCodec.AllowedBitrates() == 0 || |
|
286 iAllowedBitrates < aMccCodec.AllowedBitrates() ); |
|
287 |
|
288 User::LeaveIfError( notValid ? KErrNotSupported : KErrNone ); |
|
289 |
|
290 return NULL; |
|
291 } |
|
292 |
|
293 // ----------------------------------------------------------------------------- |
|
294 // CMceComMessageCodec::DoMccRequireSignalling |
|
295 // ----------------------------------------------------------------------------- |
|
296 // |
|
297 TInt CMceComMessageCodec::DoMccRequireSignalling( |
|
298 const CMceSrvStream& aStream, |
|
299 const CMccCodecInformation& aMccCurentCodec, |
|
300 const CMccCodecInformation& aMccUpdateCodec ) const |
|
301 { |
|
302 TInt action = KMceNoSignalling; |
|
303 |
|
304 if ( aStream.StreamType() == CMceComMediaStream::EReceiveStream || |
|
305 aStream.StreamType() == CMceComMediaStream::EReceiveOnlyStream ) |
|
306 { |
|
307 if ( aMccCurentCodec.PTime() != aMccUpdateCodec.PTime() || |
|
308 aMccCurentCodec.MaxPTime() != aMccUpdateCodec.MaxPTime() ) |
|
309 { |
|
310 action = KMceRequiresSignalling; |
|
311 } |
|
312 } |
|
313 |
|
314 return action; |
|
315 } |
|
316 |
|
317 |
|
318 // ----------------------------------------------------------------------------- |
|
319 // CMceComMessageCodec::DoMccRequireSignalling |
|
320 // ----------------------------------------------------------------------------- |
|
321 // |
|
322 TInt CMceComMessageCodec::DoMccRequireSignalling( |
|
323 const CMceSrvStream& aOldStream, |
|
324 const CMceSrvStream& aCurrentStream, |
|
325 const CMccCodecInformation& /*aMccCurentCodec*/, |
|
326 const CMccCodecInformation& /*aMccUpdateCodec*/ ) const |
|
327 { |
|
328 TInt action = KMceNoSignalling; |
|
329 |
|
330 // Check for MSRP capabilities |
|
331 |
|
332 // Checking for Sink properties |
|
333 RPointerArray<CMceComMediaSink> Oldsinks = aOldStream.Data().Sinks(); |
|
334 TBuf8<50> aOldAWtype; |
|
335 TBuf8<50> aOldAcceptTypestemp; |
|
336 for ( TInt i = 0; i < Oldsinks.Count(); i++ ) |
|
337 { |
|
338 if(Oldsinks[i]->Type() == KMceMSRPSink) |
|
339 { |
|
340 aOldAWtype = static_cast<CMceComMsrpSink*>(Oldsinks[i])->iAcceptWrappedTypes;//Oldsinks[i]->iAcceptWrappedTypes; |
|
341 TInt aPos = static_cast<CMceComMsrpSink*>(Oldsinks[i])->iAcceptTypes.MdcaCount(); |
|
342 if(aPos) |
|
343 { |
|
344 aOldAcceptTypestemp.Append(static_cast<CMceComMsrpSink*>(Oldsinks[i])->iAcceptTypes.MdcaPoint(aPos)); |
|
345 } |
|
346 } |
|
347 } |
|
348 |
|
349 RPointerArray<CMceComMediaSink> Newsinks = aCurrentStream.Data().Sinks(); |
|
350 TBuf8<50> aNewAWtype; |
|
351 TBuf8<50> aNewAcceptTypestemp; |
|
352 for ( TInt i = 0; i < Newsinks.Count(); i++ ) |
|
353 { |
|
354 if(Newsinks[i]->Type() == KMceMSRPSink) |
|
355 { |
|
356 aNewAWtype = static_cast<CMceComMsrpSink*>(Newsinks[i])->iAcceptWrappedTypes; |
|
357 TInt aPos = static_cast<CMceComMsrpSink*>(Newsinks[i])->iAcceptTypes.MdcaCount(); |
|
358 if(aPos) |
|
359 { |
|
360 aNewAcceptTypestemp.Append(static_cast<CMceComMsrpSink*>(Newsinks[i])->iAcceptTypes.MdcaPoint(aPos)); |
|
361 } |
|
362 |
|
363 if (aOldAWtype.FindC(aNewAWtype) == KErrNotFound ) |
|
364 { |
|
365 // Msrp/AcceptwrappedTypes change detected. requires signalling |
|
366 action = KMceRequiresSipSignallingOnly; |
|
367 } |
|
368 if (aOldAcceptTypestemp.FindC(aNewAcceptTypestemp) == KErrNotFound ) |
|
369 { |
|
370 //Msrp/AcceptTypes change detected. requires signalling |
|
371 action = KMceRequiresSipSignallingOnly; |
|
372 } |
|
373 } |
|
374 } |
|
375 |
|
376 aOldAWtype.Zero(); |
|
377 aNewAWtype.Zero(); |
|
378 aOldAcceptTypestemp.Zero(); |
|
379 aNewAcceptTypestemp.Zero(); |
|
380 |
|
381 // Checking for Source properties |
|
382 CMceComMsrpSource* msrpOldSource = static_cast<CMceComMsrpSource*>(aOldStream.Data().Source()); |
|
383 |
|
384 if(msrpOldSource->Type() == KMceMSRPSource) |
|
385 { |
|
386 aOldAWtype = msrpOldSource->iAcceptWrappedTypes; //static_cast<CMceComMsrpSink*>( msrpOldSource->iFlatData )->iAcceptWrappedTypes; |
|
387 TInt aPos = msrpOldSource->iAcceptTypes.MdcaCount(); |
|
388 for(TInt j=0; j<aPos; j++) |
|
389 { |
|
390 aOldAcceptTypestemp.Append(msrpOldSource->iAcceptTypes.MdcaPoint(j)); |
|
391 } |
|
392 } |
|
393 |
|
394 CMceComMsrpSource* msrpNewSource = static_cast<CMceComMsrpSource*> (aCurrentStream.Data().Source()); |
|
395 if(msrpNewSource->Type() == KMceMSRPSource) |
|
396 { |
|
397 |
|
398 aNewAWtype = msrpNewSource->iAcceptWrappedTypes; |
|
399 TInt aPos = msrpNewSource->iAcceptTypes.MdcaCount(); |
|
400 for(TInt j=0; j<aPos; j++) |
|
401 { |
|
402 aNewAcceptTypestemp.Append(msrpNewSource->iAcceptTypes.MdcaPoint(j)); |
|
403 } |
|
404 |
|
405 if (aOldAWtype.FindC(aNewAWtype) == KErrNotFound ) |
|
406 { |
|
407 // Msrp/AcceptwrappedTypes change detected. requires signalling |
|
408 action = KMceRequiresSipSignallingOnly; |
|
409 } |
|
410 |
|
411 if (aOldAcceptTypestemp.FindC(aNewAcceptTypestemp) == KErrNotFound ) |
|
412 { |
|
413 //Msrp/AcceptTypes change detected. requires signalling |
|
414 action = KMceRequiresSipSignallingOnly; |
|
415 } |
|
416 } |
|
417 |
|
418 return action; |
|
419 } |
|
420 |
|
421 |
|
422 // ----------------------------------------------------------------------------- |
|
423 // CMceComMessageCodec::MccPopulateL |
|
424 // ----------------------------------------------------------------------------- |
|
425 // |
|
426 void CMceComMessageCodec::MccPopulateL( CMccCodecInformation& aMccCodec, |
|
427 CMceSrvStream& /*aStream*/, |
|
428 TMceNegotiationRole aRole ) |
|
429 { |
|
430 //MccEncodeL( aMccCodec, aStream ); |
|
431 if ( aRole == EMceRoleOfferer ) |
|
432 { |
|
433 // Create fmtp |
|
434 aMccCodec.CreateFmtpAttrListL(); |
|
435 } |
|
436 |
|
437 UpdateL( aMccCodec ); |
|
438 |
|
439 } |
|
440 |
|
441 // ----------------------------------------------------------------------------- |
|
442 // CMceComCodec::UpdateL |
|
443 // ----------------------------------------------------------------------------- |
|
444 // |
|
445 void CMceComMessageCodec::UpdateL( CMccCodecInformation& aMccCodec ) |
|
446 { |
|
447 //SetFmtpAttributeL( aMccCodec.GetFmtpL() ); |
|
448 iSdpName = aMccCodec.SdpName(); |
|
449 } |
|
450 |
|
451 // ----------------------------------------------------------------------------- |
|
452 // CMceComMessageCodec::DoMccAdjustL |
|
453 // ----------------------------------------------------------------------------- |
|
454 // |
|
455 void CMceComMessageCodec::DoMccAdjustL( CMccCodecInformation& /*aMccCodec*/, |
|
456 CMceSrvStream& /*aStream*/ ) |
|
457 { |
|
458 |
|
459 } |
|
460 |
|
461 // ----------------------------------------------------------------------------- |
|
462 // CMceComMessageCodec::DoSetDefaultFmtpAttributeL |
|
463 // ----------------------------------------------------------------------------- |
|
464 // |
|
465 void CMceComMessageCodec::DoSetDefaultFmtpAttributeL() |
|
466 { |
|
467 // NOP |
|
468 } |
|
469 |
|
470 |
|
471 #endif// MCE_COMMON_SERVER_SIDE |
|
472 |