mmserv/tms/tmscallserver/inc/tmsdtmftoneplayer.h
changeset 14 80975da52420
child 20 b67dd1fc57c5
equal deleted inserted replaced
12:5a06f39ad45b 14:80975da52420
       
     1 /*
       
     2  * Copyright (c) 2009 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: Telephony Multimedia Service
       
    15  *
       
    16  */
       
    17 
       
    18 #ifndef TMSAUDIODTMFTONEPLAYER_H
       
    19 #define TMSAUDIODTMFTONEPLAYER_H
       
    20 
       
    21 // INCLUDES
       
    22 #include <glib.h>
       
    23 #include <sounddevice.h>
       
    24 #include "tmsdtmftoneplayerobserver.h"
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class CMMFDevSound;
       
    28 
       
    29 // CLASS DECLARATION
       
    30 
       
    31 /**
       
    32  *  plays DTMF tones using media server
       
    33  */
       
    34 
       
    35 namespace TMS {
       
    36 
       
    37 class TMSAudioDtmfTonePlayer : public MDevSoundObserver
       
    38     {
       
    39 public:
       
    40     // Constructors and destructor
       
    41 
       
    42     /**
       
    43      * Two-phased constructor.
       
    44      */
       
    45     static TMSAudioDtmfTonePlayer* NewL(TMSDTMFTonePlayerObserver& obsrvr,
       
    46             guint aAudioPreference, guint aAudioPriority);
       
    47 
       
    48     /**
       
    49      * Destructor.
       
    50      */
       
    51     virtual ~TMSAudioDtmfTonePlayer();
       
    52 
       
    53 public:
       
    54 
       
    55     /**
       
    56      * Sets volume.
       
    57      * @param aVolume volume value or KDtmfSilent.
       
    58      * @return None.
       
    59      */
       
    60     void SetVolume(gint aVolume);
       
    61 
       
    62     /**
       
    63      * Starts playing given dtmf tone infinitely.
       
    64      * @param aTone Tone to be played.
       
    65      * @return None.
       
    66      */
       
    67     void PlayDtmfTone(TDes& tone);
       
    68 
       
    69     /**
       
    70      * Cancels playing.
       
    71      * @param None.
       
    72      * @return None.
       
    73      */
       
    74     void Cancel();
       
    75 
       
    76 public:
       
    77     //From MDevSoundObserver
       
    78     /**
       
    79      * See MDevSoundObserver
       
    80      */
       
    81     void InitializeComplete(TInt aError);
       
    82 
       
    83     /**
       
    84      * See MDevSoundObserver
       
    85      */
       
    86     void ToneFinished(TInt aError);
       
    87 
       
    88     /**
       
    89      * See MDevSoundObserver
       
    90      */
       
    91     void BufferToBeFilled(CMMFBuffer* aBuffer);
       
    92 
       
    93     /**
       
    94      * See MDevSoundObserver
       
    95      */
       
    96     void PlayError(TInt aError);
       
    97 
       
    98     /**
       
    99      * See MDevSoundObserver
       
   100      */
       
   101     void BufferToBeEmptied(CMMFBuffer* aBuffer);
       
   102 
       
   103     /**
       
   104      * See MDevSoundObserver
       
   105      */
       
   106     void RecordError(TInt aError);
       
   107 
       
   108     /**
       
   109      * See MDevSoundObserver
       
   110      */
       
   111     void ConvertError(TInt aError);
       
   112     /**
       
   113      * See MDevSoundObserver
       
   114      */
       
   115     void DeviceMessage(TUid aMessageType, const TDesC8& aMsg);
       
   116 
       
   117 protected:
       
   118 
       
   119     /**
       
   120      * C++ default constructor.
       
   121      */
       
   122     TMSAudioDtmfTonePlayer(TMSDTMFTonePlayerObserver& obsrvr,
       
   123             guint aAudioPreference, guint aAudioPriority);
       
   124 
       
   125     void ConstructL();
       
   126 
       
   127     /**
       
   128      * Normalize tone.
       
   129      * @param aTone dtmf tone.
       
   130      * @return None.
       
   131      */
       
   132     void Normalize(TChar& aTone);
       
   133 
       
   134 private:
       
   135     //new functions
       
   136 
       
   137     /**
       
   138      * Converts the given value to the one that matches tha range used by
       
   139      * CMMFDevSound. The CMMFDevSound uses valuess that can from 0 to the
       
   140      * value returned by a call to CMMFDevSound::MaxVolume().
       
   141      */
       
   142     gint ConvertVolume(gint aVolume);
       
   143 
       
   144 protected:
       
   145     // Data
       
   146 
       
   147     // Current volume setting.
       
   148     gint iVolume;
       
   149 
       
   150     // DTMF player instance
       
   151     CMMFDevSound* iDTMFPlayer;
       
   152 
       
   153     TMSDTMFTonePlayerObserver& iObserver;
       
   154     guint iPref;
       
   155     guint iPrior;
       
   156 
       
   157     };
       
   158 
       
   159 } //namespace TMS
       
   160 
       
   161 #endif // TMSAUDIODTMFTONEPLAYER_H
       
   162 
       
   163 // End of File