|
1 /* |
|
2 * Copyright (c) 2008 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 |
|
24 #ifndef C3GPMUXER_H |
|
25 #define C3GPMUXER_H |
|
26 |
|
27 #include <e32base.h> |
|
28 #include <e32std.h> |
|
29 #include <f32file.h> |
|
30 #include <e32msgqueue.h> |
|
31 #include <openmax/il/khronos/v1_x/OMX_Core.h> |
|
32 #include <c3gplibrary.h> |
|
33 |
|
34 #include "comxil3gpmuxer.h" |
|
35 #include "endwaitao.h" |
|
36 |
|
37 |
|
38 |
|
39 class MOmxILCallbackNotificationIf; |
|
40 |
|
41 NONSHARABLE_CLASS(C3GPMuxer) : public CActive |
|
42 { |
|
43 |
|
44 friend class C3GPMuxerWriterThreadObserver; |
|
45 public: |
|
46 static C3GPMuxer* NewL(MOmxILCallbackNotificationIf& aCallbacks); |
|
47 ~C3GPMuxer(); |
|
48 |
|
49 void ProcessThisBufferL(OMX_BUFFERHEADERTYPE* aBufferHeader, TUint32 aPortIndex); |
|
50 void FlushBuffers(TUint32 aPortIndex); |
|
51 TBool RemoveBuffer(OMX_BUFFERHEADERTYPE* aBufferHeader); |
|
52 void SetFilename(const HBufC* aFilename); |
|
53 void SetAudioVideoProperties(OMX_U32& aFrameWidth, OMX_U32& aFrameHeight, |
|
54 OMX_U32& aFramerate, OMX_U32& aBitRate, OMX_U32& aAudioFramerate); |
|
55 void StartL(TBool aAudioPortEnabled, TBool aVideoPortEnabled); |
|
56 void Pause(); |
|
57 TBool IsMuxerInvalid() const; |
|
58 void HandleError(TInt aError); |
|
59 OMX_ERRORTYPE SymbianErrorToOmx(TInt aError); |
|
60 protected: |
|
61 void RunL(); |
|
62 void RunAudioVideoL(); |
|
63 void RunAudioL(); |
|
64 void RunVideoL(); |
|
65 void DoCancel(); |
|
66 |
|
67 private: |
|
68 C3GPMuxer(MOmxILCallbackNotificationIf& aCallbacks); |
|
69 void ConstructL(); |
|
70 |
|
71 void OpenComposerL(); |
|
72 void WriteVideoBufferL(); |
|
73 void WriteAudioBuffer(); |
|
74 void DoFlushBuffers(TUint32 aPortIndex); |
|
75 void ReturnBuffer(OMX_BUFFERHEADERTYPE* aBuffer, TUint32 aPortIndex); |
|
76 static TInt ThreadEntryPoint(TAny* aPtr); |
|
77 void RunThreadL(); |
|
78 TBool RemoveFromQueue(RMsgQueue<OMX_BUFFERHEADERTYPE*>& aQueue, OMX_BUFFERHEADERTYPE* aBufferHeader); |
|
79 void CalculateVideoTimeScale(OMX_U32& aFramerate); |
|
80 TInt CalculateNextFrameDuration(); |
|
81 TInt CalculateNextFrameDurationPartial(TBool aFrameWritten); |
|
82 |
|
83 private: |
|
84 MOmxILCallbackNotificationIf& iCallbacks; |
|
85 C3GPCompose* iComposer; |
|
86 const HBufC* iFilename; // Not owned by this class |
|
87 TSize iVideoSize; |
|
88 TInt iVideoTimeScale; |
|
89 TInt iDefaultVideoFrameDuration; |
|
90 TUint iBitRate; |
|
91 TBool iAudioPortEnabled; |
|
92 TBool iVideoPortEnabled; |
|
93 RMsgQueue<OMX_BUFFERHEADERTYPE*> iAudioQueue; |
|
94 RMsgQueue<OMX_BUFFERHEADERTYPE*> iVideoQueue; |
|
95 OMX_BUFFERHEADERTYPE* iAudioBuffer; |
|
96 OMX_BUFFERHEADERTYPE* iCurrentVideoBuffer; |
|
97 TBool iComposerOpened; |
|
98 TUint iAudioFrameDuration; |
|
99 RThread iThread; |
|
100 RMutex iQueMutex; |
|
101 TBool iThreadRunning; |
|
102 CEndWaitAO* iEndWaitAO; |
|
103 RMsgQueue<OMX_BUFFERHEADERTYPE*> iRemoveQueue; |
|
104 TBool iPaused; |
|
105 TBool iMuxerInvalid; |
|
106 RBuf8 iPartialFrame; |
|
107 OMX_BUFFERHEADERTYPE* iNextVideoBuffer; |
|
108 TInt64 iVideoDuration; |
|
109 TUint iRemoveQueueLength; |
|
110 TBool iRemoveQueueNeedsReallocation; |
|
111 TBool iRequestOutstanding; |
|
112 }; |
|
113 |
|
114 #endif //C3GPMUXER_H |