|
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 "mcemedianegotiated.h" |
|
22 #include "mcemediamanager.h" |
|
23 #include "mcecomsession.h" |
|
24 #include "mcesdpsession.h" |
|
25 #include "mceansweringmediaupdate.h" |
|
26 #include "mcepreparingoffererstreams.h" |
|
27 #include "mcepreparinganswererstreams.h" |
|
28 #include "mceofferingmedia.h" |
|
29 #include "mcemediaobserver.h" |
|
30 #include "mcemmlogs.h" |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // TMceMediaNegotiated::TMceEndState::SetAsCurrentStateL |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 void TMceMediaNegotiated::TMceEndState::SetAsCurrentStateL( CMceComSession& aSession ) |
|
37 { |
|
38 MCEMM_DEBUG("TMceMediaNegotiated::TMceEndState::SetAsCurrentStateL() "); |
|
39 |
|
40 TMceMediaNegotiated::TMceEndState* |
|
41 self = new (ELeave) TMceMediaNegotiated::TMceEndState( aSession ); |
|
42 |
|
43 CleanupStack::PushL( self ); |
|
44 aSession.SetNegotiationStateL( self ); |
|
45 CleanupStack::Pop( self ); |
|
46 |
|
47 } |
|
48 |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // TMceMediaNegotiated::TMceEndState::TMceEndState |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 TMceMediaNegotiated::TMceEndState::TMceEndState( CMceComSession& aSession ) |
|
55 : TMceMediaState( aSession ) |
|
56 { |
|
57 } |
|
58 |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // TMceMediaNegotiated::TMceEndState::Callback |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 void TMceMediaNegotiated::TMceEndState::Callback() |
|
65 { |
|
66 |
|
67 iSession.MediaObserver().Updated( iSession ); |
|
68 |
|
69 } |
|
70 |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // TMceMediaNegotiated::TMceEndState::NeedToNegotiate |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 TBool TMceMediaNegotiated::TMceEndState::NeedToNegotiate( CSdpDocument* aSdpDocument ) |
|
77 { |
|
78 TBool needToNegotiate = EFalse; |
|
79 |
|
80 if ( aSdpDocument ) |
|
81 { |
|
82 MCEMM_DEBUG("TMceMediaNegotiated::TMceEndState::NeedToNegotiate(): \ |
|
83 checking if session refresh"); |
|
84 needToNegotiate = !iSession.SdpSession().IsSessionRefresh( aSdpDocument ); |
|
85 } |
|
86 else if ( iSession.Backup() )//update |
|
87 { |
|
88 MCEMM_DEBUG("TMceMediaNegotiated::TMceEndState::NeedToNegotiate(): \ |
|
89 session update. checking if signalling is required"); |
|
90 needToNegotiate = iSession.SdpSession().SignallingRequired() != KMceNoSignalling; |
|
91 } |
|
92 else |
|
93 { |
|
94 MCEMM_DEBUG("TMceMediaNegotiated::TMceEndState::NeedToNegotiate(): \ |
|
95 checking preconditions"); |
|
96 needToNegotiate = iSession.SdpSession().NeedToNegotiate( iSession ); |
|
97 } |
|
98 |
|
99 MCEMM_DEBUG_DVALUE("TMceMediaNegotiated::TMceEndState::NeedToNegotiate(): \ |
|
100 return", needToNegotiate ); |
|
101 return needToNegotiate; |
|
102 |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // TMceMediaNegotiated::TMceEndState::EncodeL |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 CSdpDocument* TMceMediaNegotiated::TMceEndState::EncodeL() |
|
110 { |
|
111 |
|
112 //if answer to session refresh, offer is generated to answer aswell |
|
113 |
|
114 if ( iSession.SdpSession().IsSessionRefresh() ) |
|
115 { |
|
116 iSession.SdpSession().PrepareSessionRefreshL( iSession ); |
|
117 } |
|
118 |
|
119 CSdpDocument* sdp = iSession.SdpSession().CreateOfferL( iSession, CMceSdpSession::ERefresh ); |
|
120 |
|
121 return sdp; |
|
122 |
|
123 } |
|
124 |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // TMceMediaNegotiated::TMceEndState::UpdateL |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 void TMceMediaNegotiated::TMceEndState::UpdateL() |
|
131 { |
|
132 |
|
133 if ( iSession.AnswerType() == KMceNegotiationAnswerTypeFinal ) |
|
134 { |
|
135 iSession.SdpSession().Manager().CleanupL( iSession ); |
|
136 iSession.AnswerType() = KMceNegotiationAnswerTypeNotDefined; |
|
137 } |
|
138 else |
|
139 { |
|
140 iSession.SdpSession().SignallingRequired() = KMceRequiresSipSignallingOnly; |
|
141 iSession.AnswerType() = KMceNegotiationAnswerTypeNotDefined; |
|
142 TMcePreparingOffererStreams::SetAsCurrentStateL( iSession ); |
|
143 } |
|
144 |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // TMceMediaNegotiated::TMceEndState::CloneL |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 TMceMediaState* TMceMediaNegotiated::TMceEndState::CloneL( CMceComSession& aSession ) const |
|
152 { |
|
153 TMceMediaNegotiated::TMceEndState* |
|
154 state = new (ELeave) TMceMediaNegotiated::TMceEndState( aSession ); |
|
155 |
|
156 state->SetRole( Role() ); |
|
157 state->iStackIndex = iStackIndex; |
|
158 |
|
159 return state; |
|
160 |
|
161 } |
|
162 |
|
163 |
|
164 // ----------------------------------------------------------------------------- |
|
165 // TMceMediaNegotiated::TMceEndState::DecodeL |
|
166 // ----------------------------------------------------------------------------- |
|
167 // |
|
168 TMceSipWarningCode TMceMediaNegotiated::TMceEndState::DecodeL( CSdpDocument& aSdpDocument ) |
|
169 { |
|
170 MCEMM_DEBUG("TMceOfferingMedia::TMceMediaNegotiated::DecodeL, Entry "); |
|
171 |
|
172 TMceSipWarningCode status = (TMceSipWarningCode)KErrNone; |
|
173 |
|
174 if ( !iSession.SdpSession().ContextSwitchRequested() ) |
|
175 { |
|
176 status = iSession.SdpSession().DecodeAnswerL( aSdpDocument, iSession ); |
|
177 TMceOfferingMedia::SetAsCurrentStateL( iSession, KFromSubstate ); |
|
178 } |
|
179 else |
|
180 { |
|
181 CMceSdpSession& forkedSdpSession = iSession.SdpSession().ForkL(); |
|
182 CMceComSession& forkedSession = *forkedSdpSession.MediaSession(); |
|
183 status = forkedSession.NegotiationState().DecodeL( aSdpDocument ); |
|
184 } |
|
185 |
|
186 MCEMM_DEBUG("TMceOfferingMedia::TMceMediaNegotiated::DecodeL, Exit "); |
|
187 |
|
188 return status; |
|
189 |
|
190 |
|
191 } |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // TMceMediaNegotiated::TMceAnswererWaitingAnswerState::SetAsCurrentStateL |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 void TMceMediaNegotiated::TMceAnswererWaitingAnswerState::SetAsCurrentStateL( |
|
198 CMceComSession& aSession ) |
|
199 { |
|
200 |
|
201 TMceMediaNegotiated::TMceAnswererWaitingAnswerState* |
|
202 self = new (ELeave) TMceMediaNegotiated::TMceAnswererWaitingAnswerState( aSession ); |
|
203 |
|
204 CleanupStack::PushL( self ); |
|
205 aSession.SetNegotiationStateL( self ); |
|
206 CleanupStack::Pop( self ); |
|
207 |
|
208 } |
|
209 |
|
210 // ----------------------------------------------------------------------------- |
|
211 // TMceMediaNegotiated::TMceAnswererEndState::SetAsCurrentStateL |
|
212 // ----------------------------------------------------------------------------- |
|
213 // |
|
214 void TMceMediaNegotiated::TMceAnswererEndState::SetAsCurrentStateL( CMceComSession& aSession ) |
|
215 { |
|
216 MCEMM_DEBUG("TMceMediaNegotiated::TMceAnswererEndState::SetAsCurrentStateL() "); |
|
217 |
|
218 TMceMediaNegotiated::TMceAnswererEndState* |
|
219 self = new (ELeave) TMceMediaNegotiated::TMceAnswererEndState( aSession ); |
|
220 |
|
221 CleanupStack::PushL( self ); |
|
222 aSession.SetNegotiationStateL( self ); |
|
223 CleanupStack::Pop( self ); |
|
224 |
|
225 } |
|
226 |
|
227 |
|
228 // ----------------------------------------------------------------------------- |
|
229 // TMceMediaNegotiated::TMceAnswererEndState::TMceAnswererEndState |
|
230 // ----------------------------------------------------------------------------- |
|
231 // |
|
232 TMceMediaNegotiated::TMceAnswererEndState::TMceAnswererEndState( CMceComSession& aSession ) |
|
233 : TMceEndState( aSession ) |
|
234 { |
|
235 SetRole( EMceRoleAnswerer ); |
|
236 } |
|
237 |
|
238 // ----------------------------------------------------------------------------- |
|
239 // TMceMediaNegotiated::TMceAnswererWaitingAnswerState::TMceAnswererWaitingAnswerState |
|
240 // ----------------------------------------------------------------------------- |
|
241 // |
|
242 TMceMediaNegotiated::TMceAnswererWaitingAnswerState::TMceAnswererWaitingAnswerState( |
|
243 CMceComSession& aSession ) |
|
244 : TMceEndState( aSession ) |
|
245 { |
|
246 SetRole( EMceRoleAnswerer ); |
|
247 } |
|
248 |
|
249 |
|
250 |
|
251 // ----------------------------------------------------------------------------- |
|
252 // TMceMediaNegotiated::TMceAnswererWaitingAnswerState::EncodeL |
|
253 // ----------------------------------------------------------------------------- |
|
254 // |
|
255 CSdpDocument* TMceMediaNegotiated::TMceAnswererWaitingAnswerState::EncodeL() |
|
256 { |
|
257 MCEMM_DEBUG("TMceMediaNegotiated::TMceAnswererWaitingAnswerState::EncodeL(), Entry "); |
|
258 |
|
259 CSdpDocument* answer = &iSession.SdpSession().CreateAnswerL( iSession ); |
|
260 |
|
261 TMceMediaNegotiated::TMceAnswererEndState::SetAsCurrentStateL( iSession ); |
|
262 |
|
263 MCEMM_DEBUG("TMceMediaNegotiated::TMceAnswererWaitingAnswerState::EncodeL(), Exit "); |
|
264 |
|
265 return answer; |
|
266 |
|
267 } |
|
268 |
|
269 // ----------------------------------------------------------------------------- |
|
270 // TMceMediaNegotiated::TMceAnswererWaitingAnswerState::EncodeL |
|
271 // ----------------------------------------------------------------------------- |
|
272 // |
|
273 TBool TMceMediaNegotiated::TMceAnswererWaitingAnswerState::NeedToNegotiate( |
|
274 CSdpDocument* /*aSdpDocument*/ ) |
|
275 { |
|
276 MCEMM_DEBUG("TMceMediaNegotiated::TMceAnswererWaitingAnswerState::NeedToNegotiate() "); |
|
277 |
|
278 return ETrue; |
|
279 } |
|
280 |
|
281 |
|
282 // ----------------------------------------------------------------------------- |
|
283 // TMceMediaNegotiated::TMceAnswererEndState::DecodeL |
|
284 // ----------------------------------------------------------------------------- |
|
285 // |
|
286 TMceSipWarningCode TMceMediaNegotiated::TMceAnswererEndState::DecodeL( CSdpDocument& aSdpDocument ) |
|
287 { |
|
288 MCEMM_DEBUG("TMceMediaNegotiated::TMceAnswererEndState::DecodeL(), Entry "); |
|
289 |
|
290 TMceSipWarningCode code = |
|
291 iSession.SdpSession().DecodeOfferL( aSdpDocument, iSession ); |
|
292 |
|
293 MCEMM_DEBUG("TMceMediaNegotiated::TMceAnswererEndState::DecodeL(), Exit "); |
|
294 |
|
295 return code; |
|
296 |
|
297 } |
|
298 |
|
299 // ----------------------------------------------------------------------------- |
|
300 // TMceMediaNegotiated::TMceAnswererEndState::UpdateL |
|
301 // ----------------------------------------------------------------------------- |
|
302 // |
|
303 void TMceMediaNegotiated::TMceAnswererEndState::UpdateL() |
|
304 { |
|
305 MCEMM_DEBUG("TMceMediaNegotiated::TMceAnswererEndState::UpdateL(), Entry "); |
|
306 |
|
307 TMcePreparingAnswererStreams::SetAsCurrentStateL( iSession ); |
|
308 |
|
309 MCEMM_DEBUG("TMceMediaNegotiated::TMceAnswererEndState::UpdateL(), Exit "); |
|
310 } |
|
311 |
|
312 |
|
313 // ----------------------------------------------------------------------------- |
|
314 // TMceMediaNegotiated::SetAsCurrentStateL |
|
315 // ----------------------------------------------------------------------------- |
|
316 // |
|
317 void TMceMediaNegotiated::SetAsCurrentStateL( CMceComSession& aSession, |
|
318 TMceNegotiationRole aRole ) |
|
319 { |
|
320 MCEMM_DEBUG("TMceMediaNegotiated::SetAsCurrentStateL() "); |
|
321 |
|
322 if ( aRole == EMceRoleOfferer ) |
|
323 { |
|
324 TMceMediaNegotiated::TMceEndState::SetAsCurrentStateL( aSession ); |
|
325 } |
|
326 else |
|
327 { |
|
328 TMceMediaNegotiated::TMceAnswererWaitingAnswerState::SetAsCurrentStateL( aSession ); |
|
329 } |
|
330 |
|
331 } |
|
332 |
|
333 // ----------------------------------------------------------------------------- |
|
334 // TMceMediaNegotiated::TMceMediaNegotiated |
|
335 // ----------------------------------------------------------------------------- |
|
336 // |
|
337 TMceMediaNegotiated::TMceMediaNegotiated ( CMceComSession& aSession ) |
|
338 : TMceMediaState( aSession ) |
|
339 { |
|
340 } |
|
341 |
|
342 |
|
343 // ----------------------------------------------------------------------------- |
|
344 // TMceMediaNegotiated::DecodeL |
|
345 // ----------------------------------------------------------------------------- |
|
346 // |
|
347 TMceSipWarningCode TMceMediaNegotiated::DecodeL( CSdpDocument& aSdpDocument ) |
|
348 { |
|
349 |
|
350 MCEMM_DEBUG("TMceMediaNegotiated::DecodeL(), Entry "); |
|
351 |
|
352 SetRole( EMceRoleAnswerer ); |
|
353 |
|
354 TMceSipWarningCode code = |
|
355 iSession.SdpSession().DecodeOfferL( aSdpDocument, iSession ); |
|
356 |
|
357 MCEMM_DEBUG("TMceMediaNegotiated::DecodeL(), Exit "); |
|
358 |
|
359 return code; |
|
360 |
|
361 } |
|
362 |
|
363 |
|
364 // ----------------------------------------------------------------------------- |
|
365 // TMceMediaNegotiated::UpdateL |
|
366 // ----------------------------------------------------------------------------- |
|
367 // |
|
368 void TMceMediaNegotiated::UpdateL() |
|
369 { |
|
370 |
|
371 MCEMM_DEBUG("TMceMediaNegotiated::UpdateL(), Entry "); |
|
372 if ( iRole == EMceRoleOfferer ) |
|
373 { |
|
374 OfferL(); |
|
375 } |
|
376 else |
|
377 { |
|
378 AnswerL(); |
|
379 } |
|
380 MCEMM_DEBUG("TMceMediaNegotiated::UpdateL(), Exit "); |
|
381 } |
|
382 |
|
383 |
|
384 |
|
385 // ----------------------------------------------------------------------------- |
|
386 // TMceMediaNegotiated::OfferL |
|
387 // ----------------------------------------------------------------------------- |
|
388 // |
|
389 |
|
390 void TMceMediaNegotiated::OfferL() |
|
391 { |
|
392 MCEMM_DEBUG("TMceMediaNegotiated::OfferL(), Entry "); |
|
393 |
|
394 // re-create mcc streams structure |
|
395 iSession.PrepareL( iSession.SdpSession().Manager() ); |
|
396 |
|
397 iSession.SdpSession().Manager().PrepareUpdateL( iSession.SdpSession() ); |
|
398 |
|
399 if ( iSession.SdpSession().SignallingRequired() != KMceNoSignalling ) |
|
400 { |
|
401 //prepare all inactive streams for offer |
|
402 TMceSrvStreamIterator streams( iSession.MccStreams() ); |
|
403 CMceSrvStream* stream = NULL; |
|
404 |
|
405 while( streams.Next( stream, CMceSrvStream::EInactive ) ) |
|
406 { |
|
407 iSession.SdpSession().Manager().ValidateMccStreamL( *stream ); |
|
408 MCEMM_DEBUG_STREAM( "TMceMediaNegotiated::OfferL(): \ |
|
409 validated inactive stream", *stream ); |
|
410 } |
|
411 } |
|
412 |
|
413 |
|
414 //set next state, this state will become unusable |
|
415 TMcePreparingOffererStreams::SetAsCurrentStateL( iSession ); |
|
416 |
|
417 MCEMM_DEBUG("TMceMediaNegotiated::OfferL(), Exit "); |
|
418 } |
|
419 |
|
420 |
|
421 // ----------------------------------------------------------------------------- |
|
422 // TMceMediaNegotiated::AnswerL |
|
423 // ----------------------------------------------------------------------------- |
|
424 // |
|
425 /*lint -e666 */ |
|
426 |
|
427 void TMceMediaNegotiated::AnswerL() |
|
428 { |
|
429 MCEMM_DEBUG("TMceMediaNegotiated::AnswerL(), Entry "); |
|
430 |
|
431 //second incoming offer (prack) inside dialog iCodecSelection== |
|
432 // KMceCodecSelectionMerge.In this situation codec is not allowed to |
|
433 //initialize, codec is not updated by mceclient |
|
434 if ( iSession.iCodecSelection != KMceCodecSelectionMerge ) |
|
435 { |
|
436 // create mcc streams structure |
|
437 iSession.PrepareL( iSession.SdpSession().Manager() ); |
|
438 |
|
439 TMceSrvStreamIterator streams( iSession.MccStreams() ); |
|
440 CMceSrvStream* stream = NULL; |
|
441 |
|
442 while( streams.Next( stream ) ) |
|
443 { |
|
444 iSession.SdpSession().Manager().InitializeMccStreamL( *stream ); |
|
445 iSession.SdpSession().Manager().ValidateMccStreamL( *stream ); |
|
446 MCEMM_DEBUG_STREAM( "TMceMediaNegotiated::AnswerL(): \ |
|
447 initialized & validated stream", *stream ); |
|
448 |
|
449 } |
|
450 } |
|
451 //set next state, this state will become unusable |
|
452 TMceAnsweringMediaUpdate::SetAsCurrentStateL( iSession ); |
|
453 |
|
454 |
|
455 MCEMM_DEBUG("TMceMediaNegotiated::AnswerL(), Exit "); |
|
456 } |
|
457 |