mmserv/tms/tmscallserver/src/tmscsdownlink.cpp
branchRCL_3
changeset 11 3570217d8c21
child 17 60e492b28869
equal deleted inserted replaced
9:f5c5c82a163e 11:3570217d8c21
       
     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 "tmscsdownlink.h"
       
    20 #include "tmscsdevsoundobserver.h"
       
    21 
       
    22 using namespace TMS;
       
    23 
       
    24 const gint KDefaultVolume = 4;
       
    25 const gint KDefaultMaxVolume = 10;
       
    26 
       
    27 // -----------------------------------------------------------------------------
       
    28 // Static constructor
       
    29 // -----------------------------------------------------------------------------
       
    30 //
       
    31 TMSCSDownlink* TMSCSDownlink::NewL(TMSCSPDevSoundObserver& aObserver)
       
    32     {
       
    33     TMSCSDownlink* self = new (ELeave) TMSCSDownlink(aObserver);
       
    34     CleanupStack::PushL(self);
       
    35     self->ConstructL();
       
    36     CleanupStack::Pop(self);
       
    37     return self;
       
    38     }
       
    39 
       
    40 // -----------------------------------------------------------------------------
       
    41 // Destructor.
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 TMSCSDownlink::~TMSCSDownlink()
       
    45     {
       
    46     }
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // Sets volume
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 void TMSCSDownlink::SetVolume(gint aVolume)
       
    53     {
       
    54     if (iDevSound)
       
    55         {
       
    56         gint maxVolume(iDevSound->MaxVolume());
       
    57         maxVolume = (maxVolume > 0) ? maxVolume : KDefaultMaxVolume;
       
    58         gint scaledVolume = (aVolume * maxVolume) / KDefaultMaxVolume;
       
    59         iDevSound->SetVolume(scaledVolume);
       
    60         }
       
    61     }
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 // Gives volume
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 gint TMSCSDownlink::Volume()
       
    68     {
       
    69     gint vol = 0;
       
    70     if (iDevSound)
       
    71         {
       
    72         vol = iDevSound->Volume();
       
    73         }
       
    74     return vol;
       
    75     }
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // Gives max volume
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 gint TMSCSDownlink::MaxVolume()
       
    82     {
       
    83     gint vol = 0;
       
    84     if (iDevSound)
       
    85         {
       
    86         vol = iDevSound->MaxVolume();
       
    87         }
       
    88     return vol;
       
    89     }
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // From class MDevSoundObserver
       
    93 // Downlink stream has been activated successfully.
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 void TMSCSDownlink::BufferToBeFilled(CMMFBuffer* /*aBuffer*/)
       
    97     {
       
    98     //CSPLOGSTRING( CSPINT, "TMSCSDownlink:: activated" );
       
    99     // We dont react to devsound messages unless we are activating.
       
   100     if (IsActivationOngoing())
       
   101         {
       
   102         iActive = ETrue;
       
   103         iActivationOngoing = EFalse;
       
   104         iObserver.DownlinkActivatedSuccessfully();
       
   105         }
       
   106     }
       
   107 
       
   108 // -----------------------------------------------------------------------------
       
   109 // From class MDevSoundObserver
       
   110 // Downlink stream activation failed
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 void TMSCSDownlink::PlayError(TInt aError)
       
   114     {
       
   115     //CSPLOGSTRING( CSPINT, "TMSCSDownlink::PlayError" );
       
   116 
       
   117     // We dont react to devsound messages unless we are activating.
       
   118     if (IsActivationOngoing())
       
   119         {
       
   120         //CSPLOGSTRING( CSPINT, "TMSCSDownlink::PlayError activation failed" );
       
   121         if (aError == KErrAccessDenied)
       
   122             {
       
   123             iActivationOngoing = EFalse;
       
   124             iObserver.DownlinkActivationFailed();
       
   125             }
       
   126         }
       
   127     }
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // From class CSPDevsound
       
   131 // Tries to activate Downlink stream.
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 void TMSCSDownlink::DoActivateL()
       
   135     {
       
   136     if (iDevSound)
       
   137         {
       
   138         iDevSound->PlayInitL();
       
   139         }
       
   140     }
       
   141 
       
   142 // -----------------------------------------------------------------------------
       
   143 // Constructor
       
   144 // -----------------------------------------------------------------------------
       
   145 //
       
   146 TMSCSDownlink::TMSCSDownlink(TMSCSPDevSoundObserver& aObserver) :
       
   147     TMSCSPDevSound(aObserver)
       
   148     {
       
   149     }
       
   150 
       
   151 // -----------------------------------------------------------------------------
       
   152 // Second phase constructor
       
   153 // -----------------------------------------------------------------------------
       
   154 //
       
   155 void TMSCSDownlink::ConstructL()
       
   156     {
       
   157     TMSCSPDevSound::ConstructL(EMMFStatePlaying, KAudioPrefCSCallDownlink,
       
   158             KAudioPriorityCSCallDownlink);
       
   159 
       
   160     if (iDevSound)
       
   161         {
       
   162         iDevSound->SetVolume(KDefaultVolume);
       
   163         }
       
   164     }
       
   165 
       
   166 //  End of File