|
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 ASBREAKEVENTHANDLER_H_ |
|
25 #define ASBREAKEVENTHANDLER_H_ |
|
26 |
|
27 #include <e32base.h> |
|
28 |
|
29 #include <openmax/il/khronos/v1_x/OMX_Component.h> |
|
30 |
|
31 class MASBreakCallback |
|
32 { |
|
33 public: |
|
34 virtual void AllComponentsEOS() = 0; |
|
35 virtual void AllComponentsTransitioned(OMX_STATETYPE aNewState, |
|
36 OMX_STATETYPE aOldState) = 0; |
|
37 virtual void EventReceived(OMX_COMPONENTTYPE* aComponent, OMX_EVENTTYPE aEvent, TUint32 aData1, TUint32 aData2, TAny* aEventData) = 0; |
|
38 virtual void ComponentTransitioned(OMX_STATETYPE aNewState, |
|
39 OMX_STATETYPE aOldState) = 0; |
|
40 virtual void BufferDone(OMX_COMPONENTTYPE* aComp, OMX_BUFFERHEADERTYPE* aBufHdr, TBool aSource) = 0; |
|
41 }; |
|
42 |
|
43 class RASBreakEventHandler |
|
44 { |
|
45 public: |
|
46 RASBreakEventHandler(MASBreakCallback& aHandler); |
|
47 TInt Create(); |
|
48 void Close(); |
|
49 |
|
50 void InstallIntoL(OMX_COMPONENTTYPE* aComponent, const TDesC& aName); |
|
51 void AddComponentL(OMX_COMPONENTTYPE* aComponent, const TDesC& aName); |
|
52 |
|
53 void AwaitTransition(OMX_STATETYPE aNewState, OMX_STATETYPE aOldState); |
|
54 void AwaitEOS(); |
|
55 void AwaitEOS(OMX_COMPONENTTYPE* aComponent); |
|
56 void AwaitSingleTransition(OMX_COMPONENTTYPE* aComponent, OMX_STATETYPE aNewState, OMX_STATETYPE aOldState); |
|
57 |
|
58 OMX_CALLBACKTYPE& CallbackStruct(); |
|
59 |
|
60 static OMX_ERRORTYPE EventHandler(OMX_HANDLETYPE hComponent, |
|
61 OMX_PTR pAppData, |
|
62 OMX_EVENTTYPE eEvent, |
|
63 OMX_U32 nData1, |
|
64 OMX_U32 nData2, |
|
65 OMX_PTR pEventData); |
|
66 static OMX_ERRORTYPE FillBufferDone(OMX_IN OMX_HANDLETYPE hComponent, |
|
67 OMX_IN OMX_PTR pAppData, |
|
68 OMX_IN OMX_BUFFERHEADERTYPE* pBuffer); |
|
69 static OMX_ERRORTYPE EmptyBufferDone(OMX_IN OMX_HANDLETYPE hComponent, |
|
70 OMX_IN OMX_PTR pAppData, |
|
71 OMX_IN OMX_BUFFERHEADERTYPE* pBuffer); |
|
72 |
|
73 private: |
|
74 void StateSet(OMX_COMPONENTTYPE* aComponent, OMX_STATETYPE aState); |
|
75 void EndOfStream(OMX_COMPONENTTYPE* aComponent); |
|
76 OMX_ERRORTYPE DoBufferDone(OMX_COMPONENTTYPE* aComponent, |
|
77 OMX_BUFFERHEADERTYPE* aBufHdr, |
|
78 TBool aSource); |
|
79 OMX_ERRORTYPE DoEventHandler(OMX_COMPONENTTYPE* aComponent, |
|
80 OMX_EVENTTYPE aEvent, |
|
81 OMX_U32 aData1, |
|
82 OMX_U32 aData2, |
|
83 OMX_PTR aEventData); |
|
84 const TDesC* ComponentName(OMX_COMPONENTTYPE* aComponent); |
|
85 |
|
86 OMX_CALLBACKTYPE iOmxCallbackType; |
|
87 |
|
88 OMX_STATETYPE iNewState; |
|
89 OMX_STATETYPE iOldState; |
|
90 |
|
91 enum TMode { EIdle, EAwaitingTransition, EAwaitingEOS, EAwaitingSingleTransition }; |
|
92 MASBreakCallback& iHandler; |
|
93 |
|
94 class TComponentInfo |
|
95 { |
|
96 public: |
|
97 static TBool CompareHandle(OMX_COMPONENTTYPE* const * a1, const TComponentInfo& a2) |
|
98 { |
|
99 return (*a1) == a2.iHandle; |
|
100 } |
|
101 |
|
102 OMX_COMPONENTTYPE* iHandle; |
|
103 TBool iComplete; |
|
104 HBufC* iName; |
|
105 }; |
|
106 |
|
107 RArray<TComponentInfo> iComponents; |
|
108 TInt iCounter; |
|
109 TMode iMode; |
|
110 RMutex iMutex; |
|
111 |
|
112 OMX_COMPONENTTYPE* iEOSComponent; // from which component we expect EOS. all components if NULL |
|
113 }; |
|
114 |
|
115 #endif /*ASBREAKEVENTHANDLER_H_*/ |