mmresourcemgmt/mmresctrl/inc/mmrcserversession.h
changeset 0 79dd3e2336a0
equal deleted inserted replaced
-1:000000000000 0:79dd3e2336a0
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef MMRCSERVERSESSION_H__
       
    17 #define MMRCSERVERSESSION_H__
       
    18 
       
    19 #include <e32std.h>
       
    20 #include <e32base.h>
       
    21 #include <a3f/a3fbase.h>
       
    22 #include <e32msgqueue.h>
       
    23 #include "mmrcclientserver.h"
       
    24 
       
    25 /**
       
    26 * @file
       
    27 * @internalTechnology
       
    28 */
       
    29 
       
    30 class MMultimediaResourceControlObserver;
       
    31 class MLogicalChain;
       
    32 class CFourCCConvertor;
       
    33 class MAudioContext;
       
    34 class CMMRCServerController;
       
    35 class CMMRCServerSession;
       
    36 class CMMRCClientSideServerRequestToAdaptationAO;
       
    37 class CMMRCServerSideAdaptationResponseAO;
       
    38 class CAudioContext;
       
    39 
       
    40 enum TMMRCServerSessionRequestType
       
    41 	{
       
    42 	ENormalRequest, 
       
    43 	EPreemptionRequest, 
       
    44 	};
       
    45 
       
    46 /**
       
    47 Panic category and codes that MMRCServerSession raises on the client
       
    48 */
       
    49 _LIT(KMMRCServerSessionPanicCategory, "MMRCServerSession");
       
    50 
       
    51 enum TMMRCServerSessionPanicCodes
       
    52 	{
       
    53 	ECloneLeftWhenSendingResponseToClient =1,
       
    54 	EMsgQueueFailedToSendMsg
       
    55 	};
       
    56 
       
    57 /**
       
    58 @internalComponent
       
    59 This class implements the MMRC Server Session. 
       
    60 */
       
    61 NONSHARABLE_CLASS(CMMRCServerSession) : public CSession2
       
    62 	{
       
    63 	//friend class CTimeoutClientAcknowledment;
       
    64 public:
       
    65 	/**
       
    66 	 * Constructs, and returns a pointer to, a new CMMRCServerSession object.
       
    67 	 * Leaves on failure.
       
    68 	 * @param CMMRCServerController& A reference on the MMRC Server controller
       
    69 	 * @param CFourCCConvertor& A reference to the Fourcc to format converter 	 
       
    70 	 * @return CMMRCServerSession* A pointer to newly created utlitly object.
       
    71 	 */
       
    72 	static CMMRCServerSession* NewL(CMMRCServerController& aMMRCServerController, 
       
    73 									const CFourCCConvertor& aFourCCConvertor);
       
    74 
       
    75 	/**
       
    76 	 * Constructs, leaves object on the cleanup stack, and returns a pointer
       
    77 	 * to, a new CMMRCServerSession object.
       
    78 	 * Leaves on failure.
       
    79 	 * @param CMMRCServerController& A reference on the MMRC Server controller
       
    80 	 * @param CFourCCConvertor& A reference to the Fourcc to format converter 	 
       
    81 	 * @return CMMRCServerSession* A pointer to newly created utlitly object.
       
    82 	 */
       
    83 	static CMMRCServerSession* NewLC(CMMRCServerController& aMMRCServerController, 
       
    84 									const CFourCCConvertor& aFourCCConvertor);
       
    85 
       
    86 	/**
       
    87 	 * Destructor.
       
    88 	 */
       
    89 	~CMMRCServerSession();
       
    90 
       
    91 
       
    92 	/**
       
    93 	 * from CSession2
       
    94 	 * @param aMessage - Function and data for the session
       
    95 	 */	
       
    96 	void ServiceL(const RMessage2& aMessage);  
       
    97 	
       
    98 	/*
       
    99 	 * 
       
   100 	 */
       
   101 	void StartProcessL();
       
   102 
       
   103 	/*
       
   104 	 * 
       
   105 	 */
       
   106 	void StartPreemptionL();
       
   107 
       
   108 	/**
       
   109 	 * Callback on a resource request
       
   110 	 * @param TMMRCServerToClientMessageResults aResult the result on the request
       
   111 	 * @leave
       
   112 	 */
       
   113 	void AdaptationRequestAcknowledgment(TMMRCAdaptationToServerRequestResults aResult, TInt aError);
       
   114 
       
   115 	/**
       
   116 	 * Notify all the paused client that a resource has been unallocated
       
   117 	 */
       
   118 	void NotifyClientResourceUnallocated();
       
   119 
       
   120 	/**
       
   121 	 * return the current committed chain (const)
       
   122 	 * @return the current committed chain
       
   123 	 */
       
   124 	const MLogicalChain* LogicalChainRequested() const;
       
   125 	
       
   126 	/**
       
   127 	 * return the current committed chain (const)
       
   128 	 * @return the current committed chain
       
   129 	 */
       
   130 	const MLogicalChain* LogicalChainRequestedStack() const;
       
   131 
       
   132 	/**
       
   133 	 * return the last committed chain (const)
       
   134 	 * @return the last committed chain
       
   135 	 */
       
   136 	const MLogicalChain* LogicalChainLastCommited() const;
       
   137 
       
   138 	/*
       
   139 	 * 
       
   140 	 */
       
   141 	const MAudioContext* AudioContext() const;
       
   142 	
       
   143 	/**
       
   144 	 * return the current committed chain
       
   145 	 * @return the current committed chain
       
   146 	 */
       
   147 	MLogicalChain* LogicalChainRequested();
       
   148 	
       
   149 	/**
       
   150 	 * return the current committed chain
       
   151 	 * @return the current committed chain
       
   152 	 */
       
   153 	MLogicalChain* LogicalChainRequestedStack();
       
   154 
       
   155 	/**
       
   156 	 * return the last committed chain
       
   157 	 * @return the last committed chain
       
   158 	 */
       
   159 	MLogicalChain* LogicalChainLastCommited();
       
   160 
       
   161 	/**
       
   162 	 * 
       
   163 	 */		
       
   164 	CMMRCClientSideServerRequestToAdaptationAO* AdaptationProxy();
       
   165 	
       
   166 	
       
   167 	CMMRCServerSideAdaptationResponseAO* ServerProxy();
       
   168 	/**
       
   169 	 * 
       
   170 	 */		
       
   171 	TUint64 ContextId();
       
   172 
       
   173 	/**
       
   174 	 * 
       
   175 	 */		
       
   176 	TBool HasMultimediaCapability() const;
       
   177 	
       
   178 	/**
       
   179 	 * 
       
   180 	 */		
       
   181 	void Clean();
       
   182 
       
   183 	/**
       
   184 	 * 
       
   185 	 */		
       
   186 	TBool IsServerShuttingDown();
       
   187 
       
   188 	TInt RequestsSent();
       
   189 	
       
   190 	TInt SendRequestToAdaptation(TMMRCServerSessionRequestType aRequestType);
       
   191 
       
   192 	TInt GetPriority() const;
       
   193 
       
   194 	/**
       
   195 	 * 
       
   196 	 */		
       
   197 	TBool HasUserEnvironmentCapability();
       
   198 	
       
   199 	/*
       
   200 	 * 
       
   201 	 */
       
   202 	TInt NotifyClientOfError(TInt aError);
       
   203 	
       
   204 protected:
       
   205 
       
   206 	void IncrementRequestsSent();
       
   207 
       
   208 	/*
       
   209 	 * 
       
   210 	 */
       
   211 	void Disconnect(const RMessage2& aMessage);
       
   212 	
       
   213 private:
       
   214 
       
   215 	//Constructor
       
   216 	/**
       
   217 	 * By default Symbian 2nd phase constructor is private.
       
   218 	 * @param CMMRCServerController& A reference on the MMRC Server controller
       
   219 	 * @param CFourCCConvertor& A reference to the Fourcc to format converter 	 
       
   220 	 */
       
   221 	CMMRCServerSession(CMMRCServerController& aMMRCServerController, 
       
   222 						const CFourCCConvertor& aFourCCConvertor);
       
   223 	
       
   224 	/**
       
   225 	 * By default Symbian 2nd phase constructor is private.
       
   226 	 */
       
   227 	void ConstructL();
       
   228 	
       
   229 	/**
       
   230 	 * Dispatch the message received from ServeL
       
   231 	 * EMMRCClientToServerSetMsgQueueHandle - Initialise the queue handler
       
   232 	 * EMMRCClientToServerMessage - Process a message from the client
       
   233 	 * EMMRCClientToServerMessageUpdate - Process a message update from the client
       
   234 	 * EMMRCClientToServerMessageAcknowledgement - Process the acknowldgement from the client
       
   235 	 * @param aMessage - Function and data for the session
       
   236 	 * @return error code
       
   237 	 * @leave in case of writeL leave or request leave
       
   238 	 */	
       
   239 	TInt DispatchMessageL(const RMessage2& aMessage);
       
   240 	
       
   241 	/*
       
   242 	 * 
       
   243 	 */
       
   244 	TInt EnqueueRequestL(const RMessage2& aMessage);
       
   245 
       
   246 	/*
       
   247 	 * 
       
   248 	 */
       
   249 	void PreProcessRequestL(const RMessage2& aMessage);
       
   250 	
       
   251 	
       
   252 	/*
       
   253 	 * 
       
   254 	 */
       
   255 	void ProcessResourceDataRequestL(const RMessage2& aMessage);
       
   256 	
       
   257 	/*
       
   258 	 * 
       
   259 	 */
       
   260 	void SendRequestResponseToClient(TMMRCQueueItem& messageItem);
       
   261 
       
   262 	/*
       
   263 	 * 
       
   264 	 */
       
   265 	void SendPreemptionNotificationToClient(TMMRCQueueItem& messageItem);
       
   266 	
       
   267 	
       
   268 	/*
       
   269 	 * 
       
   270 	 */
       
   271 	void Panic(TMMRCServerSessionPanicCodes aCode);
       
   272 
       
   273 private:
       
   274 	RMsgQueue<TMMRCQueueItem> iMsgQueue;			//
       
   275 	CMMRCServerController& iMMRCServerController;	// a reference on the MMRC Server controller
       
   276 	//RThread iClientThread;
       
   277 	RThread iServerThread;
       
   278 	RThread iClientThread;
       
   279 	TBool iShutdown;
       
   280 	//owned
       
   281 	CMMRCServerSideAdaptationResponseAO* iMMRCServerSideAdaptationResponseAO;
       
   282 	MLogicalChain* iLogicalChainRequestedStack;			// the new committed chain
       
   283 	MLogicalChain* iLogicalChainLastCommitedStack;		// the last committed
       
   284 	MLogicalChain* iLogicalChainRequested;			// the new committed chain
       
   285 	MLogicalChain* iLogicalChainLastCommited;		// the last committed
       
   286 	MLogicalChain* iLogicalChainRequestResponse;			// A copy of the chain for client response
       
   287 	MLogicalChain* iLogicalChainPreemptionNotification;	// A copy of the chain for preemption notification to the client
       
   288 
       
   289 	//not owned (can be null pointers)
       
   290 	CAudioContext* iAudioContext;
       
   291 	const CFourCCConvertor* iFourCCConvertor;
       
   292 	CMMRCClientSideServerRequestToAdaptationAO* iMMRCClientSideServerRequestToAdaptationAO;
       
   293 
       
   294 	//not own
       
   295 	TInt32 iContextId;
       
   296 	TInt32 iRequestsSent;
       
   297 	TBool iClientHasMMCapability;
       
   298 	TBool iClientHasUECapability;
       
   299 	};
       
   300 
       
   301 #endif //__MMRCSERVERSESSION_H__