|
1 /* |
|
2 * Copyright (c) 2006-2008 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: Representation of SVP MT session |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <centralrepository.h> |
|
19 #include <mcesecureoutsession.h> |
|
20 #include <mceaudiocodec.h> |
|
21 #include <settingsinternalcrkeys.h> |
|
22 #include <mcertpsink.h> |
|
23 #include <mceaudiostream.h> |
|
24 #include <mceinsession.h> |
|
25 #include <mcemediasource.h> |
|
26 #include <mcertpsource.h> |
|
27 |
|
28 #include "svpmtsession.h" |
|
29 #include "svpaudioutility.h" |
|
30 #include "svpsipconsts.h" |
|
31 #include "svplogger.h" |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // CSVPMtSession::CSVPMtSession |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 CSVPMtSession::CSVPMtSession( CMceInSession* aMtSession, |
|
38 TMceTransactionDataContainer& aContainer, |
|
39 TUint32 aVoIPProfileId, |
|
40 MSVPSessionObserver& aObserver, |
|
41 CSVPUtility& aSVPUtility, |
|
42 CSVPRtpObserver& aRtpObserver, |
|
43 TInt aKeepAliveValue, |
|
44 TBool aPreconditions ) |
|
45 : CSVPSessionBase( aContainer, aObserver, aSVPUtility, aRtpObserver ) |
|
46 { |
|
47 iSession = aMtSession; |
|
48 iVoIPProfileId = aVoIPProfileId; |
|
49 iKeepAliveValue = aKeepAliveValue; |
|
50 iPreconditions = aPreconditions; |
|
51 |
|
52 CMceSession::TControlPathSecurityLevel securityLevel = |
|
53 aMtSession->ControlPathSecurityLevel(); |
|
54 |
|
55 // Not secure call event is sent according this, in mt case event isn't sent |
|
56 iCallEventToBeSent = MCCPCallObserver::ECCPSecureNotSpecified; |
|
57 |
|
58 if ( CMceSession::EControlPathSecure == securityLevel && |
|
59 KMceSessionSecure == aMtSession->Type() ) |
|
60 { |
|
61 SVPDEBUG1( "CSVPMtSession::CSVPMtSession Mt secure" ) |
|
62 iSecured = ETrue; |
|
63 } |
|
64 else |
|
65 { |
|
66 SVPDEBUG1( "CSVPMtSession::CSVPMtSession Mt non secure" ) |
|
67 iSecured = EFalse; |
|
68 } |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // CSVPMtSession::NewL |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 CSVPMtSession* CSVPMtSession::NewL( CMceInSession* aMtSession, |
|
76 TMceTransactionDataContainer& aContainer, |
|
77 TUint32 aServiceId, |
|
78 TUint32 aVoIPProfileId, |
|
79 MSVPSessionObserver& aObserver, |
|
80 CSVPUtility& aSVPUtility, |
|
81 CSVPRtpObserver& aRtpObserver, |
|
82 TInt aKeepAliveValue, |
|
83 TBool aPreconditions ) |
|
84 { |
|
85 CSVPMtSession* self = new ( ELeave ) CSVPMtSession( aMtSession, |
|
86 aContainer, |
|
87 aVoIPProfileId, |
|
88 aObserver, |
|
89 aSVPUtility, |
|
90 aRtpObserver, |
|
91 aKeepAliveValue, |
|
92 aPreconditions ); |
|
93 CleanupStack::PushL( self ); |
|
94 self->ConstructL( aServiceId ); |
|
95 CleanupStack::Pop( self ); |
|
96 return self; |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // CSVPMtSession::~CSVPMtSession |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 CSVPMtSession::~CSVPMtSession() |
|
104 { |
|
105 SVPDEBUG1( "CSVPMtSession::~CSVPMtSession" ) |
|
106 } |
|
107 |
|
108 // --------------------------------------------------------------------------- |
|
109 // CSVPMtSession::ConstructL |
|
110 // --------------------------------------------------------------------------- |
|
111 // |
|
112 void CSVPMtSession::ConstructL( TUint32 aServiceId ) |
|
113 { |
|
114 SVPDEBUG1( "CSVPMtSession::ConstructL In" ) |
|
115 |
|
116 iCallParameters = CCCPCallParameters::NewL(); |
|
117 iCallParameters->SetServiceId( aServiceId ); |
|
118 iCallParameters->SetCallType( CCPCall::ECallTypePS ); |
|
119 |
|
120 // modify QoS preconditions |
|
121 if ( iPreconditions ) |
|
122 { |
|
123 SVPDEBUG1( "CSVPMtSession::ConstructL preconditions supported" ) |
|
124 iSession->SetModifierL( KMcePreconditions, KMcePreconditionsSupported ); |
|
125 } |
|
126 else |
|
127 { |
|
128 SVPDEBUG1( "CSVPMtSession::ConstructL preconditions NOT supported" ) |
|
129 iSession->SetModifierL( KMcePreconditions, KMcePreconditionsNotUsed ); |
|
130 } |
|
131 |
|
132 // modify Old way hold on |
|
133 iSession->SetModifierL( KMceMediaDirection, KMceMediaDirectionWithAddress ); |
|
134 |
|
135 InitializePropertyWatchingL(); |
|
136 |
|
137 SVPDEBUG1( "CSVPMtSession::ConstructL Out" ) |
|
138 } |
|
139 |
|
140 |
|
141 // from MCCPCall |
|
142 // --------------------------------------------------------------------------- |
|
143 // CSVPMtSession::Answer |
|
144 // --------------------------------------------------------------------------- |
|
145 // |
|
146 TInt CSVPMtSession::Answer() |
|
147 { |
|
148 SVPDEBUG1( "CSVPMtSession::Answer In" ) |
|
149 |
|
150 // stop expires timer |
|
151 StopTimers(); |
|
152 |
|
153 // answer to session |
|
154 TRAPD( err, DoAnswerL() ); |
|
155 |
|
156 if ( KErrNone != err ) |
|
157 { |
|
158 SVPDEBUG2( "CSVPMtSession::Answer Out return(err)=%d", err ) |
|
159 return err; |
|
160 } |
|
161 else |
|
162 { |
|
163 ExecCbCallStateChanged( MCCPCallObserver::ECCPStateAnswering ); |
|
164 SVPDEBUG2( "CSVPMtSession::Answer Out return=%d", err ) |
|
165 return err; |
|
166 } |
|
167 } |
|
168 |
|
169 // --------------------------------------------------------------------------- |
|
170 // CSVPMtSession::DoAnswerL |
|
171 // --------------------------------------------------------------------------- |
|
172 // |
|
173 void CSVPMtSession::DoAnswerL() |
|
174 { |
|
175 SVPDEBUG1( "CSVPMtSession::DoAnswerL In" ) |
|
176 |
|
177 static_cast<CMceInSession*>( iSession )->AcceptL(); |
|
178 HandleMtStreamsL( iSession->Streams() ); |
|
179 |
|
180 SVPDEBUG1( "CSVPMtSession::DoAnswerL Out" ) |
|
181 } |
|
182 |
|
183 // --------------------------------------------------------------------------- |
|
184 // CSVPMtSession::HandleMtStreamsL |
|
185 // --------------------------------------------------------------------------- |
|
186 // |
|
187 void CSVPMtSession::HandleMtStreamsL( |
|
188 const RPointerArray<CMceMediaStream>& aStreams ) |
|
189 { |
|
190 SVPDEBUG1( "CSVPMtSession::HandleMtStreamsL In" ) |
|
191 |
|
192 // go through streams and enable rtp source and speaker sink if found |
|
193 for ( TInt i = 0; i < aStreams.Count(); i++ ) |
|
194 { |
|
195 SVPDEBUG1( "CSVPMtSession::HandleMtStreamsL for-loop" ) |
|
196 |
|
197 CMceMediaStream* stream1 = aStreams[ i ]; |
|
198 CMceMediaStream& boundStream = stream1->BoundStreamL();// fetch bound stream |
|
199 |
|
200 // enable RTP source |
|
201 if ( stream1->Source() && stream1->Source()->Type() == KMceRTPSource ) |
|
202 { |
|
203 SVPDEBUG1( "CSVPMtSession::HandleMtStreamsL RTPSource found" ) |
|
204 stream1->Source()->EnableL(); |
|
205 SVPDEBUG1( "CSVPMtSession::HandleMtStreamsL RTPSource ENABLED" ) |
|
206 } |
|
207 |
|
208 // enable speaker sink |
|
209 SVPAudioUtility::EnableSpeakerSinkL( stream1->Sinks() ); |
|
210 |
|
211 // enable mic source |
|
212 if ( stream1->Source() ) |
|
213 { |
|
214 SVPAudioUtility::EnableMicSourceL( *stream1->Source() ); |
|
215 } |
|
216 |
|
217 // enable mic source from bound stream, if found |
|
218 if ( boundStream.Source() ) |
|
219 { |
|
220 SVPAudioUtility::EnableMicSourceL( *boundStream.Source() ); |
|
221 } |
|
222 } |
|
223 |
|
224 SVPDEBUG1( "CSVPMtSession::HandleMtStreamsL Out" ) |
|
225 } |
|
226 |
|
227 // --------------------------------------------------------------------------- |
|
228 // CSVPMtSession::IsCallForwarded |
|
229 // --------------------------------------------------------------------------- |
|
230 // |
|
231 TBool CSVPMtSession::IsCallForwarded() const |
|
232 { |
|
233 return EFalse; |
|
234 } |
|
235 |
|
236 // --------------------------------------------------------------------------- |
|
237 // CSVPMtSession::Release |
|
238 // --------------------------------------------------------------------------- |
|
239 // |
|
240 TInt CSVPMtSession::Release() |
|
241 { |
|
242 SVPDEBUG1( "CSVPMtSession::Release" ) |
|
243 delete this; |
|
244 return KErrNone; |
|
245 } |
|
246 |
|
247 // --------------------------------------------------------------------------- |
|
248 // CSVPMtSession::Reject |
|
249 // --------------------------------------------------------------------------- |
|
250 // |
|
251 TInt CSVPMtSession::Reject() |
|
252 { |
|
253 SVPDEBUG1( "CSVPMtSession::Reject In" ) |
|
254 |
|
255 TRAPD( err, static_cast<CMceInSession*>(iSession )->RejectL( |
|
256 KSVPBusyHereReason, KSVPBusyHereVal ) ); |
|
257 |
|
258 if ( !err ) |
|
259 { |
|
260 ExecCbCallStateChanged( MCCPCallObserver::ECCPStateIdle ); |
|
261 } |
|
262 |
|
263 SVPDEBUG2( "CSVPMtSession::Reject Out return=%d", err ) |
|
264 return err; |
|
265 } |
|
266 |
|
267 // --------------------------------------------------------------------------- |
|
268 // CSVPMtSession::Queue |
|
269 // --------------------------------------------------------------------------- |
|
270 // |
|
271 TInt CSVPMtSession::Queue() |
|
272 { |
|
273 SVPDEBUG1( "CSVPMtSession::Queue In" ) |
|
274 |
|
275 // Get PS waiting setting |
|
276 TInt error( KErrNone ); |
|
277 TInt psWaiting( EFalse ); |
|
278 CRepository* repository = NULL; |
|
279 |
|
280 TRAP( error, repository = CRepository::NewL( KCRUidRichCallSettings ) ); |
|
281 |
|
282 if ( KErrNone == error ) |
|
283 { |
|
284 error = repository->Get( KRCSPSCallWaiting, psWaiting ); |
|
285 delete repository; |
|
286 repository = NULL; |
|
287 |
|
288 if ( psWaiting ) |
|
289 { |
|
290 // send 180 ringing |
|
291 Ringing(); |
|
292 SVPDEBUG1( "CSVPMtSession::Queue Sending 180 Ringing" ) |
|
293 |
|
294 // send 182 queued |
|
295 SVPDEBUG1( "CSVPMtSession::Queue() Sending 182 Queued" ) |
|
296 TRAPD( err, static_cast<CMceInSession*> ( iSession )->RespondL( |
|
297 KSVPQueuedReason, KSVPQueuedVal ) ); |
|
298 |
|
299 if ( err ) |
|
300 { |
|
301 SVPDEBUG2( "CSVPMtSession::Queue Out return=%d", err ) |
|
302 return err; |
|
303 } |
|
304 } |
|
305 else |
|
306 { |
|
307 // ps waiting off, return error |
|
308 SVPDEBUG1( "CSVPMtSession::Queue Out return=KErrNotReady" ) |
|
309 return KErrNotReady; |
|
310 } |
|
311 } |
|
312 |
|
313 SVPDEBUG2( "CSVPMtSession::Queue Out return=%d", error ) |
|
314 return error; |
|
315 } |
|
316 |
|
317 // --------------------------------------------------------------------------- |
|
318 // CSVPMtSession::Ringing |
|
319 // --------------------------------------------------------------------------- |
|
320 // |
|
321 TInt CSVPMtSession::Ringing() |
|
322 { |
|
323 SVPDEBUG1( "CSVPMtSession::Ringing In" ) |
|
324 |
|
325 TRAPD( err, static_cast<CMceInSession*>( iSession )->RingL() ); |
|
326 |
|
327 SVPDEBUG2( "CSVPMtSession::Ringing Out return=%d", err ) |
|
328 return err; |
|
329 } |
|
330 |
|
331 // --------------------------------------------------------------------------- |
|
332 // CSVPMtSession::Hold |
|
333 // --------------------------------------------------------------------------- |
|
334 // |
|
335 TInt CSVPMtSession::Hold() |
|
336 { |
|
337 SVPDEBUG1( "CSVPMtSession::Hold In" ) |
|
338 |
|
339 TBool sessionUpdateOngoing = ETrue; |
|
340 TRAP_IGNORE( SetRtpKeepAliveL( iSession, sessionUpdateOngoing ) ); |
|
341 |
|
342 TInt status = CSVPSessionBase::Hold(); |
|
343 |
|
344 SVPDEBUG2( "CSVPMtSession::Hold Out return=%d", status ) |
|
345 return status; |
|
346 } |
|
347 |
|
348 // --------------------------------------------------------------------------- |
|
349 // CSVPMtSession::Resume |
|
350 // --------------------------------------------------------------------------- |
|
351 // |
|
352 TInt CSVPMtSession::Resume() |
|
353 { |
|
354 SVPDEBUG1( "CSVPMtSession::Resume" ) |
|
355 return CSVPSessionBase::Resume(); |
|
356 } |
|
357 |
|
358 // --------------------------------------------------------------------------- |
|
359 // CSVPMtSession::IsMobileOriginated |
|
360 // --------------------------------------------------------------------------- |
|
361 // |
|
362 TBool CSVPMtSession::IsMobileOriginated() const |
|
363 { |
|
364 SVPDEBUG1( "CSVPMtSession::IsMobileOriginated = EFalse" ) |
|
365 return EFalse; |
|
366 } |
|
367 |
|
368 // --------------------------------------------------------------------------- |
|
369 // CSVPMtSession::SetRtpKeepAliveL |
|
370 // --------------------------------------------------------------------------- |
|
371 // |
|
372 void CSVPMtSession::SetRtpKeepAliveL( CMceSession* aSession, |
|
373 TBool aSessionUpdateOngoing ) |
|
374 { |
|
375 SVPDEBUG1( "CSVPMtSession::SetRtpKeepAliveL In" ) |
|
376 |
|
377 __ASSERT_ALWAYS( aSession, User::Leave( KErrArgument ) ); |
|
378 UpdateKeepAliveL( *aSession, aSessionUpdateOngoing ); |
|
379 |
|
380 SVPDEBUG1( "CSVPMtSession::SetRtpKeepAliveL Out" ) |
|
381 } |
|
382 |