omxil/omxilcomponentcommon/src/common/omxilincontextcallbackmanager.h
changeset 56 b6488ac24ddc
parent 47 481b3bce574a
child 57 1cbb0d5bf7f2
equal deleted inserted replaced
47:481b3bce574a 56:b6488ac24ddc
     1 // Copyright (c) 2008-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 
       
    17 /**
       
    18    @file
       
    19    @internalComponent
       
    20 */
       
    21 
       
    22 #ifndef OMXILINCONTEXTCALLBACKMANAGER_H
       
    23 #define OMXILINCONTEXTCALLBACKMANAGER_H
       
    24 
       
    25 #include "omxilcallbackmanager.h"
       
    26 
       
    27 /**
       
    28    OpenMAX IL call backs and buffer marks manager. This is a synchronous
       
    29    implementation of MOmxILCallbackManagerIf.
       
    30 
       
    31  */
       
    32 NONSHARABLE_CLASS(COmxILInContextCallbackManager) :
       
    33 	public CBase,
       
    34 	public MOmxILCallbackManagerIf,
       
    35 	private XOmxILCallbackManagerIfImpl
       
    36 	{
       
    37 
       
    38 public:
       
    39 
       
    40 	IMPORT_C static COmxILInContextCallbackManager* NewL(
       
    41 		OMX_HANDLETYPE apComponentHandle,
       
    42 		OMX_PTR apAppData,
       
    43 		OMX_CALLBACKTYPE* apCallbacks);
       
    44 
       
    45 	IMPORT_C ~COmxILInContextCallbackManager();
       
    46 
       
    47 	IMPORT_C void SetPortManager(COmxILPortManager& apPortManager);
       
    48 
       
    49 	IMPORT_C void SetFsm(COmxILFsm& apFsm);
       
    50 
       
    51 	//
       
    52 	// Methods for Callback Registration (from MOmxILCallbackManagerIf)
       
    53 	//
       
    54 	IMPORT_C OMX_ERRORTYPE RegisterComponentHandle(
       
    55 		OMX_HANDLETYPE aComponentHandle);
       
    56 
       
    57 	IMPORT_C OMX_ERRORTYPE RegisterILClientCallbacks(
       
    58 		const OMX_CALLBACKTYPE* apCallbacks,
       
    59 		const OMX_PTR apAppData);
       
    60 
       
    61 	IMPORT_C OMX_ERRORTYPE RegisterTunnelCallback(
       
    62 		OMX_U32 aLocalPortIndex,
       
    63 		OMX_DIRTYPE aLocalPortDirection,
       
    64 		OMX_HANDLETYPE aTunnelledComponentHandle,
       
    65 		OMX_U32 aTunnelledPortIndex
       
    66 		);
       
    67 
       
    68 	IMPORT_C OMX_ERRORTYPE DeregisterTunnelCallback(
       
    69 		OMX_U32 aLocalPortIndex);
       
    70 
       
    71 	IMPORT_C OMX_ERRORTYPE RegisterBufferMarkPropagationPort(
       
    72 		OMX_U32 aPortIndex,
       
    73 		OMX_U32 aPropagationPortIndex);
       
    74 
       
    75 	IMPORT_C TBool BufferRemovalIndication(
       
    76 		OMX_BUFFERHEADERTYPE* apBufferHeader,
       
    77 		OMX_DIRTYPE aDirection);
       
    78 
       
    79 
       
    80 	//
       
    81 	// Methods for Callback Notification (from MOmxILCallbackManagerIf)
       
    82 	//
       
    83 
       
    84 	IMPORT_C OMX_ERRORTYPE TransitionCompleteNotification(
       
    85 		OMX_STATETYPE aOmxState);
       
    86 
       
    87 	IMPORT_C OMX_ERRORTYPE CommandCompleteNotification(
       
    88 		OMX_COMMANDTYPE aOmxCommand,
       
    89 		OMX_U32 aOmxPortIndex);
       
    90 
       
    91 	//
       
    92 	// Methods for Callback Notification (from MOmxILCallbackManagerIf)
       
    93 	//
       
    94 
       
    95 	IMPORT_C OMX_ERRORTYPE ErrorEventNotification(
       
    96 		OMX_ERRORTYPE aOmxError);
       
    97 
       
    98 	IMPORT_C OMX_ERRORTYPE EventNotification(
       
    99 		OMX_EVENTTYPE aEvent,
       
   100 		TUint32 aData1,
       
   101 		TUint32 aData2,
       
   102 		OMX_STRING aExtraInfo);
       
   103 
       
   104 	IMPORT_C OMX_ERRORTYPE BufferDoneNotification(
       
   105 		OMX_BUFFERHEADERTYPE* apBufferHeader,
       
   106 		OMX_U32 aLocalPortIndex,
       
   107 		OMX_DIRTYPE aLocalPortDirection);
       
   108 
       
   109 	IMPORT_C OMX_ERRORTYPE ClockBufferDoneNotification(
       
   110 		OMX_BUFFERHEADERTYPE* apBufferHeader,
       
   111 		OMX_U32 aLocalPortIndex,
       
   112 		OMX_DIRTYPE aLocalPortDirection);
       
   113 
       
   114 	IMPORT_C OMX_ERRORTYPE PortSettingsChangeNotification(
       
   115 		OMX_U32 aLocalPortIndex,
       
   116 		TUint aPortSettingsIndex,
       
   117 		const TDesC8& aPortSettings);
       
   118 
       
   119 
       
   120 private:
       
   121 
       
   122 	class TOmxILBuffer
       
   123 		{
       
   124 
       
   125 	public:
       
   126 
       
   127 		OMX_BUFFERHEADERTYPE* ipBufferHeader;
       
   128 		OMX_U32 iLocalPortIndex;
       
   129 		OMX_DIRTYPE iLocalPortDirection;
       
   130 
       
   131 	// Default Constructor
       
   132 	inline TOmxILBuffer();
       
   133 
       
   134 	// Constructor
       
   135 	inline TOmxILBuffer(
       
   136 		OMX_BUFFERHEADERTYPE* apBufferHeader,
       
   137 		OMX_U32 aLocalPortIndex,
       
   138 		OMX_DIRTYPE aLocalPortDirection);
       
   139 
       
   140 		};
       
   141 
       
   142 private:
       
   143 
       
   144 	// Convenience typedef
       
   145 	typedef RArray<TOmxILBuffer> RCbMgrBufferQueue;
       
   146 
       
   147 
       
   148 private:
       
   149 
       
   150 	COmxILInContextCallbackManager(OMX_HANDLETYPE apComponentHandle,
       
   151 								   OMX_PTR apAppData,
       
   152 								   OMX_CALLBACKTYPE* apCallbacks);
       
   153 	void ConstructL();
       
   154 
       
   155 	void LockCallbackManager();
       
   156 	void UnlockCallbackManager();
       
   157 
       
   158 	void SignalOrPropagateBufferMarks(
       
   159 		OMX_BUFFERHEADERTYPE* apBufferHeader,
       
   160 		OMX_U32 aLocalPortIndex);
       
   161 
       
   162 	void ProcessBufferDoneNotification(
       
   163 		OMX_BUFFERHEADERTYPE* apBufferHeader,
       
   164 		OMX_U32 aLocalPortIndex,
       
   165 		OMX_DIRTYPE aLocalPortDirection);
       
   166 
       
   167 	void FlushQueue(RCbMgrBufferQueue& aQueue);
       
   168 
       
   169 	TBool RemoveBuffersByBufferHeader(
       
   170 		RCbMgrBufferQueue& aQueue,
       
   171 		OMX_BUFFERHEADERTYPE* apBufferHeader,
       
   172 		const OMX_DIRTYPE aDirection);
       
   173 
       
   174 	void FlushBuffersByPortIndex(RCbMgrBufferQueue& aQueue,
       
   175 								 const OMX_U32 aLocalPortIndex);
       
   176 
       
   177 
       
   178 private:
       
   179 
       
   180 	RFastLock iLock;
       
   181 
       
   182 	// Queue of buffer done notifications that need to be queued during
       
   183 	// OMX_StatePaused state
       
   184 	RCbMgrBufferQueue iPendingQueue;
       
   185 
       
   186 	// Flag to enable unconditional flushing of buffer done notifications
       
   187 	TBool iFlushPendingQueue;
       
   188 
       
   189 	OMX_STATETYPE iCurrentState;
       
   190 	OMX_STATETYPE iPreviousState;
       
   191 
       
   192 	};
       
   193 
       
   194 inline
       
   195 COmxILInContextCallbackManager::TOmxILBuffer::TOmxILBuffer()
       
   196 	:
       
   197 	ipBufferHeader(0),
       
   198 	iLocalPortIndex(0),
       
   199 	iLocalPortDirection(OMX_DirMax)
       
   200 	{
       
   201 	}
       
   202 
       
   203 inline
       
   204 COmxILInContextCallbackManager::TOmxILBuffer::TOmxILBuffer(
       
   205 	OMX_BUFFERHEADERTYPE* apBufferHeader,
       
   206 	OMX_U32 aLocalPortIndex,
       
   207 	OMX_DIRTYPE aLocalPortDirection
       
   208 	)
       
   209 	:
       
   210 	ipBufferHeader(apBufferHeader),
       
   211 	iLocalPortIndex(aLocalPortIndex),
       
   212 	iLocalPortDirection(aLocalPortDirection)
       
   213 	{
       
   214 	}
       
   215 
       
   216 
       
   217 #endif // OMXILINCONTEXTCALLBACKMANAGER_H