16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 |
19 |
20 // USER INCLUDES |
20 // USER INCLUDES |
|
21 |
21 #include "musengreceivesession.h" |
22 #include "musengreceivesession.h" |
|
23 #include "musengsessionobserver.h" |
|
24 #include "musengreceivesessionobserver.h" |
22 #include "musengmceutils.h" |
25 #include "musengmceutils.h" |
23 #include "musenglogger.h" |
26 #include "musenglogger.h" |
|
27 #include "mussettings.h" |
24 #include "mussipprofilehandler.h" |
28 #include "mussipprofilehandler.h" |
25 #include "mussessionproperties.h" |
|
26 #include "musengremotevideoplayer.h" |
|
27 |
29 |
28 // SYSTEM INCLUDES |
30 // SYSTEM INCLUDES |
29 #include <lcsessionobserver.h> |
|
30 #include <mcemanager.h> |
31 #include <mcemanager.h> |
31 #include <mceinsession.h> |
32 #include <mceinsession.h> |
32 #include <mcestreambundle.h> |
33 #include <mcestreambundle.h> |
33 #include <mceaudiostream.h> |
34 #include <mceaudiostream.h> |
34 #include <mcevideostream.h> |
35 #include <mcevideostream.h> |
36 #include <mcertpsource.h> |
37 #include <mcertpsource.h> |
37 #include <mcedisplaysink.h> |
38 #include <mcedisplaysink.h> |
38 #include <mcespeakersink.h> |
39 #include <mcespeakersink.h> |
39 #include <mceaudiocodec.h> |
40 #include <mceaudiocodec.h> |
40 #include <mceavccodec.h> |
41 #include <mceavccodec.h> |
41 #include <e32property.h> |
|
42 |
42 |
43 #include <utf.h> |
43 #include <utf.h> |
|
44 |
|
45 |
|
46 const TUint8 KMusEngRtpKeepAliveTimer = 5; // this should be 30 sec, this a temporary fix |
|
47 const TUint8 KMusEngKeepAlivePayloadTypeVideoH263 = 96; |
|
48 const TUint8 KMusEngKeepAlivePayloadTypeAudio = 97; |
|
49 const TUint8 KMusEngKeepAlivePayloadTypeVideoAvc = 98; |
44 |
50 |
45 const TInt KMusEngJitterBufferLength = 51; //Must be bigger than treshold |
51 const TInt KMusEngJitterBufferLength = 51; //Must be bigger than treshold |
46 // Using following value increases treshold buffer to 1 second from |
52 // Using following value increases treshold buffer to 1 second from |
47 // default 100 ms |
53 // default 100 ms |
48 const TInt KMusEngJitterBufferTreshold = 50; |
54 const TInt KMusEngJitterBufferTreshold = 50; |
49 const TInt KMusEngTresholdToSecondsFactor = 20; |
55 const TInt KMusEngTresholdToSecondsFactor = 20; |
50 const TInt KMusEngTwoSecondInMilliSeconds = 2000; |
56 const TInt KMusEngOneSecondInMilliSeconds = 1000; |
51 // Use inactivity timer value that is a little bigger than treshold in seconds |
57 // Use inactivity timer value that is a little bigger than treshold in seconds |
52 const TUint KMusEngInactivityTimer = KMusEngTresholdToSecondsFactor * |
58 const TUint KMusEngInactivityTimer = KMusEngTresholdToSecondsFactor * |
53 KMusEngJitterBufferTreshold + |
59 KMusEngJitterBufferTreshold + |
54 KMusEngTwoSecondInMilliSeconds; |
60 KMusEngOneSecondInMilliSeconds; |
55 |
61 |
56 _LIT8( KMusEngSwisIdentifier, "Require: precondition" ); |
62 _LIT8( KMusEngSwisIdentifier, "Require: precondition" ); |
57 _LIT8( KMusEngAssertedIdentity, "P-Asserted-Identity" ); |
63 _LIT8( KMusEngAssertedIdentity, "P-Asserted-Identity" ); |
58 _LIT8( KMusEngBiggerSign, ">" ); |
64 _LIT8( KMusEngBiggerSign, ">" ); |
59 |
65 |
62 |
68 |
63 // ----------------------------------------------------------------------------- |
69 // ----------------------------------------------------------------------------- |
64 // |
70 // |
65 // ----------------------------------------------------------------------------- |
71 // ----------------------------------------------------------------------------- |
66 // |
72 // |
67 CMusEngReceiveSession* CMusEngReceiveSession::NewL() |
73 CMusEngReceiveSession::~CMusEngReceiveSession() |
|
74 { |
|
75 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::~CMusEngReceiveSession()" ) |
|
76 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::~CMusEngReceiveSession()" ) |
|
77 } |
|
78 |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 EXPORT_C CMusEngReceiveSession* CMusEngReceiveSession::NewL( |
|
85 const TRect& aRect, |
|
86 MMusEngSessionObserver& aSessionObserver, |
|
87 MMusEngReceiveSessionObserver& aReceiveSessionObserver ) |
68 { |
88 { |
69 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::NewL(...)" ) |
89 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::NewL(...)" ) |
70 |
90 |
71 CMusEngReceiveSession* self = new( ELeave )CMusEngReceiveSession(); |
91 CMusEngReceiveSession* self = new( ELeave ) CMusEngReceiveSession( |
|
92 aSessionObserver, |
|
93 aReceiveSessionObserver, |
|
94 aRect ); |
72 CleanupStack::PushL( self ); |
95 CleanupStack::PushL( self ); |
73 self->ConstructL(); |
96 self->ConstructL(); |
74 CleanupStack::Pop( self ); |
97 CleanupStack::Pop( self ); |
75 |
98 |
76 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::NewL(...)" ) |
99 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::NewL(...)" ) |
77 return self; |
100 return self; |
78 } |
101 } |
79 |
102 |
80 // ----------------------------------------------------------------------------- |
103 |
81 // |
104 // ----------------------------------------------------------------------------- |
82 // ----------------------------------------------------------------------------- |
105 // |
83 // |
106 // ----------------------------------------------------------------------------- |
84 CMusEngReceiveSession::CMusEngReceiveSession() |
107 // |
85 : CMusEngMceSession() |
108 EXPORT_C void CMusEngReceiveSession::AcceptInvitationL( |
86 { |
109 const TBool& aAccept ) |
87 } |
110 { |
88 |
111 MUS_LOG1( "mus: [ENGINE] -> CMusEngReceiveSession::\ |
89 // ----------------------------------------------------------------------------- |
112 AcceptInvitationL( %d )", aAccept ) |
90 // |
113 |
91 // ----------------------------------------------------------------------------- |
114 __ASSERT_ALWAYS( iSession && iSession->State() == CMceSession::EProceeding, |
92 // |
115 User::Leave( KErrNotReady ) ); |
93 void CMusEngReceiveSession::ConstructL() |
116 |
94 { |
117 // Accept or reject |
95 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::ConstructL()" ) |
118 if ( aAccept ) |
96 |
119 { |
97 CMusEngMceSession::ConstructL(); |
120 InSession()->AcceptL(); |
98 |
121 } |
99 iOriginator = HBufC8::NewL( KMaxUriLength ); |
122 else |
100 |
123 { |
101 iRemoteDisplayName = HBufC::NewL( KMaxUriLength ); |
|
102 |
|
103 iRemoteVideoPlayer = CMusEngRemoteVideoPlayer::NewL( *this, *this ); |
|
104 |
|
105 iReceivingInactivityTimeout = KMusEngInactivityTimer; |
|
106 |
|
107 iKeepaliveTimer = KMusEngRtpKeepAliveTimer; |
|
108 |
|
109 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::ConstructL()" ) |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 CMusEngReceiveSession::~CMusEngReceiveSession() |
|
117 { |
|
118 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::~CMusEngReceiveSession()" ) |
|
119 |
|
120 if ( iOriginator ) |
|
121 { |
|
122 TRAP_IGNORE( SaveContactL( *iOriginator ) ) |
|
123 } |
|
124 delete iOriginator; |
|
125 |
|
126 delete iRemoteDisplayName; |
|
127 |
|
128 delete iRemoteVideoPlayer; |
|
129 |
|
130 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::~CMusEngReceiveSession()" ) |
|
131 } |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // From MLcSession |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 MLcSession::TLcSessionState CMusEngReceiveSession::LcSessionState() const |
|
138 { |
|
139 TLcSessionState state = CMusEngMceSession::LcSessionState(); |
|
140 if ( !iSession && state == MLcSession::EUninitialized ) |
|
141 { |
|
142 state = MLcSession::EReceived; |
|
143 } |
|
144 return state; |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // From MLcSession |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 void CMusEngReceiveSession::EstablishLcSessionL() |
|
152 { |
|
153 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::EstablishLcSessionL" ) |
|
154 |
|
155 __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) ); |
|
156 InSession()->AcceptL(); |
|
157 |
|
158 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::EstablishLcSessionL" ) |
|
159 } |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // From MLcSession |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 void CMusEngReceiveSession::TerminateLcSessionL() |
|
166 { |
|
167 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::EstablishLcSessionL" ) |
|
168 |
|
169 __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) ); |
|
170 |
|
171 if ( iSession->State() == CMceSession::EIncoming || |
|
172 iSession->State() == CMceSession::EProceeding ) |
|
173 { |
|
174 // Reject |
|
175 if ( iOperatorVariant ) |
124 if ( iOperatorVariant ) |
176 { |
125 { |
177 // In operator variant, session is rejected with 486 instead of 603. |
126 // In operator variant, session is rejected with 486 instead of 603. |
178 // Also the reason phrase is supposed to be "Busy". |
127 // Also the reason phrase is supposed to be "Busy". |
179 InSession()->RejectL( KMusEngSipReasonPhraseBusy(), |
128 InSession()->RejectL( KMusEngSipReasonPhraseBusy(), |
182 else |
131 else |
183 { |
132 { |
184 InSession()->RejectL(); |
133 InSession()->RejectL(); |
185 } |
134 } |
186 } |
135 } |
187 else |
136 |
188 { |
137 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::\ |
189 iSession->TerminateL(); |
138 AcceptInvitationL(...)" ) |
190 } |
139 } |
191 |
140 |
192 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::EstablishLcSessionL" ) |
|
193 } |
|
194 |
|
195 // ----------------------------------------------------------------------------- |
|
196 // From MLcSession |
|
197 // ----------------------------------------------------------------------------- |
|
198 // |
|
199 MLcVideoPlayer* CMusEngReceiveSession::RemoteVideoPlayer() |
|
200 { |
|
201 return iRemoteVideoPlayer; |
|
202 } |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // From MLcSession |
|
206 // ----------------------------------------------------------------------------- |
|
207 // |
|
208 const TDesC& CMusEngReceiveSession::RemoteDisplayName() |
|
209 { |
|
210 TBuf<RProperty::KMaxPropertySize> buffer; |
|
211 |
|
212 TInt error = RProperty::Get( NMusSessionApi::KCategoryUid, |
|
213 NMusSessionApi::KContactName, |
|
214 buffer ); |
|
215 if ( error == KErrNone && buffer.Length() ) |
|
216 { |
|
217 iRemoteDisplayName->Des().Copy( buffer ); |
|
218 } |
|
219 |
|
220 else if ( iOriginator ) |
|
221 { |
|
222 iRemoteDisplayName->Des().Copy(*iOriginator); |
|
223 } |
|
224 return *iRemoteDisplayName; |
|
225 } |
|
226 |
141 |
227 // ----------------------------------------------------------------------------- |
142 // ----------------------------------------------------------------------------- |
228 // When reserving resources is ready, this function reports observer about |
143 // When reserving resources is ready, this function reports observer about |
229 // incoming session and signals this also to other end terminal ( 180 ringing ). |
144 // incoming session and signals this also to other end terminal ( 180 ringing ). |
230 // ----------------------------------------------------------------------------- |
145 // ----------------------------------------------------------------------------- |
237 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::\ |
152 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::\ |
238 HandleSessionStateChanged()" ) |
153 HandleSessionStateChanged()" ) |
239 |
154 |
240 MUS_ENG_LOG_SESSION_STATE_AND_STATUS( aSession, aStatusCode, aReasonPhrase ) |
155 MUS_ENG_LOG_SESSION_STATE_AND_STATUS( aSession, aStatusCode, aReasonPhrase ) |
241 |
156 |
242 if ( iSession && |
157 if ( iSession && iSession == &aSession && |
243 iSession == &aSession && |
|
244 aSession.State() == CMceSession::EProceeding ) |
158 aSession.State() == CMceSession::EProceeding ) |
245 { |
159 { |
246 // Indicates that resource reservation is ready, user can be notified |
160 // Indicates that resource reservation is ready, user can be notified |
247 // if we do not have to wait for PRACK |
161 // if we do not have to wait for PRACK |
248 |
162 |
249 if ( !iRingLCalled ) |
163 if ( !iRingLCalled ) |
250 { |
164 { |
251 // Notify other end terminal |
165 // Notify other end terminal |
252 TRAP_IGNORE( InSession()->RingL() ) |
166 TRAP_IGNORE( InSession()->RingL() ) |
253 iRingLCalled = ETrue; |
167 iRingLCalled = ETrue; |
254 TPtr8 ptrOriginator( iOriginator->Des() ); |
168 |
255 ptrOriginator.Copy( iSession->Originator() ); |
169 // Notify user |
256 InformObserverAboutSessionStateChange(); |
170 TBuf16<KMaxUriLength> originator; |
|
171 CnvUtfConverter::ConvertToUnicodeFromUtf8( originator, |
|
172 iSession->Originator() ); |
|
173 |
|
174 TBuf16<KMaxUriLength> identity; |
|
175 CnvUtfConverter::ConvertToUnicodeFromUtf8( identity, |
|
176 iIdentity ); |
|
177 iReceiveSessionObserver.IncomingSession( originator, identity ); |
257 } |
178 } |
258 else |
179 else |
259 { |
180 { |
260 MUS_LOG( "mus: [ENGINE] User and remote end already notified." ) |
181 MUS_LOG( "mus: [ENGINE] User and remote end already notified." ) |
261 } |
182 } |
271 |
192 |
272 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::\ |
193 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::\ |
273 HandleSessionStateChanged()" ) |
194 HandleSessionStateChanged()" ) |
274 } |
195 } |
275 |
196 |
|
197 |
276 // ----------------------------------------------------------------------------- |
198 // ----------------------------------------------------------------------------- |
277 // Sets keepalive timer for video and calls base class variant of this function |
199 // Sets keepalive timer for video and calls base class variant of this function |
278 // ----------------------------------------------------------------------------- |
200 // ----------------------------------------------------------------------------- |
279 // |
201 // |
280 void CMusEngReceiveSession::AdjustVideoCodecL( CMceVideoCodec& aVideoCodec, |
202 void CMusEngReceiveSession::AdjustVideoCodecL( CMceVideoCodec& aVideoCodec ) |
281 TMceSourceType aSourceType ) |
|
282 { |
203 { |
283 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::AdjustVideoCodecL()" ) |
204 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::AdjustVideoCodecL()" ) |
284 |
205 |
285 CMusEngMceSession::AdjustVideoCodecL( aVideoCodec, aSourceType ); |
206 CMusEngMceSession::AdjustVideoCodecL( aVideoCodec ); |
286 |
207 |
287 MUS_LOG1( "mus: [ENGINE] Keepalive timer:%d", iKeepaliveTimer ) |
208 aVideoCodec.SetKeepAliveTimerL( KMusEngRtpKeepAliveTimer ); |
288 aVideoCodec.SetKeepAliveTimerL( iKeepaliveTimer ); |
|
289 if ( aVideoCodec.SdpName() == KMceSDPNameH263() || |
209 if ( aVideoCodec.SdpName() == KMceSDPNameH263() || |
290 aVideoCodec.SdpName() == KMceSDPNameH2632000() ) |
210 aVideoCodec.SdpName() == KMceSDPNameH2632000() ) |
291 { |
211 { |
292 aVideoCodec.SetKeepAlivePayloadTypeL( KMusEngKeepAlivePayloadTypeVideoH263 ); |
212 aVideoCodec.SetKeepAlivePayloadTypeL( KMusEngKeepAlivePayloadTypeVideoH263 ); |
293 } |
213 } |
303 aVideoCodec.SetKeepAliveDataL( KNullDesC8() ); |
223 aVideoCodec.SetKeepAliveDataL( KNullDesC8() ); |
304 |
224 |
305 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::AdjustVideoCodecL()" ) |
225 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::AdjustVideoCodecL()" ) |
306 } |
226 } |
307 |
227 |
|
228 |
308 // ----------------------------------------------------------------------------- |
229 // ----------------------------------------------------------------------------- |
309 // Sets keepalive timer for audio and calls base class variant of this function |
230 // Sets keepalive timer for audio and calls base class variant of this function |
310 // ----------------------------------------------------------------------------- |
231 // ----------------------------------------------------------------------------- |
311 // |
232 // |
312 void CMusEngReceiveSession::AdjustAudioCodecL( CMceAudioCodec& aAudioCodec ) |
233 void CMusEngReceiveSession::AdjustAudioCodecL( CMceAudioCodec& aAudioCodec ) |
313 { |
234 { |
314 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::AdjustAudioCodecL()" ) |
235 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::AdjustAudioCodecL()" ) |
315 |
236 |
316 CMusEngMceSession::AdjustAudioCodecL( aAudioCodec ); |
237 CMusEngMceSession::AdjustAudioCodecL( aAudioCodec ); |
317 |
238 |
318 aAudioCodec.SetKeepAliveTimerL( iKeepaliveTimer ); |
239 aAudioCodec.SetKeepAliveTimerL( KMusEngRtpKeepAliveTimer ); |
319 aAudioCodec.SetKeepAlivePayloadTypeL( KMusEngKeepAlivePayloadTypeAudio ); |
240 aAudioCodec.SetKeepAlivePayloadTypeL( KMusEngKeepAlivePayloadTypeAudio ); |
320 aAudioCodec.SetKeepAliveDataL( KNullDesC8() ); |
241 aAudioCodec.SetKeepAliveDataL( KNullDesC8() ); |
321 |
242 |
322 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::AdjustAudioCodecL()" ) |
243 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::AdjustAudioCodecL()" ) |
323 } |
244 } |
324 |
245 |
|
246 |
325 // ----------------------------------------------------------------------------- |
247 // ----------------------------------------------------------------------------- |
326 // |
248 // |
327 // ----------------------------------------------------------------------------- |
249 // ----------------------------------------------------------------------------- |
328 // |
250 // |
329 void CMusEngReceiveSession::DoCodecSelectionL( CMceVideoStream& aVideoStream ) |
251 void CMusEngReceiveSession::DoCodecSelectionL( CMceVideoStream& aVideoStream ) |
398 CMusEngMceSession::DoCodecSelectionL( aVideoStream ); |
321 CMusEngMceSession::DoCodecSelectionL( aVideoStream ); |
399 } |
322 } |
400 |
323 |
401 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::DoCodecSelectionL()" ) |
324 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::DoCodecSelectionL()" ) |
402 } |
325 } |
|
326 |
403 |
327 |
404 // ----------------------------------------------------------------------------- |
328 // ----------------------------------------------------------------------------- |
405 // If incoming session does not have valid structure and cannot be reconstructed |
329 // If incoming session does not have valid structure and cannot be reconstructed |
406 // as such, session is rejected automatically. |
330 // as such, session is rejected automatically. |
407 // ----------------------------------------------------------------------------- |
331 // ----------------------------------------------------------------------------- |
408 // |
332 // |
409 void CMusEngReceiveSession::IncomingSession( |
333 void CMusEngReceiveSession::IncomingSession( |
410 CMceInSession* aSession, |
334 CMceInSession* aSession, |
411 TMceTransactionDataContainer* aContainer ) |
335 TMceTransactionDataContainer* aContainer ) |
412 { |
336 { |
413 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::IncomingSession(...)" ) |
337 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::IncomingSession(...)" ) |
414 |
338 |
415 if ( !aContainer || |
339 if ( !aContainer || |
416 ( iSession && |
340 ( iSession && |
449 } |
375 } |
450 |
376 |
451 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::IncomingSession()" ) |
377 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::IncomingSession()" ) |
452 } |
378 } |
453 |
379 |
|
380 |
454 // ----------------------------------------------------------------------------- |
381 // ----------------------------------------------------------------------------- |
455 // |
382 // |
456 // ----------------------------------------------------------------------------- |
383 // ----------------------------------------------------------------------------- |
457 // |
384 // |
458 void CMusEngReceiveSession::IncomingUpdate( |
385 void CMusEngReceiveSession::IncomingUpdate( |
459 CMceSession& aOrigSession, |
386 CMceSession& aOrigSession, |
460 CMceInSession* aUpdatedSession, |
387 CMceInSession* aUpdatedSession, |
461 TMceTransactionDataContainer* aContainer ) |
388 TMceTransactionDataContainer* aContainer ) |
462 { |
389 { |
463 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::IncomingUpdate(...)" ) |
390 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::IncomingUpdate(...)" ) |
464 |
391 |
465 if ( iSession && |
392 if ( iSession && |
466 iSession == &aOrigSession ) |
393 iSession == &aOrigSession ) |
505 |
433 |
506 if ( aStream.Type() == KMceVideo && |
434 if ( aStream.Type() == KMceVideo && |
507 aStream.Source() && |
435 aStream.Source() && |
508 aStream.Source()->Type() == KMceRTPSource ) |
436 aStream.Source()->Type() == KMceRTPSource ) |
509 { |
437 { |
|
438 |
510 if ( aStream.State() == CMceMediaStream::EBuffering ) |
439 if ( aStream.State() == CMceMediaStream::EBuffering ) |
511 { |
440 { |
512 iBuffered = ETrue; |
441 iReceiveSessionObserver.StreamBuffering(); |
513 InformObserverAboutPlayerStateChange( iRemoteVideoPlayer ); |
|
514 } |
442 } |
515 else if ( aStream.State() == CMceMediaStream::EStreaming ) |
443 else if ( aStream.State() == CMceMediaStream::EStreaming ) |
516 { |
444 { |
517 ReceivingStarted(); |
445 CMceRtpSource* rtpSource = |
|
446 static_cast<CMceRtpSource*>( aStream.Source() ); |
|
447 TRAPD( err , |
|
448 rtpSource->EnableInactivityTimerL( KMusEngInactivityTimer ) ); |
|
449 if ( err != KErrNone ) |
|
450 { |
|
451 MUS_LOG1("mus: [ENGINE] EnableInactivityTimerL Fails %d",err) |
|
452 iSessionObserver.SessionFailed(); |
|
453 } |
|
454 else |
|
455 { |
|
456 iSessionObserver.StreamStreaming(); |
|
457 } |
518 } |
458 } |
519 else |
459 else |
520 { |
460 { |
521 // Cannot handle, forward to CMusEngMceSession |
461 // Cannot handle, forward to CMusEngMceSession |
522 CMusEngMceSession::StreamStateChanged( aStream ); |
462 CMusEngMceSession::StreamStateChanged( aStream ); |
523 } |
463 } |
|
464 |
524 } |
465 } |
525 else |
466 else |
526 { |
467 { |
527 // Cannot handle, forward to CMusEngMceSession |
468 // Cannot handle, forward to CMusEngMceSession |
528 CMusEngMceSession::StreamStateChanged( aStream ); |
469 CMusEngMceSession::StreamStateChanged( aStream ); |
529 } |
470 } |
530 |
471 |
531 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::StreamStateChanged()" ) |
472 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::StreamStateChanged()" ) |
532 } |
473 } |
533 |
474 |
|
475 |
|
476 // ----------------------------------------------------------------------------- |
|
477 // |
|
478 // ----------------------------------------------------------------------------- |
|
479 // |
|
480 CMusEngReceiveSession::CMusEngReceiveSession( |
|
481 MMusEngSessionObserver& aSessionObserver, |
|
482 MMusEngReceiveSessionObserver& aReceiveSessionObserver, |
|
483 const TRect& aRect ) |
|
484 : CMusEngMceSession( aRect, aSessionObserver ), |
|
485 iReceiveSessionObserver( aReceiveSessionObserver ) |
|
486 { |
|
487 } |
|
488 |
|
489 |
|
490 // ----------------------------------------------------------------------------- |
|
491 // |
|
492 // ----------------------------------------------------------------------------- |
|
493 // |
|
494 void CMusEngReceiveSession::ConstructL() |
|
495 { |
|
496 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::ConstructL()" ) |
|
497 |
|
498 CMusEngMceSession::ConstructL(); |
|
499 |
|
500 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::ConstructL()" ) |
|
501 } |
|
502 |
|
503 |
534 // ----------------------------------------------------------------------------- |
504 // ----------------------------------------------------------------------------- |
535 // |
505 // |
536 // ----------------------------------------------------------------------------- |
506 // ----------------------------------------------------------------------------- |
537 // |
507 // |
538 CMceInSession* CMusEngReceiveSession::InSession() |
508 CMceInSession* CMusEngReceiveSession::InSession() |
539 { |
509 { |
540 return static_cast<CMceInSession*>(iSession); |
510 return static_cast<CMceInSession*>(iSession); |
541 } |
511 } |
|
512 |
542 |
513 |
543 // ----------------------------------------------------------------------------- |
514 // ----------------------------------------------------------------------------- |
544 // Check if incoming session is originated from VideoSharing 2.2 client, |
515 // Check if incoming session is originated from VideoSharing 2.2 client, |
545 // which sends PRACK for 180 Ringing whether it is required or not. In |
516 // which sends PRACK for 180 Ringing whether it is required or not. In |
546 // order to let MCE handle the PRACK correctly, force 180 Ringing to be |
517 // order to let MCE handle the PRACK correctly, force 180 Ringing to be |
547 // sent reliably. |
518 // sent reliably. |
548 // ----------------------------------------------------------------------------- |
519 // ----------------------------------------------------------------------------- |
549 // |
520 // |
550 void CMusEngReceiveSession::PrepareToRequire100RelL( |
521 void CMusEngReceiveSession::PrepareToRequire100RelL( |
551 TMceTransactionDataContainer* aContainer) |
522 TMceTransactionDataContainer* aContainer) |
552 { |
523 { |
553 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::PrepareToRequire100RelL()" ) |
524 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::PrepareToRequire100RelL()" ) |
554 |
525 |
555 __ASSERT_ALWAYS( aContainer, User::Leave( KErrArgument ) ); |
526 __ASSERT_ALWAYS( aContainer, User::Leave( KErrArgument ) ); |
556 |
527 |
565 KErrNotFound ) |
536 KErrNotFound ) |
566 { |
537 { |
567 iSession->SetModifierL( KMce100Rel, KMce100RelRequired ); |
538 iSession->SetModifierL( KMce100Rel, KMce100RelRequired ); |
568 MUS_LOG( "mus: [ENGINE] Forced to require 100rel" ) |
539 MUS_LOG( "mus: [ENGINE] Forced to require 100rel" ) |
569 } |
540 } |
570 } |
541 } |
|
542 |
571 } |
543 } |
572 |
544 |
573 CleanupStack::PopAndDestroy( headers ); |
545 CleanupStack::PopAndDestroy( headers ); |
574 |
546 |
575 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::PrepareToRequire100RelL()" ) |
547 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::PrepareToRequire100RelL()" ) |
576 } |
548 } |
|
549 |
577 |
550 |
578 // ----------------------------------------------------------------------------- |
551 // ----------------------------------------------------------------------------- |
579 // Check that incoming session contains only incoming video and audio |
552 // Check that incoming session contains only incoming video and audio |
580 // streams. All the other streams will be removed. If there is no |
553 // streams. All the other streams will be removed. If there is no |
581 // display sinks and speakers, they will be created. |
554 // display sinks and speakers, they will be created. |
780 } |
752 } |
781 |
753 |
782 delete headers; |
754 delete headers; |
783 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::AssertedIdentity()" ) |
755 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::AssertedIdentity()" ) |
784 } |
756 } |
785 |
|
786 // ----------------------------------------------------------------------------- |
|
787 // RTP Inactivity timeout event |
|
788 // Once inactivity timeout occurs, state change is notified and receiving |
|
789 // and buffering statuses are cleared. That is safe to do as once receiving |
|
790 // again continues for real, buffering and streaming events will occur always |
|
791 // sequentially. If buffering status would not be cleared, some unwanted |
|
792 // sreaming events would be passed towards client when it disables/enables |
|
793 // display sink of remote stream while inactivity timer has expired. |
|
794 // ----------------------------------------------------------------------------- |
|
795 // |
|
796 void CMusEngReceiveSession::InactivityTimeout( CMceMediaStream& aStream, |
|
797 CMceRtpSource& /*aSource*/ ) |
|
798 { |
|
799 MUS_LOG( "mus: [ENGINE] -> CMusEngTwoWayRecvSession::InactivityTimeout()" ) |
|
800 |
|
801 if ( aStream.Type() == KMceVideo && iReceiving ) |
|
802 { |
|
803 iReceiving = EFalse; |
|
804 iBuffered = EFalse; |
|
805 InformObserverAboutPlayerStateChange( iRemoteVideoPlayer ); |
|
806 } |
|
807 |
|
808 MUS_LOG( "mus: [ENGINE] <- CMusEngTwoWayRecvSession::InactivityTimeout()" ) |
|
809 } |
|
810 |
|
811 // ----------------------------------------------------------------------------- |
|
812 // |
|
813 // ----------------------------------------------------------------------------- |
|
814 // |
|
815 void CMusEngReceiveSession::ReceivingStarted() |
|
816 { |
|
817 if ( iSession && iBuffered ) |
|
818 { |
|
819 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::ReceivingStarted()" ) |
|
820 |
|
821 TInt err = MusEngMceUtils::EnableInactivityTimer( |
|
822 *iSession, iReceivingInactivityTimeout ); |
|
823 |
|
824 if ( err != KErrNone ) |
|
825 { |
|
826 MUS_LOG1("mus: [ENGINE] ReceivingStarted failed %d", err) |
|
827 InformObserverAboutSessionFailure( err ); |
|
828 } |
|
829 else |
|
830 { |
|
831 iReceiving = ETrue; |
|
832 InformObserverAboutPlayerStateChange( iRemoteVideoPlayer ); |
|
833 InformUiProviderAboutReceivingStart(); |
|
834 } |
|
835 |
|
836 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::ReceivingStarted()" ) |
|
837 } |
|
838 } |
|
839 |
|
840 // ----------------------------------------------------------------------------- |
|
841 // |
|
842 // ----------------------------------------------------------------------------- |
|
843 // |
|
844 TBool CMusEngReceiveSession::IsDisplayActive() |
|
845 { |
|
846 return ( IsDisplayEnabled() && iReceiving ); |
|
847 } |
|
848 // End of File |
|