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