Torc  0.1
torcomxcore.cpp
Go to the documentation of this file.
1 /* Class TorcOMXCore
2 *
3 * This file is part of the Torc project.
4 *
5 * Copyright (C) Mark Kendall 2013-18
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20 * USA.
21 */
22 
23 // Torc
24 #include "torclogging.h"
25 #include "torcomxcore.h"
26 
27 QString EventToString(OMX_EVENTTYPE Event)
28 {
29  switch (Event)
30  {
31  case OMX_EventCmdComplete: return QStringLiteral("CmdComplete");
32  case OMX_EventError: return QStringLiteral("Error");
33  case OMX_EventMark: return QStringLiteral("Mark");
34  case OMX_EventPortSettingsChanged: return QStringLiteral("PortSettingsChanged");
35  case OMX_EventBufferFlag: return QStringLiteral("BufferFlag");
36  case OMX_EventResourcesAcquired: return QStringLiteral("ResourcesAcquired");
37  case OMX_EventComponentResumed: return QStringLiteral("ComponentResumed");
38  case OMX_EventDynamicResourcesAvailable: return QStringLiteral("DynamicResourcesAvailable");
39  case OMX_EventPortFormatDetected: return QStringLiteral("PortFormatDetected");
40  default: break;
41  }
42 
43  return QStringLiteral("Unknown %1").arg(Event);
44 }
45 
46 QString StateToString(OMX_STATETYPE State)
47 {
48  switch (State)
49  {
50  case OMX_StateInvalid: return QStringLiteral("Invalid");
51  case OMX_StateLoaded: return QStringLiteral("Loaded");
52  case OMX_StateIdle: return QStringLiteral("Idle");
53  case OMX_StateExecuting: return QStringLiteral("Executing");
54  case OMX_StatePause: return QStringLiteral("Pause");
55  case OMX_StateWaitForResources: return QStringLiteral("WaitForResources");
56  default: break;
57  }
58  return QStringLiteral("Unknown %1").arg(State);
59 }
60 
61 QString ErrorToString(OMX_ERRORTYPE Error)
62 {
63  switch (Error)
64  {
65  case OMX_ErrorNone: return QStringLiteral("None");
66  case OMX_ErrorInsufficientResources: return QStringLiteral("InsufficientResources");
67  case OMX_ErrorUndefined: return QStringLiteral("Undefined");
68  case OMX_ErrorInvalidComponentName: return QStringLiteral("InvalidComponentName");
69  case OMX_ErrorComponentNotFound: return QStringLiteral("ComponentNotFound");
70  case OMX_ErrorInvalidComponent: return QStringLiteral("InvalidComponent");
71  case OMX_ErrorBadParameter: return QStringLiteral("BadParameter");
72  case OMX_ErrorNotImplemented: return QStringLiteral("NotImplemented");
73  case OMX_ErrorUnderflow: return QStringLiteral("Underflow");
74  case OMX_ErrorOverflow: return QStringLiteral("Overflow");
75  case OMX_ErrorHardware: return QStringLiteral("Hardware");
76  case OMX_ErrorInvalidState: return QStringLiteral("InvalidState");
77  case OMX_ErrorStreamCorrupt: return QStringLiteral("StreamCorrupt");
78  case OMX_ErrorPortsNotCompatible: return QStringLiteral("PortsNotCompatible");
79  case OMX_ErrorResourcesLost: return QStringLiteral("ResourcesLost");
80  case OMX_ErrorNoMore: return QStringLiteral("NoMore");
81  case OMX_ErrorVersionMismatch: return QStringLiteral("VersionMismatch");
82  case OMX_ErrorNotReady: return QStringLiteral("NotReady");
83  case OMX_ErrorTimeout: return QStringLiteral("Timeout");
84  case OMX_ErrorSameState: return QStringLiteral("SameState");
85  case OMX_ErrorResourcesPreempted: return QStringLiteral("ResourcesPreempted");
86  case OMX_ErrorPortUnresponsiveDuringAllocation: return QStringLiteral("PortUnresponsiveDuringAllocation");
87  case OMX_ErrorPortUnresponsiveDuringDeallocation: return QStringLiteral("PortUnresponsiveDuringDeallocation");
88  case OMX_ErrorPortUnresponsiveDuringStop: return QStringLiteral("PortUnresponsiveDuringStop");
89  case OMX_ErrorIncorrectStateTransition: return QStringLiteral("IncorrectStateTransition");
90  case OMX_ErrorIncorrectStateOperation: return QStringLiteral("IncorrectStateOperation");
91  case OMX_ErrorUnsupportedSetting: return QStringLiteral("UnsupportedSetting");
92  case OMX_ErrorUnsupportedIndex: return QStringLiteral("UnsupportedIndex");
93  case OMX_ErrorBadPortIndex: return QStringLiteral("BadPortIndex");
94  case OMX_ErrorPortUnpopulated: return QStringLiteral("PortUnpopulated");
95  case OMX_ErrorComponentSuspended: return QStringLiteral("ComponentSuspended");
96  case OMX_ErrorDynamicResourcesUnavailable: return QStringLiteral("DynamicResourcesUnavailable");
97  case OMX_ErrorMbErrorsInFrame: return QStringLiteral("MbErrorsInFrame");
98  case OMX_ErrorFormatNotDetected: return QStringLiteral("FormatNotDetected");
99  case OMX_ErrorContentPipeOpenFailed: return QStringLiteral("ContentPipeOpenFailed");
100  case OMX_ErrorContentPipeCreationFailed: return QStringLiteral("ContentPipeCreationFailed");
101  case OMX_ErrorSeperateTablesUsed: return QStringLiteral("SeperateTablesUsed");
102  case OMX_ErrorTunnelingUnsupported: return QStringLiteral("TunnelingUnsupported");
103  case OMX_ErrorMax: return QStringLiteral("Max");
104  default: break;
105  }
106 
107  return QStringLiteral("Unknown error 0x%1").arg(Error, 0, 16);
108 }
109 
110 QString CommandToString(OMX_COMMANDTYPE Command)
111 {
112  switch (Command)
113  {
114  case OMX_CommandStateSet: return QStringLiteral("StateSet");
115  case OMX_CommandFlush: return QStringLiteral("Flush");
116  case OMX_CommandPortDisable: return QStringLiteral("PortDisable");
117  case OMX_CommandPortEnable: return QStringLiteral("PortEnable");
118  case OMX_CommandMarkBuffer: return QStringLiteral("MarkBuffer");
119  case OMX_CommandMax: return QStringLiteral("Max");
120  default: break;
121  }
122 
123  return QStringLiteral("Unknown %1").arg(Command);
124 }
125 
126 QString DomainToString(OMX_INDEXTYPE Domain)
127 {
128  switch (Domain)
129  {
130  case OMX_IndexParamAudioInit: return QStringLiteral("Audio");
131  case OMX_IndexParamImageInit: return QStringLiteral("Image");
132  case OMX_IndexParamVideoInit: return QStringLiteral("Video");
133  case OMX_IndexParamOtherInit: return QStringLiteral("Other");
134  default: break;
135  }
136 
137  return QStringLiteral("Unknown");
138 }
139 
141 {
142  OMX_ERRORTYPE error = OMX_Init();
143  if (OMX_ErrorNone != error)
144  {
145  LOG(VB_GENERAL, LOG_ERR, QStringLiteral("Failed to initialise OMXCore (Error '%1')").arg(ErrorToString(error)));
146  return;
147  }
148 
149  LOG(VB_GENERAL, LOG_INFO, QStringLiteral("Available OMX components:"));
150  OMX_U32 index = 0;
151  char componentname[128];
152  while (OMX_ComponentNameEnum(&componentname[0], 128, index++) == OMX_ErrorNone)
153  LOG(VB_GENERAL, LOG_INFO, QString(componentname));
154 }
155 
157 {
158  LOG(VB_GENERAL, LOG_INFO, QStringLiteral("Closing OpenMax Core"));
159  OMX_Deinit();
160 }
QString StateToString(OMX_STATETYPE State)
Definition: torcomxcore.cpp:46
QString ErrorToString(OMX_ERRORTYPE Error)
Definition: torcomxcore.cpp:61
QString CommandToString(OMX_COMMANDTYPE Command)
QString DomainToString(OMX_INDEXTYPE Domain)
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: torclogging.h:20
QString EventToString(OMX_EVENTTYPE Event)
Definition: torcomxcore.cpp:27