convergedcallengine/csplugin/inc/cspaudiostreams.h
branchRCL_3
changeset 20 987c9837762f
parent 0 ff3b6d0fd310
equal deleted inserted replaced
19:7d48bed6ce0c 20:987c9837762f
       
     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:  Starts and stops audio streams.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CSPAUDIOSTREAMS_H
       
    20 #define CSPAUDIOSTREAMS_H
       
    21 
       
    22 
       
    23 #include <e32base.h>
       
    24 #include <TelephonyAudioRouting.h>
       
    25 #include "MTelephonyAudioRoutingObserver.h" 
       
    26 #include "mcspdevsoundobserver.h"
       
    27 #include "mcsptimerobserver.h"
       
    28 
       
    29 class MCSPDevSoundFactory;
       
    30 class CSPTimer;
       
    31 class CSPMicrophone;
       
    32 class CSPSpeaker;
       
    33 class MCSPAudioStreamObserver;
       
    34 class CSPTimer;
       
    35 
       
    36 
       
    37 /**
       
    38  *  Starts and stops audio streams.
       
    39  *  If the activation fails then there is a retry timer which
       
    40  *  will try the activation later.
       
    41  */
       
    42 NONSHARABLE_CLASS( CSPAudioStreams ) : 
       
    43     public CBase, 
       
    44     public MCSPDevSoundObserver,
       
    45     public MCSPTimerObserver,
       
    46     public MTelephonyAudioRoutingObserver
       
    47     {
       
    48 
       
    49 public:
       
    50 
       
    51     /**
       
    52     * Two-phased constructing.
       
    53     */
       
    54     static CSPAudioStreams* NewL( );
       
    55 
       
    56     /**
       
    57     * Two-phased constructing.
       
    58     */    
       
    59     static CSPAudioStreams* NewLC( );
       
    60 
       
    61     /**
       
    62     * C++ default destructor.
       
    63     */
       
    64     virtual ~CSPAudioStreams();
       
    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     * Sets volume for ear. 
       
    78     */
       
    79     void VolumeChangedEar( TInt aVolume );
       
    80     
       
    81     /**
       
    82     * Sets volume for loudspeaker. 
       
    83     */
       
    84     void VolumeChangedLoudspeaker( TInt aVolume );
       
    85     
       
    86     /**
       
    87     * Stores volume levels.
       
    88     */
       
    89     void StoreVolumes(TInt aVolumeEar, TInt aVolumeLoudspeaker);
       
    90 
       
    91     /**
       
    92     * Set unmuted.
       
    93     */    
       
    94     void SetUnmuted();
       
    95 
       
    96     /**
       
    97     * Set muted.
       
    98     */
       
    99     void SetMuted();
       
   100 
       
   101     /**
       
   102     * Gives access to CSPMicrophone instance. Ownership not given.
       
   103     * @return MCSPMic instance.
       
   104     */
       
   105     CSPMicrophone& Mic() const;
       
   106     
       
   107     /**
       
   108     * Gives access to CSPSpeaker instance. Ownership not given.
       
   109     * @return MCSPSpeaker instance.
       
   110     */
       
   111     CSPSpeaker& Speaker() const;
       
   112     
       
   113     /**
       
   114     * Set observer for audio stream events.
       
   115     * @param aObserver
       
   116     */
       
   117     void SetAudioStreamObserver( MCSPAudioStreamObserver& aObserver );
       
   118     
       
   119 // from base class MCSPDevSoundObserver
       
   120 
       
   121     /**
       
   122     * From MCSPDevSoundObserver
       
   123     * Notification that Mic has been activated successfully
       
   124     */
       
   125     void MicActivatedSuccessfully();
       
   126     
       
   127     /**
       
   128     * From MCSPDevSoundObserver
       
   129     * Notification that speaker has been activated successfully
       
   130     */   
       
   131     void SpeakerActivatedSuccessfully();
       
   132     
       
   133     /**
       
   134     * From MCSPDevSoundObserver
       
   135     * Notification that Mic initialisation failed.
       
   136     */
       
   137     void MicActivationFailed();
       
   138     
       
   139     /**
       
   140     * From MCSPDevSoundObserver
       
   141     * Notification that Speaker activation failed.
       
   142     */
       
   143     void SpeakerActivationFailed();
       
   144     
       
   145 // from base class MCSPTimerObserver
       
   146 
       
   147     /**
       
   148     * From MCSPTimerObserver.
       
   149     * Notify from CSPTimer that timeout passed.
       
   150     */
       
   151     void TimerEvent();
       
   152     
       
   153 protected:  // Functions from base classes  
       
   154 
       
   155 // from base class MTelephonyAudioRoutingObserver
       
   156         
       
   157     /**
       
   158     * @see MTelephonyAudioRoutingObserver.
       
   159     */
       
   160     void AvailableOutputsChanged( CTelephonyAudioRouting& aTelephonyAudioRouting );
       
   161             
       
   162     /**
       
   163     * @see MTelephonyAudioRoutingObserver.
       
   164     */
       
   165     void OutputChanged( CTelephonyAudioRouting& aTelephonyAudioRouting);
       
   166     
       
   167     /**
       
   168     * @see MTelephonyAudioRoutingObserver.
       
   169     */
       
   170     void SetOutputComplete( CTelephonyAudioRouting& aTelephonyAudioRouting, TInt aError);
       
   171   
       
   172 private:
       
   173     
       
   174     /** 
       
   175     * C++ default constructor. 
       
   176     */  
       
   177     CSPAudioStreams( );
       
   178 
       
   179     void ConstructL( );
       
   180     
       
   181     static TInt TimerCallBack( TAny* aThisPtr );
       
   182     
       
   183     void AudioStreamsStarted();
       
   184     
       
   185     void StartTimer();
       
   186     
       
   187     void StartMicAndSpeaker();
       
   188     
       
   189     TBool IsMicAndSpeakerStarted();
       
   190     
       
   191     void ApplyVolume(TInt aVolumeEar, TInt aVolumeLoudspeaker);
       
   192 
       
   193 private: // data
       
   194 
       
   195     /**
       
   196     * Mic.
       
   197     * own.
       
   198     */     
       
   199     CSPMicrophone* iMic;
       
   200     
       
   201     /**
       
   202     * Speaker.
       
   203     * Own.
       
   204     */
       
   205     CSPSpeaker* iSpeaker;
       
   206      
       
   207     /**
       
   208     * Timer for retrying the activation of streams (mic & speaker) if
       
   209     * there was a failure in activation.
       
   210     * Own.
       
   211     */
       
   212     CSPTimer* iTimer;
       
   213     
       
   214     /**
       
   215     * Timeout value used with timer. Timeout value doubles every retry to
       
   216     * activate the streams.
       
   217     */
       
   218     TInt iTimeout;
       
   219     
       
   220     /**
       
   221     * Audio output for checking if loadspeaker or ear volume should be used.
       
   222     * Own.
       
   223     */
       
   224     CTelephonyAudioRouting* iAudioRouting;
       
   225     
       
   226     /**
       
   227     *  Observer for stream events.
       
   228     * Not own.
       
   229     */
       
   230     MCSPAudioStreamObserver* iStreamObserver;
       
   231     
       
   232     /**
       
   233     *  Ear volume. 
       
   234     */    
       
   235     TInt iVolumeEar;
       
   236     
       
   237     /**
       
   238     *  Loudspeaker volume. 
       
   239     */
       
   240     TInt iVolumeLoudspeaker;
       
   241          
       
   242     };
       
   243 
       
   244 #endif // CSPAUDIOSTREAMS_H