Torc  0.1
torcomxcomponent.h
Go to the documentation of this file.
1 #ifndef TORCOMXCOMPONENT_H
2 #define TORCOMXCOMPONENT_H
3 
4 // Qt
5 #include <QMutex>
6 #include <QWaitCondition>
7 
8 // Torc
9 #include "torcomxcore.h"
10 
11 // OpenMaxIL
12 #include "OMX_Core.h"
13 #include "OMX_Component.h"
14 
15 class TorcOMXPort;
16 
18 {
19  public:
20  TorcOMXEvent(OMX_EVENTTYPE Type, OMX_U32 Data1, OMX_U32 Data2);
21 
22  OMX_EVENTTYPE m_type;
23  OMX_U32 m_data1;
24  OMX_U32 m_data2;
25 };
26 
27 class TorcOMXComponent final
28 {
29  public:
30  static OMX_ERRORTYPE EventHandlerCallback (OMX_HANDLETYPE Component, OMX_PTR OMXComponent, OMX_EVENTTYPE Event, OMX_U32 Data1, OMX_U32 Data2, OMX_PTR EventData);
31  static OMX_ERRORTYPE EmptyBufferDoneCallback (OMX_HANDLETYPE Component, OMX_PTR OMXComponent, OMX_BUFFERHEADERTYPE *Buffer);
32  static OMX_ERRORTYPE FillBufferDoneCallback (OMX_HANDLETYPE Component, OMX_PTR OMXComponent, OMX_BUFFERHEADERTYPE *Buffer);
33 
34  public:
35  explicit TorcOMXComponent(OMX_STRING Component);
37 
38  bool IsValid (void);
39  QString GetName (void);
40  OMX_HANDLETYPE GetHandle (void);
41  OMX_ERRORTYPE SetState (OMX_STATETYPE State, bool Wait = true);
42  OMX_STATETYPE GetState (void);
43  OMX_ERRORTYPE SetParameter (OMX_INDEXTYPE Index, OMX_PTR Structure);
44  OMX_ERRORTYPE GetParameter (OMX_INDEXTYPE Index, OMX_PTR Structure);
45  OMX_ERRORTYPE SetConfig (OMX_INDEXTYPE Index, OMX_PTR Structure);
46  OMX_ERRORTYPE GetConfig (OMX_INDEXTYPE Index, OMX_PTR Structure);
47  OMX_U32 GetPort (OMX_DIRTYPE Direction, OMX_U32 Index, OMX_INDEXTYPE Domain);
48  OMX_ERRORTYPE EnablePort (OMX_DIRTYPE Direction, OMX_U32 Index, bool Enable, OMX_INDEXTYPE Domain, bool Wait = true);
49  OMX_ERRORTYPE DisablePorts (OMX_INDEXTYPE Domain);
50  OMX_U32 GetAvailableBuffers (OMX_DIRTYPE Direction, OMX_U32 Index, OMX_INDEXTYPE Domain);
51  OMX_U32 GetInUseBuffers (OMX_DIRTYPE Direction, OMX_U32 Index, OMX_INDEXTYPE Domain);
52  OMX_ERRORTYPE EmptyThisBuffer (OMX_BUFFERHEADERTYPE *Buffer);
53  OMX_ERRORTYPE FillThisBuffer (OMX_BUFFERHEADERTYPE *Buffer);
54  OMX_ERRORTYPE CreateBuffers (OMX_DIRTYPE Direction, OMX_U32 Index, OMX_INDEXTYPE Domain, QObject* Owner = nullptr);
55  OMX_ERRORTYPE DestroyBuffers (OMX_DIRTYPE Direction, OMX_U32 Index, OMX_INDEXTYPE Domain);
56  OMX_BUFFERHEADERTYPE* GetBuffer (OMX_DIRTYPE Direction, OMX_U32 Index, OMX_U32 Timeout, OMX_INDEXTYPE Domain);
57  OMX_ERRORTYPE FlushBuffer (OMX_DIRTYPE Direction, OMX_U32 Index, OMX_INDEXTYPE Domain);
58  OMX_ERRORTYPE EventHandler (OMX_HANDLETYPE Component, OMX_EVENTTYPE Event, OMX_U32 Data1, OMX_U32 Data2, OMX_PTR EventData);
59  OMX_ERRORTYPE EmptyBufferDone (OMX_HANDLETYPE Component, OMX_BUFFERHEADERTYPE *Buffer);
60  OMX_ERRORTYPE FillBufferDone (OMX_HANDLETYPE Component, OMX_BUFFERHEADERTYPE *Buffer);
61  OMX_ERRORTYPE SendCommand (OMX_COMMANDTYPE Command, OMX_U32 Parameter, OMX_PTR Data);
62  OMX_ERRORTYPE WaitForResponse (OMX_U32 Command, OMX_U32 Data2, OMX_S32 Timeout);
63 
64  protected:
65  void AnalysePorts (OMX_INDEXTYPE Domain);
66  TorcOMXPort* FindPort (OMX_DIRTYPE Direction, OMX_U32 Index, OMX_INDEXTYPE Domain);
67 
68  protected:
69  bool m_valid;
70  OMX_HANDLETYPE m_handle;
71  QMutex m_lock;
72  QString m_componentName;
73  QList<TorcOMXPort*> m_inputPorts;
74  QList<TorcOMXPort*> m_outputPorts;
75  QList<TorcOMXEvent> m_eventQueue;
77  QWaitCondition m_eventQueueWait;
78 
79  private:
80  Q_DISABLE_COPY(TorcOMXComponent)
81 };
82 
83 #endif
84 
OMX_HANDLETYPE m_handle
OMX_EVENTTYPE m_type
TorcOMXEvent(OMX_EVENTTYPE Type, OMX_U32 Data1, OMX_U32 Data2)
QList< TorcOMXPort * > m_outputPorts
QWaitCondition m_eventQueueWait
QList< TorcOMXEvent > m_eventQueue
QList< TorcOMXPort * > m_inputPorts