|
1 /* |
|
2 * Copyright (c) 2006 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: Connection multiplexer is responsible for handling network |
|
15 * connections, send and receive data from the |
|
16 * network and allow client to start media flow between |
|
17 * connection multiplexer and socket media connection wrapper. |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 #include <in_sock.h> |
|
25 #include <es_sock.h> |
|
26 |
|
27 #include "cncmconnectionmultiplexer.h" |
|
28 #include "mncmconnectionmultiplexerobserver.h" |
|
29 #include "cncmmediasource.h" |
|
30 #include "ncmconnectionmultiplexerlogs.h" |
|
31 #include "cncmsession.h" |
|
32 #include "cncmstream.h" |
|
33 #include "cncmconnection.h" |
|
34 //#include "natfwmediawrapper.h" |
|
35 |
|
36 const TUint KFirstSessionId = 1; |
|
37 |
|
38 //Media connection is allways the first one |
|
39 const TUint KMediaConnection = 1; |
|
40 |
|
41 const TUint KDefaultProtocolSource = 0; |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // CNcmConnectionMultiplexer::CNcmConnectionMultiplexer |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 CNcmConnectionMultiplexer::CNcmConnectionMultiplexer( |
|
48 MNcmConnectionMultiplexerObserver& aObserver ) : |
|
49 iObserver( aObserver ), iNextSessionId( KFirstSessionId ) |
|
50 { |
|
51 } |
|
52 |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // CNcmConnectionMultiplexer::NewL |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 EXPORT_C CNcmConnectionMultiplexer* CNcmConnectionMultiplexer::NewL( |
|
59 MNcmConnectionMultiplexerObserver& aObserver ) |
|
60 { |
|
61 __CONNECTIONMULTIPLEXER( "CNcmConnectionMultiplexer::NewL" ) |
|
62 |
|
63 CNcmConnectionMultiplexer* self = |
|
64 new (ELeave) CNcmConnectionMultiplexer( aObserver ); |
|
65 |
|
66 return self; |
|
67 } |
|
68 |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // CNcmConnectionMultiplexer::~CNcmConnectionMultiplexer |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 CNcmConnectionMultiplexer::~CNcmConnectionMultiplexer() |
|
75 { |
|
76 __CONNECTIONMULTIPLEXER( |
|
77 "CNcmConnectionMultiplexer::~CNcmConnectionMultiplexer" ) |
|
78 |
|
79 iSessions.ResetAndDestroy(); |
|
80 } |
|
81 |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // CNcmConnectionMultiplexer::CreateSessionL |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 EXPORT_C TUint CNcmConnectionMultiplexer::CreateSessionL( TUint32 aIapId, |
|
88 TUint aPortRangeStart, TUint aPortRangeStop ) |
|
89 { |
|
90 |
|
91 CNcmSession* session = |
|
92 CNcmSession::NewLC( iNextSessionId, aIapId, |
|
93 aPortRangeStart, aPortRangeStop, iObserver, *this ); |
|
94 |
|
95 iSessions.AppendL( session ); |
|
96 CleanupStack::Pop( session ); |
|
97 |
|
98 iNextSessionId++; |
|
99 |
|
100 return session->SessionId(); |
|
101 } |
|
102 |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // CNcmConnectionMultiplexer::CreateStreamL |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 EXPORT_C TUint CNcmConnectionMultiplexer::CreateStreamL( TUint aSessionId, |
|
109 TInt aQos, TUint aProtocol ) |
|
110 { |
|
111 __CONNECTIONMULTIPLEXER( "CNcmConnectionMultiplexer::CreateStreamL" ) |
|
112 |
|
113 CNcmSession* session( SessionByIdL( aSessionId ) ); |
|
114 |
|
115 //__ASSERT_ALWAYS( session->Initialized(), User::Leave( KErrNotReady ) ); |
|
116 |
|
117 /* TUint streamId( session->CreateStreamL( aQos, aProtocol ) ); |
|
118 |
|
119 TInetAddr localAddr( session->LocalIPv4Address() ); |
|
120 localAddr.SetPort( session->LocalIPv4Address().Port() ); |
|
121 |
|
122 //StreamByIdL( streamId )->SetLocalAddr( localAddr ); |
|
123 |
|
124 //Create a default connection for stream |
|
125 //CreateDefaultConnectionL( streamId, aProtocol ); |
|
126 |
|
127 return streamId;*/ |
|
128 return ( session->CreateStreamL( aQos, aProtocol ) ); |
|
129 } |
|
130 |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // CNcmConnectionMultiplexer::GetStreamInfoL |
|
134 // --------------------------------------------------------------------------- |
|
135 // |
|
136 EXPORT_C void CNcmConnectionMultiplexer::GetStreamInfoL( |
|
137 TUint /*aStreamId*/, TUint32& /*aIapId*/, TInt& /*aQos*/, |
|
138 TUint& /*aProtocol*/ ) |
|
139 { |
|
140 __CONNECTIONMULTIPLEXER( "CNcmConnectionMultiplexer::GetStreamInfoL" ) |
|
141 /* |
|
142 CNATFWMultiplexerStream* stream( StreamByIdL( aStreamId ) ); |
|
143 |
|
144 aIapId = SessionByStreamIdL( aStreamId )->IapId(); |
|
145 aQos = stream->Qos(); |
|
146 aProtocol = stream->StreamProtocol();*/ |
|
147 } |
|
148 |
|
149 |
|
150 // --------------------------------------------------------------------------- |
|
151 // CNcmConnectionMultiplexer::LocalIPAddressL |
|
152 // --------------------------------------------------------------------------- |
|
153 // |
|
154 EXPORT_C TInetAddr& CNcmConnectionMultiplexer::LocalIPAddressL( |
|
155 TUint aStreamId, TUint aConnectionId ) |
|
156 { |
|
157 return StreamByIdL( aStreamId )-> |
|
158 ConnectionL( aConnectionId )->LocalAddress(); |
|
159 } |
|
160 |
|
161 |
|
162 // --------------------------------------------------------------------------- |
|
163 // CNcmConnectionMultiplexer::GetSessionInfoL |
|
164 // --------------------------------------------------------------------------- |
|
165 // |
|
166 EXPORT_C RSocketServ* CNcmConnectionMultiplexer::GetSessionInfoL( |
|
167 TUint aSessionId, TName& aConnectionName ) |
|
168 { |
|
169 __CONNECTIONMULTIPLEXER( "CNcmConnectionMultiplexer::GetSessionInfoL" ) |
|
170 |
|
171 CNcmSession* session( SessionByIdL( aSessionId ) ); |
|
172 |
|
173 User::LeaveIfError( session->GetConnectionName( aConnectionName ) ); |
|
174 |
|
175 return &session->SocketServer(); |
|
176 } |
|
177 |
|
178 |
|
179 // --------------------------------------------------------------------------- |
|
180 // CNcmConnectionMultiplexer::CreateConnectionL |
|
181 // --------------------------------------------------------------------------- |
|
182 // |
|
183 EXPORT_C TUint CNcmConnectionMultiplexer::CreateConnectionL( |
|
184 TUint aStreamId, TUint /*aAddrFamily*/ ) |
|
185 { |
|
186 __CONNECTIONMULTIPLEXER( |
|
187 "CNcmConnectionMultiplexer::CreateConnectionL" ) |
|
188 |
|
189 CNcmStream* stream( StreamByIdL( aStreamId ) ); |
|
190 CNcmSession* session( SessionByStreamIdL( aStreamId ) ); |
|
191 |
|
192 TInetAddr addr( KInetAddrNone, 0 ); |
|
193 |
|
194 // Create Connection |
|
195 return stream->CreateConnectionL( |
|
196 *this, stream->ConnectionObserverHandler(), |
|
197 session->SocketServer(), |
|
198 session->Connection(), addr, EFalse ); |
|
199 |
|
200 // return 2; |
|
201 } |
|
202 |
|
203 |
|
204 // --------------------------------------------------------------------------- |
|
205 // CNcmConnectionMultiplexer::CreateConnectionL |
|
206 // --------------------------------------------------------------------------- |
|
207 // |
|
208 EXPORT_C TUint CNcmConnectionMultiplexer::CreateConnectionL( |
|
209 TUint aStreamId, const TInetAddr& /*aLocalAddr*/ ) |
|
210 { |
|
211 CNcmStream* stream( StreamByIdL( aStreamId ) ); |
|
212 CNcmSession* session( SessionByStreamIdL( aStreamId ) ); |
|
213 |
|
214 TInetAddr addr( KInetAddrNone, 0 ); |
|
215 |
|
216 // Create Connection |
|
217 return stream->CreateConnectionL( |
|
218 *this, stream->ConnectionObserverHandler(), |
|
219 session->SocketServer(), |
|
220 session->Connection(), addr, ETrue ); |
|
221 |
|
222 // return 2; |
|
223 } |
|
224 |
|
225 |
|
226 // --------------------------------------------------------------------------- |
|
227 // CNcmConnectionMultiplexer::OpenTcpConnectionL |
|
228 // --------------------------------------------------------------------------- |
|
229 // |
|
230 EXPORT_C void CNcmConnectionMultiplexer::OpenTcpConnectionL( |
|
231 TUint /*aStreamId*/, TUint /*aConnectionId*/, |
|
232 TNATFWTcpConnectionSetup /*aConfig*/, const TInetAddr& /*aDestAddr*/ ) |
|
233 { |
|
234 __CONNECTIONMULTIPLEXER( |
|
235 "CNcmConnectionMultiplexer::OpenTcpConnectionL" ) |
|
236 } |
|
237 |
|
238 |
|
239 // --------------------------------------------------------------------------- |
|
240 // CNcmConnectionMultiplexer::CancelTcpConnectionSetupL |
|
241 // --------------------------------------------------------------------------- |
|
242 // |
|
243 EXPORT_C void CNcmConnectionMultiplexer::CloseTcpConnection( |
|
244 TUint /*aStreamId*/, TUint /*aConnectionId*/ ) |
|
245 { |
|
246 __CONNECTIONMULTIPLEXER( |
|
247 "CNcmConnectionMultiplexer::CloseTcpConnectionSetup" ) |
|
248 } |
|
249 |
|
250 |
|
251 // --------------------------------------------------------------------------- |
|
252 // CNcmConnectionMultiplexer::RemoveSessionL |
|
253 // --------------------------------------------------------------------------- |
|
254 // |
|
255 EXPORT_C void CNcmConnectionMultiplexer::RemoveSessionL( TUint aSessionId ) |
|
256 { |
|
257 __CONNECTIONMULTIPLEXER( "CNcmConnectionMultiplexer::RemoveSessionL" ) |
|
258 |
|
259 TInt sessionCount( iSessions.Count() ); |
|
260 |
|
261 for ( TInt i = 0; i < sessionCount; i++ ) |
|
262 { |
|
263 if ( iSessions[i]->SessionId() == aSessionId ) |
|
264 { |
|
265 delete iSessions[i]; |
|
266 iSessions.Remove( i ); |
|
267 return; |
|
268 } |
|
269 } |
|
270 User::Leave( KErrNotFound ); |
|
271 } |
|
272 |
|
273 // --------------------------------------------------------------------------- |
|
274 // CNcmConnectionMultiplexer::RemoveStreamL |
|
275 // --------------------------------------------------------------------------- |
|
276 // |
|
277 EXPORT_C void CNcmConnectionMultiplexer::RemoveStreamL( TUint aStreamId ) |
|
278 { |
|
279 __CONNECTIONMULTIPLEXER( "CNcmConnectionMultiplexer::RemoveStreamL" ) |
|
280 |
|
281 CNcmSession* session( SessionByStreamIdL( aStreamId ) ); |
|
282 |
|
283 session->RemoveStreamL( aStreamId ); |
|
284 } |
|
285 |
|
286 |
|
287 // --------------------------------------------------------------------------- |
|
288 // CNcmConnectionMultiplexer::RemoveConnectionL |
|
289 // --------------------------------------------------------------------------- |
|
290 // |
|
291 EXPORT_C void CNcmConnectionMultiplexer::RemoveConnectionL( |
|
292 TUint /*aStreamId*/, TUint /*aConnectionId*/ ) |
|
293 { |
|
294 __CONNECTIONMULTIPLEXER( "CNcmConnectionMultiplexer::RemoveConnectionL" ) |
|
295 |
|
296 /* CNATFWMultiplexerStream* stream( StreamByIdL( aStreamId ) ); |
|
297 |
|
298 if ( KMediaConnection == aConnectionId ) |
|
299 { |
|
300 //Default media stream can't be deleted. |
|
301 User::Leave( KErrPermissionDenied ); |
|
302 } |
|
303 |
|
304 stream->RemoveConnectionL( aConnectionId ); */ |
|
305 } |
|
306 |
|
307 |
|
308 // --------------------------------------------------------------------------- |
|
309 // CNcmConnectionMultiplexer::RegisterIncomingConnectionObserverL |
|
310 // --------------------------------------------------------------------------- |
|
311 // |
|
312 EXPORT_C void CNcmConnectionMultiplexer:: |
|
313 RegisterIncomingConnectionObserverL( TUint /*aStreamId*/, |
|
314 MNcmIncomingConnectionObserver& /*aObserver*/ ) |
|
315 { |
|
316 __CONNECTIONMULTIPLEXER( |
|
317 "CNcmConnectionMultiplexer::RegisterIncomingConnectionObserver" ) |
|
318 /* |
|
319 StreamByIdL( aStreamId )-> |
|
320 ConnectionObserverHandler(). |
|
321 RegisterIncomingConnectionObserverL( aObserver );*/ |
|
322 } |
|
323 |
|
324 |
|
325 // --------------------------------------------------------------------------- |
|
326 // CNcmConnectionMultiplexer::RegisterOutgoingConnectionObserverL |
|
327 // --------------------------------------------------------------------------- |
|
328 // |
|
329 EXPORT_C void CNcmConnectionMultiplexer:: |
|
330 RegisterOutgoingConnectionObserverL( |
|
331 TUint /*aStreamId*/, MNcmOutgoingConnectionObserver& /*aObserver*/ ) |
|
332 { |
|
333 __CONNECTIONMULTIPLEXER( |
|
334 "CNcmConnectionMultiplexer::RegisterOutgoingConnectionObserver" ) |
|
335 /* |
|
336 StreamByIdL( aStreamId )-> |
|
337 ConnectionObserverHandler(). |
|
338 RegisterOutgoingConnectionObserverL( aObserver );*/ |
|
339 } |
|
340 |
|
341 |
|
342 // --------------------------------------------------------------------------- |
|
343 // CNcmConnectionMultiplexer::RegisterMessageObserverL |
|
344 // --------------------------------------------------------------------------- |
|
345 // |
|
346 EXPORT_C void CNcmConnectionMultiplexer::RegisterMessageObserverL( |
|
347 TUint /*aStreamId*/, MNcmMessageObserver& /*aObserver*/ ) |
|
348 { |
|
349 __CONNECTIONMULTIPLEXER( |
|
350 "CNcmConnectionMultiplexer::RegisterMessageObserverL" ) |
|
351 } |
|
352 |
|
353 // --------------------------------------------------------------------------- |
|
354 // CNcmConnectionMultiplexer::UnregisterMessageObserverL |
|
355 // --------------------------------------------------------------------------- |
|
356 // |
|
357 EXPORT_C void CNcmConnectionMultiplexer::UnregisterMessageObserverL( |
|
358 TUint /*aStreamId*/, MNcmMessageObserver& /*aObserver*/ ) |
|
359 { |
|
360 __CONNECTIONMULTIPLEXER( |
|
361 "CNcmConnectionMultiplexer::UnregisterMessageObserverL" ) |
|
362 } |
|
363 |
|
364 // --------------------------------------------------------------------------- |
|
365 // CNcmConnectionMultiplexer::UnregisterIncomingConnectionObserverL |
|
366 // --------------------------------------------------------------------------- |
|
367 // |
|
368 EXPORT_C void CNcmConnectionMultiplexer:: |
|
369 UnregisterIncomingConnectionObserverL( |
|
370 TUint /*aStreamId*/, MNcmIncomingConnectionObserver& /*aObserver*/ ) |
|
371 { |
|
372 __CONNECTIONMULTIPLEXER( |
|
373 "CNcmConnectionMultiplexer::UnregisterIncomingConnectionObserver" ) |
|
374 /* |
|
375 StreamByIdL( aStreamId )->ConnectionObserverHandler(). |
|
376 UnregisterIncomingConnectionObserverL( aObserver );*/ |
|
377 } |
|
378 |
|
379 |
|
380 // --------------------------------------------------------------------------- |
|
381 // CNcmConnectionMultiplexer::UnregisterOutgoingConnectionObserverL |
|
382 // --------------------------------------------------------------------------- |
|
383 // |
|
384 EXPORT_C void CNcmConnectionMultiplexer:: |
|
385 UnregisterOutgoingConnectionObserverL( |
|
386 TUint /*aStreamId*/, MNcmOutgoingConnectionObserver& /*aObserver*/ ) |
|
387 { |
|
388 __CONNECTIONMULTIPLEXER( |
|
389 "CNcmConnectionMultiplexer::UnregisterOutgoingConnectionObserver" ) |
|
390 /* |
|
391 StreamByIdL( aStreamId )->ConnectionObserverHandler(). |
|
392 UnregisterOutgoingConnectionObserverL( aObserver );*/ |
|
393 } |
|
394 |
|
395 // --------------------------------------------------------------------------- |
|
396 // CNcmConnectionMultiplexer::RegisterConnectionObserverL |
|
397 // --------------------------------------------------------------------------- |
|
398 // |
|
399 EXPORT_C void CNcmConnectionMultiplexer::RegisterConnectionObserverL( |
|
400 TUint /*aStreamId*/, MNcmConnectionObserver& /*aObserver*/ ) |
|
401 { |
|
402 __CONNECTIONMULTIPLEXER( |
|
403 "CNcmConnectionMultiplexer::RegisterConnectionObserverL" ) |
|
404 /* |
|
405 StreamByIdL( aStreamId )-> |
|
406 ConnectionObserverHandler(). |
|
407 RegisterConnectionObserverL( aObserver );*/ |
|
408 } |
|
409 |
|
410 |
|
411 // --------------------------------------------------------------------------- |
|
412 // CNcmConnectionMultiplexer::UnregisterConnectionObserverL |
|
413 // --------------------------------------------------------------------------- |
|
414 // |
|
415 EXPORT_C void CNcmConnectionMultiplexer::UnregisterConnectionObserverL( |
|
416 TUint /*aStreamId*/, MNcmConnectionObserver& /*aObserver*/ ) |
|
417 { |
|
418 __CONNECTIONMULTIPLEXER( |
|
419 "CNcmConnectionMultiplexer::UnregisterConnectionObserverL" ) |
|
420 /* |
|
421 StreamByIdL( aStreamId )->ConnectionObserverHandler(). |
|
422 UnregisterConnectionObserverL( aObserver );*/ |
|
423 } |
|
424 |
|
425 |
|
426 // --------------------------------------------------------------------------- |
|
427 // CNcmConnectionMultiplexer::RegisterMediaWrapperL |
|
428 // --------------------------------------------------------------------------- |
|
429 // |
|
430 EXPORT_C void CNcmConnectionMultiplexer::RegisterMediaWrapperL( |
|
431 MNATFWMediaWrapper* /*aMediaWrapper*/ ) |
|
432 { |
|
433 /* __CONNECTIONMULTIPLEXER( |
|
434 "CNcmConnectionMultiplexer::RegisterMediaWrapperL" ) |
|
435 |
|
436 __ASSERT_ALWAYS( aMediaWrapper, User::Leave( KErrNotReady ) ); |
|
437 |
|
438 TUint streamId( aMediaWrapper->StreamId() ); |
|
439 |
|
440 CNATFWMultiplexerStream* stream( StreamByIdL( streamId ) ); |
|
441 |
|
442 stream->RegisterWrapperL( aMediaWrapper ); |
|
443 |
|
444 // set up media source (ownership tranferred) |
|
445 CNATFWMultiplexerConnection* connection( |
|
446 stream->ConnectionL( KMediaConnection ) ); |
|
447 |
|
448 User::LeaveIfError( connection->RegisterSource( |
|
449 CNATFWMultiplexerMediaSource::NewL( *connection, *this, |
|
450 stream->WrapperL(), SessionByStreamIdL( streamId )->SocketServer(), |
|
451 stream->LocalAddress() ) ) );*/ |
|
452 } |
|
453 |
|
454 |
|
455 // --------------------------------------------------------------------------- |
|
456 // CNcmConnectionMultiplexer::SendL |
|
457 // --------------------------------------------------------------------------- |
|
458 // |
|
459 EXPORT_C void CNcmConnectionMultiplexer::SendL( TUint /*aStreamId*/, |
|
460 TUint /*aConnectionId*/, const TDesC8& /*aMessage*/, |
|
461 MNcmSenderObserver* /*aSenderObserver*/ ) |
|
462 { |
|
463 __CONNECTIONMULTIPLEXER( "CNcmConnectionMultiplexer::SendL" ) |
|
464 |
|
465 /* CNATFWMultiplexerConnection* connection = StreamByIdL( aStreamId )-> |
|
466 ConnectionL( aConnectionId ); |
|
467 |
|
468 __ASSERT_ALWAYS( connection, User::Leave( KErrArgument ) ); |
|
469 |
|
470 // Get source for plug-in (always the first one) |
|
471 RPointerArray<CNATFWMultiplexerSourceBase> sources; |
|
472 CleanupClosePushL( sources ); |
|
473 |
|
474 connection->GetSources( sources ); |
|
475 |
|
476 if ( !sources.Count() ) |
|
477 { |
|
478 User::Leave( KErrNotFound ); |
|
479 } |
|
480 |
|
481 // Send the message |
|
482 User::LeaveIfError( static_cast<CNATFWMultiplexerProtocolSource*>( |
|
483 sources[KDefaultProtocolSource] )->Send( aMessage, KAFUnspec, |
|
484 aSenderObserver ) ); |
|
485 |
|
486 CleanupStack::PopAndDestroy( &sources );*/ |
|
487 } |
|
488 |
|
489 |
|
490 // --------------------------------------------------------------------------- |
|
491 // CNcmConnectionMultiplexer::SendL |
|
492 // --------------------------------------------------------------------------- |
|
493 // |
|
494 EXPORT_C void CNcmConnectionMultiplexer::SendL( TUint /*aStreamId*/, |
|
495 TUint /*aConnectionId*/, const TDesC8& /*aMessage*/, |
|
496 const TInetAddr& /*aDestinationAddress*/, |
|
497 MNcmSenderObserver* /*aSenderObserver*/ ) |
|
498 { |
|
499 __CONNECTIONMULTIPLEXER( "CNcmConnectionMultiplexer::SendL" ) |
|
500 |
|
501 /* CNATFWMultiplexerConnection* connection( NULL ); |
|
502 CNATFWMultiplexerStream* stream = StreamByIdL( aStreamId ); |
|
503 |
|
504 if ( aConnectionId ) |
|
505 { |
|
506 connection = stream->ConnectionL( aConnectionId ); |
|
507 } |
|
508 else |
|
509 { |
|
510 connection = |
|
511 stream->ConnectionByDestinationAddressL( aDestinationAddress ); |
|
512 } |
|
513 |
|
514 __ASSERT_ALWAYS( connection, User::Leave( KErrArgument ) ); |
|
515 |
|
516 // Get source for plug-in (always the first one) |
|
517 RPointerArray<CNATFWMultiplexerSourceBase> sources; |
|
518 CleanupClosePushL( sources ); |
|
519 |
|
520 connection->GetSources( sources ); |
|
521 |
|
522 __ASSERT_ALWAYS( sources.Count(), User::Leave( KErrNotFound ) ); |
|
523 |
|
524 // Send the message |
|
525 User::LeaveIfError( static_cast<CNATFWMultiplexerProtocolSource*>( |
|
526 sources[KDefaultProtocolSource] )-> |
|
527 Send( aMessage, aDestinationAddress, aSenderObserver ) ); |
|
528 |
|
529 CleanupStack::PopAndDestroy( &sources ); */ |
|
530 } |
|
531 |
|
532 // --------------------------------------------------------------------------- |
|
533 // CNcmConnectionMultiplexer::SendL |
|
534 // --------------------------------------------------------------------------- |
|
535 // |
|
536 EXPORT_C void CNcmConnectionMultiplexer::SendL( TUint /*aStreamId*/, |
|
537 TUint /*aConnectionId*/, const TDesC8& /*aMessage*/, TBool /*aSendDirectly*/, |
|
538 MNcmSenderObserver* /*aSenderObserver*/ ) |
|
539 { |
|
540 __CONNECTIONMULTIPLEXER( "CNcmConnectionMultiplexer::SendL" ) |
|
541 /* |
|
542 if ( aSendDirectly ) |
|
543 { |
|
544 CNATFWMultiplexerSocketDestination* dest = |
|
545 static_cast<CNATFWMultiplexerSocketDestination*>( |
|
546 StreamByIdL( aStreamId )-> |
|
547 ConnectionL( aConnectionId )->Destination() ); |
|
548 |
|
549 dest->PutMessage( aMessage, aSenderObserver ); |
|
550 } |
|
551 else |
|
552 { |
|
553 this->SendL( aStreamId, aConnectionId, aMessage, aSenderObserver ); |
|
554 }*/ |
|
555 } |
|
556 |
|
557 |
|
558 // --------------------------------------------------------------------------- |
|
559 // CNcmConnectionMultiplexer::SendL |
|
560 // --------------------------------------------------------------------------- |
|
561 // |
|
562 EXPORT_C void CNcmConnectionMultiplexer::SendL( TUint /*aStreamId*/, const TDesC8& /*aMessage*/, |
|
563 const TInetAddr& /*aNextHopAddress*/, const TInetAddr& /*aDestinationAddress*/ ) |
|
564 { |
|
565 __CONNECTIONMULTIPLEXER( "CNcmConnectionMultiplexer::SendL" ) |
|
566 } |
|
567 |
|
568 |
|
569 // --------------------------------------------------------------------------- |
|
570 // CNcmConnectionMultiplexer::SocketHandlesL |
|
571 // --------------------------------------------------------------------------- |
|
572 // |
|
573 //EXPORT_C RConnection& CNcmConnectionMultiplexer::GetSocketHandlesL( |
|
574 // TUint /*aStreamId*/, TUint /*aConnectionId*/, RSocketServ& /*aSocketServ*/, |
|
575 // RSocket& /*aSocket*/ ) |
|
576 // { |
|
577 // __CONNECTIONMULTIPLEXER( |
|
578 // "CNcmConnectionMultiplexer::GetSocketHandlesL" ) |
|
579 /* |
|
580 CNATFWMultiplexerSocketDestination* dest = |
|
581 static_cast<CNATFWMultiplexerSocketDestination*>( |
|
582 StreamByIdL( aStreamId )-> |
|
583 ConnectionL( aConnectionId )->Destination() ); |
|
584 |
|
585 aSocketServ = SessionByStreamIdL( aStreamId )->SocketServer(); |
|
586 aSocket = dest->Socket(); |
|
587 |
|
588 return SessionByStreamIdL( aStreamId )->Connection();*/ |
|
589 // RConnection* connection = NULL; |
|
590 |
|
591 // return *connection; |
|
592 // } |
|
593 |
|
594 |
|
595 // --------------------------------------------------------------------------- |
|
596 // CNcmConnectionMultiplexer::PortStore |
|
597 // --------------------------------------------------------------------------- |
|
598 // |
|
599 EXPORT_C CNcmPortStore& CNcmConnectionMultiplexer::PortStoreL( |
|
600 TUint /*aSessionId*/ ) |
|
601 { |
|
602 __CONNECTIONMULTIPLEXER( "CNcmConnectionMultiplexer::PortStore" ) |
|
603 CNcmPortStore* store = NULL; |
|
604 // return SessionByIdL( aSessionId )->PortStore(); |
|
605 return *store; |
|
606 } |
|
607 |
|
608 // --------------------------------------------------------------------------- |
|
609 // CNcmConnectionMultiplexer::SetSendingStateL |
|
610 // --------------------------------------------------------------------------- |
|
611 // |
|
612 EXPORT_C void CNcmConnectionMultiplexer::SetSendingStateL( |
|
613 TUint /*aStreamId*/, TUint /*aConnectionId*/, const TInetAddr& /*aDestAddr*/, |
|
614 TNATFWStreamingState /*aState*/ ) |
|
615 { |
|
616 __CONNECTIONMULTIPLEXER( "CNcmConnectionMultiplexer::SetSendingStateL" ) |
|
617 /* |
|
618 CNATFWMultiplexerSocketDestination* dest = |
|
619 static_cast<CNATFWMultiplexerSocketDestination*>( |
|
620 StreamByIdL( aStreamId )-> |
|
621 ConnectionL( aConnectionId )->Destination() ); |
|
622 |
|
623 dest->SetSendingStateL( aDestAddr, aState ); */ |
|
624 } |
|
625 |
|
626 |
|
627 // --------------------------------------------------------------------------- |
|
628 // CNcmConnectionMultiplexer::SetReceivingStateL |
|
629 // --------------------------------------------------------------------------- |
|
630 // |
|
631 EXPORT_C void CNcmConnectionMultiplexer::SetReceivingStateL( |
|
632 TUint /*aStreamId*/, TUint /*aConnectionId*/, TNATFWStreamingState /*aState*/ ) |
|
633 { |
|
634 __CONNECTIONMULTIPLEXER( |
|
635 "CNcmConnectionMultiplexer::SetReceivingStateL" ) |
|
636 /* |
|
637 CNATFWMultiplexerSocketDestination* dest = |
|
638 static_cast<CNATFWMultiplexerSocketDestination*>( |
|
639 StreamByIdL( aStreamId )-> |
|
640 ConnectionL( aConnectionId )->Destination() ); |
|
641 |
|
642 dest->SetReceivingStateL( aState );*/ |
|
643 } |
|
644 |
|
645 |
|
646 // --------------------------------------------------------------------------- |
|
647 // CNcmConnectionMultiplexer::SetAcceptedFromAddressL |
|
648 // --------------------------------------------------------------------------- |
|
649 // |
|
650 EXPORT_C void CNcmConnectionMultiplexer::SetAcceptedFromAddressL( |
|
651 TUint /*aStreamId*/, TUint /*aConnectionId*/, const TInetAddr& /*aAddress*/ ) |
|
652 { |
|
653 __CONNECTIONMULTIPLEXER( |
|
654 "CNcmConnectionMultiplexer::SetAcceptedFromAddressL" ) |
|
655 |
|
656 /* CNcmSocketDestination* dest = |
|
657 static_cast<CNcmSocketDestination*>( |
|
658 StreamByIdL( aStreamId )-> |
|
659 ConnectionL( aConnectionId )->Destination() ); |
|
660 |
|
661 dest->SetAcceptedFromAddress( aAddress );*/ |
|
662 } |
|
663 |
|
664 |
|
665 // --------------------------------------------------------------------------- |
|
666 // From class MNATFWMultiplexerConnectionObserver |
|
667 // |
|
668 // CNcmConnectionMultiplexer::ConnectionError |
|
669 // --------------------------------------------------------------------------- |
|
670 // |
|
671 void CNcmConnectionMultiplexer::ConnectionError( |
|
672 TUint /*aSessionId*/, TUint /*aStreamId*/, TUint /*aConnectionId*/, |
|
673 TMultiplexerConnectionNotifyType /*aNotifyType*/, TInt /*aError*/ ) |
|
674 { |
|
675 __CONNECTIONMULTIPLEXER( |
|
676 "CNcmConnectionMultiplexer::MultiplexerError" ) |
|
677 |
|
678 /* CNATFWMultiplexerStream* stream( StreamById( aStreamId ) ); |
|
679 |
|
680 if ( stream ) |
|
681 { |
|
682 // Notify connection observers |
|
683 stream->ConnectionObserverHandler(). |
|
684 ConnectionNotify( aStreamId, aConnectionId, aNotifyType, aError ); |
|
685 |
|
686 // Lets notify stream user |
|
687 iObserver.Notify( aSessionId, aStreamId, |
|
688 MNcmConnectionMultiplexerObserver::EStreamError, aError ); |
|
689 }*/ |
|
690 } |
|
691 |
|
692 |
|
693 // --------------------------------------------------------------------------- |
|
694 // From class MNATFWMultiplexerSocketDestinationObserver |
|
695 // |
|
696 // CNcmConnectionMultiplexer::ConnectionNotify |
|
697 // --------------------------------------------------------------------------- |
|
698 // |
|
699 void CNcmConnectionMultiplexer::ConnectionNotify( TUint /*aStreamId*/, |
|
700 TUint /*aConnectionId*/, TMultiplexerConnectionNotifyType /*aType*/, |
|
701 TInt /*aError*/ ) |
|
702 { |
|
703 __CONNECTIONMULTIPLEXER( |
|
704 "CNcmConnectionMultiplexer::ConnectionNotify" ) |
|
705 /* |
|
706 TRAP_IGNORE( |
|
707 ConnectionNotifyL( aStreamId, aConnectionId, aType, aError ) )*/ |
|
708 } |
|
709 |
|
710 |
|
711 // --------------------------------------------------------------------------- |
|
712 // From class MNATFWMultiplexerSocketDestinationObserver |
|
713 // |
|
714 // CNcmConnectionMultiplexer::GetNewFreePort |
|
715 // --------------------------------------------------------------------------- |
|
716 // |
|
717 void CNcmConnectionMultiplexer::GetNewFreePort( TUint /*aStreamId*/, |
|
718 TUint /*aConnectionId*/, TUint& /*aPort*/ ) |
|
719 { |
|
720 __CONNECTIONMULTIPLEXER( |
|
721 "CNcmConnectionMultiplexer::GetNewFreePort" ) |
|
722 |
|
723 //TRAP_IGNORE( GetNewFreePortL( aStreamId, aConnectionId, aPort ) ) |
|
724 } |
|
725 |
|
726 |
|
727 // --------------------------------------------------------------------------- |
|
728 // CNcmConnectionMultiplexer::ConnectionNotifyL |
|
729 // --------------------------------------------------------------------------- |
|
730 // |
|
731 void CNcmConnectionMultiplexer::ConnectionNotifyL( TUint /*aStreamId*/, |
|
732 TUint aConnectionId, TMultiplexerConnectionNotifyType aType, |
|
733 TInt /*aError*/ ) |
|
734 { |
|
735 |
|
736 // CNATFWMultiplexerStream* stream( StreamByIdL( aStreamId ) ); |
|
737 |
|
738 // TUint sessionId( SessionByStreamIdL( aStreamId )->SessionId() ); |
|
739 |
|
740 if ( KMediaConnection == aConnectionId ) |
|
741 { |
|
742 switch ( aType ) |
|
743 { |
|
744 case EMultiplexerReceivingActivated: |
|
745 { |
|
746 // MNATFWMediaWrapper& wrapper = stream->WrapperL(); |
|
747 // TRAPD( error, wrapper.ConnectL() ); |
|
748 |
|
749 /* if ( KErrNone != error ) |
|
750 { |
|
751 __CONNECTIONMULTIPLEXER_INT1( |
|
752 "CNcmConnectionMultiplexer::ConnectionNotify - Wrapper connecting error: ", error ) |
|
753 |
|
754 CNATFWMultiplexerSocketDestination* dest = |
|
755 static_cast<CNATFWMultiplexerSocketDestination*>( |
|
756 stream->ConnectionL( aConnectionId )->Destination() ); |
|
757 |
|
758 dest->SetReceivingStateL( EStreamingStatePassive ); |
|
759 |
|
760 iObserver.Notify( sessionId, aStreamId, |
|
761 MNcmConnectionMultiplexerObserver::EStreamError, |
|
762 aError ); |
|
763 } |
|
764 else |
|
765 { |
|
766 iObserver.Notify( sessionId, aStreamId, |
|
767 MNcmConnectionMultiplexerObserver:: |
|
768 EReceivingActivated, aError ); |
|
769 }*/ |
|
770 break; |
|
771 } |
|
772 |
|
773 case EMultiplexerSendingActivated: |
|
774 { |
|
775 /* MNATFWMediaWrapper& wrapper = stream->WrapperL(); |
|
776 |
|
777 TRAPD( error, wrapper.StartListeningL() ); |
|
778 |
|
779 if ( KErrNone != error ) |
|
780 { |
|
781 __CONNECTIONMULTIPLEXER_INT1( |
|
782 "CNcmConnectionMultiplexer::ConnectionNotify - Wrapper start listenin error: ", error ) |
|
783 |
|
784 CNATFWMultiplexerSocketDestination* dest = |
|
785 static_cast<CNATFWMultiplexerSocketDestination*>( |
|
786 stream->ConnectionL( aConnectionId )->Destination() ); |
|
787 |
|
788 dest->SetSendingStateL( KAFUnspec, EStreamingStatePassive ); |
|
789 |
|
790 iObserver.Notify( sessionId, aStreamId, |
|
791 MNcmConnectionMultiplexerObserver::EStreamError, |
|
792 aError ); |
|
793 |
|
794 } |
|
795 else |
|
796 { |
|
797 iObserver.Notify( sessionId, aStreamId, |
|
798 MNcmConnectionMultiplexerObserver::ESendingActivated |
|
799 ,aError ); |
|
800 } |
|
801 |
|
802 */ |
|
803 break; |
|
804 } |
|
805 |
|
806 case EMultiplexerReceivingDeactivated: |
|
807 { |
|
808 /* MNATFWMediaWrapper& wrapper = stream->WrapperL(); |
|
809 wrapper.DeactivateSending(); |
|
810 |
|
811 iObserver.Notify( sessionId, aStreamId, |
|
812 MNcmConnectionMultiplexerObserver::EReceivingDeactivated |
|
813 ,aError ); |
|
814 */ |
|
815 break; |
|
816 } |
|
817 |
|
818 case EMultiplexerSendingDeactivated: |
|
819 { |
|
820 /* MNATFWMediaWrapper& wrapper = stream->WrapperL(); |
|
821 wrapper.DeactivateReceiving(); |
|
822 |
|
823 iObserver.Notify( sessionId, aStreamId, |
|
824 MNcmConnectionMultiplexerObserver::ESendingDeactivated |
|
825 ,aError ); */ |
|
826 |
|
827 break; |
|
828 } |
|
829 case EMultiplexerConnectionError: |
|
830 { |
|
831 /* iObserver.Notify( sessionId, aStreamId, |
|
832 MNcmConnectionMultiplexerObserver::EStreamError, |
|
833 aError ); */ |
|
834 break; |
|
835 } |
|
836 case EMultiplexerConnectionRemoved: |
|
837 { |
|
838 break; |
|
839 } |
|
840 } |
|
841 } |
|
842 else |
|
843 { |
|
844 /* stream->ConnectionObserverHandler(). |
|
845 ConnectionNotify( aStreamId, aConnectionId, aType, aError );*/ |
|
846 } |
|
847 } |
|
848 |
|
849 |
|
850 // --------------------------------------------------------------------------- |
|
851 // From class MNATFWMultiplexerSessionObserver |
|
852 // |
|
853 // Called as a result for CreateSessionL() when wrapper is connected |
|
854 // --------------------------------------------------------------------------- |
|
855 // |
|
856 void CNcmConnectionMultiplexer::SessionCreationFailed( TUint /*aSessionId*/ ) |
|
857 { |
|
858 __CONNECTIONMULTIPLEXER( "CNcmConnectionMultiplexer::SessionCreationFailed" ) |
|
859 |
|
860 // TRAP_IGNORE( RemoveSessionL( aSessionId ) ) |
|
861 } |
|
862 |
|
863 |
|
864 // --------------------------------------------------------------------------- |
|
865 // CNcmConnectionMultiplexer::SessionByIdL() |
|
866 // --------------------------------------------------------------------------- |
|
867 // |
|
868 CNcmSession* CNcmConnectionMultiplexer::SessionByIdL( |
|
869 TUint aSessionId ) |
|
870 { |
|
871 TInt ind( iSessions.Count() ); |
|
872 |
|
873 while ( ind-- ) |
|
874 { |
|
875 if ( iSessions[ind]->SessionId() == aSessionId ) |
|
876 { |
|
877 return iSessions[ind]; |
|
878 } |
|
879 } |
|
880 |
|
881 User::Leave( KErrNotFound ); |
|
882 #ifndef _DEBUG_EUNIT |
|
883 return NULL; |
|
884 #endif |
|
885 } |
|
886 |
|
887 |
|
888 // --------------------------------------------------------------------------- |
|
889 // CNcmConnectionMultiplexer::StreamByIdL() |
|
890 // --------------------------------------------------------------------------- |
|
891 // |
|
892 CNcmStream* CNcmConnectionMultiplexer::StreamByIdL( |
|
893 TUint aStreamId ) |
|
894 { |
|
895 TInt sessInd( iSessions.Count() ); |
|
896 |
|
897 while ( sessInd-- ) |
|
898 { |
|
899 CNcmStream* stream = iSessions[sessInd]-> |
|
900 StreamByIdL( aStreamId ); |
|
901 |
|
902 if ( stream ) |
|
903 { |
|
904 return stream; |
|
905 } |
|
906 } |
|
907 |
|
908 User::Leave( KErrNotFound ); |
|
909 #ifndef _DEBUG_EUNIT |
|
910 return NULL; |
|
911 #endif |
|
912 } |
|
913 |
|
914 |
|
915 // --------------------------------------------------------------------------- |
|
916 // CNcmConnectionMultiplexer::StreamById() |
|
917 // --------------------------------------------------------------------------- |
|
918 // |
|
919 //CNATFWMultiplexerStream* CNcmConnectionMultiplexer::StreamById( |
|
920 // TUint /*aStreamId*/ ) |
|
921 /* { |
|
922 CNATFWMultiplexerStream* stream( NULL ); |
|
923 |
|
924 TRAP_IGNORE( ( stream = StreamByIdL( aStreamId ) ) ) |
|
925 |
|
926 return stream; |
|
927 }*/ |
|
928 |
|
929 // --------------------------------------------------------------------------- |
|
930 // CNcmConnectionMultiplexer::SessionByStreamIdL() |
|
931 // --------------------------------------------------------------------------- |
|
932 // |
|
933 CNcmSession* CNcmConnectionMultiplexer::SessionByStreamIdL( |
|
934 TUint aStreamId ) |
|
935 { |
|
936 TInt sessInd( iSessions.Count() ); |
|
937 |
|
938 while ( sessInd-- ) |
|
939 { |
|
940 CNcmStream* stream = iSessions[sessInd]-> |
|
941 StreamByIdL( aStreamId ); |
|
942 |
|
943 if ( stream ) |
|
944 { |
|
945 return iSessions[sessInd]; |
|
946 } |
|
947 } |
|
948 |
|
949 User::Leave( KErrNotFound ); |
|
950 #ifndef _DEBUG_EUNIT |
|
951 return NULL; |
|
952 #endif |
|
953 } |
|
954 |
|
955 |
|
956 // --------------------------------------------------------------------------- |
|
957 // CNcmConnectionMultiplexer::CreateDefaultConnectionL |
|
958 // --------------------------------------------------------------------------- |
|
959 // |
|
960 //void CNcmConnectionMultiplexer::CreateDefaultConnectionL( TUint /*aStreamId*/, |
|
961 // TUint /*aProtocol*/ ) |
|
962 /* { |
|
963 __CONNECTIONMULTIPLEXER( |
|
964 "CNcmConnectionMultiplexer::CreateConnectionL" ) |
|
965 |
|
966 CNATFWMultiplexerStream* stream( StreamByIdL( aStreamId ) ); |
|
967 |
|
968 // Create Connection ( Create multiplexer ) |
|
969 TUint connectionId = stream-> |
|
970 CreateConnectionL( *this, stream->ConnectionObserverHandler() ); |
|
971 |
|
972 // Retrive created Multiplexer instance |
|
973 CNATFWMultiplexerConnection* connection = |
|
974 stream->ConnectionL( connectionId ); |
|
975 |
|
976 // set up protocol source (ownership tranferred) |
|
977 connection->RegisterSource( |
|
978 CNATFWMultiplexerProtocolSource::NewL( *connection ) ); |
|
979 |
|
980 // set up destination (ownership tranferred) |
|
981 connection->SetDestination( CNATFWMultiplexerSocketDestination::NewL( |
|
982 aStreamId, |
|
983 connectionId, |
|
984 stream->Port(), |
|
985 stream->Qos(), |
|
986 SessionByStreamIdL( aStreamId )->SocketServer(), |
|
987 SessionByStreamIdL( aStreamId )->Connection(), |
|
988 aProtocol, |
|
989 *connection, |
|
990 *this ) ); |
|
991 }*/ |
|
992 |
|
993 // --------------------------------------------------------------------------- |
|
994 // From class MNATFWMultiplexerMediaSourceObserver |
|
995 // |
|
996 // CNcmConnectionMultiplexer::WrapperSenderError |
|
997 // --------------------------------------------------------------------------- |
|
998 // |
|
999 void CNcmConnectionMultiplexer::WrapperSenderError( TUint /*aStreamId*/, |
|
1000 TInt /*aError*/ ) |
|
1001 { |
|
1002 /* |
|
1003 this->ConnectionNotify( aStreamId, KMediaConnection, |
|
1004 EMultiplexerConnectionError, aError );*/ |
|
1005 } |
|
1006 |
|
1007 // --------------------------------------------------------------------------- |
|
1008 // From class MNcmMediaSourceObserver |
|
1009 // |
|
1010 // CNcmConnectionMultiplexer::FirstMediaPacketSent |
|
1011 // --------------------------------------------------------------------------- |
|
1012 // |
|
1013 void CNcmConnectionMultiplexer::FirstMediaPacketSent( TUint /*aStreamId*/ ) |
|
1014 { |
|
1015 /* __CONNECTIONMULTIPLEXER_INT1( |
|
1016 "CNcmConnectionMultiplexer::FirstMediaPacketSent- aStreamId: ", aStreamId ) |
|
1017 |
|
1018 TInt connectionId( 0 ); |
|
1019 |
|
1020 TRAP_IGNORE( |
|
1021 connectionId = StreamByIdL( aStreamId )->MediaConnectionId() ) |
|
1022 |
|
1023 TRAP_IGNORE( this->ConnectionNotifyL( aStreamId, connectionId, |
|
1024 EMultiplexerFirstMediaPacketSent, KErrNone ) )*/ |
|
1025 } |
|
1026 |
|
1027 |
|
1028 // --------------------------------------------------------------------------- |
|
1029 // From class MNATFWMultiplexerMediaSourceObserver |
|
1030 // |
|
1031 // CNcmConnectionMultiplexer::GetFreePort |
|
1032 // --------------------------------------------------------------------------- |
|
1033 // |
|
1034 void CNcmConnectionMultiplexer::GetFreePort( TUint /*aStreamId*/, TUint& /*aPort*/ ) |
|
1035 { |
|
1036 __CONNECTIONMULTIPLEXER( "CNcmConnectionMultiplexer::GetFreePort" ) |
|
1037 //TRAP_IGNORE( ( aPort = SessionByStreamIdL( aStreamId )->PortStore().Port() ) ); |
|
1038 } |
|
1039 |
|
1040 |
|
1041 // --------------------------------------------------------------------------- |
|
1042 // CNcmConnectionMultiplexer::CancelMessageSend |
|
1043 // --------------------------------------------------------------------------- |
|
1044 // |
|
1045 void CNcmConnectionMultiplexer::CancelMessageSend( TUint /*aStreamId*/, TUint /*aConnectionId*/, |
|
1046 const MNcmSenderObserver* /*aSenderObserver*/ ) |
|
1047 { |
|
1048 |
|
1049 } |