|
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: Remote holded state for hold state machine. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <badesca.h> |
|
20 #include <mcesession.h> |
|
21 #include <mcertpsource.h> |
|
22 #include <mcertpsink.h> |
|
23 #include <mcemediastream.h> |
|
24 #include <mceaudiostream.h> |
|
25 #include "svpholdinstate.h" |
|
26 #include "svpholdcontext.h" |
|
27 #include "svpholdcontroller.h" |
|
28 #include "svpholdobserver.h" |
|
29 #include "svpholdmediahandler.h" |
|
30 #include "svplogger.h" |
|
31 |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // CSVPHoldInState::CSVPHoldInState |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 CSVPHoldInState::CSVPHoldInState() |
|
38 { |
|
39 } |
|
40 |
|
41 // --------------------------------------------------------------------------- |
|
42 // CSVPHoldInState::NewLC |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 CSVPHoldInState* CSVPHoldInState::NewLC() |
|
46 { |
|
47 CSVPHoldInState* self = new ( ELeave ) CSVPHoldInState; |
|
48 CleanupStack::PushL( self ); |
|
49 return self; |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // CSVPHoldInState::~CSVPHoldInState |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 CSVPHoldInState::~CSVPHoldInState() |
|
57 { |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // CSVPHoldInState::DoApplyL |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 void CSVPHoldInState::DoApplyL( CSVPHoldContext& aContext ) |
|
65 { |
|
66 SVPDEBUG1( "CSVPHoldInState::DoApply" ) |
|
67 |
|
68 CMceSession* session = aContext.SessionObject(); |
|
69 const RPointerArray< CMceMediaStream >& streams = session->Streams(); |
|
70 TSVPHoldStateIndex nextState = KSVPHoldEstablishingStateIndex; |
|
71 |
|
72 SVPDEBUG2( "CSVPHoldInState::DoApply streams: %d", streams.Count() ) |
|
73 |
|
74 TInt audioStreamsHandled = 0; |
|
75 TInt streamCount = streams.Count(); |
|
76 while ( streamCount ) |
|
77 { |
|
78 streamCount--; |
|
79 CMceMediaStream* mediaStream = streams[ streamCount ]; |
|
80 if ( KMceAudio == mediaStream->Type() ) |
|
81 { |
|
82 // This media is audio stream. Handling depends on the request |
|
83 SVPDEBUG2( "CSVPHoldInState::DoApply - Hold request = %i", |
|
84 aContext.HoldRequest() ) |
|
85 |
|
86 nextState = PerformRequestL( aContext, *mediaStream, *session ); |
|
87 audioStreamsHandled++; |
|
88 } |
|
89 } |
|
90 |
|
91 if ( 0 == audioStreamsHandled ) |
|
92 { |
|
93 SVPDEBUG1( "CSVPHoldInState::DoApply KErrSVPHoldStateError" ) |
|
94 |
|
95 User::Leave( KErrSVPHoldStateError ); |
|
96 } |
|
97 |
|
98 aContext.SetCurrentStateL( aContext, nextState ); |
|
99 |
|
100 SVPDEBUG1( "CSVPHoldInState::DoApply - Handled" ) |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // CSVPHoldInState::PerformRequestL |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 TSVPHoldStateIndex |
|
108 CSVPHoldInState::PerformRequestL( CSVPHoldContext& aContext, |
|
109 CMceMediaStream& aMediaStream, |
|
110 CMceSession& aSession ) |
|
111 { |
|
112 TSVPHoldStateIndex nextState = KSVPHoldEstablishingStateIndex; |
|
113 switch ( aContext.HoldRequest() ) |
|
114 { |
|
115 case ESVPLocalDoubleHold: |
|
116 { |
|
117 LocalSessionDoubleHoldL( aContext, aMediaStream, aSession ); |
|
118 break; |
|
119 } |
|
120 |
|
121 case ESVPRemoteResume: |
|
122 { |
|
123 RemoteSessionResumeL( aContext, aMediaStream, aSession ); |
|
124 break; |
|
125 } |
|
126 |
|
127 case ESVPLocalHold: |
|
128 case ESVPLocalDoubleHoldResume: |
|
129 case ESVPLocalResume: |
|
130 case ESVPRemoteHold: |
|
131 case ESVPRemoteDoubleHold: |
|
132 case ESVPRemoteDoubleHoldResume: |
|
133 { |
|
134 // Cannot occur in In state |
|
135 User::Leave( KErrSVPHoldStateError ); |
|
136 break; |
|
137 } |
|
138 |
|
139 default: |
|
140 { |
|
141 // Error in request solving, state change not needed: |
|
142 nextState = KSVPHoldInStateIndex; |
|
143 |
|
144 SVPDEBUG2( "CSVPHoldInState::PerformRequestL - Error, request %i", |
|
145 aContext.HoldRequest() ); |
|
146 break; |
|
147 } |
|
148 } |
|
149 |
|
150 return nextState; |
|
151 } |
|
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // CSVPHoldInState::LocalSessionDoubleHoldL |
|
155 // --------------------------------------------------------------------------- |
|
156 // |
|
157 void CSVPHoldInState::LocalSessionDoubleHoldL( CSVPHoldContext& aContext, |
|
158 CMceMediaStream& aMediaStream, |
|
159 CMceSession& aSession ) |
|
160 { |
|
161 SVPDEBUG1( "CSVPHoldInState::LocalSessionDoubleHoldL - In" ); |
|
162 |
|
163 // Handle media stream: |
|
164 aContext.MediaHandler(). |
|
165 PerformMediaActionL( aMediaStream, |
|
166 ESVPLocalDoubleHold ); |
|
167 |
|
168 // Update session |
|
169 aSession.UpdateL(); |
|
170 SVPDEBUG1( "CSVPHoldInState::LocalSessionDoubleHoldL - done" ); |
|
171 } |
|
172 |
|
173 // --------------------------------------------------------------------------- |
|
174 // CSVPHoldInState::RemoteSessionResumeL |
|
175 // --------------------------------------------------------------------------- |
|
176 // |
|
177 void CSVPHoldInState::RemoteSessionResumeL( CSVPHoldContext& aContext, |
|
178 CMceMediaStream& aMediaStream, |
|
179 CMceSession& aSession ) |
|
180 { |
|
181 SVPDEBUG1( "CSVPHoldInState::RemoteSessionResumeL - In" ) |
|
182 |
|
183 MDesC8Array* attributeLines = aMediaStream.MediaAttributeLinesL(); |
|
184 CleanupDeletePushL( attributeLines ); |
|
185 |
|
186 // Check that request has reasonable direction attribute: |
|
187 if ( ESVPNoType == aContext.SolveRequestL( aSession, attributeLines ) ) |
|
188 { |
|
189 // Not hold request |
|
190 SVPDEBUG1( "CSVPHoldInState::RemoteSessionResumeL ESVPNoType") |
|
191 |
|
192 User::Leave( KErrSVPHoldNotHoldRequest ); |
|
193 } |
|
194 |
|
195 CleanupStack::PopAndDestroy( attributeLines ); |
|
196 |
|
197 // Handle media stream: |
|
198 aContext.MediaHandler().PerformMediaActionL( |
|
199 aMediaStream, ESVPRemoteResume ); |
|
200 |
|
201 // Update session |
|
202 aSession.UpdateL(); |
|
203 |
|
204 SVPDEBUG1( "CSVPHoldInState::RemoteSessionResumeL - done" ) |
|
205 } |
|
206 |
|
207 // --------------------------------------------------------------------------- |
|
208 // CSVPHoldInState::DoEnter |
|
209 // --------------------------------------------------------------------------- |
|
210 // |
|
211 void CSVPHoldInState::DoEnter( CSVPHoldContext& aContext ) |
|
212 { |
|
213 SVPDEBUG1( "CSVPHoldInState::DoEnter" ); |
|
214 |
|
215 TInt err = KErrNone; |
|
216 |
|
217 // succesfull action is informed to client |
|
218 switch ( aContext.HoldRequest() ) |
|
219 { |
|
220 case ESVPRemoteHold: |
|
221 { |
|
222 SVPDEBUG1( "CSVPHoldInState::DoEnter - RemoteHold" ); |
|
223 // For music on hold IOP with some vendors leave speaker enabled: |
|
224 TBool leaveSpeakerEnabled = ETrue; |
|
225 TRAP( err, aContext.MediaHandler(). |
|
226 DisableAudioL( aContext, |
|
227 leaveSpeakerEnabled ) ); |
|
228 |
|
229 aContext.HoldObserver().SessionRemoteHeld(); |
|
230 break; |
|
231 } |
|
232 |
|
233 case ESVPLocalDoubleHoldResume: |
|
234 { |
|
235 SVPDEBUG1( "CSVPHoldInState::DoEnter - Local DH resume" ); |
|
236 TRAP( err, aContext.MediaHandler().DisableAudioL( aContext ) ); |
|
237 aContext.HoldObserver().SessionLocallyResumed(); |
|
238 break; |
|
239 } |
|
240 |
|
241 default: |
|
242 { |
|
243 // Nothing to do; occurs only with state rollback |
|
244 SVPDEBUG1( "CSVPHoldInState::DoEnter - Default" ); |
|
245 break; |
|
246 } |
|
247 } |
|
248 |
|
249 if ( aContext.RemoteRequestNotProcessed() ) |
|
250 { |
|
251 SVPDEBUG1( "CSVPHoldInState::DoEnter - Remote request completed" ); |
|
252 aContext.SetRemoteRequestNotProcessed( EFalse ); |
|
253 } |
|
254 } |
|
255 |
|
256 // --------------------------------------------------------------------------- |
|
257 // CSVPHoldInState::IsOutEstablishingStateActive |
|
258 // --------------------------------------------------------------------------- |
|
259 // |
|
260 TBool CSVPHoldInState::IsOutEstablishingStateActive() |
|
261 { |
|
262 return EFalse; |
|
263 } |
|
264 |
|
265 |