|
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: Video session interface. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CVTENGMEDIAHANDLER_H |
|
21 #define CVTENGMEDIAHANDLER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <mvtprotocolhandler.h> |
|
26 #include "MVtEngMedia.h" |
|
27 #include "vtengcommands.h" |
|
28 #include "CVtEngLocalVideo.h" |
|
29 #include "MVtEngSettingObserver.h" |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 class CVtEngLocalVideo; |
|
33 class CVtEngRemoteVideo; |
|
34 class MVtEngFrameObserver; |
|
35 class CVtEngOperation; |
|
36 class CVtEngExtensionBase; |
|
37 |
|
38 // CLASS DECLARATION |
|
39 |
|
40 /** |
|
41 * Media control. |
|
42 * |
|
43 * @lib videoteleng.lib |
|
44 * @since Series 60 2.6 |
|
45 */ |
|
46 NONSHARABLE_CLASS( CVtEngMediaHandler ) : |
|
47 public CBase, |
|
48 public MVtEngMedia, |
|
49 public MVtEngSettingObserver, |
|
50 public MVtProtocolHandler |
|
51 { |
|
52 public: // Constructor and destructor. |
|
53 |
|
54 /** |
|
55 * Symbian two-phase constructor. |
|
56 * @return media handler instance |
|
57 */ |
|
58 static CVtEngMediaHandler* NewL(); |
|
59 |
|
60 /** |
|
61 * Destructor. |
|
62 */ |
|
63 ~CVtEngMediaHandler(); |
|
64 |
|
65 public: // From MVtEngMedia. |
|
66 |
|
67 /** |
|
68 * @see MVtEngMedia |
|
69 */ |
|
70 virtual TInt GetMediaState( |
|
71 const TMediaDirection aMediaDirection, |
|
72 TInt& aActiveMedia ) const; |
|
73 |
|
74 /** |
|
75 * @see MVtEngMedia |
|
76 */ |
|
77 virtual TBool RenderingStarted( |
|
78 const TMediaDirection |
|
79 aDirection ) const; |
|
80 |
|
81 /** |
|
82 * @see MVtEngMedia |
|
83 */ |
|
84 virtual TInt GetSource( TMediaSource& aSource ) const; |
|
85 |
|
86 /** |
|
87 * @see MVtEngMedia |
|
88 */ |
|
89 virtual TInt GetSourcesCaps( TInt& aCaps ) const; |
|
90 |
|
91 /** |
|
92 * @see MVtEngMedia |
|
93 */ |
|
94 virtual TInt GetCurrentCameraId( TCameraId& aId ) const; |
|
95 |
|
96 /** |
|
97 * @see MVtEngMedia |
|
98 */ |
|
99 virtual TInt GetCameraInfo( |
|
100 const TCameraId aId, |
|
101 TCameraInfo& aInfo ) const; |
|
102 |
|
103 /** |
|
104 * @see MVtEngMedia |
|
105 */ |
|
106 virtual TInt GetCurrentZoomStep( TInt& aCurrentStep ); |
|
107 |
|
108 /** |
|
109 * @see MVtEngMedia |
|
110 */ |
|
111 virtual TInt GetMaxZoomStep( TInt& aMaxZoomStep ); |
|
112 |
|
113 /** |
|
114 * @see MVtEngMedia |
|
115 */ |
|
116 virtual TInt GetMajorZoomStepCount( TInt& aCount ); |
|
117 |
|
118 /** |
|
119 * @see MVtEngMedia |
|
120 */ |
|
121 virtual void GetMajorZoomStep( TInt aIndex, TInt& aStep ); |
|
122 |
|
123 /** |
|
124 * @see MVtEngMedia |
|
125 */ |
|
126 virtual TInt GetFreezeSupported( TBool& aFreezeSupported ) const; |
|
127 |
|
128 /** |
|
129 * @see MVtEngMedia |
|
130 */ |
|
131 virtual TInt GetFreezeState( TBool& aFrozen ) const; |
|
132 |
|
133 /** |
|
134 * @see MVtEngMedia |
|
135 */ |
|
136 virtual TInt GetDsaState( |
|
137 const TMediaDirection aMediaDirection, |
|
138 TBool& aActive ) const; |
|
139 |
|
140 /** |
|
141 * @see MVtEngMedia |
|
142 */ |
|
143 virtual TBool VideoCallConnected () const; |
|
144 |
|
145 /** |
|
146 * @see MVtEngMedia |
|
147 */ |
|
148 virtual void GetVideoQuality( TVideoQuality& aVideoQuality ) const; |
|
149 |
|
150 /** |
|
151 * @see MVtEngMedia |
|
152 */ |
|
153 virtual void GetObjectSharingState( |
|
154 TShareObjectState& aObjectSharingState ) const; |
|
155 |
|
156 /** |
|
157 * @ see MVtEngMedia |
|
158 */ |
|
159 virtual void GetCameraOrientations( |
|
160 TCameraOrientation& aPrimaryCameraOrientation, |
|
161 TCameraOrientation& aSecondaryCameraOrientation ) const; |
|
162 |
|
163 public: // New functions. |
|
164 |
|
165 /** |
|
166 * Tells if the Protocol initialization has completed. |
|
167 * @return ETrue if initialized |
|
168 */ |
|
169 TBool ProtoInitialized() const; |
|
170 |
|
171 /** |
|
172 * Performs an operation in the handler. |
|
173 * @param operation to be performed on the handler |
|
174 */ |
|
175 virtual void HandleL( CVtEngOperation& aOperation ); |
|
176 |
|
177 /** |
|
178 * Returns if command can be performed by media handler. |
|
179 * @return KErrNone if a command can be perfomed |
|
180 * KErrNotReady if not in appropriate state |
|
181 * KErrNotSupported if command is not for media handler |
|
182 */ |
|
183 TInt ValidateCommand( const TVtEngCommandId aCommand ) const; |
|
184 |
|
185 /** |
|
186 * Returns ETrue if video channel is closed. |
|
187 */ |
|
188 TBool IsVideoChannelClosed() const; |
|
189 |
|
190 /** |
|
191 * Request update last remote video frame through MVtEngFrameObserver::vtSetFrame |
|
192 */ |
|
193 void RequestLastRemoteFrame(); |
|
194 |
|
195 public: // from MVtProtocolHandler |
|
196 |
|
197 /** |
|
198 * Handles callback from protocol. |
|
199 * @param aResponse response |
|
200 */ |
|
201 virtual void HandleSessionCommandEventL(const TVtCommandResponse& aResponse); |
|
202 |
|
203 public: // From MVtProtocolHandler. |
|
204 |
|
205 /** |
|
206 * Handles callback from protocol audiocontroller. |
|
207 * @param aId which command |
|
208 * @param aCmd which audio command |
|
209 * @param aContextData any additional data |
|
210 * @param aStatus how did it end up with |
|
211 */ |
|
212 virtual void HandleAudioOutputControlCommandComplete(TInt aId, |
|
213 TVtAudioOutputControlCommand aCmd, |
|
214 TAny *aContextData, |
|
215 TInt aStatus); |
|
216 |
|
217 public: // From MVtProtocolHandler. |
|
218 |
|
219 /** |
|
220 * Handles event from protocol. |
|
221 * @param aEvent event |
|
222 */ |
|
223 virtual void HandleSessionInformationalEventL( |
|
224 const TVtIndicationEvent& aEvent); |
|
225 |
|
226 public: // from MVtProtocolHandler |
|
227 |
|
228 /** |
|
229 * Handles error event from protocol. |
|
230 * @param aEvent error event |
|
231 */ |
|
232 virtual void HandleSessionErrorEventL(const TVtErrorEvent& aEvent); |
|
233 |
|
234 public: // from MVtEngSettingObserver |
|
235 |
|
236 /** |
|
237 * Handles shared data setting change. |
|
238 * @param aId setting id |
|
239 * @param aValue setting value |
|
240 */ |
|
241 virtual void HandleSettingChangedL( |
|
242 CVtEngSettings::TSettingId aId, |
|
243 const TDesC& aValue ); |
|
244 |
|
245 public: // From MVtProtocolHandler. |
|
246 |
|
247 /** |
|
248 * @see MVtProtocolHandler. |
|
249 */ |
|
250 void HandleVideoEncoderCommandCompletedL( |
|
251 const TVtCommandResponse& aResponse ); |
|
252 |
|
253 /** |
|
254 * @see MVtProtocolHandler. |
|
255 */ |
|
256 void HandleVideoEncoderInformationalEventL( |
|
257 const TVtIndicationEvent& aEvent); |
|
258 |
|
259 public: // From MVtProtocolHandler |
|
260 |
|
261 /** |
|
262 * @see MVtProtocolHandler. |
|
263 * @since 3.1 |
|
264 */ |
|
265 void HandleH324MConfigCommandCompletedL( const TVtCommandResponse& aResponse ); |
|
266 |
|
267 /** |
|
268 * @see MVtProtocolHandler. |
|
269 * @since 3.1 |
|
270 */ |
|
271 void HandleH324MConfigInformationalEventL( |
|
272 const TVtIndicationEvent& aEvent ); |
|
273 |
|
274 public: // New functions. |
|
275 |
|
276 /** |
|
277 * Initializes media handler. |
|
278 * @param aStatus signaling handle |
|
279 */ |
|
280 void InitializeL( TRequestStatus& aStatus ); |
|
281 |
|
282 /** |
|
283 * Cancels media handler initialization. |
|
284 */ |
|
285 void CancelInitialize(); |
|
286 |
|
287 /** |
|
288 * Initializes default blank provider. |
|
289 * @param aStatus signaling handle |
|
290 */ |
|
291 void InitializeProviderL( TRequestStatus& aStatus ); |
|
292 |
|
293 /** |
|
294 * Cancel Image sharing initialization. |
|
295 */ |
|
296 void CancelInitializeShareImage(); |
|
297 |
|
298 /** |
|
299 * Sets protocol interface. |
|
300 * aProto2Way protocol interface |
|
301 */ |
|
302 void SetSessionCommand( MVtSessionCommand* aProto2Way ); |
|
303 |
|
304 /** |
|
305 * Unitializes media handler. |
|
306 * @param aStatus request semaphore to complete |
|
307 * when uninitialization is complete |
|
308 */ |
|
309 void Uninitialize( TRequestStatus& aStatus ); |
|
310 |
|
311 /** |
|
312 * Goes to next step of uninitialization process, it can |
|
313 * be one of following |
|
314 * - Cancel all Protocol commands |
|
315 * - Protocol disconnect |
|
316 * - Protocol reset |
|
317 * - Switch blank provider. |
|
318 */ |
|
319 void UninitializeNextStep(); |
|
320 |
|
321 /** |
|
322 * Sets selected camera ID. |
|
323 * @param aId camera ID (primary or secondary) |
|
324 * @param aUpdateRequired if ETrue switch could not be performed |
|
325 * Switch will be done when engine has been initialized. |
|
326 */ |
|
327 void SetSelectedCameraId( |
|
328 const TCameraId aId, |
|
329 TBool aUpdateRequired = EFalse ); |
|
330 |
|
331 /** |
|
332 * Handles source initialization or switch. |
|
333 * @param aResult Symbian OS error code |
|
334 */ |
|
335 void HandleLocalVideoOperationCompleteL( const TInt aResult ); |
|
336 |
|
337 /** |
|
338 * SDK init info. |
|
339 * @return Protocol initialization info |
|
340 */ |
|
341 TVtInitInfo& SdkInitInfo(); |
|
342 |
|
343 /** |
|
344 * Returns protocol state maintained by VTEngine, not by Protocol. |
|
345 * @return state |
|
346 */ |
|
347 MVtProtocolCommand::TVtProtocolState ProtoState(); |
|
348 |
|
349 /** |
|
350 * Sets up video connection to remote terminal. |
|
351 * @return Symbian OS error code |
|
352 */ |
|
353 TInt Connect(); |
|
354 |
|
355 /** |
|
356 * Disconnects session. |
|
357 * @return Symbian OS error code |
|
358 */ |
|
359 TInt Disconnect(); |
|
360 |
|
361 /** |
|
362 * Adds video data source to protocol engine. |
|
363 * @param Video channel logical channel ID number. |
|
364 * @return Symbian OS error code |
|
365 */ |
|
366 TInt AddVideoSource( TUint aChannelId ); |
|
367 |
|
368 /** |
|
369 * Adds audio data source to protocol engine. |
|
370 * @param Audio channel logical channel ID number. |
|
371 * @return Symbian OS error code |
|
372 */ |
|
373 TInt AddAudioSource( TUint aChannelId ); |
|
374 |
|
375 /** |
|
376 * Adds video sink. |
|
377 * @param Video channel logical channel ID number. |
|
378 * @return Symbian OS error code |
|
379 */ |
|
380 TInt AddVideoSink( TUint aChannelId ); |
|
381 |
|
382 /** |
|
383 * Adds audio sink. |
|
384 * @param Audio channel logical channel ID number. |
|
385 * @return Symbian OS error code |
|
386 */ |
|
387 TInt AddAudioSink( TUint aChannelId ); |
|
388 |
|
389 /** |
|
390 * Sets the output volume for Protocol. |
|
391 * @param aVolume the level of the volume |
|
392 * @return Symbian OS error code |
|
393 */ |
|
394 TInt SetVolume( const TInt aVolume, |
|
395 CVtEngOperation* aOperation = NULL ); |
|
396 |
|
397 /** |
|
398 * Enables video when primary camera becomes available. |
|
399 * @param aEnable do we enable or disable |
|
400 * @return Symbian OS error code |
|
401 */ |
|
402 TInt AutoEnableVideo( TBool aEnable = ETrue ); |
|
403 |
|
404 /** |
|
405 * Deletes protocol instance and associated Protocol interfaces. |
|
406 */ |
|
407 void FinalizeUninitialization(); |
|
408 |
|
409 /** |
|
410 * Creates extension according to API Uid. |
|
411 * @since S60 v3.2 |
|
412 * @param aUid extension API Uid. |
|
413 * @return Extension pointer |
|
414 * @exeption Leaves if creation fails |
|
415 * |
|
416 */ |
|
417 CVtEngExtensionBase* CreateExtensionsL( const TUid& aUid ); |
|
418 |
|
419 /** |
|
420 * Checks if there is already an operation pending. |
|
421 * @return KVtEngCommandNone if no operation is pending or Command identifier |
|
422 */ |
|
423 TVtEngCommandId GetPendingCommand(); |
|
424 |
|
425 private: // new functions |
|
426 |
|
427 /** |
|
428 * Sends a sync message to Protocol after provider switch. |
|
429 */ |
|
430 void RequestFrame( ); |
|
431 |
|
432 /** |
|
433 * Sets video quality |
|
434 */ |
|
435 void SetVideoQualityL( |
|
436 const TVideoQuality aVideoQuality, |
|
437 const TBool aSetPeerVideoQuality ); |
|
438 |
|
439 /** |
|
440 * Sets peer video quality |
|
441 */ |
|
442 void SetPeerVideoQuality( const TVideoQuality aVideoQuality ); |
|
443 |
|
444 /** |
|
445 * Check's flag's validity. If not valid, panic's in debug mode. |
|
446 * @param aFlag flag to check. |
|
447 */ |
|
448 void AssertFlag( const TInt aFlag ) const; |
|
449 |
|
450 /** |
|
451 * Gets the version information from SysUtil |
|
452 * and sets it into Protocol. |
|
453 */ |
|
454 void SetVersionInfoL(); |
|
455 |
|
456 /** |
|
457 * Sets supported resolutions to Protocol. |
|
458 */ |
|
459 void SetSupportedResolutions(); |
|
460 |
|
461 /** |
|
462 * Sets used call setup enhancement parameters. |
|
463 */ |
|
464 void SetFastCsupOptions(); |
|
465 |
|
466 /** |
|
467 * Does Protocol reset. |
|
468 */ |
|
469 void ResetProtoL(); |
|
470 |
|
471 /** |
|
472 * Does the actual disconnecting with Protocol. |
|
473 */ |
|
474 void DisconnectProtoL(); |
|
475 |
|
476 /** |
|
477 * Sets the defaults for volumes. |
|
478 */ |
|
479 void InitializeVolume(); |
|
480 |
|
481 /** |
|
482 * Checks if a flag in iProtoInitFlags is set. |
|
483 * @return ETrue if flag is set |
|
484 */ |
|
485 TBool IsFlag( const TInt aFlag ) const; |
|
486 |
|
487 /** |
|
488 * Sets a flag in iProtoInitFlags. |
|
489 * @param aFlag flag to set |
|
490 */ |
|
491 inline void SetFlag( const TInt aFlag ); |
|
492 |
|
493 /** |
|
494 * Clears a flag in iProtoInitFlags. |
|
495 * @param aFlag flag to clear |
|
496 */ |
|
497 inline void ClearFlag( const TInt aFlag ); |
|
498 |
|
499 /** |
|
500 * Requests the volume controller. |
|
501 * @return ETrue if retrieved ok |
|
502 */ |
|
503 TBool RequestAudioControllerL(); |
|
504 |
|
505 /** |
|
506 * Spatial trade off indication handling method. Indication is |
|
507 * sent by the peer every time when its spatial trade off is updated. |
|
508 * @param aLogicalChannelId Indication's logical channel Id. |
|
509 * @param aTradeOff Indication trade off value. |
|
510 */ |
|
511 void HandleSpatialTradeoffIndication( |
|
512 const TUint16 aLogicalChannelId, const TUint8 aTradeOff ); |
|
513 |
|
514 /** |
|
515 * Spatial trade off command handling method. Spatial trade off |
|
516 * command is sent by the peer whenever peer wants to adjust our |
|
517 * video quality. |
|
518 * @param aLogicalChannelId Command's logical channel Id. |
|
519 * @param aTradeOff New trade off value. |
|
520 */ |
|
521 void HandleSpatialTradeoffCommandL( |
|
522 const TUint16 aLogicalChannelId, const TUint8 aTradeOff ); |
|
523 |
|
524 private: // constructor and destructor |
|
525 |
|
526 /** |
|
527 * C++ default constructor. |
|
528 */ |
|
529 CVtEngMediaHandler(); |
|
530 |
|
531 /** |
|
532 * Symbian constructor that may leave. |
|
533 */ |
|
534 void ConstructL(); |
|
535 |
|
536 private: |
|
537 /** |
|
538 * Operation values |
|
539 */ |
|
540 enum TOperation |
|
541 { |
|
542 /** |
|
543 * No-op. |
|
544 * 0 |
|
545 */ |
|
546 ENone, |
|
547 |
|
548 /** |
|
549 * Add video source to protocol. |
|
550 * 1 |
|
551 */ |
|
552 EAddVideoSource, |
|
553 |
|
554 /** |
|
555 * Add video source to protocol. |
|
556 * 2 |
|
557 */ |
|
558 EAddVideoSink, |
|
559 |
|
560 /** |
|
561 * Add audio source to protocol. |
|
562 * 3 |
|
563 */ |
|
564 EAddAudioSource, |
|
565 |
|
566 /** |
|
567 * Add audio source to protocol. |
|
568 * 4 |
|
569 */ |
|
570 EAddAudioSink, |
|
571 |
|
572 /** |
|
573 * Connect protocol. |
|
574 * 5 |
|
575 */ |
|
576 EConnectProto, |
|
577 |
|
578 /** |
|
579 * Mute audio. |
|
580 * 6 |
|
581 */ |
|
582 EMuteAudio, |
|
583 |
|
584 /** |
|
585 * Resume audio sending. |
|
586 * 7 |
|
587 */ |
|
588 EUnmuteAudio, |
|
589 |
|
590 /** |
|
591 * Enable video for peer. |
|
592 * 8 |
|
593 */ |
|
594 EEnableVideo, |
|
595 |
|
596 /** |
|
597 * Disable video for peer. |
|
598 * 9 |
|
599 */ |
|
600 EDisableVideo, |
|
601 |
|
602 /** |
|
603 * Cancel ongoing request to Protocol |
|
604 * as part of uninitiazation process. |
|
605 * 10 |
|
606 */ |
|
607 EUninitializeCancelAllProto, |
|
608 |
|
609 /** |
|
610 * Disconnect protocol. |
|
611 * 11 |
|
612 */ |
|
613 EDisconnectProto, |
|
614 |
|
615 /** |
|
616 * Destructs local/remote video and VS instances. |
|
617 * 12 |
|
618 */ |
|
619 EDestructInternals, |
|
620 |
|
621 /** |
|
622 * Terminates H.324 session. |
|
623 * 13 |
|
624 */ |
|
625 ETerminateSession, |
|
626 |
|
627 /** |
|
628 * Removing sinks and sources. |
|
629 * 14 |
|
630 */ |
|
631 ERemovingSinksAndSources, |
|
632 |
|
633 /** |
|
634 * Request 324 control interface from protocol. |
|
635 * 15 |
|
636 */ |
|
637 EGet324CtrlInterface, |
|
638 |
|
639 /** |
|
640 * Set volume. |
|
641 * 16 |
|
642 */ |
|
643 ESetAudioVolume, |
|
644 |
|
645 /** |
|
646 * Gets the maximum volume for Protocol. |
|
647 * 17 |
|
648 */ |
|
649 EGetAudioGetMaxVolume, |
|
650 |
|
651 /** |
|
652 * Reset protocol. |
|
653 * 18 |
|
654 */ |
|
655 EDestructProtoPhaseDisconnect, |
|
656 |
|
657 /** |
|
658 * Destruct switch blank. |
|
659 * 19 |
|
660 */ |
|
661 EDestructSwitchBlank, |
|
662 |
|
663 /** |
|
664 * Reset protocol. |
|
665 * 20 |
|
666 */ |
|
667 EDestructProtoPhaseReset, |
|
668 |
|
669 /** |
|
670 * Check Protocol state. |
|
671 * 21 |
|
672 */ |
|
673 ECheckProtoState, |
|
674 |
|
675 /** |
|
676 * Enables video internally (not originated by UI). |
|
677 * 22 |
|
678 */ |
|
679 EEnableVideoInternal, |
|
680 |
|
681 /** |
|
682 * Disables video internally (not originated by UI). |
|
683 * 23 |
|
684 */ |
|
685 EDisableVideoInternal, |
|
686 |
|
687 /** |
|
688 * Request H263Enc interface from protocol. |
|
689 * 24 |
|
690 */ |
|
691 EGetH263EncInterface, |
|
692 |
|
693 /** |
|
694 * Requests an intra frame. |
|
695 * 25 |
|
696 */ |
|
697 ESendIntraframe, |
|
698 |
|
699 /** |
|
700 * Set supported resolutions. |
|
701 * 26 |
|
702 */ |
|
703 ESetSupportedResolutions, |
|
704 |
|
705 /** |
|
706 * Set video quality (by changing framerate) |
|
707 * 27 |
|
708 */ |
|
709 ESetVideoQuality, |
|
710 |
|
711 /** |
|
712 * Remove H324 interface |
|
713 * 28 |
|
714 */ |
|
715 ERemove324CtrlInterface, |
|
716 |
|
717 /** |
|
718 * Remove video encoder interface |
|
719 * 29 |
|
720 */ |
|
721 ERemoveH263EncInterface, |
|
722 |
|
723 /** |
|
724 * Sends Video Temporal-spatial trade off command |
|
725 * 30 |
|
726 */ |
|
727 ESendVTSTO, |
|
728 |
|
729 /** |
|
730 * Sets fast call setup options |
|
731 * 31 |
|
732 */ |
|
733 ESetFastCsupOptions, |
|
734 |
|
735 /** |
|
736 * Sets vendor id |
|
737 * 32 |
|
738 */ |
|
739 ESetVendorId, |
|
740 |
|
741 /** |
|
742 * Set interval when I-frames are sent |
|
743 * 33 |
|
744 */ |
|
745 ESetIFrameInterval |
|
746 }; |
|
747 |
|
748 /** |
|
749 * Operation and related command id. |
|
750 */ |
|
751 struct TCmdOpPair |
|
752 { |
|
753 // Operation |
|
754 TOperation iOp; |
|
755 // Command id returned by proto2way asynch request |
|
756 TInt iProtoCmdId; |
|
757 }; |
|
758 |
|
759 /** |
|
760 * Enables/Disables video sending. |
|
761 * @param aEnable ETrue if video is to be enabled |
|
762 * @param aOp operation to be added |
|
763 * NOTE. Valid only for enabling video, not when disabled. |
|
764 * @see void AutoEnableVideo |
|
765 * @return started operation or ENone |
|
766 */ |
|
767 TOperation EnableVideoL( |
|
768 const TBool aEnable, |
|
769 const TOperation aOp = EEnableVideo ); |
|
770 |
|
771 /** |
|
772 * Calls Protocol pausing and acts according to the result. |
|
773 * @return operation id for performed operation |
|
774 */ |
|
775 TOperation DoPauseVideo(); |
|
776 |
|
777 /** |
|
778 * Continues to next step of uninitialization. |
|
779 * @param aOp operation to perform |
|
780 * @return command id |
|
781 */ |
|
782 void ContinueUninitializeL( const TOperation aOp ); |
|
783 |
|
784 /** |
|
785 * Cancels all the running commands within Protocol. |
|
786 * @param operation to be returned |
|
787 * EUninitializeCancelAllProto if cancellation is ongoing |
|
788 * (either because was already or just started) |
|
789 * ENone if cancellation is not ongoing |
|
790 * @return error code |
|
791 * KErrNotReady if engine not in suitable state |
|
792 * KErrAlreadyExists if cancel was already pending |
|
793 * KErrNone if cancellation request succeeded |
|
794 * other Symbian OS error code if cancellation fails |
|
795 */ |
|
796 TInt CancelAllProtoCommands( TOperation &aOp ); |
|
797 |
|
798 /** |
|
799 * Stops view finder and remote video rendering. |
|
800 */ |
|
801 void StopRendering(); |
|
802 |
|
803 /** |
|
804 * Updates volume to Protocol (if possible). |
|
805 */ |
|
806 void UpdateVolume(); |
|
807 |
|
808 /** |
|
809 * Initiates protocol engine reset. |
|
810 */ |
|
811 void ResetProto2WayL(); |
|
812 |
|
813 /** |
|
814 * Removes operation from pending operations array. |
|
815 * @param aOp TOperation |
|
816 * @return ETrue if operation was found (and hence removed) |
|
817 */ |
|
818 template<class T> |
|
819 TBool RemoveOperation( const T& aOp ); |
|
820 |
|
821 /** |
|
822 * Adds operation pending for callback. |
|
823 * @param aOp operation value |
|
824 * @param aCmdId protocol commd id or 0 if not Protocol cmd |
|
825 * @param aResetExisting if ETrue removes existing operations |
|
826 * from array |
|
827 * @return index of the operation in array (i.e. >= 0 ) |
|
828 */ |
|
829 TInt AddOperation( |
|
830 const TOperation aOp, |
|
831 TInt aCmdId, |
|
832 const TBool aResetExisting = EFalse ); |
|
833 |
|
834 /** |
|
835 * Checks if an operation is pending. |
|
836 * @param aOp operation |
|
837 * @return index if operation is pending or KErrNotFound |
|
838 */ |
|
839 TInt IsPending( const TOperation aOp ) const; |
|
840 |
|
841 /** |
|
842 * Checks if an operation is pending. |
|
843 * @param aCmdId command id |
|
844 * @return index if operation is pending or KErrNotFound |
|
845 */ |
|
846 TInt IsPending( const TInt aCmdId ) const; |
|
847 |
|
848 /** |
|
849 * Completes asynchronous operation. |
|
850 * @param aResult |
|
851 * @return KErrNotFound if no operation else KErrNone |
|
852 */ |
|
853 TInt CompleteOp( const TInt aResult ); |
|
854 |
|
855 /** |
|
856 * Completes asynchronous operation asynchronously. |
|
857 * @param aResult |
|
858 * @return KErrNotFound if no operation else KErrNone |
|
859 */ |
|
860 void AsyncCompleteOp( const TInt aResult = KErrNone ); |
|
861 |
|
862 /** |
|
863 * Checks if specific operation matches to response from protocol. |
|
864 * @param aProtoCmdId command id returned by protocol |
|
865 * @param aOperation operation to search for in pending commands |
|
866 * @param aIndex index in iPendingOps array if found |
|
867 * @return ETrue if there's corrensponding entry in pending ops |
|
868 */ |
|
869 TBool MatchResponseToPendingOps( |
|
870 const TInt aProtoCmdId, |
|
871 const TOperation aOperation, |
|
872 TInt* aIndex = NULL ); |
|
873 |
|
874 /** |
|
875 * Starts "self-destruction" timer. |
|
876 */ |
|
877 void StartDisconnectTimerL(); |
|
878 |
|
879 /** |
|
880 * Assigns new pending operation. Only one can be pending at a time |
|
881 * so if there already is pending operation it is completed with error. |
|
882 * @param aOperation operation to assign as pending |
|
883 * @param aReplaceError error code to complete penging operation if |
|
884 * one exists. If KErrNone is passed, replacement is not done. |
|
885 * @return KErrNone if assignment done successfully i.e. there was |
|
886 not pending operation that was completed. |
|
887 * KErrCancel if some other operation was pending and was |
|
888 * completed with aReplaceError. Operation is |
|
889 * still assigned successfully. |
|
890 * KErrGeneral if operation was not assigned. |
|
891 */ |
|
892 TInt AssignPendingOp( |
|
893 CVtEngOperation& aOperation, |
|
894 TInt aReplaceError = KErrCancel ); |
|
895 |
|
896 /** |
|
897 * Callback function that completes ongoing operation. |
|
898 * @param aAny pointer to an instance of the class. |
|
899 * @return always KErrNone. |
|
900 */ |
|
901 static TInt DoCompleteOp( TAny* aAny ); |
|
902 |
|
903 /** |
|
904 * Implementation of self-destruction timer activity. |
|
905 * Causes a panic. |
|
906 * @param aAny pointer to an instance of the class |
|
907 * Not used. |
|
908 * @return KErrNone; |
|
909 */ |
|
910 static TInt TimerCallback( TAny* aAny ); |
|
911 |
|
912 /** |
|
913 * Creates and enques async callback for uninitialization. |
|
914 * @see iNextStepCallback |
|
915 */ |
|
916 void NextUninitStepCallbackL(); |
|
917 |
|
918 /** |
|
919 * Callback method for async uninitialization step. |
|
920 * @seeiNextStepCallback |
|
921 * @return KErrNone; |
|
922 */ |
|
923 static TInt UninitCallback( TAny* aAny ); |
|
924 |
|
925 /** |
|
926 * Query 2-way's additional interfaces, encoder and H324 |
|
927 * @return KErrNone; |
|
928 */ |
|
929 void QueryProtoInterfacesL(); |
|
930 |
|
931 /** |
|
932 * Release 2-way's additional interfaces, encoder and H324 |
|
933 * @return KErrNone; |
|
934 */ |
|
935 void ReleaseProtoInterfacesL(); |
|
936 |
|
937 /** |
|
938 * Check for pending Protocol extension interface commands. |
|
939 * @return ETrue if one or more extension command is pending |
|
940 */ |
|
941 TBool ExtensionCommandsPending() const; |
|
942 |
|
943 /** |
|
944 * Checks is it possible to add sink / source from session |
|
945 * state point of view. |
|
946 * @return ETrue if adding is allowed. |
|
947 */ |
|
948 TBool MediaAddingValidity() const; |
|
949 |
|
950 /** |
|
951 * Provider initialization state |
|
952 */ |
|
953 enum TInitState |
|
954 { |
|
955 /** |
|
956 * Initialization not ongoing. |
|
957 */ |
|
958 EInitStateNone, |
|
959 |
|
960 /** |
|
961 * Initialize still image. |
|
962 */ |
|
963 EStateInitStillImage, |
|
964 |
|
965 /** |
|
966 * Initilize default blank provider. |
|
967 */ |
|
968 EStateInitProvider, |
|
969 |
|
970 /** |
|
971 * Provider is set to none. |
|
972 */ |
|
973 EStateWaitingProviderChangeForUninit, |
|
974 |
|
975 /** |
|
976 * Initialization has been cancelled. |
|
977 */ |
|
978 EStateInitCanceled |
|
979 }; |
|
980 |
|
981 /** |
|
982 * State flags. |
|
983 */ |
|
984 enum |
|
985 { |
|
986 // Protocol state flags |
|
987 // Sink/source added |
|
988 EProtoAudioSourceAdded = 0x000001, |
|
989 EProtoVideoSourceAdded = 0x000002, |
|
990 EProtoAudioSinkAdded = 0x000004, |
|
991 EProtoVideoSinkAdded = 0x000008, |
|
992 // Track paused |
|
993 EProtoAudioTrackPaused = 0x000040, |
|
994 EProtoVideoTrackPaused = 0x000080, |
|
995 |
|
996 // Pause/resume related flags. |
|
997 ETwoStageOperation = 0x000100, |
|
998 ESourceUpdateNeeded = 0x000200, |
|
999 EProtoPauseVideoRequested= 0x000400, |
|
1000 EProtoPauseVideoBlankProv= 0x000800, |
|
1001 EProtoContVideoBlankProv = 0x001000, |
|
1002 EProtoContVideoBlankInit = 0x002000, |
|
1003 |
|
1004 // Must send intra |
|
1005 EProtoSendIntraFrame = 0x004000, |
|
1006 |
|
1007 // 324 interface acquired |
|
1008 EProto324IFAcquired = 0x008000, |
|
1009 |
|
1010 // Cancel all command is called on Protocol |
|
1011 // or there's nothing to cancel |
|
1012 EProtoCancelProtoCmdsOk = 0x010000, |
|
1013 |
|
1014 // NON Protocol related flags |
|
1015 |
|
1016 EVideoQualitySetByPeer= 0x020000, |
|
1017 |
|
1018 // Outgoing video channel closed (after being open) |
|
1019 // Used for preventing video pause/resume when |
|
1020 // the channel is not open |
|
1021 EOutVideoChannelClosed = 0x040000, |
|
1022 |
|
1023 // Outgoing audio channel closed (after being open) |
|
1024 // Used for preventing audio pause/resume |
|
1025 // the channel is not open |
|
1026 EOutAudioChannelClosed = 0x080000 |
|
1027 }; |
|
1028 |
|
1029 |
|
1030 /** |
|
1031 * Defines actions that can be taken when sharing started |
|
1032 * and/or stopped |
|
1033 */ |
|
1034 enum TVideoEngAction |
|
1035 { |
|
1036 EVideoActionNone, |
|
1037 EVideoActionEnable, |
|
1038 EVideoActionDisable |
|
1039 }; |
|
1040 |
|
1041 /** |
|
1042 * Helper class for handling video quality manipulation. |
|
1043 */ |
|
1044 class TVtEngVideoQuality |
|
1045 { |
|
1046 |
|
1047 public: |
|
1048 |
|
1049 // Forward for inner class |
|
1050 class TVQSParams; |
|
1051 |
|
1052 public: |
|
1053 |
|
1054 /** |
|
1055 * Constructor. |
|
1056 */ |
|
1057 TVtEngVideoQuality(); |
|
1058 |
|
1059 /** |
|
1060 * Destructor. |
|
1061 */ |
|
1062 ~TVtEngVideoQuality(); |
|
1063 |
|
1064 /** |
|
1065 * Sets new local video quality setting. |
|
1066 * @param aId Operation id. |
|
1067 * @param aSetPeer ETrue if peer video quality needs to be set, |
|
1068 * EFalse otherwise. |
|
1069 */ |
|
1070 void SettingVideoQuality( TInt aId, const TVideoQuality aValue, |
|
1071 TBool aSetPeer ); |
|
1072 |
|
1073 /** |
|
1074 * Get current local video quality setting. |
|
1075 * @return Current local video quality setting. |
|
1076 */ |
|
1077 TVideoQuality VideoQuality() const; |
|
1078 |
|
1079 /** |
|
1080 * Setting video quality succeeded. |
|
1081 * @return ETrue if record with given id was found, EFalse other |
|
1082 * wise. |
|
1083 */ |
|
1084 TBool SettingSucceeded( TInt aId, TVQSParams& aParams ); |
|
1085 |
|
1086 /** |
|
1087 * Setting video quality failed. |
|
1088 */ |
|
1089 void SettingFailed( TInt aId ); |
|
1090 |
|
1091 /** |
|
1092 * Called when video quality indication is received from peer. |
|
1093 */ |
|
1094 void UpdateVideoQuality( const TVideoQuality aVideoQuality ); |
|
1095 |
|
1096 /** |
|
1097 * Converts given trade off value to video quality enum. |
|
1098 */ |
|
1099 TVideoQuality FromTradeOff( const TInt aTradeOff ) const; |
|
1100 |
|
1101 /** |
|
1102 * Converts given video quality enum to trade off value. |
|
1103 */ |
|
1104 TInt ToFrameRate( const TVideoQuality aVideoQuality ) const; |
|
1105 |
|
1106 /** |
|
1107 * Converts given video quality value to frame rate. |
|
1108 */ |
|
1109 TUint8 ToTradeOff( const TVideoQuality aVideoQuality ) const; |
|
1110 |
|
1111 /** |
|
1112 * Finds id of setting param and returns index to it. |
|
1113 */ |
|
1114 TInt FindVQSParam( TInt aId ) const; |
|
1115 |
|
1116 public: |
|
1117 |
|
1118 /** |
|
1119 * Video quality parameters. |
|
1120 */ |
|
1121 struct TVQSParams |
|
1122 { |
|
1123 |
|
1124 public: |
|
1125 |
|
1126 // Default constructor |
|
1127 TVQSParams(); |
|
1128 |
|
1129 // Constructor with initializing parameters |
|
1130 TVQSParams( TInt aId, const TVideoQuality aValue, |
|
1131 TBool aSetPeer ); |
|
1132 |
|
1133 public: // data |
|
1134 |
|
1135 // Operation id |
|
1136 TInt iId; |
|
1137 |
|
1138 // VideoQuality value to be set |
|
1139 TVideoQuality iValue; |
|
1140 |
|
1141 // Defines whether peer video quality needs to be set or not |
|
1142 TBool iSetPeer; |
|
1143 |
|
1144 }; |
|
1145 |
|
1146 private: |
|
1147 |
|
1148 // Current local video quality |
|
1149 TVideoQuality iCurrent; |
|
1150 |
|
1151 // Qued params |
|
1152 RArray< TVQSParams > iParamList; |
|
1153 }; |
|
1154 |
|
1155 // Class for handling different kind of H.245 logical |
|
1156 // channels and their state in different MONA call setup |
|
1157 // scenarios |
|
1158 class TLogicalChannel |
|
1159 { |
|
1160 public: |
|
1161 |
|
1162 // H.245 logical channel ID to be established or |
|
1163 // already active |
|
1164 TUint iLogicalChannelId; |
|
1165 |
|
1166 // H.245 logical channel ID that is currently closing. |
|
1167 TUint iLogicalChannelIdClosing; |
|
1168 |
|
1169 // Variable to tell is same type (video or audio, incoming or outgoing) |
|
1170 // channel already started to close but not closed yet. If closing is pending |
|
1171 // same type channel cannot be opened until closing has finished or sink/source |
|
1172 // addition has failed for some reason. |
|
1173 TBool iSameTypeClosingPending; |
|
1174 |
|
1175 // Variable to tell is same type (video or audio, incoming or outgoing) |
|
1176 // channel ready to be opened. |
|
1177 TBool iSameTypeChannelReadyToOpen; |
|
1178 |
|
1179 }; |
|
1180 |
|
1181 private: // Data members. |
|
1182 |
|
1183 // Protocol engine pointer. |
|
1184 MVtSessionCommand* iSessionCommand; |
|
1185 |
|
1186 // Local video configuration. |
|
1187 CVtEngLocalVideo* iLocalVideo; |
|
1188 |
|
1189 // Remote video configuration. |
|
1190 CVtEngRemoteVideo* iRemoteVideo; |
|
1191 |
|
1192 // Pending internal operations. |
|
1193 TInt iCmdId; |
|
1194 CArrayFixFlat<TCmdOpPair>* iPendingOps; |
|
1195 |
|
1196 // Video Source initialization state. |
|
1197 TInitState iVSInitState; |
|
1198 |
|
1199 // Flags used to determine if audio and video sink/source |
|
1200 // is added to protocol and media state. |
|
1201 TInt iProtoStateFlags; |
|
1202 |
|
1203 // protocol state. |
|
1204 MVtProtocolCommand::TVtProtocolState iProtoState; |
|
1205 |
|
1206 // Initialization flag. |
|
1207 TBool iInitialized; |
|
1208 |
|
1209 // Remote media state. |
|
1210 TInt iRemoteMediaState; |
|
1211 |
|
1212 // Pending operation from client. |
|
1213 CVtEngOperation* iPendingOp; |
|
1214 |
|
1215 // Protocol initialization information. |
|
1216 TVtInitInfo iSdkInitInfo; |
|
1217 |
|
1218 |
|
1219 // Request status for (un)initialization. |
|
1220 TRequestStatus* iRequestStatus; |
|
1221 |
|
1222 // Audio controller handle. |
|
1223 MVtAudioConfigCommand* iAudioCtrl; |
|
1224 |
|
1225 // Timer to detect failure in disconnection. |
|
1226 CPeriodic* iTimer; |
|
1227 |
|
1228 // Protocol max volume. |
|
1229 TInt iProtoMaxVolume; |
|
1230 |
|
1231 // Selected camera is not necessary activated also. |
|
1232 TCameraId iSelectedCameraId; |
|
1233 |
|
1234 // ETrue when it is allowed to update volume. |
|
1235 TBool iUpdateVolumeAllowed; |
|
1236 |
|
1237 // ETrue when it is needed to update volume. |
|
1238 TBool iUpdateVolumeRequired; |
|
1239 |
|
1240 // Owned asynch callback. |
|
1241 CIdle* iAsyncCallback; |
|
1242 |
|
1243 // Pending volume operation. |
|
1244 CVtEngOperation* iPendingVolumeOp; |
|
1245 |
|
1246 // Used for various connection related operations. |
|
1247 TInt iConnectionStates; |
|
1248 |
|
1249 // Used while pausing and resuming video. |
|
1250 CVtEngLocalVideo::TVtEngProviderType iTempProviderInfo; |
|
1251 |
|
1252 // Used for setting the vendor info. |
|
1253 MVtH324ConfigCommand* iH324Config; |
|
1254 |
|
1255 |
|
1256 // Used H263 interface. |
|
1257 MVtVideoConfigCommand* iH263Encoder; |
|
1258 |
|
1259 // Video quality |
|
1260 TVtEngVideoQuality iVideoQuality; |
|
1261 |
|
1262 // Sharing object while video is disable will set this flag |
|
1263 TVideoEngAction iVideoAction; |
|
1264 |
|
1265 // Logical channel structure for outgoing video channel(s). |
|
1266 TLogicalChannel iVideoOutgoingLogicalChannel; |
|
1267 |
|
1268 // Logical channel structure for outgoing audio channel(s). |
|
1269 TLogicalChannel iAudioOutgoingLogicalChannel; |
|
1270 |
|
1271 // Logical channel structure for incoming video channel(s). |
|
1272 TLogicalChannel iVideoIncomingLogicalChannel; |
|
1273 |
|
1274 // Logical channel structure for incoming audio channel(s). |
|
1275 TLogicalChannel iAudioIncomingLogicalChannel; |
|
1276 |
|
1277 /* For proceeding to next uninit step asynchronously. |
|
1278 * Needed because Proto extension interface cannot be released within |
|
1279 * callback |
|
1280 */ |
|
1281 CAsyncCallBack* iNextStepCallback; |
|
1282 |
|
1283 |
|
1284 /* Do not complete operation on pause command. This flag |
|
1285 * is used when image sharing is stopped and video was disabled |
|
1286 * when sharing was initially started to prevent black frame sending |
|
1287 * during blank switch. |
|
1288 */ |
|
1289 TBool iPauseNoCompleteOp; |
|
1290 |
|
1291 /** |
|
1292 * Result for asynchronous operation completion. |
|
1293 */ |
|
1294 TInt iAsyncCompleteOpResult; |
|
1295 }; |
|
1296 |
|
1297 #endif // CVTENGMEDIAHANDLER_H |
|
1298 |
|
1299 // End of File |