16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 |
19 |
20 // USER INCLUDES |
20 // USER INCLUDES |
21 |
|
22 #include "musengreceivesession.h" |
21 #include "musengreceivesession.h" |
23 #include "musengsessionobserver.h" |
|
24 #include "musengreceivesessionobserver.h" |
|
25 #include "musengmceutils.h" |
22 #include "musengmceutils.h" |
26 #include "musenglogger.h" |
23 #include "musenglogger.h" |
27 #include "mussettings.h" |
|
28 #include "mussipprofilehandler.h" |
24 #include "mussipprofilehandler.h" |
|
25 #include "mussessionproperties.h" |
|
26 #include "musengremotevideoplayer.h" |
29 |
27 |
30 // SYSTEM INCLUDES |
28 // SYSTEM INCLUDES |
|
29 #include <lcsessionobserver.h> |
31 #include <mcemanager.h> |
30 #include <mcemanager.h> |
32 #include <mceinsession.h> |
31 #include <mceinsession.h> |
33 #include <mcestreambundle.h> |
32 #include <mcestreambundle.h> |
34 #include <mceaudiostream.h> |
33 #include <mceaudiostream.h> |
35 #include <mcevideostream.h> |
34 #include <mcevideostream.h> |
37 #include <mcertpsource.h> |
36 #include <mcertpsource.h> |
38 #include <mcedisplaysink.h> |
37 #include <mcedisplaysink.h> |
39 #include <mcespeakersink.h> |
38 #include <mcespeakersink.h> |
40 #include <mceaudiocodec.h> |
39 #include <mceaudiocodec.h> |
41 #include <mceavccodec.h> |
40 #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; |
|
50 |
44 |
51 const TInt KMusEngJitterBufferLength = 51; //Must be bigger than treshold |
45 const TInt KMusEngJitterBufferLength = 51; //Must be bigger than treshold |
52 // Using following value increases treshold buffer to 1 second from |
46 // Using following value increases treshold buffer to 1 second from |
53 // default 100 ms |
47 // default 100 ms |
54 const TInt KMusEngJitterBufferTreshold = 50; |
48 const TInt KMusEngJitterBufferTreshold = 50; |
55 const TInt KMusEngTresholdToSecondsFactor = 20; |
49 const TInt KMusEngTresholdToSecondsFactor = 20; |
56 const TInt KMusEngOneSecondInMilliSeconds = 1000; |
50 const TInt KMusEngTwoSecondInMilliSeconds = 2000; |
57 // Use inactivity timer value that is a little bigger than treshold in seconds |
51 // Use inactivity timer value that is a little bigger than treshold in seconds |
58 const TUint KMusEngInactivityTimer = KMusEngTresholdToSecondsFactor * |
52 const TUint KMusEngInactivityTimer = KMusEngTresholdToSecondsFactor * |
59 KMusEngJitterBufferTreshold + |
53 KMusEngJitterBufferTreshold + |
60 KMusEngOneSecondInMilliSeconds; |
54 KMusEngTwoSecondInMilliSeconds; |
61 |
55 |
62 _LIT8( KMusEngSwisIdentifier, "Require: precondition" ); |
56 _LIT8( KMusEngSwisIdentifier, "Require: precondition" ); |
63 _LIT8( KMusEngAssertedIdentity, "P-Asserted-Identity" ); |
57 _LIT8( KMusEngAssertedIdentity, "P-Asserted-Identity" ); |
64 _LIT8( KMusEngBiggerSign, ">" ); |
58 _LIT8( KMusEngBiggerSign, ">" ); |
65 |
59 |
68 |
62 |
69 // ----------------------------------------------------------------------------- |
63 // ----------------------------------------------------------------------------- |
70 // |
64 // |
71 // ----------------------------------------------------------------------------- |
65 // ----------------------------------------------------------------------------- |
72 // |
66 // |
73 CMusEngReceiveSession::~CMusEngReceiveSession() |
67 CMusEngReceiveSession* CMusEngReceiveSession::NewL() |
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 ) |
|
88 { |
68 { |
89 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::NewL(...)" ) |
69 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::NewL(...)" ) |
90 |
70 |
91 CMusEngReceiveSession* self = new( ELeave ) CMusEngReceiveSession( |
71 CMusEngReceiveSession* self = new( ELeave )CMusEngReceiveSession(); |
92 aSessionObserver, |
|
93 aReceiveSessionObserver, |
|
94 aRect ); |
|
95 CleanupStack::PushL( self ); |
72 CleanupStack::PushL( self ); |
96 self->ConstructL(); |
73 self->ConstructL(); |
97 CleanupStack::Pop( self ); |
74 CleanupStack::Pop( self ); |
98 |
75 |
99 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::NewL(...)" ) |
76 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::NewL(...)" ) |
100 return self; |
77 return self; |
101 } |
78 } |
102 |
79 |
103 |
80 // ----------------------------------------------------------------------------- |
104 // ----------------------------------------------------------------------------- |
81 // |
105 // |
82 // ----------------------------------------------------------------------------- |
106 // ----------------------------------------------------------------------------- |
83 // |
107 // |
84 CMusEngReceiveSession::CMusEngReceiveSession() |
108 EXPORT_C void CMusEngReceiveSession::AcceptInvitationL( |
85 : CMusEngMceSession() |
109 const TBool& aAccept ) |
86 { |
110 { |
87 } |
111 MUS_LOG1( "mus: [ENGINE] -> CMusEngReceiveSession::\ |
88 |
112 AcceptInvitationL( %d )", aAccept ) |
89 // ----------------------------------------------------------------------------- |
113 |
90 // |
114 __ASSERT_ALWAYS( iSession && iSession->State() == CMceSession::EProceeding, |
91 // ----------------------------------------------------------------------------- |
115 User::Leave( KErrNotReady ) ); |
92 // |
116 |
93 void CMusEngReceiveSession::ConstructL() |
117 // Accept or reject |
94 { |
118 if ( aAccept ) |
95 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::ConstructL()" ) |
119 { |
96 |
120 InSession()->AcceptL(); |
97 CMusEngMceSession::ConstructL(); |
121 } |
98 |
122 else |
99 iOriginator = HBufC8::NewL( KMaxUriLength ); |
123 { |
100 |
|
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 |
124 if ( iOperatorVariant ) |
175 if ( iOperatorVariant ) |
125 { |
176 { |
126 // In operator variant, session is rejected with 486 instead of 603. |
177 // In operator variant, session is rejected with 486 instead of 603. |
127 // Also the reason phrase is supposed to be "Busy". |
178 // Also the reason phrase is supposed to be "Busy". |
128 InSession()->RejectL( KMusEngSipReasonPhraseBusy(), |
179 InSession()->RejectL( KMusEngSipReasonPhraseBusy(), |
131 else |
182 else |
132 { |
183 { |
133 InSession()->RejectL(); |
184 InSession()->RejectL(); |
134 } |
185 } |
135 } |
186 } |
136 |
187 else |
137 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::\ |
188 { |
138 AcceptInvitationL(...)" ) |
189 iSession->TerminateL(); |
139 } |
190 } |
140 |
191 |
|
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 } |
141 |
226 |
142 // ----------------------------------------------------------------------------- |
227 // ----------------------------------------------------------------------------- |
143 // When reserving resources is ready, this function reports observer about |
228 // When reserving resources is ready, this function reports observer about |
144 // incoming session and signals this also to other end terminal ( 180 ringing ). |
229 // incoming session and signals this also to other end terminal ( 180 ringing ). |
145 // ----------------------------------------------------------------------------- |
230 // ----------------------------------------------------------------------------- |
152 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::\ |
237 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::\ |
153 HandleSessionStateChanged()" ) |
238 HandleSessionStateChanged()" ) |
154 |
239 |
155 MUS_ENG_LOG_SESSION_STATE_AND_STATUS( aSession, aStatusCode, aReasonPhrase ) |
240 MUS_ENG_LOG_SESSION_STATE_AND_STATUS( aSession, aStatusCode, aReasonPhrase ) |
156 |
241 |
157 if ( iSession && iSession == &aSession && |
242 if ( iSession && |
|
243 iSession == &aSession && |
158 aSession.State() == CMceSession::EProceeding ) |
244 aSession.State() == CMceSession::EProceeding ) |
159 { |
245 { |
160 // Indicates that resource reservation is ready, user can be notified |
246 // Indicates that resource reservation is ready, user can be notified |
161 // if we do not have to wait for PRACK |
247 // if we do not have to wait for PRACK |
162 |
248 |
163 if ( !iRingLCalled ) |
249 if ( !iRingLCalled ) |
164 { |
250 { |
165 // Notify other end terminal |
251 // Notify other end terminal |
166 TRAP_IGNORE( InSession()->RingL() ) |
252 TRAP_IGNORE( InSession()->RingL() ) |
167 iRingLCalled = ETrue; |
253 iRingLCalled = ETrue; |
168 |
254 TPtr8 ptrOriginator( iOriginator->Des() ); |
169 // Notify user |
255 ptrOriginator.Copy( iSession->Originator() ); |
170 TBuf16<KMaxUriLength> originator; |
256 InformObserverAboutSessionStateChange(); |
171 CnvUtfConverter::ConvertToUnicodeFromUtf8( originator, |
|
172 iSession->Originator() ); |
|
173 |
|
174 TBuf16<KMaxUriLength> identity; |
|
175 CnvUtfConverter::ConvertToUnicodeFromUtf8( identity, |
|
176 iIdentity ); |
|
177 iReceiveSessionObserver.IncomingSession( originator, identity ); |
|
178 } |
257 } |
179 else |
258 else |
180 { |
259 { |
181 MUS_LOG( "mus: [ENGINE] User and remote end already notified." ) |
260 MUS_LOG( "mus: [ENGINE] User and remote end already notified." ) |
182 } |
261 } |
192 |
271 |
193 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::\ |
272 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::\ |
194 HandleSessionStateChanged()" ) |
273 HandleSessionStateChanged()" ) |
195 } |
274 } |
196 |
275 |
197 |
|
198 // ----------------------------------------------------------------------------- |
276 // ----------------------------------------------------------------------------- |
199 // Sets keepalive timer for video and calls base class variant of this function |
277 // Sets keepalive timer for video and calls base class variant of this function |
200 // ----------------------------------------------------------------------------- |
278 // ----------------------------------------------------------------------------- |
201 // |
279 // |
202 void CMusEngReceiveSession::AdjustVideoCodecL( CMceVideoCodec& aVideoCodec ) |
280 void CMusEngReceiveSession::AdjustVideoCodecL( CMceVideoCodec& aVideoCodec, |
|
281 TMceSourceType aSourceType ) |
203 { |
282 { |
204 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::AdjustVideoCodecL()" ) |
283 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::AdjustVideoCodecL()" ) |
205 |
284 |
206 CMusEngMceSession::AdjustVideoCodecL( aVideoCodec ); |
285 CMusEngMceSession::AdjustVideoCodecL( aVideoCodec, aSourceType ); |
207 |
286 |
208 aVideoCodec.SetKeepAliveTimerL( KMusEngRtpKeepAliveTimer ); |
287 MUS_LOG1( "mus: [ENGINE] Keepalive timer:%d", iKeepaliveTimer ) |
|
288 aVideoCodec.SetKeepAliveTimerL( iKeepaliveTimer ); |
209 if ( aVideoCodec.SdpName() == KMceSDPNameH263() || |
289 if ( aVideoCodec.SdpName() == KMceSDPNameH263() || |
210 aVideoCodec.SdpName() == KMceSDPNameH2632000() ) |
290 aVideoCodec.SdpName() == KMceSDPNameH2632000() ) |
211 { |
291 { |
212 aVideoCodec.SetKeepAlivePayloadTypeL( KMusEngKeepAlivePayloadTypeVideoH263 ); |
292 aVideoCodec.SetKeepAlivePayloadTypeL( KMusEngKeepAlivePayloadTypeVideoH263 ); |
213 } |
293 } |
223 aVideoCodec.SetKeepAliveDataL( KNullDesC8() ); |
303 aVideoCodec.SetKeepAliveDataL( KNullDesC8() ); |
224 |
304 |
225 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::AdjustVideoCodecL()" ) |
305 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::AdjustVideoCodecL()" ) |
226 } |
306 } |
227 |
307 |
228 |
|
229 // ----------------------------------------------------------------------------- |
308 // ----------------------------------------------------------------------------- |
230 // Sets keepalive timer for audio and calls base class variant of this function |
309 // Sets keepalive timer for audio and calls base class variant of this function |
231 // ----------------------------------------------------------------------------- |
310 // ----------------------------------------------------------------------------- |
232 // |
311 // |
233 void CMusEngReceiveSession::AdjustAudioCodecL( CMceAudioCodec& aAudioCodec ) |
312 void CMusEngReceiveSession::AdjustAudioCodecL( CMceAudioCodec& aAudioCodec ) |
234 { |
313 { |
235 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::AdjustAudioCodecL()" ) |
314 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::AdjustAudioCodecL()" ) |
236 |
315 |
237 CMusEngMceSession::AdjustAudioCodecL( aAudioCodec ); |
316 CMusEngMceSession::AdjustAudioCodecL( aAudioCodec ); |
238 |
317 |
239 aAudioCodec.SetKeepAliveTimerL( KMusEngRtpKeepAliveTimer ); |
318 aAudioCodec.SetKeepAliveTimerL( iKeepaliveTimer ); |
240 aAudioCodec.SetKeepAlivePayloadTypeL( KMusEngKeepAlivePayloadTypeAudio ); |
319 aAudioCodec.SetKeepAlivePayloadTypeL( KMusEngKeepAlivePayloadTypeAudio ); |
241 aAudioCodec.SetKeepAliveDataL( KNullDesC8() ); |
320 aAudioCodec.SetKeepAliveDataL( KNullDesC8() ); |
242 |
321 |
243 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::AdjustAudioCodecL()" ) |
322 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::AdjustAudioCodecL()" ) |
244 } |
323 } |
245 |
324 |
246 |
|
247 // ----------------------------------------------------------------------------- |
325 // ----------------------------------------------------------------------------- |
248 // |
326 // |
249 // ----------------------------------------------------------------------------- |
327 // ----------------------------------------------------------------------------- |
250 // |
328 // |
251 void CMusEngReceiveSession::DoCodecSelectionL( CMceVideoStream& aVideoStream ) |
329 void CMusEngReceiveSession::DoCodecSelectionL( CMceVideoStream& aVideoStream ) |
321 CMusEngMceSession::DoCodecSelectionL( aVideoStream ); |
398 CMusEngMceSession::DoCodecSelectionL( aVideoStream ); |
322 } |
399 } |
323 |
400 |
324 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::DoCodecSelectionL()" ) |
401 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::DoCodecSelectionL()" ) |
325 } |
402 } |
326 |
|
327 |
403 |
328 // ----------------------------------------------------------------------------- |
404 // ----------------------------------------------------------------------------- |
329 // If incoming session does not have valid structure and cannot be reconstructed |
405 // If incoming session does not have valid structure and cannot be reconstructed |
330 // as such, session is rejected automatically. |
406 // as such, session is rejected automatically. |
331 // ----------------------------------------------------------------------------- |
407 // ----------------------------------------------------------------------------- |
332 // |
408 // |
333 void CMusEngReceiveSession::IncomingSession( |
409 void CMusEngReceiveSession::IncomingSession( |
334 CMceInSession* aSession, |
410 CMceInSession* aSession, |
335 TMceTransactionDataContainer* aContainer ) |
411 TMceTransactionDataContainer* aContainer ) |
336 { |
412 { |
337 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::IncomingSession(...)" ) |
413 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::IncomingSession(...)" ) |
338 |
414 |
339 if ( !aContainer || |
415 if ( !aContainer || |
340 ( iSession && |
416 ( iSession && |
375 } |
449 } |
376 |
450 |
377 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::IncomingSession()" ) |
451 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::IncomingSession()" ) |
378 } |
452 } |
379 |
453 |
380 |
|
381 // ----------------------------------------------------------------------------- |
454 // ----------------------------------------------------------------------------- |
382 // |
455 // |
383 // ----------------------------------------------------------------------------- |
456 // ----------------------------------------------------------------------------- |
384 // |
457 // |
385 void CMusEngReceiveSession::IncomingUpdate( |
458 void CMusEngReceiveSession::IncomingUpdate( |
386 CMceSession& aOrigSession, |
459 CMceSession& aOrigSession, |
387 CMceInSession* aUpdatedSession, |
460 CMceInSession* aUpdatedSession, |
388 TMceTransactionDataContainer* aContainer ) |
461 TMceTransactionDataContainer* aContainer ) |
389 { |
462 { |
390 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::IncomingUpdate(...)" ) |
463 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::IncomingUpdate(...)" ) |
391 |
464 |
392 if ( iSession && |
465 if ( iSession && |
393 iSession == &aOrigSession ) |
466 iSession == &aOrigSession ) |
433 |
505 |
434 if ( aStream.Type() == KMceVideo && |
506 if ( aStream.Type() == KMceVideo && |
435 aStream.Source() && |
507 aStream.Source() && |
436 aStream.Source()->Type() == KMceRTPSource ) |
508 aStream.Source()->Type() == KMceRTPSource ) |
437 { |
509 { |
438 |
|
439 if ( aStream.State() == CMceMediaStream::EBuffering ) |
510 if ( aStream.State() == CMceMediaStream::EBuffering ) |
440 { |
511 { |
441 iReceiveSessionObserver.StreamBuffering(); |
512 iBuffered = ETrue; |
|
513 InformObserverAboutPlayerStateChange( iRemoteVideoPlayer ); |
442 } |
514 } |
443 else if ( aStream.State() == CMceMediaStream::EStreaming ) |
515 else if ( aStream.State() == CMceMediaStream::EStreaming ) |
444 { |
516 { |
445 CMceRtpSource* rtpSource = |
517 ReceivingStarted(); |
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 } |
|
458 } |
518 } |
459 else |
519 else |
460 { |
520 { |
461 // Cannot handle, forward to CMusEngMceSession |
521 // Cannot handle, forward to CMusEngMceSession |
462 CMusEngMceSession::StreamStateChanged( aStream ); |
522 CMusEngMceSession::StreamStateChanged( aStream ); |
463 } |
523 } |
464 |
|
465 } |
524 } |
466 else |
525 else |
467 { |
526 { |
468 // Cannot handle, forward to CMusEngMceSession |
527 // Cannot handle, forward to CMusEngMceSession |
469 CMusEngMceSession::StreamStateChanged( aStream ); |
528 CMusEngMceSession::StreamStateChanged( aStream ); |
470 } |
529 } |
471 |
530 |
472 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::StreamStateChanged()" ) |
531 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::StreamStateChanged()" ) |
473 } |
532 } |
474 |
533 |
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 |
|
504 // ----------------------------------------------------------------------------- |
534 // ----------------------------------------------------------------------------- |
505 // |
535 // |
506 // ----------------------------------------------------------------------------- |
536 // ----------------------------------------------------------------------------- |
507 // |
537 // |
508 CMceInSession* CMusEngReceiveSession::InSession() |
538 CMceInSession* CMusEngReceiveSession::InSession() |
509 { |
539 { |
510 return static_cast<CMceInSession*>(iSession); |
540 return static_cast<CMceInSession*>(iSession); |
511 } |
541 } |
512 |
|
513 |
542 |
514 // ----------------------------------------------------------------------------- |
543 // ----------------------------------------------------------------------------- |
515 // Check if incoming session is originated from VideoSharing 2.2 client, |
544 // Check if incoming session is originated from VideoSharing 2.2 client, |
516 // which sends PRACK for 180 Ringing whether it is required or not. In |
545 // which sends PRACK for 180 Ringing whether it is required or not. In |
517 // order to let MCE handle the PRACK correctly, force 180 Ringing to be |
546 // order to let MCE handle the PRACK correctly, force 180 Ringing to be |
518 // sent reliably. |
547 // sent reliably. |
519 // ----------------------------------------------------------------------------- |
548 // ----------------------------------------------------------------------------- |
520 // |
549 // |
521 void CMusEngReceiveSession::PrepareToRequire100RelL( |
550 void CMusEngReceiveSession::PrepareToRequire100RelL( |
522 TMceTransactionDataContainer* aContainer) |
551 TMceTransactionDataContainer* aContainer) |
523 { |
552 { |
524 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::PrepareToRequire100RelL()" ) |
553 MUS_LOG( "mus: [ENGINE] -> CMusEngReceiveSession::PrepareToRequire100RelL()" ) |
525 |
554 |
526 __ASSERT_ALWAYS( aContainer, User::Leave( KErrArgument ) ); |
555 __ASSERT_ALWAYS( aContainer, User::Leave( KErrArgument ) ); |
527 |
556 |
536 KErrNotFound ) |
565 KErrNotFound ) |
537 { |
566 { |
538 iSession->SetModifierL( KMce100Rel, KMce100RelRequired ); |
567 iSession->SetModifierL( KMce100Rel, KMce100RelRequired ); |
539 MUS_LOG( "mus: [ENGINE] Forced to require 100rel" ) |
568 MUS_LOG( "mus: [ENGINE] Forced to require 100rel" ) |
540 } |
569 } |
541 } |
570 } |
542 |
|
543 } |
571 } |
544 |
572 |
545 CleanupStack::PopAndDestroy( headers ); |
573 CleanupStack::PopAndDestroy( headers ); |
546 |
574 |
547 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::PrepareToRequire100RelL()" ) |
575 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::PrepareToRequire100RelL()" ) |
548 } |
576 } |
549 |
|
550 |
577 |
551 // ----------------------------------------------------------------------------- |
578 // ----------------------------------------------------------------------------- |
552 // Check that incoming session contains only incoming video and audio |
579 // Check that incoming session contains only incoming video and audio |
553 // streams. All the other streams will be removed. If there is no |
580 // streams. All the other streams will be removed. If there is no |
554 // display sinks and speakers, they will be created. |
581 // display sinks and speakers, they will be created. |
752 } |
780 } |
753 |
781 |
754 delete headers; |
782 delete headers; |
755 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::AssertedIdentity()" ) |
783 MUS_LOG( "mus: [ENGINE] <- CMusEngReceiveSession::AssertedIdentity()" ) |
756 } |
784 } |
|
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 |