javauis/mmapi_akn/baseline/inc/cmmavolumecontrol.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 21 Jun 2010 15:32:50 +0300
branchRCL_3
changeset 21 4376525cdefb
parent 14 04becd199f91
child 24 6c158198356e
permissions -rw-r--r--
Revision: v2.1.30 Kit: 2010125

/*
* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  This class is used for volume setting
*
*/


#ifndef CMMAVOLUMECONTROL_H
#define CMMAVOLUMECONTROL_H

//  INCLUDES
#include "cmmacontrol.h"
#include "mmmaplayerstatelistener.h"
#include <mprofilechangeobserver.h>

// CONSTANS
_LIT(KMMAVolumeControlName, "VolumeControl");
const TInt KMMAVolumeMaxLevel = 100;

class CMMAPlayer;
class CProfileChangeNotifyHandler;
//  CLASS DECLARATION
/**
*   This class is used for volume setting
*
*
*/

class CMMAVolumeControl : public CMMAControl,
        public MMMAPlayerStateListener,
        public MProfileChangeObserver
{
public:
    static void StaticSetLevelL(CMMAVolumeControl* aVolumeControl,
                                TInt aLevel);
    static void StaticGetLevelL(CMMAVolumeControl* aVolumeControl,
                                TInt* aLevel);

    ~CMMAVolumeControl();

protected:
    CMMAVolumeControl(CMMAPlayer* aPlayer);
    void ConstructBaseL();

    /**
     * Sets the level to player.
     * @param aLevel Sound level to set.
     */
    virtual void DoSetLevelL(TInt aLevel) = 0;

    /**
     * Get volume level from player.
     * @return Current level.
     */
    virtual TInt DoGetLevelL() = 0;

public: // From CMMAControl
    const TDesC& ClassName() const;

    /**
     * Refresh volume control.
     */
    void RefreshControl();

public: // From MMMAPlayerStateListener
    void StateChanged(TInt aState);

public: // from MProfileChangeObserver
    void HandleActiveProfileEventL(TProfileEvent aProfileEvent, TInt aProfileId );

public: // New methods
    /**
     * Adds new volume level to volume control. Actual volume level will
     * be calculated using all levels added to the control.
     * @return Index for new level.
     */
    IMPORT_C TInt AddLevelL();

    /**
     * Sets new volume level for certain level index. After level is set
     * new actual level is calculated and commited to player in derived
     * class.
     * @param aLevelIndex Level's index
     * @param aVolumeLevel New volume level for level index. Level must be
     * between 0 and 100.
     */
    IMPORT_C void SetVolumeLevelL(TInt aLevelIndex,
                                  TInt aVolumeLevel);
    void GetVolumeLevelL(TInt aLevelIndex,
                         TInt* aVolumeLevel);
    void SetProfilesBasedSoundMutingL();
    /**
     * Sets the audio o/p preference. Based on this the profile based
     * volume setting is done.
     */
    IMPORT_C void SetAudioOutputPreferenceL( TInt aRoutingPreference);

private: // New methods

    /**
     * Refresh volume level, basically set the volume level again.
     */
    void RefreshVolume();

    /**
     * Sets level if player is started and sends java event level
     * changed.
     * @param aLevel Sound level to set.
     */
    void SetLevelL(TInt aLevel);

    /**
     * Calculates new overall level using all values in iLevels array.
     * @return Current level.
     */
    TInt CalculateLevel();
    
    void SetJavaSoundVolumeLevelL();
    
    void SetProfileSoundVolumeLevelL();
protected: // data
    CMMAPlayer* iPlayer;

    // Previous level setted to player. Used to check if level is changed.
    TInt iLevel;

    // Array containing all levels.
    RArray< TInt > iLevels;
    // profile change notifier 
    // Owning
    CProfileChangeNotifyHandler* iProfChangeNotifier;
    // Current audio o/p preference.
    TInt iAudioOutputPreference;
    // Current profile Id.
    TInt iProfileId;
};

#endif // CMMAVOLUMECONTROL_H