javauis/amms_akn/mmacontrol/inc/cammsaudiooutputcontrol.h
branchRCL_3
changeset 26 2455ef1f5bbc
equal deleted inserted replaced
25:ae942d28ec0e 26:2455ef1f5bbc
       
     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:  Manipulates the audio output mode.
       
    15 *
       
    16 */
       
    17 #ifndef CAMMSAUDIOOUTPUTCONTROL_H
       
    18 #define CAMMSAUDIOOUTPUTCONTROL_H
       
    19 
       
    20 //  INCLUDES
       
    21 #include "cammscontrol.h"
       
    22 #include <cmmamidiplayer.h>
       
    23 #include <mmmaplayerstatelistener.h>
       
    24 // for audio routing control
       
    25 #include <AudioOutput.h>
       
    26 
       
    27 // for audio routing observers
       
    28 #include <MAudioOutputObserver.h>
       
    29 #include <AccMonitor.h>
       
    30 #include <AccMonitorInfo.h>
       
    31 
       
    32 
       
    33 class CMMAVolumeControl;
       
    34 
       
    35 // CONSTANTS
       
    36 _LIT(KAMMSAudioOutputControl, "AudioOutputControl");
       
    37 // CLASS DECLARATION
       
    38 
       
    39 /**
       
    40 *
       
    41 *  Controls for the Audio Routing.
       
    42 *  This class delegates Audio Routing setting calls to RMMFController.
       
    43 *
       
    44 *
       
    45 *  @since X.X
       
    46 */
       
    47 NONSHARABLE_CLASS(CAMMSAudioOutputControl)
       
    48         : public CAMMSControl, public MMMAPlayerStateListener ,
       
    49           public MAccMonitorObserver
       
    50 {
       
    51 public:
       
    52     // Constructors and destructor
       
    53     /**
       
    54     * Two-phased constructor.
       
    55     * @param aPlayer Player that has this control.
       
    56     */
       
    57     static CAMMSAudioOutputControl* NewLC(CMMAPlayer* aPlayer);
       
    58 
       
    59     /**
       
    60     * Destructor.
       
    61     */
       
    62     ~CAMMSAudioOutputControl();
       
    63 
       
    64 public:
       
    65     // New functions
       
    66     /**
       
    67     * Sets the AudioOutput.
       
    68     *
       
    69     * @param aPreference The new AudioOutput to be set.
       
    70     */
       
    71     TInt SetAudioOutput(TInt aPreference);
       
    72 
       
    73     /**
       
    74     * Gets the Audio Routing preference.
       
    75     *
       
    76     * @return The previously set Audio Routing preference.
       
    77     */
       
    78     TInt GetAudioOutput();
       
    79     /**
       
    80     * Reset the AudioOutput java object with changed value of current
       
    81     */
       
    82     void GetCurrentPreference();
       
    83     /**
       
    84     * Gets the Audio Routing preference.
       
    85     *
       
    86     * @return The previously set Audio Routing preference. and if not set retruns the device default
       
    87     */
       
    88 
       
    89     TInt GetCurrentPrefInt();
       
    90     /**
       
    91     * Gets the Audio Routing Device Default.
       
    92     *
       
    93     * @returns the device default
       
    94     */
       
    95     TInt GetDeviceDefaultPreference();
       
    96     /**
       
    97     * Create an Observer to get the notification for the Headset state.
       
    98     * Also initializes iCurrentActualPreference with CAudioOutput::EPrivate if headset is connected.
       
    99     * @returns the device default
       
   100     */
       
   101     void CreateHeadsetStateObserverL();
       
   102     /**
       
   103     * Actual native control is created using this function
       
   104     */
       
   105     void CreateNativeAudioOutputControlL();
       
   106     /**
       
   107     * seting java object used to send as callback event
       
   108     */
       
   109     void SetJavaAudioOutputObject(jobject object);
       
   110     /**
       
   111     * Reset the value of java object with current values
       
   112     */
       
   113     void ResetJavaAudioOutputObject();
       
   114     /**
       
   115     * Check if there is any change in Current output Mode,It sends a event to java
       
   116     * If there is no change it returns silently
       
   117     */
       
   118     void NotifyJavaOnChange();
       
   119 
       
   120 
       
   121 public:
       
   122     // From MMMAPlayerStateListener
       
   123     void StateChanged(TInt aState);
       
   124 
       
   125 
       
   126 public:
       
   127     // From MAudioOutputObserver
       
   128 
       
   129     void DisconnectedL(CAccMonitorInfo *aAccessoryInfo);
       
   130     void ConnectedL(CAccMonitorInfo* aAccessoryInfo);
       
   131     void AccMonitorObserverError(TInt aError);
       
   132 
       
   133 public:
       
   134     // Functions from base classes
       
   135     const TDesC& ClassName() const;
       
   136 
       
   137 protected:
       
   138     // New functions
       
   139     /**
       
   140     * @param aAmmsPreference AMMS preference to be set.
       
   141     */
       
   142     TInt SetAudioOutputToMmf(CAudioOutput::TAudioOutputPreference aAmmsPreference);
       
   143 
       
   144 private:
       
   145     /**
       
   146     * C++ constructor.
       
   147     * @param aPlayer Player that has this control.
       
   148     */
       
   149     CAMMSAudioOutputControl(CMMAPlayer* aPlayer);
       
   150 
       
   151     /**
       
   152     * Symbian 2nd phase constructor.
       
   153     */
       
   154     void ConstructL();
       
   155 
       
   156     CMMAVolumeControl* GetVolumeControl();
       
   157 
       
   158 private:
       
   159     //Data
       
   160     // Preference visible in AMMS.
       
   161     CAudioOutput::TAudioOutputPreference iRoutingUserPreference;
       
   162     // Preference of the device changes by inserting/removing Jack.
       
   163     CAudioOutput::TAudioOutputPreference iDefaultDevicePreference;
       
   164     // Preference of the device changes by inserting/removing Jack.
       
   165     TInt iCurrentPreference;
       
   166     // owned
       
   167     CAudioOutput* iAudioOutput;
       
   168     CMMAPlayer::TPlayerState iPlayerState;
       
   169     // Reference to volume control to set the current audio o/p preference.
       
   170     // Not owning
       
   171     CMMAVolumeControl* iVolumeControl;
       
   172     // Owning
       
   173     CAccMonitor *iAccMonitor;
       
   174     RConnectedAccessories iArray;
       
   175     jobject iJavaAudioOutputObj;
       
   176     JNIEnv* iJni;
       
   177 
       
   178 };
       
   179 
       
   180 #endif // CAMMSAUDIOOUTPUTCONTROL_H
       
   181 
       
   182