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