1 | /* |
2 | Copyright (c) 2012, Broadcom Europe Ltd |
3 | All rights reserved. |
4 | |
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the following conditions are met: |
7 | * Redistributions of source code must retain the above copyright |
8 | notice, this list of conditions and the following disclaimer. |
9 | * Redistributions in binary form must reproduce the above copyright |
10 | notice, this list of conditions and the following disclaimer in the |
11 | documentation and/or other materials provided with the distribution. |
12 | * Neither the name of the copyright holder nor the |
13 | names of its contributors may be used to endorse or promote products |
14 | derived from this software without specific prior written permission. |
15 | |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY |
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ |
27 | |
28 | #include "interface/vmcs_host/khronos/IL/OMX_Core.h" |
29 | #include "interface/vmcs_host/khronos/IL/OMX_Component.h" |
30 | #include "interface/vmcs_host/khronos/IL/OMX_Video.h" |
31 | #include "interface/vmcs_host/khronos/IL/OMX_Audio.h" |
32 | #include "interface/vmcs_host/khronos/IL/OMX_Broadcom.h" |
33 | #include "mmalomx_logging.h" |
34 | #include "mmalomx.h" |
35 | #include "mmalomx_util_params.h" |
36 | #include "interface/vcos/vcos_types.h" |
37 | |
38 | VCOS_LOG_CAT_T mmalomx_log_category; |
39 | static VCOS_LOG_LEVEL_T mmalomx_log_level = VCOS_LOG_ERROR; |
40 | |
41 | #define MMALOMX_SAT(a,b,c) ((a)<(b)?(a):(a)>(c)?(c):(a)) |
42 | |
43 | void mmalomx_logging_init(void) |
44 | { |
45 | vcos_log_set_level(VCOS_LOG_CATEGORY, mmalomx_log_level); |
46 | vcos_log_register("mmalomx" , VCOS_LOG_CATEGORY); |
47 | } |
48 | |
49 | void mmalomx_logging_deinit(void) |
50 | { |
51 | mmalomx_log_level = mmalomx_log_category.level; |
52 | vcos_log_unregister(VCOS_LOG_CATEGORY); |
53 | } |
54 | |
55 | const char *mmalomx_param_to_string(OMX_INDEXTYPE param) |
56 | { |
57 | static const struct { |
58 | const char *string; |
59 | const OMX_INDEXTYPE param; |
60 | } param_to_names[] = |
61 | { |
62 | {"OMX_IndexParamPriorityMgmt" , OMX_IndexParamPriorityMgmt}, |
63 | {"OMX_IndexParamAudioInit" , OMX_IndexParamAudioInit}, |
64 | {"OMX_IndexParamImageInit" , OMX_IndexParamImageInit}, |
65 | {"OMX_IndexParamVideoInit" , OMX_IndexParamVideoInit}, |
66 | {"OMX_IndexParamOtherInit" , OMX_IndexParamOtherInit}, |
67 | {"OMX_IndexParamPortDefinition" , OMX_IndexParamPortDefinition}, |
68 | {"OMX_IndexParamCompBufferSupplier" , OMX_IndexParamCompBufferSupplier}, |
69 | {"OMX_IndexParamAudioPortFormat" , OMX_IndexParamAudioPortFormat}, |
70 | {"OMX_IndexParamVideoPortFormat" , OMX_IndexParamVideoPortFormat}, |
71 | {"OMX_IndexParamImagePortFormat" , OMX_IndexParamImagePortFormat}, |
72 | {"OMX_IndexParamOtherPortFormat" , OMX_IndexParamOtherPortFormat}, |
73 | {"OMX_IndexParamAudioPcm" , OMX_IndexParamAudioPcm}, |
74 | {"OMX_IndexParamAudioAac" , OMX_IndexParamAudioAac}, |
75 | {"OMX_IndexParamAudioMp3" , OMX_IndexParamAudioMp3}, |
76 | {"OMX_IndexParamVideoMpeg2" , OMX_IndexParamVideoMpeg2}, |
77 | {"OMX_IndexParamVideoMpeg4" , OMX_IndexParamVideoMpeg4}, |
78 | {"OMX_IndexParamVideoWmv" , OMX_IndexParamVideoWmv}, |
79 | {"OMX_IndexParamVideoRv" , OMX_IndexParamVideoRv}, |
80 | {"OMX_IndexParamVideoAvc" , OMX_IndexParamVideoAvc}, |
81 | {"OMX_IndexParamVideoH263" , OMX_IndexParamVideoH263}, |
82 | {"OMX_IndexParamStandardComponentRole" , OMX_IndexParamStandardComponentRole}, |
83 | {"OMX_IndexParamContentURI" , OMX_IndexParamContentURI}, |
84 | {"OMX_IndexParamCommonSensorMode" , OMX_IndexParamCommonSensorMode}, |
85 | {"OMX_IndexConfigCommonWhiteBalance" , OMX_IndexConfigCommonWhiteBalance}, |
86 | {"OMX_IndexConfigCommonDigitalZoom" , OMX_IndexConfigCommonDigitalZoom}, |
87 | {"OMX_IndexConfigCommonExposureValue" , OMX_IndexConfigCommonExposureValue}, |
88 | {"OMX_IndexConfigCapturing" , OMX_IndexConfigCapturing}, |
89 | {"OMX_IndexAutoPauseAfterCapture" , OMX_IndexAutoPauseAfterCapture}, |
90 | {"OMX_IndexConfigCommonRotate" , OMX_IndexConfigCommonRotate}, |
91 | {"OMX_IndexConfigCommonMirror" , OMX_IndexConfigCommonMirror}, |
92 | {"OMX_IndexConfigCommonScale" , OMX_IndexConfigCommonScale}, |
93 | {"OMX_IndexConfigCommonInputCrop" , OMX_IndexConfigCommonInputCrop}, |
94 | {"OMX_IndexConfigCommonOutputCrop" , OMX_IndexConfigCommonOutputCrop}, |
95 | {"OMX_IndexParamNumAvailableStreams" , OMX_IndexParamNumAvailableStreams}, |
96 | {"OMX_IndexParamActiveStream" , OMX_IndexParamActiveStream}, |
97 | {"OMX_IndexParamVideoBitrate" , OMX_IndexParamVideoBitrate}, |
98 | {"OMX_IndexParamVideoProfileLevelQuerySupported" , OMX_IndexParamVideoProfileLevelQuerySupported}, |
99 | |
100 | {"OMX_IndexParam unknown" , (OMX_INDEXTYPE)0} |
101 | }; |
102 | const char *name = mmalomx_parameter_name_omx((uint32_t)param); |
103 | int i; |
104 | |
105 | if (name) |
106 | return name; |
107 | |
108 | for(i = 0; param_to_names[i].param && |
109 | param_to_names[i].param != param; i++); |
110 | |
111 | return param_to_names[i].string; |
112 | } |
113 | |
114 | const char *mmalomx_cmd_to_string(OMX_COMMANDTYPE cmd) |
115 | { |
116 | static const char *names[] = { |
117 | "OMX_CommandStateSet" , "OMX_CommandFlush" , "OMX_CommandPortDisable" , |
118 | "OMX_CommandPortEnable" , "OMX_CommandMarkBuffer" , "OMX_Command unknown" |
119 | }; |
120 | |
121 | return names[MMALOMX_SAT((int)cmd, 0, (int)vcos_countof(names)-1)]; |
122 | } |
123 | |
124 | const char *mmalomx_state_to_string(OMX_STATETYPE state) |
125 | { |
126 | static const char *names[] = { |
127 | "OMX_StateInvalid" , "OMX_StateLoaded" , "OMX_StateIdle" , |
128 | "OMX_StateExecuting" , "OMX_StatePause" , "OMX_StateWaitForResources" , |
129 | "OMX_State unknown" |
130 | }; |
131 | |
132 | return names[MMALOMX_SAT((int)state, 0, (int)vcos_countof(names)-1)]; |
133 | } |
134 | |
135 | const char *mmalomx_event_to_string(OMX_EVENTTYPE event) |
136 | { |
137 | static const char *names[] = { |
138 | "OMX_EventCmdComplete" , "OMX_EventError" , "OMX_EventMark" , |
139 | "OMX_EventPortSettingsChanged" , "OMX_EventBufferFlag" , |
140 | "OMX_EventResourcesAcquired" , "OMX_EventComponentResumed" , |
141 | "OMX_EventDynamicResourcesAvailable" , "OMX_EventPortFormatDetected" , |
142 | "OMX_Event unknown" |
143 | }; |
144 | |
145 | return names[MMALOMX_SAT((int)event, 0, (int)vcos_countof(names)-1)]; |
146 | } |
147 | |
148 | const char *mmalomx_error_to_string(OMX_ERRORTYPE error) |
149 | { |
150 | static const char *names[] = { |
151 | "OMX_ErrorInsufficientResources" , "OMX_ErrorUndefined" , |
152 | "OMX_ErrorInvalidComponentName" , "OMX_ErrorComponentNotFound" , |
153 | "OMX_ErrorInvalidComponent" , "OMX_ErrorBadParameter" , |
154 | "OMX_ErrorNotImplemented" , "OMX_ErrorUnderflow" , |
155 | "OMX_ErrorOverflow" , "OMX_ErrorHardware" , "OMX_ErrorInvalidState" , |
156 | "OMX_ErrorStreamCorrupt" , "OMX_ErrorPortsNotCompatible" , |
157 | "OMX_ErrorResourcesLost" , "OMX_ErrorNoMore" , "OMX_ErrorVersionMismatch" , |
158 | "OMX_ErrorNotReady" , "OMX_ErrorTimeout" , "OMX_ErrorSameState" , |
159 | "OMX_ErrorResourcesPreempted" , "OMX_ErrorPortUnresponsiveDuringAllocation" , |
160 | "OMX_ErrorPortUnresponsiveDuringDeallocation" , |
161 | "OMX_ErrorPortUnresponsiveDuringStop" , "OMX_ErrorIncorrectStateTransition" , |
162 | "OMX_ErrorIncorrectStateOperation" , "OMX_ErrorUnsupportedSetting" , |
163 | "OMX_ErrorUnsupportedIndex" , "OMX_ErrorBadPortIndex" , |
164 | "OMX_ErrorPortUnpopulated" , "OMX_ErrorComponentSuspended" , |
165 | "OMX_ErrorDynamicResourcesUnavailable" , "OMX_ErrorMbErrorsInFrame" , |
166 | "OMX_ErrorFormatNotDetected" , "OMX_ErrorContentPipeOpenFailed" , |
167 | "OMX_ErrorContentPipeCreationFailed" , "OMX_ErrorSeperateTablesUsed" , |
168 | "OMX_ErrorTunnelingUnsupported" , |
169 | "OMX_Error unknown" |
170 | }; |
171 | |
172 | if(error == OMX_ErrorNone) return "OMX_ErrorNone" ; |
173 | |
174 | error -= OMX_ErrorInsufficientResources; |
175 | return names[MMALOMX_SAT((int)error, 0, (int)vcos_countof(names)-1)]; |
176 | } |
177 | |