|
1 /* |
|
2 * Copyright (c) 2004-2007 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: Mcc Internal definitions |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef MCCINTERNALDEF_H |
|
22 #define MCCINTERNALDEF_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32base.h> |
|
26 #include <mmf/common/mmfcontroller.h> |
|
27 #include <tconvbase64.h> |
|
28 |
|
29 |
|
30 #include "rtpdef.h" |
|
31 #include "mmccinterfacedef.h" |
|
32 #include "mccinternalcodecs.h" |
|
33 #include "mccuids.hrh" |
|
34 |
|
35 // CONSTANTS |
|
36 const TUid KMccControllerUid = { KImplUidMccController }; |
|
37 const TUid KMccAmrFormatterUid = { KDllUidAmrPayloadFormat }; |
|
38 const TUid KMccJitterBufferUid = { KDllUidMccJitterBuffer }; |
|
39 const TUid KMccMultiplexerUid = { KDllUidMccMultiplexer }; |
|
40 const TUid KMccDtmfFormatterUid = { KDllUidDTMFPayloadFormat }; |
|
41 const TUid KMccMedianattraversalUid = { KImplUidMccmedianattraversal }; |
|
42 |
|
43 const TInt KMaxBitrates = 12; |
|
44 |
|
45 // VoIP codecs have a two byte header |
|
46 const TInt KVoIPHeaderLength = 2; |
|
47 |
|
48 // VoIP codec header bytes can be audio, comfort noise or unvoiced non-sid |
|
49 // (null/no data) frame. Unvoiced non sid frame can be detected by header |
|
50 // byte being something else than audio or comfort noise. |
|
51 const TUint8 KVoIPAudioFrame = 1; |
|
52 const TUint8 KVoIPCNFrame = 2; |
|
53 |
|
54 // Bits per byte |
|
55 const TInt KBitsPerByte = 8; |
|
56 |
|
57 // Defines unassigned payload type |
|
58 const TUint8 KMccPTNotDefined = 128; |
|
59 |
|
60 // Used to define exitence of codec which is not supported by mcc |
|
61 const TUint32 KMccFourCCUnsupported = 0x4EEEEEEE; |
|
62 |
|
63 const TInt KMccFourCCArraySize = 10; |
|
64 |
|
65 // Use TPckgBuf<TInt> as a parameter value. Should not overlap with values from API. |
|
66 const TUint32 KMccPrerollTime = 60; |
|
67 |
|
68 // Increased RTP socket size in bytes, default socket size is around 4KB |
|
69 const TInt KMccIncreasedRtpSocketSize = 10000; |
|
70 |
|
71 // MACROS |
|
72 |
|
73 #ifdef _DEBUG |
|
74 #define TRACE_MCC_CONTROLLER |
|
75 #define TRACE_MCC_INTERFACE |
|
76 #endif |
|
77 |
|
78 |
|
79 #ifdef TRACE_MCC_CONTROLLER |
|
80 #define MCC_CONTROLLER_WRITE(a) \ |
|
81 { _LIT( KName, a); RDebug::Print(KName); } |
|
82 #define MCC_CONTROLLER_WRITE2(a, b) \ |
|
83 { _LIT(KName, a); RDebug::Print(KName, b); } |
|
84 #define MCC_CONTROLLER_WRITE3(a, b, c) \ |
|
85 { _LIT(KName, a); RDebug::Print(KName, b, c); } |
|
86 #define MCC_CONTROLLER_WRITE4(a, b, c, d) \ |
|
87 { _LIT(KName, a); RDebug::Print(KName, b, c, d); } |
|
88 #else |
|
89 #define MCC_CONTROLLER_WRITE(a) |
|
90 #define MCC_CONTROLLER_WRITE2(a, b) |
|
91 #define MCC_CONTROLLER_WRITE3(a, b, c) |
|
92 #define MCC_CONTROLLER_WRITE4(a, b, c, d) |
|
93 #endif |
|
94 |
|
95 #define MCC_CONTROL_ALL_ENDPOINTS(a) ( a == 0 ) |
|
96 |
|
97 #define MCC_ENDPOINT_ID(a) reinterpret_cast<TUint32>( a ) |
|
98 |
|
99 #define IS_MCC_EVENT(a)\ |
|
100 ( a.iEventType == KUidMediaTypeAudio ||\ |
|
101 a.iEventType == KUidMediaTypeVideo ||\ |
|
102 a.iEventType == KMccFileSinkUid ||\ |
|
103 a.iEventType == KMccFileSourceUid ||\ |
|
104 a.iEventType == KMccRtpSourceUid ||\ |
|
105 a.iEventType == KMccRtpSinkUid ||\ |
|
106 a.iEventType == KMccVideoSourceUid ||\ |
|
107 a.iEventType == KMccVideoSinkUid ||\ |
|
108 a.iEventType == KMccJitterBufferUid ||\ |
|
109 a.iEventType == KMccAmrFormatterUid ||\ |
|
110 a.iEventType == KMccMultiplexerUid ||\ |
|
111 a.iEventType == KMccDtmfFormatterUid ||\ |
|
112 a.iEventType == KMccAnySourceUid ||\ |
|
113 a.iEventType == KMccAnySinkUid ) |
|
114 |
|
115 #define MCC_STREAM_STATE_CHANGE_EVENT( aEvent )\ |
|
116 ( aEvent->iEventCategory == KMccEventCategoryStream &&\ |
|
117 ( aEvent->iEventType == KMccStreamPrepared ||\ |
|
118 aEvent->iEventType == KMccStreamStarted ||\ |
|
119 aEvent->iEventType == KMccStreamPaused ||\ |
|
120 aEvent->iEventType == KMccStreamResumed ||\ |
|
121 aEvent->iEventType == KMccStreamStopped ) ) |
|
122 |
|
123 #define MCC_INTERNAL_ENDPOINT( aEndpointUid )\ |
|
124 ( aEndpointUid == KImplUidMccFileSource ||\ |
|
125 aEndpointUid == KImplUidMccFileSink ||\ |
|
126 aEndpointUid == KImplUidMccJitterBuffer ||\ |
|
127 aEndpointUid == KImplUidRtpDataSource ||\ |
|
128 aEndpointUid == KImplUidRtpDataSink ||\ |
|
129 aEndpointUid == KImplUidMccVideoSource ||\ |
|
130 aEndpointUid == KImplUidMccVideoSink ||\ |
|
131 aEndpointUid == KImplUidMccAnySource ||\ |
|
132 aEndpointUid == KImplUidMccAnySink ) |
|
133 |
|
134 |
|
135 #define MCC_IS_AVC_USER_ENTRY( a ) \ |
|
136 ( a && a->iCodecInfo.iSdpName.CompareF( KAVCSdpName ) == 0 ) |
|
137 |
|
138 #define MCC_IS_H263_USER_ENTRY( a ) \ |
|
139 ( a && ( a->iCodecInfo.iSdpName.CompareF( KH263SdpName ) == 0 || \ |
|
140 a->iCodecInfo.iSdpName.CompareF( KH2632000SdpName ) == 0 || \ |
|
141 a->iCodecInfo.iSdpName.CompareF( KH2631998SdpName ) == 0 ) ) |
|
142 |
|
143 #define MCC_IS_AVC_PRIMARY_CODEC \ |
|
144 ( iUsers.Count() > 0 && MCC_IS_AVC_USER_ENTRY( iUsers[ 0 ] ) ) |
|
145 |
|
146 #define MCC_IS_H263_PRIMARY_CODEC \ |
|
147 ( iUsers.Count() > 0 && MCC_IS_H263_USER_ENTRY( iUsers[ 0 ] ) ) |
|
148 |
|
149 |
|
150 // DATA TYPES |
|
151 enum TMccMediaQualityCustomCmd |
|
152 { |
|
153 EStartMediaQualityObserving, |
|
154 ECancelMediaQualityObserving |
|
155 }; |
|
156 |
|
157 enum TSrCustomCommandMessages |
|
158 { |
|
159 ERequestEventNotification = 0, |
|
160 EMccClose, |
|
161 EMccCreateSession, |
|
162 EMccSetRemoteAddress, |
|
163 EMccSetRemoteRtcpAddr, |
|
164 EMccCloseSession, |
|
165 EMccCreateLink, |
|
166 EMccCloseLink, |
|
167 EMccCreateStream, |
|
168 EMccPrepareStream, |
|
169 EMccInactivityTimerStart, |
|
170 EMccInactivityTimerStop, |
|
171 EMccDeleteStream, |
|
172 EMccStartStream, |
|
173 EMccStopStream, |
|
174 EMccPauseStream, |
|
175 EMccResumeStream, |
|
176 EMccGetCodec, |
|
177 EMccGetFmtpAttr, |
|
178 EMccSetCodec, |
|
179 EMccGetSupportedCodecs, |
|
180 EMccStreamSettings, |
|
181 EMccSetAudioPriority, |
|
182 EMccCancel, |
|
183 EMccSendMediaSignal, |
|
184 EMccSendRtcpRR, |
|
185 EMccSendRtcpSR, |
|
186 EMccSendRtcpData, |
|
187 EMccGetSupportedBitrates, |
|
188 EMccGetSSRC, |
|
189 EMccGetSinkId, |
|
190 EMccGetSourceId, |
|
191 EMccEnableViewFinder, |
|
192 EMccDisableViewFinder, |
|
193 EMccGetViewFinderSettings, |
|
194 EMccGetCamInfo, |
|
195 EMccGetNumOfCams, |
|
196 EMccSetCamValue1, |
|
197 EMccGetCamValue1, |
|
198 EMccSetCamValue2, |
|
199 EMccGetCamValue2, |
|
200 EMccLinkExists, |
|
201 EMccStreamsExists, |
|
202 EMccUpdateDataSource, |
|
203 EMccUpdateDataSink, |
|
204 EMccReuse, |
|
205 EMccSetAudioRoute, |
|
206 EMccGetAudioRoute, |
|
207 EMccSetEndpointParameter, |
|
208 EMccGetEndpointParameter, |
|
209 EMccGetReferenceCount, |
|
210 EMccTranscodeFile, |
|
211 EMccCancelTranscodeFile, |
|
212 EMccBindContextIntoStream, |
|
213 EMccRemoveContext |
|
214 }; |
|
215 |
|
216 |
|
217 /* |
|
218 * Message class for redundancy configuration |
|
219 * @since Series 60 3.0 |
|
220 * @lib mmcccontroller.dll |
|
221 */ |
|
222 class TMccRedundancy |
|
223 { |
|
224 public: |
|
225 TMccRedundancy() : |
|
226 iSessionID( 0 ), |
|
227 iLinkID( 0 ), |
|
228 iStreamID( 0 ), |
|
229 iStatus( EFalse ), |
|
230 iRedundancyPT( 0 ), |
|
231 iRedCount( 0 ) |
|
232 {} |
|
233 |
|
234 TUint32 iSessionID; |
|
235 TUint32 iLinkID; |
|
236 TUint32 iStreamID; |
|
237 TBool iStatus; |
|
238 TUint8 iRedundancyPT; |
|
239 TInt iRedCount; |
|
240 }; |
|
241 |
|
242 typedef TPckgBuf<TMccRedundancy> TMccRedundancyPckg; |
|
243 |
|
244 /* |
|
245 * Message class for creating Mcc sessions |
|
246 * @since Series 60 3.0 |
|
247 * @lib MMccController.dll |
|
248 */ |
|
249 class TMccCreateSession |
|
250 { |
|
251 public: |
|
252 TMccCreateSession() : |
|
253 iSessionID( 0 ) |
|
254 {} |
|
255 |
|
256 TUint32 iSessionID; |
|
257 }; |
|
258 |
|
259 typedef TPckgBuf<TMccCreateSession> TMccCreateSessionPckg; |
|
260 |
|
261 /* |
|
262 * Message class for creating Mcc links |
|
263 * @since Series 60 3.0 |
|
264 * @lib MMccController.dll |
|
265 */ |
|
266 class TMccCreateLink |
|
267 { |
|
268 public: |
|
269 TMccCreateLink() : |
|
270 iSessionID( 0 ), |
|
271 iLinkType( KMccLinkGeneral ), |
|
272 iLinkID( 0 ), |
|
273 iRemoteAddress( KInetAddrAny ), |
|
274 iLocalAddress( KInetAddrAny ), |
|
275 iLocalRtcpAddress( KInetAddrAny ), |
|
276 iIapId( 0 ), |
|
277 iIpTOS( 0 ), |
|
278 iMediaSignaling( 0 ) |
|
279 {} |
|
280 |
|
281 TUint32 iSessionID; |
|
282 TInt iLinkType; |
|
283 TUint32 iLinkID; |
|
284 TInetAddr iRemoteAddress; |
|
285 TInetAddr iLocalAddress; |
|
286 TInetAddr iLocalRtcpAddress; |
|
287 TInt iIapId; |
|
288 TInt iIpTOS; |
|
289 TInt iMediaSignaling; |
|
290 }; |
|
291 |
|
292 typedef TPckgBuf<TMccCreateLink> TMccCreateLinkPckg; |
|
293 |
|
294 /* |
|
295 * Message class for starting Mcc inactivity timer |
|
296 * @since Series 60 3.0 |
|
297 * @lib MMccController.dll |
|
298 */ |
|
299 class TMccInactivityTimer |
|
300 { |
|
301 public: |
|
302 TMccInactivityTimer(): |
|
303 iSessionID( 0 ), |
|
304 iLinkID( 0 ), |
|
305 iStreamID( 0 ), |
|
306 iTimeoutTime( 0 ) |
|
307 {} |
|
308 |
|
309 TUint32 iSessionID; |
|
310 TUint32 iLinkID; |
|
311 TUint32 iStreamID; |
|
312 TUint32 iTimeoutTime; |
|
313 }; |
|
314 |
|
315 typedef TPckgBuf<TMccInactivityTimer> TMccInactivityTimerPckg; |
|
316 |
|
317 /* |
|
318 * Message class for session messages |
|
319 * @since Series 60 3.0 |
|
320 * @lib mmcccontroller.dll |
|
321 */ |
|
322 class TMccSession |
|
323 { |
|
324 public: |
|
325 TMccSession() : |
|
326 iSessionID( 0 ), |
|
327 iLinkID( 0 ), |
|
328 iStreamID( 0 ), |
|
329 iEndpointID( 0 ), |
|
330 iStreamType( KMccAudioUplinkStream ), |
|
331 iCodec(), |
|
332 iFourCCArray( TFixedArray<TFourCC, KMccFourCCArraySize>() ), |
|
333 iPort( 0 ), |
|
334 iPayloadType( 0 ), |
|
335 iEnableVAD( NULL ), |
|
336 iPacketizationRate( 1 ), |
|
337 iPTime( 20 ), |
|
338 iMaxPTime( 200 ) |
|
339 {} |
|
340 |
|
341 |
|
342 TUint32 iSessionID; |
|
343 TUint32 iLinkID; |
|
344 TUint32 iStreamID; |
|
345 TUint32 iEndpointID; |
|
346 TInt iStreamType; |
|
347 TFourCC iCodec; |
|
348 TFixedArray<TFourCC, KMccFourCCArraySize> iFourCCArray; |
|
349 TUint iPort; |
|
350 TUint8 iPayloadType; |
|
351 TBool iEnableVAD; |
|
352 TInt iPacketizationRate; |
|
353 TUint iPTime; |
|
354 TUint iMaxPTime; |
|
355 }; |
|
356 |
|
357 typedef TPckgBuf<TMccSession> TMccSessionPckg; |
|
358 |
|
359 /* |
|
360 * Message class for stream messages |
|
361 * @since Series 60 3.0 |
|
362 * @lib mmcccontroller.dll |
|
363 */ |
|
364 class TMccStream |
|
365 { |
|
366 public: |
|
367 TMccStream() : |
|
368 iSessionID( 0 ), |
|
369 iLinkID( 0 ), |
|
370 iStreamID( 0 ), |
|
371 iEndpointID( 0 ), |
|
372 iStreamType( KMccAudioUplinkStream ), |
|
373 iCodec(), |
|
374 iBitrate( 0 ), |
|
375 iPriority( 0 ), |
|
376 iPayloadType( 0 ), |
|
377 iEnableVAD( NULL ), |
|
378 iPacketizationRate( 1 ), |
|
379 iPTime( 20 ), |
|
380 iMaxPTime( 200 ), |
|
381 iEnableRTCP( EFalse ), |
|
382 iStreamPaused( EFalse ) |
|
383 {} |
|
384 |
|
385 TUint32 iSessionID; |
|
386 TUint32 iLinkID; |
|
387 TUint32 iStreamID; |
|
388 TUint32 iEndpointID; |
|
389 TInt iStreamType; |
|
390 TFourCC iCodec; |
|
391 TInt iBitrate; |
|
392 TInt iPriority; |
|
393 TUint8 iPayloadType; |
|
394 TBool iEnableVAD; |
|
395 TInt iPacketizationRate; |
|
396 TUint iPTime; |
|
397 TUint iMaxPTime; |
|
398 TBool iEnableRTCP; |
|
399 TBool iStreamPaused; |
|
400 }; |
|
401 |
|
402 typedef TPckgBuf<TMccStream> TMccStreamPckg; |
|
403 |
|
404 /* |
|
405 * Message class for stream creation parameters |
|
406 * @since Series 60 3.0 |
|
407 * @lib mmcccontroller.dll |
|
408 */ |
|
409 class TMccCreateStreamParam |
|
410 { |
|
411 public: |
|
412 TMccCreateStreamParam() : |
|
413 iPayloadType( 0 ), |
|
414 iFourCC( 0 ), |
|
415 iStreamType( KMccAudioUplinkStream ), |
|
416 iPrioritySettings(), |
|
417 iStandByTimer( 0 ) |
|
418 {} |
|
419 |
|
420 TUint8 iPayloadType; |
|
421 TFourCC iFourCC; |
|
422 TInt iStreamType; |
|
423 TMMFPrioritySettings iPrioritySettings; |
|
424 TUint iStandByTimer; |
|
425 }; |
|
426 |
|
427 typedef TPckgBuf<TMccCreateStreamParam> TMccCreateStreamParamPckg; |
|
428 |
|
429 /* |
|
430 * Message class for setting remote address |
|
431 * @since Series 60 3.0 |
|
432 * @lib mmcccontroller.dll |
|
433 */ |
|
434 class TMccAddress |
|
435 { |
|
436 public: |
|
437 TMccAddress() : |
|
438 iSessionID( 0 ), |
|
439 iLinkID( 0 ), |
|
440 iStreamID( 0 ), |
|
441 iAddress() |
|
442 {} |
|
443 |
|
444 TUint32 iSessionID; |
|
445 TUint32 iLinkID; |
|
446 TUint32 iStreamID; |
|
447 TInetAddr iAddress; |
|
448 }; |
|
449 |
|
450 typedef TPckgBuf<TMccAddress> TMccAddressPckg; |
|
451 |
|
452 |
|
453 /* |
|
454 * Message class for setting remote address |
|
455 * @since Series 60 3.0 |
|
456 * @lib mmcccontroller.dll |
|
457 */ |
|
458 class TMccSSRC |
|
459 { |
|
460 public: |
|
461 TMccSSRC() : |
|
462 iSSRC( 0 ) |
|
463 {} |
|
464 |
|
465 TUint32 iSSRC; |
|
466 }; |
|
467 |
|
468 typedef TPckgBuf<TMccSSRC> TMccSSRCPckg; |
|
469 |
|
470 |
|
471 /* |
|
472 * Message class for payload messages |
|
473 * @since Series 60 3.0 |
|
474 * @lib mmcccontroller.dll |
|
475 */ |
|
476 class TMccPayload |
|
477 { |
|
478 public: |
|
479 TMccPayload() |
|
480 : |
|
481 iSessionID( 0 ), |
|
482 iStreamID( 0 ), |
|
483 iCurrentDlPacketCount( 0 ), |
|
484 iRtcpType( 0 ), |
|
485 iSSRC( 0 ), |
|
486 iApp(), |
|
487 iSdesParams(), |
|
488 iReason( NULL ), |
|
489 iEventType( 0 ), |
|
490 iError( 0 ) |
|
491 { |
|
492 iTimeStamps.iNTPTimeStampSec = 0; |
|
493 iTimeStamps.iNTPTimeStampFrac = 0; |
|
494 iTimeStamps.iTimeStamp = 0; |
|
495 } |
|
496 |
|
497 TUint32 iSessionID; |
|
498 TUint32 iStreamID; |
|
499 TInt iCurrentDlPacketCount; |
|
500 TInt iRtcpType; |
|
501 TRtpSSRC iSSRC; |
|
502 TRtcpApp iApp; |
|
503 TTimeStamps iTimeStamps; |
|
504 TRtpSdesParams iSdesParams; |
|
505 TBuf8<KMaxRtcpReason> iReason; |
|
506 TInt iEventType; |
|
507 TInt iError; |
|
508 }; |
|
509 |
|
510 typedef TPckgBuf<TMccPayload> TMccPayloadPckg; |
|
511 |
|
512 /* |
|
513 * Message class for bitrate messages |
|
514 * @since Series 60 3.0 |
|
515 * @lib mmcccontroller.dll |
|
516 */ |
|
517 class TMccBitrates |
|
518 { |
|
519 public: |
|
520 TMccBitrates() |
|
521 { |
|
522 for ( TInt i = 0; i < KMaxBitrates; i++ ) |
|
523 { |
|
524 iBitrates[i] = 0; |
|
525 } |
|
526 } |
|
527 TUint32 iBitrates[KMaxBitrates]; |
|
528 }; |
|
529 |
|
530 typedef TPckgBuf<TMccBitrates> TMccBitratesPckg; |
|
531 |
|
532 |
|
533 /** |
|
534 * Class for generic messages |
|
535 * @since Series 60 3.0 |
|
536 * @lib mmcccontroller.dll |
|
537 */ |
|
538 class TMccGenericMessage |
|
539 { |
|
540 public: |
|
541 inline TMccGenericMessage() : |
|
542 iSessionID( 0 ), |
|
543 iLinkID( 0 ), |
|
544 iStreamID( 0 ), |
|
545 iEndpointID( 0 ), |
|
546 iMessageFunction( 0 ), |
|
547 iParam1( KNullDesC8 ), |
|
548 iParam2( 0 ), |
|
549 iParam3( 0 ), |
|
550 iParam4( 0 ) |
|
551 { } |
|
552 |
|
553 public: |
|
554 // Session ID |
|
555 TUint32 iSessionID; |
|
556 |
|
557 // Link ID |
|
558 TUint32 iLinkID; |
|
559 |
|
560 // Stream ID |
|
561 TUint32 iStreamID; |
|
562 |
|
563 // Stream ID |
|
564 TUint32 iEndpointID; |
|
565 |
|
566 // Message function |
|
567 TInt iMessageFunction; |
|
568 |
|
569 TBuf8<256> iParam1; |
|
570 |
|
571 TUint32 iParam2; |
|
572 |
|
573 TReal iParam3; |
|
574 |
|
575 TInt iParam4; |
|
576 |
|
577 }; |
|
578 |
|
579 // Typedef so we can use it in IPC/ITC messages |
|
580 typedef TPckgBuf<TMccGenericMessage> TMccGenericMsgBuffer; |
|
581 |
|
582 /** |
|
583 * Class for security use |
|
584 * @since Series 60 3.0 |
|
585 * @lib mmcccontroller.dll |
|
586 */ |
|
587 class TMccSecurityDestination |
|
588 { |
|
589 public: |
|
590 inline TMccSecurityDestination() : |
|
591 iSessionID( 0 ), |
|
592 iLinkID( 0 ), |
|
593 iStreamID( 0 ), |
|
594 iEndpointID( 0 ) |
|
595 { } |
|
596 |
|
597 public: |
|
598 // Session ID |
|
599 TUint32 iSessionID; |
|
600 |
|
601 // Link ID |
|
602 TUint32 iLinkID; |
|
603 |
|
604 // Stream ID |
|
605 TUint32 iStreamID; |
|
606 |
|
607 // Stream ID |
|
608 TUint32 iEndpointID; |
|
609 |
|
610 }; |
|
611 |
|
612 typedef TPckgBuf<TMccSecurityDestination> TMccSecurityDestinationBuffer; |
|
613 |
|
614 /* |
|
615 * Mcc Event handling interface |
|
616 * @since Series 60 3.0 |
|
617 * @lib mmcccontroller.dll |
|
618 */ |
|
619 class MMccEventHandler |
|
620 { |
|
621 public: |
|
622 |
|
623 /** |
|
624 * Pure virtual function SendMccEventToClient. |
|
625 * Send Mcc event to client |
|
626 * @since Series 60 3.0 |
|
627 * @param aEvent - [input] Event to be handled |
|
628 * @return KErrNone if successful |
|
629 */ |
|
630 virtual TInt SendMccEventToClient( TMccEvent& aEvent ) = 0; |
|
631 |
|
632 /** |
|
633 * Event handling interface |
|
634 * @since Series 60 3.0 |
|
635 * @param [input] aState The new state |
|
636 * @param [input] aLink The link in which the state change occurred |
|
637 * @return void |
|
638 */ |
|
639 virtual void StateChange( TInt aState, TUint32 aLink ) = 0; |
|
640 |
|
641 /** |
|
642 * Error passing to the client |
|
643 * @since Series 60 3.0 |
|
644 * @param [input] aError The error that occured |
|
645 * @param [input] aLink The link in which the error occurred |
|
646 * @return void |
|
647 */ |
|
648 virtual void ErrorOccured( TInt aError, |
|
649 TUint32 aSessionId, |
|
650 TUint32 aLinkId, |
|
651 TUint32 aStreamId, |
|
652 TUint32 aEndpointId ) = 0; |
|
653 }; |
|
654 |
|
655 /* |
|
656 * Class encapsulating key-value pairs. |
|
657 * @since Series 60 3.2 |
|
658 * @lib mmcccontroller.dll |
|
659 */ |
|
660 template<class K, class V > |
|
661 class TMccKeyValuePair |
|
662 { |
|
663 public: |
|
664 |
|
665 TMccKeyValuePair( K& aKey, V& aValue ) |
|
666 : |
|
667 iKey( aKey ), iValue( aValue ) { }; |
|
668 |
|
669 K Key() const { return iKey; }; |
|
670 |
|
671 V Value() const { return iValue; }; |
|
672 |
|
673 static TBool CompareKey( const K* aKey, const TMccKeyValuePair& aPair ) |
|
674 { |
|
675 return ( aPair.iKey == *aKey ); |
|
676 } |
|
677 |
|
678 static TBool CompareValue( const V* aValue, const TMccKeyValuePair& aPair ) |
|
679 { |
|
680 return ( aPair.iValue == *aValue ); |
|
681 } |
|
682 |
|
683 public: |
|
684 |
|
685 K iKey; |
|
686 V iValue; |
|
687 }; |
|
688 |
|
689 |
|
690 /** |
|
691 * Methods for accessing elements in "user" array |
|
692 */ |
|
693 template<class UserEntry> |
|
694 class MccUserArray |
|
695 { |
|
696 public: |
|
697 |
|
698 static UserEntry* FindUserEntryForCurrent( |
|
699 RArray<UserEntry>& aUsers, MAsyncEventHandler* aEventHandler ) |
|
700 { |
|
701 UserEntry entry( aEventHandler ); |
|
702 TIdentityRelation<UserEntry> comparison( UserMatch ); |
|
703 TInt index = aUsers.Find( entry, comparison ); |
|
704 if ( index != KErrNotFound ) |
|
705 { |
|
706 return &aUsers[ index ]; |
|
707 } |
|
708 return NULL; |
|
709 } |
|
710 |
|
711 static void RemoveCurrentUser( |
|
712 RArray<UserEntry>& aUsers, MAsyncEventHandler* aEventHandler ) |
|
713 { |
|
714 UserEntry entry( aEventHandler ); |
|
715 TIdentityRelation<UserEntry> comparison( UserMatch ); |
|
716 TInt index = aUsers.Find( entry, comparison ); |
|
717 if ( index != KErrNotFound ) |
|
718 { |
|
719 aUsers.Remove( index ); |
|
720 } |
|
721 } |
|
722 |
|
723 static TBool UserMatch( |
|
724 const UserEntry& aUser1, |
|
725 const UserEntry& aUser2 ) |
|
726 { |
|
727 // First argument is always the search term |
|
728 |
|
729 TBool match( EFalse ); |
|
730 if ( aUser1.iEventHandler ) |
|
731 { |
|
732 match = ( aUser1.iEventHandler == aUser2.iEventHandler ); |
|
733 } |
|
734 return match; |
|
735 } |
|
736 |
|
737 static UserEntry* FindUserEntryForCurrent( |
|
738 RPointerArray<UserEntry>& aUsers, MAsyncEventHandler* aEventHandler ) |
|
739 { |
|
740 UserEntry entry( aEventHandler ); |
|
741 TIdentityRelation<UserEntry> comparison( UserMatch ); |
|
742 TInt index = aUsers.Find( &entry, comparison ); |
|
743 if ( index != KErrNotFound ) |
|
744 { |
|
745 return aUsers[ index ]; |
|
746 } |
|
747 return NULL; |
|
748 } |
|
749 |
|
750 static TInt FindUserEntryIndexForCurrent( |
|
751 RPointerArray<UserEntry>& aUsers, MAsyncEventHandler* aEventHandler ) |
|
752 { |
|
753 UserEntry entry( aEventHandler ); |
|
754 TIdentityRelation<UserEntry> comparison( UserMatch ); |
|
755 return aUsers.Find( &entry, comparison ); |
|
756 } |
|
757 |
|
758 static void RemoveCurrentUser( |
|
759 RPointerArray<UserEntry>& aUsers, MAsyncEventHandler* aEventHandler ) |
|
760 { |
|
761 UserEntry entry( aEventHandler ); |
|
762 TIdentityRelation<UserEntry> comparison( UserMatch ); |
|
763 TInt index = aUsers.Find( &entry, comparison ); |
|
764 if ( index != KErrNotFound ) |
|
765 { |
|
766 delete aUsers[ index ]; |
|
767 aUsers.Remove( index ); |
|
768 } |
|
769 } |
|
770 }; |
|
771 |
|
772 class MccConversionUtility |
|
773 { |
|
774 public: |
|
775 |
|
776 static HBufC8* Base64EncodeLC( const TDesC8& aInput ) |
|
777 { |
|
778 const TUint KMccFileB64MaxSizeMod = 2; |
|
779 HBufC8* output = HBufC8::NewLC( aInput.Length() * KMccFileB64MaxSizeMod ); |
|
780 TPtr8 ptrOutput( output->Des() ); |
|
781 TBase64 encoder; |
|
782 User::LeaveIfError( encoder.Encode( aInput, ptrOutput ) ); |
|
783 return output; |
|
784 } |
|
785 }; |
|
786 |
|
787 #endif |