mmserv/tms/tmscallserver/src/csuplink.cpp
changeset 0 71ca22bcf22a
child 3 4f62049db6ac
equal deleted inserted replaced
-1:000000000000 0:71ca22bcf22a
       
     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 #include <AudioPreference.h>
       
    19 #include "csuplink.h"
       
    20 #include "mcspdevsoundobserver.h"
       
    21 
       
    22 using namespace TMS;
       
    23 
       
    24 // Mute value
       
    25 const gint KSetMuteToDevSound = 0;
       
    26 
       
    27 // ---------------------------------------------------------------------------
       
    28 // Static constructor.
       
    29 // ---------------------------------------------------------------------------
       
    30 //
       
    31 CSUplink* CSUplink::NewL(MCSPDevSoundObserver& aObserver)
       
    32     {
       
    33     CSUplink* self = new (ELeave) CSUplink(aObserver);
       
    34     CleanupStack::PushL(self);
       
    35     self->ConstructL();
       
    36     CleanupStack::Pop(self);
       
    37     return self;
       
    38     }
       
    39 
       
    40 // ---------------------------------------------------------------------------
       
    41 // Destructor
       
    42 // ---------------------------------------------------------------------------
       
    43 //
       
    44 CSUplink::~CSUplink()
       
    45     {
       
    46     }
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // Gives mic mute state
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 TBool CSUplink::IsMuted()
       
    53     {
       
    54     TBool isMuted = EFalse;
       
    55     gint gain = 0;
       
    56     if (iDevSound)
       
    57         {
       
    58         gain = iDevSound->Gain();
       
    59         }
       
    60     if (!gain)
       
    61         {
       
    62         // Mute is on
       
    63         isMuted = ETrue;
       
    64         }
       
    65     //   CSPLOGSTRING( CSPINT, "CSUplink::IsMuted" );
       
    66     return isMuted;
       
    67     }
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // Set mic muted.
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 void CSUplink::SetMuted()
       
    74     {
       
    75     if (iDevSound)
       
    76         {
       
    77         iDevSound->SetGain(KSetMuteToDevSound);
       
    78         }
       
    79     }
       
    80 
       
    81 // ---------------------------------------------------------------------------
       
    82 // Set mic unmuted
       
    83 // ---------------------------------------------------------------------------
       
    84 //
       
    85 void CSUplink::SetUnmuted()
       
    86     {
       
    87     if (iDevSound)
       
    88         {
       
    89         iDevSound->SetGain(iDevSound->MaxGain());
       
    90         }
       
    91     }
       
    92 
       
    93 // ---------------------------------------------------------------------------
       
    94 // Sets gain
       
    95 // ---------------------------------------------------------------------------
       
    96 //
       
    97 void CSUplink::SetGain(gint aGain)
       
    98     {
       
    99     if (iDevSound)
       
   100         {
       
   101         iDevSound->SetGain(aGain);
       
   102         }
       
   103     }
       
   104 
       
   105 // ---------------------------------------------------------------------------
       
   106 // Gives volume
       
   107 // ---------------------------------------------------------------------------
       
   108 //
       
   109 gint CSUplink::Gain()
       
   110     {
       
   111     gint gain = 0;
       
   112     if (iDevSound)
       
   113         {
       
   114         gain = iDevSound->Gain();
       
   115         }
       
   116     return gain;
       
   117     }
       
   118 
       
   119 // ---------------------------------------------------------------------------
       
   120 // Gives max gain
       
   121 // ---------------------------------------------------------------------------
       
   122 //
       
   123 gint CSUplink::MaxGain()
       
   124     {
       
   125     gint gain = 0;
       
   126     if (iDevSound)
       
   127         {
       
   128         gain = iDevSound->MaxGain();
       
   129         }
       
   130     return gain;
       
   131     }
       
   132 
       
   133 // ---------------------------------------------------------------------------
       
   134 // From class MDevSoundObserver
       
   135 // Activation was successfull.
       
   136 // ---------------------------------------------------------------------------
       
   137 //
       
   138 void CSUplink::BufferToBeEmptied(CMMFBuffer* /*aBuffer*/)
       
   139     {
       
   140     //  CSPLOGSTRING( CSPINT, "CSUplink::BufferToBeEmptied" );
       
   141 
       
   142     // We dont react to devsound messages unless we are activating.
       
   143     if (IsActivationOngoing())
       
   144         {
       
   145         iActive = ETrue;
       
   146         iActivationOngoing = EFalse;
       
   147         iObserver.UplinkActivatedSuccessfully();
       
   148         }
       
   149     }
       
   150 
       
   151 // ---------------------------------------------------------------------------
       
   152 // From class MDevSoundObserver
       
   153 // Activation feiled
       
   154 // ---------------------------------------------------------------------------
       
   155 //
       
   156 void CSUplink::RecordError(TInt aError)
       
   157     {
       
   158     //  CSPLOGSTRING( CSPINT, "CSUplink::RecordError" );
       
   159 
       
   160     // We dont react to devsound messages unless we are activating.
       
   161     if (IsActivationOngoing())
       
   162         {
       
   163         if (aError == KErrAccessDenied)
       
   164             {
       
   165             iActivationOngoing = EFalse;
       
   166             iObserver.UplinkActivationFailed();
       
   167             }
       
   168         }
       
   169     }
       
   170 
       
   171 // ---------------------------------------------------------------------------
       
   172 // From class CSPDevSound
       
   173 // Tries to activate mic stream. Stream becomes active when BufferToBeFilled
       
   174 // gets called.
       
   175 // ---------------------------------------------------------------------------
       
   176 //
       
   177 void CSUplink::DoActivateL()
       
   178     {
       
   179     if (iDevSound)
       
   180         {
       
   181         iDevSound->RecordInitL();
       
   182         }
       
   183     }
       
   184 
       
   185 // ---------------------------------------------------------------------------
       
   186 // Constructor
       
   187 // ---------------------------------------------------------------------------
       
   188 //
       
   189 CSUplink::CSUplink(MCSPDevSoundObserver& aObserver) :
       
   190     CSPDevSound(aObserver)
       
   191     {
       
   192     }
       
   193 
       
   194 // ---------------------------------------------------------------------------
       
   195 // Second phase constructor
       
   196 // ---------------------------------------------------------------------------
       
   197 //
       
   198 void CSUplink::ConstructL()
       
   199     {
       
   200     CSPDevSound::ConstructL(EMMFStateRecording, KAudioPrefCSCallUplink,
       
   201             KAudioPriorityCSCallUplink);
       
   202     }
       
   203 
       
   204 //  End of File