os/mm/devsoundextensions/telephonyaudiorouting/Server/inc/TelephonyAudioRoutingServer.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2006 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:   TelephonyAudioRoutingServer implementation
    15 *
    16 */
    17 
    18 
    19 
    20 #ifndef TELEPHONYAUDIOROUTINGSERVER_H
    21 #define TELEPHONYAUDIOROUTINGSERVER_H
    22 
    23 #include <e32base.h>
    24 #include "TelephonyAudioRouting.h"
    25 
    26 const TInt KMaxNumberOfSessions = 256; 
    27 
    28 enum TTelephonyAudioRoutingPanic
    29 	{
    30 	EPanicGeneral,
    31 	EPanicIllegalFunction,
    32 	EPanicResourceError
    33 	};
    34 
    35 void PanicClient(const RMessage2& aMessage,TTelephonyAudioRoutingPanic aPanic);
    36 
    37 // CLASS DECLARATION
    38 
    39 /**
    40 *  TelephonyAudioRoutingServer class declaration
    41 *
    42 *  @lib TelephonyAudioRoutingServer.lib
    43 *  @since Series 60 3.1
    44 */
    45 class CTelephonyAudioRoutingServer : public CServer2
    46 	{
    47 		
    48 	public:  // Constructors and destructor
    49         
    50         /**
    51         * Two-phased constructor.
    52         */
    53         IMPORT_C static CTelephonyAudioRoutingServer* NewL();
    54         
    55         /**
    56         * Destructor.
    57         */
    58         ~CTelephonyAudioRoutingServer();
    59         
    60 	public:
    61 	
    62 		/**
    63         * Start the TelephonyAudioRoutingServer thread
    64         * @since Series 60 3.1
    65         * @param TAny* aParams
    66         * @return KErrNone is successfull, else appropriate err code
    67         */
    68 		IMPORT_C static TInt StartThreadL(TAny* aParams);
    69 		
    70 		/**
    71         * Add a new Session.
    72         * @since Series 60 3.1
    73         * @param none
    74         * @return void
    75         */
    76 		void AddSession();
    77 		
    78 		/**
    79         * Remove an existing session.
    80         * @since Series 60 3.1
    81         * @param TInt aSessionId Id of the session to remove
    82         * @return void
    83         */
    84 		void RemoveSession(TInt aSessionId);
    85 		
    86 		/**
    87         * Notify the policy session about a request to change output.
    88         * @since Series 60 3.1
    89         * @param TInt aSessionId Id of the session to utilize, aMessage contains output value
    90         * @return void
    91         */
    92 		void DoSetOutputL (TInt aSessionId, const RMessage2& aMessage);
    93 		
    94 		/**
    95         * Assign a unique session Id to a new session.
    96         * @since Series 60 3.1
    97         * @param none
    98         * @return TInt session Id
    99         */
   100 		TInt IdentifyAndAllocateNextFreeSessionIdL();
   101 		
   102 		/**
   103         * Free the session Id or a deleted session for re-use.
   104         * @since Series 60 3.1
   105         * @param TInt aSessionId Id of the session to free
   106         * @return void
   107         */
   108 		void FreeSessionId(TInt aSessionId);
   109 		
   110 		/**
   111         * Used by policy session to indicate the session that requested a SetOutput() that
   112         * the request is complete, all the other session get OutputChanged() notification
   113         * @since Series 60 3.1
   114         * @param aOutput value of modified output, aError result of operation.
   115         * @return void
   116         */
   117 		void SetOutputCompleteL(CTelephonyAudioRouting::TAudioOutput aOutput, TInt aError);
   118 		
   119 		/**
   120         * Used by policy session to notify all sessions that the output has changed.
   121         * (Policy initiated change in output)
   122         * @since Series 60 3.1
   123         * @param aOutput value of modified output
   124         * @return void
   125         */
   126 		void OutputChanged(CTelephonyAudioRouting::TAudioOutput aOutput);		
   127 		
   128 		/**
   129         * Used by policy session to indicated to all other sessions that available outputs have changed.
   130         * @since Series 60 3.1
   131         * @param aOutputs contains array of available outputs
   132         * @return void
   133         */
   134 		void AvailableOutputsChangedL( const TArray<CTelephonyAudioRouting::TAudioOutput>& aOutputs);
   135 		
   136 		/**
   137         * Set the Id of the policy session.
   138         * @since Series 60 3.1
   139         * @param TInt aSessionId is Id to set
   140         * @return void
   141         */
   142 		void SetPolicySessionId(TInt aSessionId);
   143 		
   144     	/**
   145         * Provide caller with iCurrentAudioOutput
   146         * @since Series 60 3.1
   147         * @param none
   148         * @return iCurrentAudioOutput
   149         */
   150     	CTelephonyAudioRouting::TAudioOutput& CurrentAudioOutput();  			
   151 		
   152    		/**
   153         * Provide caller with iPreviousAudioOutput
   154         * @since Series 60 3.1
   155         * @param none
   156         * @return iPreviousAudioOutput
   157         */
   158     	CTelephonyAudioRouting::TAudioOutput& PreviousAudioOutput();  
   159     	
   160     	/**
   161         * Provide caller with iShowNoteMode
   162         * @since Series 60 3.1
   163         * @param none
   164         * @return iShowNoteMode
   165         */
   166     	TBool& ShowNoteMode(); 
   167     	
   168     	/**
   169         * Allows caller to set iShowNoteMode
   170         * @since Series 60 3.1
   171         * @param TBool aShowNoteMode
   172         * @return void
   173         */    	
   174  		void SetShowNoteMode(TBool aShowNoteMode);  	
   175     	
   176        	/**
   177         * Provide caller with iAvailableOutputs array
   178         * @since Series 60 3.1
   179         * @param none
   180         * @return: Array of available outputs
   181         */
   182     	RArray<CTelephonyAudioRouting::TAudioOutput>& AvailableOutputs();    				
   183 								
   184 		
   185 	private:
   186 	
   187 		/**
   188         * C++ default constructor.
   189         */
   190         CTelephonyAudioRoutingServer(/*TProcessId& aClientPID*/);
   191 
   192         /**
   193         * By default Symbian 2nd phase constructor is private.
   194         */
   195         void ConstructL();
   196 
   197 		/**
   198         * From CServer2
   199         * Creates a server-side client session object.
   200         */
   201 		CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
   202 		
   203 		/**
   204         * determines if audio output is in available outputs array.
   205         * @since Series 60 3.1
   206         * @param aOutput is current output value
   207         * @return TBool ETrue if current output is available, EFalse if not
   208         */		
   209 		TBool IsAvailableOutput(CTelephonyAudioRouting::TAudioOutput aOutput);
   210 			
   211 	private:
   212 	
   213 		TInt iSessionCount;
   214 		TInt iPolicySessionId;
   215 		RArray<TInt> iSetOutputRequests;
   216 		RArray<TInt> iSessionIdsInUse;
   217 		CTelephonyAudioRouting::TAudioOutput iCurrentAudioOutput;
   218 		CTelephonyAudioRouting::TAudioOutput iPreviousAudioOutput;
   219 		RArray<CTelephonyAudioRouting::TAudioOutput> iAvailableOutputs;
   220 		TBool iShowNoteMode;
   221 		
   222 
   223 	};
   224 
   225 #endif