phoneplugins/csplugin/inc/tmshandler.h
changeset 27 2f8f8080a020
child 65 2a5d4ab426d3
equal deleted inserted replaced
22:6bb1b21d2484 27:2f8f8080a020
       
     1 /*
       
     2  * Copyright (c) 2010 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: Starts and stops audio streams.
       
    15  *
       
    16  */
       
    17 
       
    18 #ifndef TMSHandler_H
       
    19 #define TMSHandler_H
       
    20 
       
    21 #include <e32base.h>
       
    22 #include "mcsptimerobserver.h"
       
    23 #include <tms.h>
       
    24 #include <tmsstreamobsrvr.h>
       
    25 
       
    26 namespace TMS {
       
    27 //FORWARD DECLARATIONS
       
    28 class TMSFactory;
       
    29 class TMSCall;
       
    30 class TMSStream;
       
    31 class TMSSource;
       
    32 class TMSSink;
       
    33 } //namespace TMS
       
    34 
       
    35 using namespace TMS;
       
    36 
       
    37 //FORWARD DECLARATIONS
       
    38 class CSPTimer;
       
    39 
       
    40 /**
       
    41  *  Starts and stops TMS audio streams.
       
    42  *  If the activation fails then there is a retry timer which
       
    43  *  will try the activation later.
       
    44  */
       
    45 NONSHARABLE_CLASS(TmsHandler) : public CBase,
       
    46                                 public MCSPTimerObserver,
       
    47                                 public TMSStreamObserver
       
    48     {
       
    49 public:
       
    50 
       
    51     /**
       
    52      * Two-phased constructing.
       
    53      */
       
    54     static TmsHandler* NewL();
       
    55 
       
    56     /**
       
    57      * Two-phased constructing.
       
    58      */
       
    59     static TmsHandler* NewLC();
       
    60 
       
    61     /**
       
    62      * C++ default destructor.
       
    63      */
       
    64     virtual ~TmsHandler();
       
    65 
       
    66     /**
       
    67      * Starts audio streams ie inits mic and speaker.
       
    68      */
       
    69     void StartStreams();
       
    70 
       
    71     /**
       
    72      * Stops audio streams ie shuts down mic and speaker.
       
    73      */
       
    74     void StopStreams();
       
    75 
       
    76     /**
       
    77      * From MCSPTimerObserver.
       
    78      * Notify from CSPTimer that timeout passed.
       
    79      */
       
    80     void TimerEvent();
       
    81 
       
    82 protected:
       
    83     // Functions from base classes
       
    84 
       
    85     // From TMSStreamObserver
       
    86     void TMSStreamEvent(const TMSStream& stream, TMSSignalEvent event);
       
    87 
       
    88 private:
       
    89 
       
    90     /**
       
    91      * C++ default constructor.
       
    92      */
       
    93     TmsHandler();
       
    94 
       
    95     void ConstructL();
       
    96 
       
    97     static TInt TimerCallBack(TAny* aThisPtr);
       
    98 
       
    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 
       
   125 private:
       
   126     // data
       
   127 
       
   128     /**
       
   129      * Timer for retrying the activation of streams (mic & speaker) if
       
   130      * there was a failure in activation.
       
   131      * Own.
       
   132      */
       
   133     CSPTimer* iTimer;
       
   134 
       
   135     /**
       
   136      * Timeout value used with timer. Timeout value doubles every retry to
       
   137      * activate the streams.
       
   138      */
       
   139     TInt iTimeout;
       
   140 
       
   141     TMSFactory* iFactory;
       
   142     TMSCall* iTmsCall;
       
   143     TMSCallType iCallType;
       
   144     TMSStream* iTmsDnlink;
       
   145     TMSStream* iTmsUplink;
       
   146     TMSSource* iTmsMicSource;
       
   147     TMSSource* iTmsModemSource;
       
   148     TMSSink* iTmsSpeakerSink;
       
   149     TMSSink* iTmsModemSink;
       
   150     TBool iUplinkStarted;
       
   151     TBool iDnlinkStarted;
       
   152     };
       
   153 
       
   154 #endif // TMSHANDLER_H