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