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