omxil/video/omxilvideoscheduler2/inc/comxilvideoschedulerpf.h
branchOpenMAX-IL_SHAI
changeset 16 eedf2dcd43c6
equal deleted inserted replaced
15:c1e808730d6c 16:eedf2dcd43c6
       
     1 /*
       
     2 * Copyright (c) 2008-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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 /**
       
    20 @file
       
    21 @internalComponent
       
    22 */
       
    23 #ifndef COMXILVIDEOSCHEDULERPF_H_
       
    24 #define COMXILVIDEOSCHEDULERPF_H_
       
    25 
       
    26 #include <e32std.h>
       
    27 #include "omxilprocessingfunction.h"
       
    28 #include "buffercopier.h"
       
    29 
       
    30 
       
    31 // forward class declarations
       
    32 class COmxILVideoScheduler;
       
    33 class CBufferCopierStateMonitor;
       
    34 
       
    35 static const TInt KRenderTimeListLength = 5;
       
    36 
       
    37 /**
       
    38  * These panics can only be raised in debug builds, and indicate an assertion failure due to programmer error.
       
    39  */
       
    40 enum TVideoSchedulerPanic
       
    41 	{
       
    42 	EPanicMutexUnheld,                  // the mutex was unheld where it was expected to be held
       
    43 	EPanicTimestampEmissionUnordered,   // buffer emission was triggered for a timestamp less than the previous emission's timestamp
       
    44 	EPanicBadOutputRegulation,          // more output buffers were sent than intended or iSinkPendingBuffer at inappropriate time
       
    45 	EPanicBadAssociation                // inconsistency between media time info and corresponding buffer header
       
    46 	};
       
    47 
       
    48 NONSHARABLE_CLASS(COmxILVideoSchedulerPF) : public COmxILProcessingFunction, public MBufferCopierIf
       
    49 	{
       
    50 public:
       
    51 	static COmxILVideoSchedulerPF* NewL(MOmxILCallbackNotificationIf& aCallbacks, COmxILVideoScheduler& aComponent, OMX_COMPONENTTYPE* aHandle);
       
    52 	~COmxILVideoSchedulerPF();
       
    53 
       
    54 	// from COmxILProcessingFunction
       
    55 	OMX_ERRORTYPE StateTransitionIndication(COmxILFsm::TStateIndex aNewState);
       
    56 	OMX_ERRORTYPE BufferFlushingIndication(TUint32 aPortIndex, OMX_DIRTYPE aDirection);
       
    57 	OMX_ERRORTYPE ParamIndication(OMX_INDEXTYPE aParamIndex, const TAny* apComponentParameterStructure);
       
    58 	OMX_ERRORTYPE ConfigIndication(OMX_INDEXTYPE aConfigIndex, const TAny* apComponentConfigStructure);
       
    59 	OMX_ERRORTYPE BufferIndication(OMX_BUFFERHEADERTYPE* apBufferHeader, OMX_DIRTYPE aDirection);
       
    60 	OMX_BOOL BufferRemovalIndication(OMX_BUFFERHEADERTYPE* apBufferHeader, OMX_DIRTYPE aDirection);
       
    61 	OMX_ERRORTYPE MediaTimeIndication(const OMX_TIME_MEDIATIMETYPE& aTimeInfo);
       
    62 
       
    63 	// from MBufferCopierIf
       
    64 	void MbcBufferCopied(OMX_BUFFERHEADERTYPE* aInBuffer, OMX_BUFFERHEADERTYPE* aOutBuffer);
       
    65 	void MbcBufferFlushed(OMX_BUFFERHEADERTYPE* aBuffer, OMX_DIRTYPE aDirection);
       
    66 	
       
    67 	MOmxILCallbackNotificationIf& GetCallbacks();
       
    68 
       
    69 private:
       
    70 	class TBufferMessage
       
    71 		{
       
    72 	public:
       
    73 		OMX_BUFFERHEADERTYPE* iBufferHeader;
       
    74 		OMX_TIME_MEDIATIMETYPE iMediaTimeInfo;
       
    75 		};
       
    76 	
       
    77 private:
       
    78 	COmxILVideoSchedulerPF(MOmxILCallbackNotificationIf& aCallbacks, COmxILVideoScheduler& aComponent, OMX_COMPONENTTYPE* aHandle);
       
    79 	void ConstructL();
       
    80 
       
    81 	TBool FindWaitingBuffer(const OMX_BUFFERHEADERTYPE* aBuffer, const OMX_TICKS& aMediaTime, TInt& aIndex) const;
       
    82 	void SubmitBufferHeldByPause();
       
    83 	TBool SendTimedOutputBuffer(OMX_BUFFERHEADERTYPE* aBuffer, const OMX_TIME_MEDIATIMETYPE& aMediaTimeInfo, TInt aIndex);
       
    84 	void SendOutputBuffer(OMX_BUFFERHEADERTYPE* aBuffer);
       
    85 	void DoSendOutputBuffer(OMX_BUFFERHEADERTYPE* aBuffer);
       
    86 	void HandleIfError(OMX_ERRORTYPE aOmxError);
       
    87 	OMX_ERRORTYPE SymbianErrorToOmx(TInt aError);
       
    88 	
       
    89 	void Panic(TVideoSchedulerPanic aPanicCode) const;
       
    90 	
       
    91 private:
       
    92 	COmxILVideoScheduler& iComponent;
       
    93 	OMX_TICKS iRenderTime;   // time it takes for Graphic Sink to render a frame
       
    94 	TBool iPausedState;
       
    95 	CBufferCopierStateMonitor* iBufferCopierStateMonitor;
       
    96 	RPointerArray<OMX_BUFFERHEADERTYPE> iWaitingBuffers; // all waiting buffers, including those that received time updates
       
    97 	TUint32 iOutputBufferSentCount;	// Only allowed to send 2 buffers at a time
       
    98 	RArray<TBufferMessage> iCompletedBuffersHeldByPause;	// buffers that receive time indications while component is paused
       
    99 	TInt64 iMaxLateness;	// how late a buffer is allowed to be before it is dropped
       
   100 
       
   101 	// to keep track of ClockState
       
   102 	OMX_TIME_CONFIG_CLOCKSTATETYPE iClockState;
       
   103 
       
   104 	// hold on to start time if received before clock enters WaitingForStartTime state
       
   105 	TInt64 iStartTime;
       
   106 	TBool iStartTimePending;
       
   107 	
       
   108 	// any buffer that is ready to be displayed but sink is not ready to receive
       
   109 	OMX_BUFFERHEADERTYPE* iSinkPendingBuffer;
       
   110 	
       
   111 	TBool iIsClockStopped;
       
   112 	TBool iInvalid;
       
   113     TUint32 iFrameDroppedCount;  // shouldn't drop more than 2 frames at a time when decoder is slow
       
   114     OMX_TICKS iTimeStamp;
       
   115     RMutex iMutex;
       
   116     OMX_BOOL iEnableDropFrameEvent;  //enable the extension to notify error when drop frame happen
       
   117 
       
   118 	TUint32 iRenderTimeList[KRenderTimeListLength];
       
   119 	TInt iRenderTimeListPos;
       
   120 	TUint32 iRenderTimeSum;    // the sum of the values in iRenderTimeList
       
   121 
       
   122 	OMX_COMPONENTTYPE* iHandle;
       
   123 	};
       
   124 
       
   125 #endif /*CCOMXILVIDEOSCHEDULERPF_H_*/