phoneplugins/csplugin/inc/tmshandler.h
changeset 65 2a5d4ab426d3
parent 27 2f8f8080a020
equal deleted inserted replaced
60:1eef62f5c541 65:2a5d4ab426d3
     9  * Initial Contributors:
     9  * Initial Contributors:
    10  * Nokia Corporation - initial contribution.
    10  * Nokia Corporation - initial contribution.
    11  *
    11  *
    12  * Contributors:
    12  * Contributors:
    13  *
    13  *
    14  * Description: Starts and stops audio streams.
    14  * Description: Activates TMS call audio control streams.
    15  *
    15  *
    16  */
    16  */
    17 
    17 
    18 #ifndef TMSHandler_H
    18 #ifndef TMSHANDLER_H
    19 #define TMSHandler_H
    19 #define TMSHANDLER_H
    20 
    20 
    21 #include <e32base.h>
    21 #include <e32base.h>
    22 #include "mcsptimerobserver.h"
       
    23 #include <tms.h>
    22 #include <tms.h>
    24 #include <tmsstreamobsrvr.h>
    23 #include <tmsstreamobsrvr.h>
    25 
    24 
    26 namespace TMS {
    25 namespace TMS {
    27 //FORWARD DECLARATIONS
    26 //FORWARD DECLARATIONS
    33 } //namespace TMS
    32 } //namespace TMS
    34 
    33 
    35 using namespace TMS;
    34 using namespace TMS;
    36 
    35 
    37 //FORWARD DECLARATIONS
    36 //FORWARD DECLARATIONS
    38 class CSPTimer;
    37 class MTmsHandlerObserver;
    39 
    38 
    40 /**
    39 /**
    41  *  Starts and stops TMS audio streams.
    40  *  Class responsible for creation and activation of TMS call audio control
    42  *  If the activation fails then there is a retry timer which
    41  *  streams.
    43  *  will try the activation later.
       
    44  */
    42  */
    45 NONSHARABLE_CLASS(TmsHandler) : public CBase,
    43 NONSHARABLE_CLASS(TmsHandler) : public CBase,
    46                                 public MCSPTimerObserver,
       
    47                                 public TMSStreamObserver
    44                                 public TMSStreamObserver
    48     {
    45     {
    49 public:
    46 public:
    50 
    47 
    51     /**
    48     /**
    52      * Two-phased constructing.
    49      * Two-phased constructing.
    53      */
    50      */
    54     static TmsHandler* NewL();
    51     static TmsHandler* NewL(MTmsHandlerObserver& aObserver);
    55 
    52 
    56     /**
    53     /**
    57      * Two-phased constructing.
    54      * Two-phased constructing.
    58      */
    55      */
    59     static TmsHandler* NewLC();
    56     static TmsHandler* NewLC(MTmsHandlerObserver& aObserver);
    60 
    57 
    61     /**
    58     /**
    62      * C++ default destructor.
    59      * C++ default destructor.
    63      */
    60      */
    64     virtual ~TmsHandler();
    61     virtual ~TmsHandler();
    65 
    62 
    66     /**
    63     /**
    67      * Starts audio streams ie inits mic and speaker.
    64      * Activates TMS call audio control streams.
    68      */
    65      */
    69     void StartStreams();
    66     TInt StartStreams();
    70 
    67 
    71     /**
    68     /**
    72      * Stops audio streams ie shuts down mic and speaker.
    69      * Deactivates TMS call audio control streams.
    73      */
    70      */
    74     void StopStreams();
    71     void StopStreams();
    75 
    72 
    76     /**
    73     /*
    77      * From MCSPTimerObserver.
    74      * Indicates whether both audio streams have been started.
    78      * Notify from CSPTimer that timeout passed.
       
    79      */
    75      */
    80     void TimerEvent();
    76     TBool AreStreamsStarted();
       
    77 
       
    78     /*
       
    79      * From TMSStreamObserver
       
    80      * TMS call audio stream control event handler.
       
    81      */
       
    82     void TMSStreamEvent(const TMSStream& stream, TMSSignalEvent event);
    81 
    83 
    82 protected:
    84 protected:
    83     // Functions from base classes
       
    84 
       
    85     // From TMSStreamObserver
       
    86     void TMSStreamEvent(const TMSStream& stream, TMSSignalEvent event);
       
    87 
       
    88 private:
       
    89 
    85 
    90     /**
    86     /**
    91      * C++ default constructor.
    87      * C++ default constructor.
    92      */
    88      */
    93     TmsHandler();
    89     TmsHandler();
    94 
    90 
    95     void ConstructL();
    91     /*
    96 
    92      * Symbian constructor
    97     static TInt TimerCallBack(TAny* aThisPtr);
    93      */
    98 
    94     void ConstructL(MTmsHandlerObserver& aObserver);
    99     void AudioStreamsStarted();
       
   100 
       
   101     void StartTimer();
       
   102 
       
   103     void StartMicAndSpeaker();
       
   104 
       
   105     TBool IsMicAndSpeakerStarted();
       
   106 
       
   107     gint CreateTMSCallControl();
       
   108     gint CreateFactory();
       
   109     gint CreateCall();
       
   110 
       
   111     gint CreateUplink();
       
   112     gint CreateDownlink();
       
   113     gint OpenUplink();
       
   114     gint OpenDownlink();
       
   115 
       
   116     gint CreateModemSource();
       
   117     gint AddModemSourceToStream();
       
   118     gint CreateModemSink();
       
   119     gint AddModemSinkToStream();
       
   120     gint CreateMicSource();
       
   121     gint AddMicSourceToStream();
       
   122     gint CreateSpeakerSink();
       
   123     gint AddSpeakerSinkToStream();
       
   124 
    95 
   125 private:
    96 private:
   126     // data
       
   127 
    97 
   128     /**
    98     /*
   129      * Timer for retrying the activation of streams (mic & speaker) if
    99      * Method creating and activating TMS call control objects.
   130      * there was a failure in activation.
       
   131      * Own.
       
   132      */
   100      */
   133     CSPTimer* iTimer;
   101     TInt CreateTMSCallControl();
   134 
   102 
   135     /**
   103     /*
   136      * Timeout value used with timer. Timeout value doubles every retry to
   104      * Processes Uplink stream state change events.
   137      * activate the streams.
       
   138      */
   105      */
   139     TInt iTimeout;
   106     void ProcessUplinkStreamChangeEvent(TInt aState);
   140 
   107 
       
   108     /*
       
   109      * Processes Downlink stream state change events.
       
   110      */
       
   111     void ProcessDownlinkStreamChangeEvent(TInt aState);
       
   112 
       
   113 private:
       
   114 
       
   115     /*
       
   116      * Observer to TMS call audio stream events.
       
   117      */
       
   118     MTmsHandlerObserver* iObserver;
       
   119 
       
   120     /*
       
   121      * Pointers to TMS call audio control objects.
       
   122      */
   141     TMSFactory* iFactory;
   123     TMSFactory* iFactory;
   142     TMSCall* iTmsCall;
   124     TMSCall* iTmsCall;
   143     TMSCallType iCallType;
   125     TMSCallType iCallType;
   144     TMSStream* iTmsDnlink;
   126     TMSStream* iTmsDnlink;
   145     TMSStream* iTmsUplink;
   127     TMSStream* iTmsUplink;
   146     TMSSource* iTmsMicSource;
   128     TMSSource* iTmsMicSource;
   147     TMSSource* iTmsModemSource;
   129     TMSSource* iTmsModemSource;
   148     TMSSink* iTmsSpeakerSink;
   130     TMSSink* iTmsSpeakerSink;
   149     TMSSink* iTmsModemSink;
   131     TMSSink* iTmsModemSink;
   150     TBool iUplinkStarted;
   132 
   151     TBool iDnlinkStarted;
   133     /*
       
   134      * Stream state control helpers
       
   135      */
       
   136     TBool iStartAfterInitComplete;
       
   137     TBool iUplInitializing;
       
   138     TBool iDnlInitializing;
   152     };
   139     };
   153 
   140 
   154 #endif // TMSHANDLER_H
   141 #endif // TMSHANDLER_H
       
   142