MythTV  master
omxcontext.cpp
Go to the documentation of this file.
1 #include "omxcontext.h"
2 using namespace omxcontext;
3 
4 #include <cstddef>
5 #include <cassert>
6 
7 #include <OMX_Core.h>
8 #ifdef USING_BROADCOM
9 #include <bcm_host.h>
10 #endif
11 
12 #include <QRegExp>
13 #include <QAtomicInt>
14 
15 #include "mythlogging.h"
16 
17 #define LOC QString("OMX:%1 ").arg(Id())
18 #define LOCA QString("OMX: ")
19 #define LOCB(c) QString("OMX:%1 ").arg((c).Id())
20 
21 
22 // Stringize a macro
23 #define _STR(s) #s
24 #define STR(s) _STR(s)
25 
26 // Compile time assertion
27 #undef STATIC_ASSERT
28 #ifdef __GNUC__
29 # define STATIC_ASSERT(e) extern char _dummy[(e) ? 1 : -1] __attribute__((unused))
30 #else
31 # define STATIC_ASSERT(e) extern char _dummy[(e) ? 1 : -1]
32 #endif
33 
34 #ifdef USING_BROADCOM
35 // NB The Broadcom BCB2835 driver is compiled with OMX_SKIP64BIT defined.
36 // If OMX_SKIP64BIT is not defined, OMX_TICKS becomes a 64-bit type which
37 // alters the size & layout of OMX_BUFFERHEADERTYPE
38 STATIC_ASSERT(offsetof(OMX_BUFFERHEADERTYPE, nTimeStamp) == 13 * 4);
39 STATIC_ASSERT(offsetof(OMX_BUFFERHEADERTYPE, nFlags) == 15 * 4);
40 STATIC_ASSERT(sizeof(OMX_BUFFERHEADERTYPE) == 18 * 4);
41 #endif // USING_BROADCOM
42 
43 
44 /*
45  * Types
46  */
47 namespace {
48 
49 #ifdef USING_BROADCOM
50 struct BroadcomLib
51 {
52  BroadcomLib()
53  {
54  LOG(VB_GENERAL, LOG_DEBUG, LOCA + "bcm_host_init...");
55  bcm_host_init();
56  }
57  ~BroadcomLib()
58  {
59  LOG(VB_GENERAL, LOG_DEBUG, LOCA + "bcm_host_deinit...");
60  bcm_host_deinit();
61  }
62 };
63 #endif
64 
65 } // namespace
66 
67 
68 /*
69  * Module data
70  */
71 static QAtomicInt s_iRefcnt;
72 static int s_ref;
73 
74 
78 // static
80 {
81  static bool s_bOK = false;
82 
83  if (s_iRefcnt.fetchAndAddOrdered(1) == 0)
84  {
85 #ifdef USING_BROADCOM
86  // BUG: Calling bcm_host_init/bcm_host_deinit more than once causes
87  // occasional InsufficientResources errors
88  static BroadcomLib s_bBcmInit;
89 #endif
90 
91  LOG(VB_GENERAL, LOG_DEBUG, LOCA + "OMX_Init...");
92  OMX_ERRORTYPE e = OMX_Init();
93  if (e == OMX_ErrorNone)
94  {
95  s_bOK = true;
96  LOG(VB_GENERAL, LOG_DEBUG, LOCA + "OMX_Init done");
97  }
98  else
99  {
100  LOG(VB_GENERAL, LOG_ERR, LOCA + QString("OMX_Init error %1")
101  .arg(Error2String(e)));
102  s_bOK = false;
103  }
104  }
105  return s_bOK;
106 }
107 
108 //static
110 {
111  if (s_iRefcnt.fetchAndAddOrdered(-1) == 1)
112  {
113 #ifdef USING_BELLAGIO
114  // version 0.9.3 throws SEGVs after repeated init/deinit
115  s_iRefcnt.fetchAndAddOrdered(1);
116 #else
117  LOG(VB_GENERAL, LOG_DEBUG, LOCA + "OMX_DeInit...");
118  OMX_ERRORTYPE e = OMX_Deinit();
119  if (e == OMX_ErrorNone)
120  LOG(VB_GENERAL, LOG_DEBUG, LOCA + "OMX_DeInit done");
121  else
122  LOG(VB_GENERAL, LOG_ERR, LOCA + QString("OMX_Deinit error %1")
123  .arg(Error2String(e)));
124 #endif
125  }
126 }
127 
129  m_ref(s_ref++), m_cb(cb)
130 {
131  if (!IncrRef())
132  {
133  LOG(VB_GENERAL, LOG_ERR, LOC + "Invalid OpenMAX context");
134  return;
135  }
136 
137  if (name.isEmpty())
138  return;
139 
140  OMX_ERRORTYPE e = GetComponent(this, QRegExp(name + "$", Qt::CaseInsensitive));
141  if (e != OMX_ErrorNone)
142  {
143  LOG(VB_GENERAL, LOG_ERR, LOC + "Can't find component: " + name);
144 
145  // List available components
146  LOG(VB_GENERAL, LOG_NOTICE, "Components available:");
147  EnumComponents(QRegExp(), LOG_NOTICE, VB_GENERAL);
148  return;
149  }
150  m_state = OMX_StateLoaded;
151 
152  char buf[128];
153  OMX_VERSIONTYPE ver, spec;
154  OMX_UUIDTYPE uuid;
155  if (OMX_GetComponentVersion(Handle(), buf, &ver, &spec, &uuid) != OMX_ErrorNone)
156  return;
157 
158  LOG(VB_GENERAL, LOG_DEBUG, LOC + QString(
159  "Attached %1 ver=%2.%3.%4.%5 spec=%6.%7.%8.%9")
160  .arg(buf)
161  .arg(ver.s.nVersionMajor).arg(ver.s.nVersionMinor)
162  .arg(ver.s.nRevision).arg(ver.s.nStep)
163  .arg(spec.s.nVersionMajor).arg(spec.s.nVersionMinor)
164  .arg(spec.s.nRevision).arg(spec.s.nStep));
165 }
166 
167 // virtual
169 {
170  Shutdown();
171 
172  if (m_handle)
173  {
174  OMX_ERRORTYPE e = OMX_FreeHandle(m_handle);
175  m_handle = nullptr;
176  m_state = OMX_StateInvalid;
177  if (e != OMX_ErrorNone)
178  LOG(VB_GENERAL, LOG_ERR, LOC + QString("OMX_FreeHandle error %1")
179  .arg(Error2String(e)));
180  }
181 
182  DecrRef();
183 }
184 
186 {
187  if (!m_handle)
188  return;
189 
190  if (m_state > OMX_StateIdle)
191  SetState(OMX_StateIdle, 50);
192 
193  if (m_state > OMX_StateLoaded)
194  {
196  SetState(OMX_StateLoaded, 50, &cb);
197  }
198 
199  for (unsigned port = 0; port < Ports(); ++port)
200  {
201  OMX_ERRORTYPE e;
202  if (PortDef(port).eDir == OMX_DirOutput)
203  e = OMX_SetupTunnel(Handle(), Base() + port, nullptr, 0);
204  else
205  e = OMX_SetupTunnel(nullptr, 0, Handle(), Base() + port);
206  if (e != OMX_ErrorNone)
207  LOG(VB_GENERAL, LOG_ERR, LOC + QString(
208  "OMX_SetupTunnel shutdown error %1").arg(Error2String(e)));
209  }
210 }
211 
213 {
214  m_cb.ReleaseBuffers(*this);
215  return OMX_ErrorNone;
216 }
217 
218 OMX_ERRORTYPE OMXComponent::Init(OMX_INDEXTYPE type)
219 {
220  if (!m_handle)
221  return OMX_ErrorInvalidComponent;
222 
223  if (m_state != OMX_StateLoaded)
224  {
225  LOG(VB_GENERAL, LOG_ERR, LOC + __func__ + " in incorrect state");
226  return OMX_ErrorInvalidState;
227  }
228 
229  switch( type)
230  {
231  case OMX_IndexParamVideoInit:
232  case OMX_IndexParamAudioInit:
233  case OMX_IndexParamImageInit:
234  case OMX_IndexParamOtherInit:
235  break;
236  default:
237  LOG(VB_GENERAL, LOG_ERR, LOC + __func__ + " invalid type");
238  return OMX_ErrorBadParameter;
239  }
240 
241  // Get port base index and count
242  OMX_PORT_PARAM_TYPE port;
243  OMX_DATA_INIT(port);
244  OMX_ERRORTYPE e = OMX_GetParameter(m_handle, type, &port);
245  if (e != OMX_ErrorNone)
246  {
247  LOG(VB_GENERAL, LOG_ERR, LOC + __func__ + QString(" error %1")
248  .arg(Error2String(e)));
249  return e;
250  }
251 
252  m_base = port.nStartPortNumber;
253  if (port.nPorts < 1)
254  {
255  LOG(VB_GENERAL, LOG_ERR, LOC + __func__ + " found no ports");
256  return OMX_ErrorPortsNotCompatible;
257  }
258 
259  m_portdefs.resize(port.nPorts);
260 
261  // Read the default port definitions
262  for (size_t i = 0; i < port.nPorts; ++i)
263  {
264  e = GetPortDef(i);
265  if (OMX_ErrorNone != e)
266  {
267  m_portdefs.clear();
268  return e;
269  }
270  }
271  return OMX_ErrorNone;
272 }
273 
274 OMX_ERRORTYPE OMXComponent::GetPortDef(unsigned index)
275 {
276  if (!m_handle)
277  return OMX_ErrorInvalidComponent;
278 
279  if ((int)index >= m_portdefs.size())
280  {
281  LOG(VB_GENERAL, LOG_ERR, LOC + __func__ + QString(" invalid index %1")
282  .arg(index));
283  return OMX_ErrorBadParameter;
284  }
285 
286  OMX_PARAM_PORTDEFINITIONTYPE &def = m_portdefs[index];
287  OMX_DATA_INIT(def);
288  def.nPortIndex = m_base + index;
289  OMX_ERRORTYPE e = OMX_GetParameter(m_handle, OMX_IndexParamPortDefinition,
290  &def);
291  if (e != OMX_ErrorNone)
292  LOG(VB_GENERAL, LOG_ERR, LOC + QString(
293  "Get IndexParamPortDefinition error %1").arg(Error2String(e)));
294  return e;
295 }
296 
297 const OMX_PARAM_PORTDEFINITIONTYPE &OMXComponent::PortDef(unsigned index) const
298 {
299  assert((int)index < m_portdefs.size());
300  return m_portdefs[index];
301 }
302 
303 OMX_PARAM_PORTDEFINITIONTYPE &OMXComponent::PortDef(unsigned index)
304 {
305  assert((int)index < m_portdefs.size());
306  return m_portdefs[index];
307 }
308 
309 void OMXComponent::ShowPortDef(unsigned index, LogLevel_t level, uint64_t mask) const
310 {
311  const OMX_PARAM_PORTDEFINITIONTYPE &def = PortDef(index);
312 
313  LOG(mask, level, LOC + QString(
314  "Port %1: %2, bufs=%3(%4) bufsize=%5@%9 %8, %6, %7")
315  .arg(def.nPortIndex)
316  .arg(def.eDir == OMX_DirInput ? "input" : "output")
317  .arg(def.nBufferCountActual).arg(def.nBufferCountMin)
318  .arg(def.nBufferSize)
319  .arg(def.bEnabled ? "enabled" : "disabled")
320  .arg(def.bPopulated ? "populated" : "unpopulated")
321  .arg(def.bBuffersContiguous ? "contiguous" : "discontiguous")
322  .arg(def.nBufferAlignment) );
323 
324  switch (def.eDomain)
325  {
326  case OMX_PortDomainVideo:
327  LOG(mask, level, LOC + QString(
328  "Port %1: video, w=%2 h=%3 stride=%4 sliceH=%5 bps=%6"
329  " fps=%7 compress=%8 enc=%9")
330  .arg(def.nPortIndex)
331  .arg(def.format.video.nFrameWidth)
332  .arg(def.format.video.nFrameHeight)
333  .arg(def.format.video.nStride)
334  .arg(def.format.video.nSliceHeight)
335  .arg(def.format.video.nBitrate)
336  .arg(def.format.video.xFramerate / 65536.0)
337  .arg(Coding2String(def.format.video.eCompressionFormat))
338  .arg(Format2String(def.format.video.eColorFormat)) );
339  break;
340  case OMX_PortDomainAudio:
341  LOG(mask, level, LOC + QString(
342  "Port %1: audio, encoding=%2")
343  .arg(def.nPortIndex)
344  .arg(Coding2String(def.format.audio.eEncoding)) );
345  break;
346  case OMX_PortDomainImage:
347  LOG(mask, level, LOC + QString(
348  "Port %1: image, w=%2 h=%3 stride=%4 sliceH=%5"
349  " compress=%6 enc=%7")
350  .arg(def.nPortIndex)
351  .arg(def.format.image.nFrameWidth)
352  .arg(def.format.image.nFrameHeight)
353  .arg(def.format.image.nStride)
354  .arg(def.format.image.nSliceHeight)
355  .arg(Coding2String(def.format.image.eCompressionFormat))
356  .arg(Format2String(def.format.image.eColorFormat)) );
357  break;
358  case OMX_PortDomainOther:
359  LOG(mask, level, LOC + QString("Port %1: other")
360  .arg(def.nPortIndex) );
361  break;
362  default:
363  LOG(mask, level, LOC + QString("Port %1: domain 0x%2")
364  .arg(def.nPortIndex).arg(def.eDomain,0,16) );
365  break;
366  }
367 }
368 
369 static inline void ShowFormat(const OMXComponent &cmpnt, LogLevel_t level,
370  uint64_t mask, const OMX_VIDEO_PARAM_PORTFORMATTYPE &fmt)
371 {
372  LOG(mask, level, LOCB(cmpnt) + QString(
373  "Port %1 #%2: compress=%3 colour=%4")
374  .arg(fmt.nPortIndex).arg(fmt.nIndex)
375  .arg(Coding2String(fmt.eCompressionFormat))
376  .arg(Format2String(fmt.eColorFormat)) );
377 }
378 
379 static inline void ShowFormat(const OMXComponent &cmpnt, LogLevel_t level,
380  uint64_t mask, const OMX_IMAGE_PARAM_PORTFORMATTYPE &fmt)
381 {
382  LOG(mask, level, LOCB(cmpnt) + QString(
383  "Port %1 #%2: compress=%3 colour=%4")
384  .arg(fmt.nPortIndex).arg(fmt.nIndex)
385  .arg(Coding2String(fmt.eCompressionFormat))
386  .arg(Format2String(fmt.eColorFormat)) );
387 }
388 
389 static inline void ShowFormat(const OMXComponent &cmpnt, LogLevel_t level,
390  uint64_t mask, const OMX_AUDIO_PARAM_PORTFORMATTYPE &fmt)
391 {
392  LOG(mask, level, LOCB(cmpnt) + QString(
393  "Port %1 #%2: encoding=%3")
394  .arg(fmt.nPortIndex).arg(fmt.nIndex)
395  .arg(Coding2String(fmt.eEncoding)) );
396 }
397 
398 static inline void ShowFormat(const OMXComponent &cmpnt, LogLevel_t level,
399  uint64_t mask, const OMX_OTHER_PARAM_PORTFORMATTYPE &fmt)
400 {
401  LOG(mask, level, LOCB(cmpnt) + QString(
402  "Port %1 #%2: encoding=%3")
403  .arg(fmt.nPortIndex).arg(fmt.nIndex)
404  .arg(Other2String(fmt.eFormat)) );
405 }
406 
407 template<typename T, OMX_INDEXTYPE type>
408 void ShowFormats(const OMXComponent &cmpnt, unsigned n, LogLevel_t level, uint64_t mask)
409 {
410  if (!VERBOSE_LEVEL_CHECK(mask, level))
411  return;
412 
413  T fmt;
414  OMX_DATA_INIT(fmt);
415  fmt.nPortIndex = cmpnt.Base() + n;
416 
417  OMX_ERRORTYPE e = OMX_ErrorNone;
418  for (OMX_U32 index = 0; e == OMX_ErrorNone && index < 100; ++index)
419  {
420  fmt.nIndex = index;
421  e = OMX_GetParameter(cmpnt.Handle(), type, &fmt);
422  switch (e)
423  {
424  case OMX_ErrorNone:
425  ShowFormat(cmpnt, level, mask, fmt);
426  break;
427  case OMX_ErrorNoMore:
428  break;
429  default:
430  LOG(mask, LOG_ERR, LOCB(cmpnt) + QString(
431  "GetParameter PortFormat error %1")
432  .arg(Error2String(e)));
433  break;
434  }
435  }
436 }
437 
438 void OMXComponent::ShowFormats(unsigned index, LogLevel_t level, uint64_t mask) const
439 {
440  if (PortDef(index).eDomain == OMX_PortDomainVideo)
441  ::ShowFormats<OMX_VIDEO_PARAM_PORTFORMATTYPE, OMX_IndexParamVideoPortFormat>(
442  *this, index, level, mask);
443  else if (PortDef(index).eDomain == OMX_PortDomainImage)
444  ::ShowFormats<OMX_IMAGE_PARAM_PORTFORMATTYPE, OMX_IndexParamImagePortFormat>(
445  *this, index, level, mask);
446  else if (PortDef(index).eDomain == OMX_PortDomainAudio)
447  ::ShowFormats<OMX_AUDIO_PARAM_PORTFORMATTYPE, OMX_IndexParamAudioPortFormat>(
448  *this, index, level, mask);
449  else if (PortDef(index).eDomain == OMX_PortDomainOther)
450  ::ShowFormats<OMX_OTHER_PARAM_PORTFORMATTYPE, OMX_IndexParamOtherPortFormat>(
451  *this, index, level, mask);
452  else
453  LOG(mask, LOG_ERR, LOC + QString("Unknown port domain 0x%1")
454  .arg(PortDef(index).eDomain,0,16));
455 }
456 
457 OMX_ERRORTYPE OMXComponent::SetState(OMX_STATETYPE state, int ms, OMXComponentAbstractCB *cb)
458 {
459  LOG(VB_PLAYBACK, LOG_DEBUG, LOC + QString("SetState %1")
460  .arg(State2String(state)));
461 
462  if (!m_handle)
463  return OMX_ErrorInvalidComponent;
464 
465  QMutexLocker lock(&m_state_lock);
466  if (m_state == state)
467  return OMX_ErrorSameState;
468  lock.unlock();
469 
470  OMX_ERRORTYPE e = SendCommand(OMX_CommandStateSet, state, nullptr, ms, cb);
471  if (e != OMX_ErrorNone)
472  return e;
473 
474  lock.relock();
475  if (m_state != state)
476  {
477  LOG(VB_GENERAL, LOG_ERR, LOC + QString(
478  "SetState %1 not set").arg(State2String(state)));
479  return OMX_ErrorNotReady;
480  }
481 
482  return OMX_ErrorNone;
483 }
484 
485 OMX_STATETYPE OMXComponent::GetState()
486 {
487  QMutexLocker lock(&m_state_lock);
488  if (m_handle)
489  OMX_GetState(m_handle, &m_state);
490  return m_state;
491 }
492 
493 OMX_ERRORTYPE OMXComponent::SendCommand(OMX_COMMANDTYPE cmd,
494  OMX_U32 nParam, void *pCmdData, int ms, OMXComponentAbstractCB *cb)
495 {
496  LOG(VB_PLAYBACK, LOG_DEBUG, LOC + __func__ + QString(" %1 %2 begin")
497  .arg(Command2String(cmd)).arg(nParam) );
498 
499  if (!m_handle)
500  return OMX_ErrorInvalidComponent;
501 
502  while (m_state_sema.tryAcquire())
503  ;
504  (void)LastError();
505 
506  OMX_ERRORTYPE e = OMX_SendCommand(m_handle, cmd, nParam, pCmdData);
507  if (e != OMX_ErrorNone)
508  {
509  LOG(VB_GENERAL, LOG_ERR, LOC + __func__ + QString(" %1 %2")
510  .arg(Command2String(cmd)).arg(Error2String(e)) );
511  return e;
512  }
513 
514  // Check for immediate errors
515  e = LastError();
516  if (e != OMX_ErrorNone)
517  {
518  LOG(VB_PLAYBACK, LOG_ERR, LOC + __func__ + QString(" %1 %2 %3")
519  .arg(Command2String(cmd)).arg(nParam).arg(Error2String(e)) );
520  return e;
521  }
522 
523  // Callback
524  if (cb)
525  {
526  e = cb->Action(this);
527  if (e != OMX_ErrorNone)
528  return e;
529  }
530 
531  // Await command completion
532  if (!m_state_sema.tryAcquire(1, ms))
533  {
534  if (ms == 0)
535  LOG(VB_PLAYBACK, LOG_DEBUG, LOC + __func__ + QString(" %1 %2 pending")
536  .arg(Command2String(cmd)).arg(nParam) );
537  else
538  LOG(VB_GENERAL, LOG_ERR, LOC + __func__ + QString(" %1 %2 timed out")
539  .arg(Command2String(cmd)).arg(nParam) );
540  return OMX_ErrorTimeout;
541  }
542 
543  e = LastError();
544  if (e != OMX_ErrorNone)
545  {
546  LOG(VB_PLAYBACK, LOG_ERR, LOC + __func__ + QString(" %1 %2 final %3")
547  .arg(Command2String(cmd)).arg(nParam).arg(Error2String(e)) );
548  return e;
549  }
550 
551  LOG(VB_PLAYBACK, LOG_DEBUG, LOC + __func__ + QString(" %1 %2 end")
552  .arg(Command2String(cmd)).arg(nParam) );
553  return OMX_ErrorNone;
554 }
555 
556 OMX_ERRORTYPE OMXComponent::WaitComplete(int ms)
557 {
558  if (!m_state_sema.tryAcquire(1, ms))
559  {
560  LOG(VB_GENERAL, LOG_DEBUG, LOC + __func__ + " Timed out");
561  return OMX_ErrorTimeout;
562  }
563 
564  OMX_ERRORTYPE e = LastError();
565  if (e != OMX_ErrorNone)
566  LOG(VB_GENERAL, LOG_ERR, LOC + __func__ + " " + Error2String(e));
567  return e;
568 }
569 
570 OMX_ERRORTYPE OMXComponent::LastError()
571 {
572  QMutexLocker lock(&m_state_lock);
573  OMX_ERRORTYPE e = m_error;
574  m_error = OMX_ErrorNone;
575  return e;
576 }
577 
578 /*
579  * Get an OpenMAX component by name
580  */
581 // static
582 OMX_ERRORTYPE OMXComponent::GetComponent(OMXComponent *cmpnt, const QRegExp &re,
583  LogLevel_t level, uint64_t mask)
584 {
585  if (!cmpnt && !VERBOSE_LEVEL_CHECK(mask, level))
586  return OMX_ErrorNone;
587 
588  char buf[128];
589 
590  OMX_ERRORTYPE e = OMX_ErrorNone;
591  for (int i = 0; e == OMX_ErrorNone; ++i)
592  {
593  e = OMX_ComponentNameEnum(buf, sizeof buf, i);
594  switch (e)
595  {
596  case OMX_ErrorNone:
597  if (!QString(buf).contains(re))
598  break;
599 
600  if (cmpnt)
601  {
602  OMX_CALLBACKTYPE cb = {&OMXComponent::EventCB,
604  return OMX_GetHandle(&cmpnt->m_handle, buf, cmpnt, &cb);
605  }
606 
607  LOG(mask, level, LOCA + QString("%1"). arg(buf));
608  break;
609 
610  case OMX_ErrorNoMore:
611  break;
612  default:
613  break;
614  }
615  }
616  return e;
617 }
618 
619 /*
620  * OpenMAX callbacks
621  * CAUTION!! Context undefined
622 */
623 //static
624 OMX_ERRORTYPE OMXComponent::EventCB(
625  OMX_IN OMX_HANDLETYPE /*pHandle*/,
626  OMX_IN OMX_PTR pAppData,
627  OMX_IN OMX_EVENTTYPE eEvent,
628  OMX_IN OMX_U32 nData1,
629  OMX_IN OMX_U32 nData2,
630  OMX_IN OMX_PTR pEventData)
631 {
632  OMXComponent *omx = reinterpret_cast<OMXComponent* >(pAppData);
633  return omx->m_cb.Event(*omx, eEvent, nData1, nData2, pEventData);
634 }
635 
636 //static
638  OMX_IN OMX_HANDLETYPE /*pHandle*/,
639  OMX_IN OMX_PTR pAppData,
640  OMX_IN OMX_BUFFERHEADERTYPE *hdr)
641 {
642  OMXComponent *omx = reinterpret_cast<OMXComponent* >(pAppData);
643  return omx->m_cb.EmptyBufferDone(*omx, hdr);
644 }
645 
646 //static
648  OMX_IN OMX_HANDLETYPE /*pHandle*/,
649  OMX_IN OMX_PTR pAppData,
650  OMX_IN OMX_BUFFERHEADERTYPE *hdr)
651 {
652  OMXComponent *omx = reinterpret_cast<OMXComponent* >(pAppData);
653  return omx->m_cb.FillBufferDone(*omx, hdr);
654 }
655 
656 
660 OMX_ERRORTYPE OMXComponentCtx::Event( OMXComponent &cmpnt,
661  OMX_EVENTTYPE eEvent, OMX_U32 nData1, OMX_U32 nData2, OMX_PTR /*pEventData*/)
662 {
663  LOG(VB_PLAYBACK, LOG_DEBUG, LOCB(cmpnt) + QString("%1 0x%2 0x%3")
664  .arg(Event2String(eEvent)).arg(nData1,0,16).arg(nData2,0,16) );
665 
666  switch(eEvent)
667  {
668  case OMX_EventCmdComplete:
669  if (!cmpnt.m_state_lock.tryLock(500))
670  {
671  LOG(VB_GENERAL, LOG_CRIT, LOCB(cmpnt) + QString(
672  "EventCmdComplete %1 deadlock")
673  .arg(Command2String(OMX_COMMANDTYPE(nData1))));
674  break;
675  }
676  switch (nData1)
677  {
678  case OMX_CommandStateSet:
679  cmpnt.m_state = OMX_STATETYPE(nData2);
680  cmpnt.m_error = OMX_ErrorNone;
681  break;
682  case OMX_CommandFlush:
683  case OMX_CommandPortDisable:
684  case OMX_CommandPortEnable:
685  case OMX_CommandMarkBuffer:
686  // nData2 = port index
687  cmpnt.m_error = OMX_ErrorNone;
688  break;
689  default:
690  LOG(VB_GENERAL, LOG_WARNING, LOCB(cmpnt) + QString(
691  "EventCmdComplete unknown %1")
692  .arg(Command2String(OMX_COMMANDTYPE(nData1))));
693  break;
694  }
695  cmpnt.m_state_lock.unlock();
696  cmpnt.m_state_sema.tryAcquire();
697  cmpnt.m_state_sema.release();
698  break;
699 
700  case OMX_EventError:
701  if (!cmpnt.m_state_lock.tryLock(500))
702  {
703  LOG(VB_GENERAL, LOG_CRIT, LOCB(cmpnt) + QString(
704  "EventError %1 deadlock")
705  .arg(Error2String(OMX_ERRORTYPE(nData1))));
706  break;
707  }
708  switch (nData1)
709  {
710  case OMX_ErrorInvalidState:
711  LOG(VB_GENERAL, LOG_ERR, LOCB(cmpnt) + "EventError: InvalidState");
712  cmpnt.m_state = OMX_StateInvalid;
713  break;
714  case OMX_ErrorResourcesPreempted:
715  LOG(VB_GENERAL, LOG_ERR, LOCB(cmpnt) + "EventError: ResourcesPreempted");
716  cmpnt.m_state = OMX_StateIdle;
717  break;
718  case OMX_ErrorResourcesLost:
719  LOG(VB_GENERAL, LOG_ERR, LOCB(cmpnt) + "EventError: ResourcesLost");
720  cmpnt.m_state = OMX_StateLoaded;
721  break;
722  case OMX_ErrorUnsupportedSetting:
723  LOG(VB_PLAYBACK, LOG_ERR, LOCB(cmpnt) + "EventError: UnsupportedSetting");
724  break;
725  default:
726  LOG(VB_GENERAL, LOG_ERR, LOCB(cmpnt) + QString("EventError: %1")
727  .arg(Error2String(OMX_ERRORTYPE(nData1))));
728  break;
729  }
730  cmpnt.m_error = OMX_ERRORTYPE(nData1);
731  cmpnt.m_state_lock.unlock();
732  cmpnt.m_state_sema.tryAcquire();
733  cmpnt.m_state_sema.release();
734  break;
735 
736  case OMX_EventMark:
737  // pEventData = linked data
738  break;
739 
740  case OMX_EventPortSettingsChanged:
741  LOG(VB_GENERAL, LOG_NOTICE, LOCB(cmpnt) + QString(
742  "EventPortSettingsChanged port %1")
743  .arg(nData1));
744  break;
745 
746  case OMX_EventBufferFlag:
747 #if 0
748  LOG(VB_PLAYBACK, LOG_DEBUG, LOCB(cmpnt) + QString(
749  "EventBufferFlag: port=%1 flags=%2")
750  .arg(nData1).arg(HeaderFlags(nData2)) );
751 #endif
752  break;
753 
754  case OMX_EventResourcesAcquired:
755  case OMX_EventComponentResumed:
756  case OMX_EventDynamicResourcesAvailable:
757  case OMX_EventPortFormatDetected:
758  //case OMX_EventParamOrConfigChanged:
759  break;
760 
761  default:
762  break;
763  }
764  return OMX_ErrorNone;
765 }
766 
768  OMX_BUFFERHEADERTYPE *hdr)
769 {
770  LOG(VB_GENERAL, LOG_NOTICE, LOCB(cmpnt) + __func__ + QString(" 0x%1")
771  .arg(quintptr(hdr),0,16));
772  assert(hdr->nSize == sizeof(OMX_BUFFERHEADERTYPE));
773  assert(hdr->nVersion.nVersion == OMX_VERSION);
774  return OMX_ErrorNone;
775 }
776 
778  OMX_BUFFERHEADERTYPE *hdr)
779 {
780  LOG(VB_GENERAL, LOG_NOTICE, LOCB(cmpnt) + __func__ + QString(" 0x%1")
781  .arg(quintptr(hdr),0,16));
782  assert(hdr->nSize == sizeof(OMX_BUFFERHEADERTYPE));
783  assert(hdr->nVersion.nVersion == OMX_VERSION);
784  return OMX_ErrorNone;
785 }
786 
787 
788 namespace omxcontext {
789 
790 #define CASE2STR(f) case f: return STR(f)
791 
792 const char *Coding2String(OMX_VIDEO_CODINGTYPE eCompressionFormat)
793 {
794  switch(eCompressionFormat)
795  {
796  CASE2STR(OMX_VIDEO_CodingUnused);
797  CASE2STR(OMX_VIDEO_CodingAutoDetect);
798  CASE2STR(OMX_VIDEO_CodingMPEG2);
799  CASE2STR(OMX_VIDEO_CodingH263);
800  CASE2STR(OMX_VIDEO_CodingMPEG4);
801  CASE2STR(OMX_VIDEO_CodingWMV);
802  CASE2STR(OMX_VIDEO_CodingRV);
803  CASE2STR(OMX_VIDEO_CodingAVC);
804  CASE2STR(OMX_VIDEO_CodingMJPEG);
805 #ifdef USING_BROADCOM
806  CASE2STR(OMX_VIDEO_CodingVP6);
807  CASE2STR(OMX_VIDEO_CodingVP7);
808  CASE2STR(OMX_VIDEO_CodingVP8);
809  CASE2STR(OMX_VIDEO_CodingYUV);
810  CASE2STR(OMX_VIDEO_CodingSorenson);
811  CASE2STR(OMX_VIDEO_CodingTheora);
812  CASE2STR(OMX_VIDEO_CodingMVC);
813 #endif
814  default:
815  // Quiet compiler warning.
816  break;
817  }
818  static char buf[32];
819  return strcpy(buf, qPrintable(QString("VIDEO_Coding 0x%1")
820  .arg(eCompressionFormat,0,16)));
821 }
822 
823 const char *Coding2String(OMX_IMAGE_CODINGTYPE eCompressionFormat)
824 {
825  switch(eCompressionFormat)
826  {
827  CASE2STR(OMX_IMAGE_CodingUnused);
828  CASE2STR(OMX_IMAGE_CodingAutoDetect);
829  CASE2STR(OMX_IMAGE_CodingJPEG);
830  CASE2STR(OMX_IMAGE_CodingJPEG2K);
831  CASE2STR(OMX_IMAGE_CodingEXIF);
832  CASE2STR(OMX_IMAGE_CodingTIFF);
833  CASE2STR(OMX_IMAGE_CodingGIF);
834  CASE2STR(OMX_IMAGE_CodingPNG);
835  CASE2STR(OMX_IMAGE_CodingLZW);
836  CASE2STR(OMX_IMAGE_CodingBMP);
837 #ifdef USING_BROADCOM
838  CASE2STR(OMX_IMAGE_CodingTGA);
839  CASE2STR(OMX_IMAGE_CodingPPM);
840 #endif
841  default:
842  // Quiet compiler warning.
843  break;
844  }
845  static char buf[32];
846  return strcpy(buf, qPrintable(QString("IMAGE_Coding 0x%1")
847  .arg(eCompressionFormat,0,16)));
848 }
849 
850 const char *Coding2String(OMX_AUDIO_CODINGTYPE eEncoding)
851 {
852  switch(eEncoding)
853  {
854  CASE2STR(OMX_AUDIO_CodingUnused);
855  CASE2STR(OMX_AUDIO_CodingAutoDetect);
856  CASE2STR(OMX_AUDIO_CodingPCM);
857  CASE2STR(OMX_AUDIO_CodingADPCM);
858  CASE2STR(OMX_AUDIO_CodingAMR);
859  CASE2STR(OMX_AUDIO_CodingGSMFR);
860  CASE2STR(OMX_AUDIO_CodingGSMEFR);
861  CASE2STR(OMX_AUDIO_CodingGSMHR);
862  CASE2STR(OMX_AUDIO_CodingPDCFR);
863  CASE2STR(OMX_AUDIO_CodingPDCEFR);
864  CASE2STR(OMX_AUDIO_CodingPDCHR);
865  CASE2STR(OMX_AUDIO_CodingTDMAFR);
866  CASE2STR(OMX_AUDIO_CodingTDMAEFR);
867  CASE2STR(OMX_AUDIO_CodingQCELP8);
868  CASE2STR(OMX_AUDIO_CodingQCELP13);
869  CASE2STR(OMX_AUDIO_CodingEVRC);
870  CASE2STR(OMX_AUDIO_CodingSMV);
871  CASE2STR(OMX_AUDIO_CodingG711);
872  CASE2STR(OMX_AUDIO_CodingG723);
873  CASE2STR(OMX_AUDIO_CodingG726);
874  CASE2STR(OMX_AUDIO_CodingG729);
875  CASE2STR(OMX_AUDIO_CodingAAC);
876  CASE2STR(OMX_AUDIO_CodingMP3);
877  CASE2STR(OMX_AUDIO_CodingSBC);
878  CASE2STR(OMX_AUDIO_CodingVORBIS);
879  CASE2STR(OMX_AUDIO_CodingWMA);
880  CASE2STR(OMX_AUDIO_CodingRA);
881  CASE2STR(OMX_AUDIO_CodingMIDI);
882 #ifdef USING_BROADCOM
883  CASE2STR(OMX_AUDIO_CodingFLAC);
884  CASE2STR(OMX_AUDIO_CodingDDP); // Any variant of Dolby Digital Plus
885  CASE2STR(OMX_AUDIO_CodingDTS);
886  CASE2STR(OMX_AUDIO_CodingWMAPRO);
887  CASE2STR(OMX_AUDIO_CodingATRAC3);
888  CASE2STR(OMX_AUDIO_CodingATRACX);
889  CASE2STR(OMX_AUDIO_CodingATRACAAL);
890 #endif
891  default:
892  // Quiet compiler warning.
893  break;
894  }
895  static char buf[32];
896  return strcpy(buf, qPrintable(QString("AUDIO_Coding 0x%1")
897  .arg(eEncoding,0,16)));
898 }
899 
900 const char *Other2String(OMX_OTHER_FORMATTYPE eFormat)
901 {
902  switch(eFormat)
903  {
904  CASE2STR(OMX_OTHER_FormatTime);
905  CASE2STR(OMX_OTHER_FormatPower);
906  CASE2STR(OMX_OTHER_FormatStats);
907  CASE2STR(OMX_OTHER_FormatBinary);
908 #ifdef USING_BROADCOM
909  CASE2STR(OMX_OTHER_FormatText);
910  CASE2STR(OMX_OTHER_FormatTextSKM2);
911  CASE2STR(OMX_OTHER_FormatText3GP5);
912 #endif
913  default:
914  // Quiet compiler warning.
915  break;
916  }
917  static char buf[32];
918  return strcpy(buf, qPrintable(QString("Other format 0x%1")
919  .arg(eFormat,0,16)));
920 }
921 
922 const char *Format2String(OMX_COLOR_FORMATTYPE eColorFormat)
923 {
924  switch(eColorFormat)
925  {
926  CASE2STR(OMX_COLOR_FormatUnused);
927  CASE2STR(OMX_COLOR_FormatMonochrome);
928  CASE2STR(OMX_COLOR_Format8bitRGB332);
929  CASE2STR(OMX_COLOR_Format12bitRGB444);
930  CASE2STR(OMX_COLOR_Format16bitARGB4444);
931  CASE2STR(OMX_COLOR_Format16bitARGB1555);
932  CASE2STR(OMX_COLOR_Format16bitRGB565);
933  CASE2STR(OMX_COLOR_Format16bitBGR565);
934  CASE2STR(OMX_COLOR_Format18bitRGB666);
935  CASE2STR(OMX_COLOR_Format18bitARGB1665);
936  CASE2STR(OMX_COLOR_Format19bitARGB1666);
937  CASE2STR(OMX_COLOR_Format24bitRGB888);
938  CASE2STR(OMX_COLOR_Format24bitBGR888);
939  CASE2STR(OMX_COLOR_Format24bitARGB1887);
940  CASE2STR(OMX_COLOR_Format25bitARGB1888);
941  CASE2STR(OMX_COLOR_Format32bitBGRA8888);
942  CASE2STR(OMX_COLOR_Format32bitARGB8888);
943  CASE2STR(OMX_COLOR_FormatYUV411Planar);
944  CASE2STR(OMX_COLOR_FormatYUV411PackedPlanar);
945  CASE2STR(OMX_COLOR_FormatYUV420Planar);
946  CASE2STR(OMX_COLOR_FormatYUV420PackedPlanar);
947  CASE2STR(OMX_COLOR_FormatYUV420SemiPlanar);
948  CASE2STR(OMX_COLOR_FormatYUV422Planar);
949  CASE2STR(OMX_COLOR_FormatYUV422PackedPlanar);
950  CASE2STR(OMX_COLOR_FormatYUV422SemiPlanar);
951  CASE2STR(OMX_COLOR_FormatYCbYCr);
952  CASE2STR(OMX_COLOR_FormatYCrYCb);
953  CASE2STR(OMX_COLOR_FormatCbYCrY);
954  CASE2STR(OMX_COLOR_FormatCrYCbY);
955  CASE2STR(OMX_COLOR_FormatYUV444Interleaved);
956  CASE2STR(OMX_COLOR_FormatRawBayer8bit);
957  CASE2STR(OMX_COLOR_FormatRawBayer10bit);
958  CASE2STR(OMX_COLOR_FormatRawBayer8bitcompressed);
959  CASE2STR(OMX_COLOR_FormatL2);
960  CASE2STR(OMX_COLOR_FormatL4);
961  CASE2STR(OMX_COLOR_FormatL8);
962  CASE2STR(OMX_COLOR_FormatL16);
963  CASE2STR(OMX_COLOR_FormatL24);
964  CASE2STR(OMX_COLOR_FormatL32);
965  CASE2STR(OMX_COLOR_FormatYUV420PackedSemiPlanar);
966  CASE2STR(OMX_COLOR_FormatYUV422PackedSemiPlanar);
967  CASE2STR(OMX_COLOR_Format18BitBGR666);
968  CASE2STR(OMX_COLOR_Format24BitARGB6666);
969  CASE2STR(OMX_COLOR_Format24BitABGR6666);
970  CASE2STR(OMX_COLOR_FormatKhronosExtensions);
971  CASE2STR(OMX_COLOR_FormatVendorStartUnused);
972 #ifdef USING_BROADCOM
973  CASE2STR(OMX_COLOR_Format32bitABGR8888);
974  CASE2STR(OMX_COLOR_Format8bitPalette);
975  CASE2STR(OMX_COLOR_FormatYUVUV128);
976  CASE2STR(OMX_COLOR_FormatRawBayer12bit);
977  CASE2STR(OMX_COLOR_FormatBRCMEGL);
978  CASE2STR(OMX_COLOR_FormatBRCMOpaque);
979  CASE2STR(OMX_COLOR_FormatYVU420PackedPlanar);
980  CASE2STR(OMX_COLOR_FormatYVU420PackedSemiPlanar);
981 #endif
982  default:
983  // Quiet compiler warning.
984  break;
985  }
986  static char buf[32];
987  return strcpy(buf, qPrintable(QString("COLOR_Format 0x%1")
988  .arg(eColorFormat,0,16)));
989 }
990 
991 const char *Event2String(OMX_EVENTTYPE eEvent)
992 {
993  switch(eEvent)
994  {
995  CASE2STR(OMX_EventCmdComplete);
996  CASE2STR(OMX_EventError);
997  CASE2STR(OMX_EventMark);
998  CASE2STR(OMX_EventPortSettingsChanged);
999  CASE2STR(OMX_EventBufferFlag);
1000  CASE2STR(OMX_EventResourcesAcquired);
1001  CASE2STR(OMX_EventComponentResumed);
1002  CASE2STR(OMX_EventDynamicResourcesAvailable);
1003  CASE2STR(OMX_EventPortFormatDetected);
1004 #ifdef USING_BROADCOM
1005  CASE2STR(OMX_EventParamOrConfigChanged);
1006 #endif
1007  default:
1008  // Quiet compiler warning.
1009  break;
1010  }
1011  static char buf[32];
1012  return strcpy(buf, qPrintable(QString("Event 0x%1").arg(eEvent,0,16)));
1013 }
1014 
1015 const char *Error2String(OMX_ERRORTYPE eError)
1016 {
1017  switch (eError)
1018  {
1019  CASE2STR(OMX_ErrorNone);
1020  CASE2STR(OMX_ErrorInsufficientResources);
1021  CASE2STR(OMX_ErrorUndefined);
1022  CASE2STR(OMX_ErrorInvalidComponentName);
1023  CASE2STR(OMX_ErrorComponentNotFound);
1024  CASE2STR(OMX_ErrorInvalidComponent);
1025  CASE2STR(OMX_ErrorBadParameter);
1026  CASE2STR(OMX_ErrorNotImplemented);
1027  CASE2STR(OMX_ErrorUnderflow);
1028  CASE2STR(OMX_ErrorOverflow);
1029  CASE2STR(OMX_ErrorHardware);
1030  CASE2STR(OMX_ErrorInvalidState);
1031  CASE2STR(OMX_ErrorStreamCorrupt);
1032  CASE2STR(OMX_ErrorPortsNotCompatible);
1033  CASE2STR(OMX_ErrorResourcesLost);
1034  CASE2STR(OMX_ErrorNoMore);
1035  CASE2STR(OMX_ErrorVersionMismatch);
1036  CASE2STR(OMX_ErrorNotReady);
1037  CASE2STR(OMX_ErrorTimeout);
1038  CASE2STR(OMX_ErrorSameState);
1039  CASE2STR(OMX_ErrorResourcesPreempted);
1040  CASE2STR(OMX_ErrorPortUnresponsiveDuringAllocation);
1041  CASE2STR(OMX_ErrorPortUnresponsiveDuringDeallocation);
1042  CASE2STR(OMX_ErrorPortUnresponsiveDuringStop);
1043  CASE2STR(OMX_ErrorIncorrectStateTransition);
1044  CASE2STR(OMX_ErrorIncorrectStateOperation);
1045  CASE2STR(OMX_ErrorUnsupportedSetting);
1046  CASE2STR(OMX_ErrorUnsupportedIndex);
1047  CASE2STR(OMX_ErrorBadPortIndex);
1048  CASE2STR(OMX_ErrorPortUnpopulated);
1049  CASE2STR(OMX_ErrorComponentSuspended);
1050  CASE2STR(OMX_ErrorDynamicResourcesUnavailable);
1051  CASE2STR(OMX_ErrorMbErrorsInFrame);
1052  CASE2STR(OMX_ErrorFormatNotDetected);
1053  CASE2STR(OMX_ErrorContentPipeOpenFailed);
1054  CASE2STR(OMX_ErrorContentPipeCreationFailed);
1055  CASE2STR(OMX_ErrorSeperateTablesUsed);
1056  CASE2STR(OMX_ErrorTunnelingUnsupported);
1057 #ifdef USING_BROADCOM
1058  CASE2STR(OMX_ErrorDiskFull);
1059  CASE2STR(OMX_ErrorMaxFileSize);
1060  CASE2STR(OMX_ErrorDrmUnauthorised);
1061  CASE2STR(OMX_ErrorDrmExpired);
1062  CASE2STR(OMX_ErrorDrmGeneral);
1063 #endif
1064  default:
1065  // Quiet compiler warning.
1066  break;
1067  }
1068  static char buf[32];
1069  return strcpy(buf, qPrintable(QString("Error 0x%1").arg(eError,0,16)));
1070 }
1071 
1072 const char *State2String(OMX_STATETYPE eState)
1073 {
1074  switch (eState)
1075  {
1076  CASE2STR(OMX_StateInvalid);
1077  CASE2STR(OMX_StateLoaded);
1078  CASE2STR(OMX_StateIdle);
1079  CASE2STR(OMX_StateExecuting);
1080  CASE2STR(OMX_StatePause);
1081  CASE2STR(OMX_StateWaitForResources);
1082  default:
1083  // Quiet compiler warning.
1084  break;
1085  }
1086  static char buf[32];
1087  return strcpy(buf, qPrintable(QString("State 0x%1").arg(eState,0,16)));
1088 }
1089 
1090 const char *Command2String(OMX_COMMANDTYPE cmd)
1091 {
1092  switch (cmd)
1093  {
1094  CASE2STR(OMX_CommandStateSet);
1095  CASE2STR(OMX_CommandFlush);
1096  CASE2STR(OMX_CommandPortDisable);
1097  CASE2STR(OMX_CommandPortEnable);
1098  CASE2STR(OMX_CommandMarkBuffer);
1099  default:
1100  // Quiet compiler warning.
1101  break;
1102  }
1103  static char buf[32];
1104  return strcpy(buf, qPrintable(QString("Command 0x%1").arg(cmd,0,16)));
1105 }
1106 
1107 #define FLAG2LIST(_f,_n,_l)\
1108  do {\
1109  if ((_n) & OMX_BUFFERFLAG_##_f) {\
1110  (_n) &= ~OMX_BUFFERFLAG_##_f;\
1111  (_l) << STR(_f);\
1112  }\
1113  } while(false)
1114 
1115 QString HeaderFlags(OMX_U32 nFlags)
1116 {
1117  QStringList flags;
1118 
1119  FLAG2LIST(EOS,nFlags,flags);
1120  FLAG2LIST(STARTTIME,nFlags,flags);
1121  FLAG2LIST(DECODEONLY,nFlags,flags);
1122  FLAG2LIST(DATACORRUPT,nFlags,flags);
1123  FLAG2LIST(ENDOFFRAME,nFlags,flags);
1124  FLAG2LIST(SYNCFRAME,nFlags,flags);
1125  FLAG2LIST(EXTRADATA,nFlags,flags);
1126  FLAG2LIST(CODECCONFIG,nFlags,flags);
1127 
1128  if (nFlags)
1129  flags << QString("0x%1").arg(nFlags,0,16);
1130 
1131  return QString("<") + flags.join(",") + ">";
1132 }
1133 
1134 #ifdef USING_BROADCOM
1135 const char *Interlace2String(OMX_INTERLACETYPE eMode)
1136 {
1137  switch (eMode)
1138  {
1139  CASE2STR(OMX_InterlaceProgressive);
1140  CASE2STR(OMX_InterlaceFieldSingleUpperFirst);
1141  CASE2STR(OMX_InterlaceFieldSingleLowerFirst);
1142  CASE2STR(OMX_InterlaceFieldsInterleavedUpperFirst);
1143  CASE2STR(OMX_InterlaceFieldsInterleavedLowerFirst);
1144  CASE2STR(OMX_InterlaceMixed);
1145  default:
1146  // Quiet compiler warning.
1147  break;
1148  }
1149  static char buf[32];
1150  return strcpy(buf, qPrintable(QString("Interlace 0x%1").arg(eMode,0,16)));
1151 }
1152 #endif // USING_BROADCOM
1153 
1154 const char *Filter2String(OMX_IMAGEFILTERTYPE eType)
1155 {
1156  switch (eType)
1157  {
1158  CASE2STR(OMX_ImageFilterNone);
1159  CASE2STR(OMX_ImageFilterNoise);
1160  CASE2STR(OMX_ImageFilterEmboss);
1161  CASE2STR(OMX_ImageFilterNegative);
1162  CASE2STR(OMX_ImageFilterSketch);
1163  CASE2STR(OMX_ImageFilterOilPaint);
1164  CASE2STR(OMX_ImageFilterHatch);
1165  CASE2STR(OMX_ImageFilterGpen);
1166  CASE2STR(OMX_ImageFilterAntialias);
1167  CASE2STR(OMX_ImageFilterDeRing);
1168  CASE2STR(OMX_ImageFilterSolarize);
1169 #ifdef USING_BROADCOM
1170  CASE2STR(OMX_ImageFilterWatercolor);
1171  CASE2STR(OMX_ImageFilterPastel);
1172  CASE2STR(OMX_ImageFilterSharpen);
1173  CASE2STR(OMX_ImageFilterFilm);
1174  CASE2STR(OMX_ImageFilterBlur);
1175  CASE2STR(OMX_ImageFilterSaturation);
1176  CASE2STR(OMX_ImageFilterDeInterlaceLineDouble);
1177  CASE2STR(OMX_ImageFilterDeInterlaceAdvanced);
1178  CASE2STR(OMX_ImageFilterColourSwap);
1179  CASE2STR(OMX_ImageFilterWashedOut);
1180  CASE2STR(OMX_ImageFilterColourPoint);
1181  CASE2STR(OMX_ImageFilterPosterise);
1182  CASE2STR(OMX_ImageFilterColourBalance);
1183  CASE2STR(OMX_ImageFilterCartoon);
1184  CASE2STR(OMX_ImageFilterAnaglyph);
1185  CASE2STR(OMX_ImageFilterDeInterlaceFast);
1186 #endif //def USING_BROADCOM
1187  default:
1188  // Quiet compiler warning.
1189  break;
1190  }
1191  static char buf[32];
1192  return strcpy(buf, qPrintable(QString("FilterType 0x%1").arg(eType,0,16)));
1193 }
1194 
1195 } // namespace omxcontext
1196 // EOF
#define CASE2STR(f)
Definition: omxcontext.cpp:790
static void DecrRef()
Definition: omxcontext.cpp:109
OMXComponentCtx & m_cb
Definition: omxcontext.h:104
QVector< OMX_PARAM_PORTDEFINITIONTYPE > m_portdefs
Definition: omxcontext.h:107
static void ShowFormat(const OMXComponent &cmpnt, LogLevel_t level, uint64_t mask, const OMX_VIDEO_PARAM_PORTFORMATTYPE &fmt)
Definition: omxcontext.cpp:369
OMX_U32 Base() const
Definition: omxcontext.h:48
QSemaphore m_state_sema
Definition: omxcontext.h:111
const OMX_PARAM_PORTDEFINITIONTYPE & PortDef(unsigned index=0) const
Definition: omxcontext.cpp:297
#define STATIC_ASSERT(e)
Definition: omxcontext.cpp:31
OMX_ERRORTYPE LastError()
Definition: omxcontext.cpp:570
virtual OMX_ERRORTYPE EmptyBufferDone(OMXComponent &, OMX_BUFFERHEADERTYPE *)
Definition: omxcontext.cpp:767
OMX_ERRORTYPE m_error
Definition: omxcontext.h:110
static OMX_ERRORTYPE GetComponent(OMXComponent *, const QRegExp &, LogLevel_t level=LOG_INFO, uint64_t mask=VB_PLAYBACK)
Definition: omxcontext.cpp:582
virtual ~OMXComponent()
Definition: omxcontext.cpp:168
static int s_ref
Definition: omxcontext.cpp:72
#define LOC
Definition: omxcontext.cpp:17
void ShowPortDef(unsigned index=0, LogLevel_t=LOG_INFO, uint64_t=VB_PLAYBACK) const
Definition: omxcontext.cpp:309
virtual void ReleaseBuffers(OMXComponent &)
Definition: omxcontext.h:123
OMX_STATETYPE GetState()
Definition: omxcontext.cpp:485
#define LOCA
Definition: omxcontext.cpp:18
static bool IncrRef()
OMXComponent.
Definition: omxcontext.cpp:79
OMX_ERRORTYPE Init(OMX_INDEXTYPE)
Definition: omxcontext.cpp:218
OMX_ERRORTYPE SetState(OMX_STATETYPE state, int ms=-1, OMXComponentAbstractCB *cb=nullptr)
Definition: omxcontext.cpp:457
#define VERBOSE_LEVEL_CHECK(_MASK_, _LEVEL_)
Definition: mythlogging.h:24
OMX_STATETYPE m_state
Definition: omxcontext.h:109
const char * Coding2String(OMX_VIDEO_CODINGTYPE eCompressionFormat)
Definition: omxcontext.cpp:792
OMX_U32 m_base
Definition: omxcontext.h:106
static void EnumComponents(const QRegExp &re, LogLevel_t level=LOG_INFO, uint64_t mask=VB_PLAYBACK)
Definition: omxcontext.h:83
const char * State2String(OMX_STATETYPE eState)
virtual OMX_ERRORTYPE FillBufferDone(OMXComponent &, OMX_BUFFERHEADERTYPE *)
Definition: omxcontext.cpp:777
void ShowFormats(const OMXComponent &cmpnt, unsigned n, LogLevel_t level, uint64_t mask)
Definition: omxcontext.cpp:408
void Shutdown()
Definition: omxcontext.cpp:185
#define LOCB(c)
Definition: omxcontext.cpp:19
OMX_ERRORTYPE WaitComplete(int ms=-1)
Definition: omxcontext.cpp:556
void OMX_DATA_INIT(T &s)
Definition: omxcontext.h:162
const char * name
Definition: ParseText.cpp:328
QMutex m_state_lock
Definition: omxcontext.h:108
OMX_ERRORTYPE ReleaseBuffers()
Definition: omxcontext.cpp:212
const char * Event2String(OMX_EVENTTYPE eEvent)
Definition: omxcontext.cpp:991
const char * Filter2String(OMX_IMAGEFILTERTYPE eType)
virtual OMX_ERRORTYPE Event(OMXComponent &, OMX_EVENTTYPE, OMX_U32, OMX_U32, OMX_PTR)
OMXComponentCtx.
Definition: omxcontext.cpp:660
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
#define FLAG2LIST(_f, _n, _l)
#define assert(x)
const char * Other2String(OMX_OTHER_FORMATTYPE eFormat)
Definition: omxcontext.cpp:900
QString HeaderFlags(OMX_U32 nFlags)
OMX_HANDLETYPE m_handle
Definition: omxcontext.h:105
const char * Error2String(OMX_ERRORTYPE eError)
OMXComponent(OMXComponent &)
static QAtomicInt s_iRefcnt
Definition: omxcontext.cpp:71
const char * Command2String(OMX_COMMANDTYPE cmd)
eState
Definition: dvbci.cpp:368
static OMX_ERRORTYPE EventCB(OMX_IN OMX_HANDLETYPE, OMX_IN OMX_PTR, OMX_IN OMX_EVENTTYPE, OMX_IN OMX_U32, OMX_IN OMX_U32, OMX_IN OMX_PTR)
Definition: omxcontext.cpp:624
OMX_ERRORTYPE GetPortDef(unsigned index=0)
Definition: omxcontext.cpp:274
static OMX_ERRORTYPE EmptyBufferCB(OMX_IN OMX_HANDLETYPE, OMX_IN OMX_PTR, OMX_IN OMX_BUFFERHEADERTYPE *)
Definition: omxcontext.cpp:637
OMX_ERRORTYPE SendCommand(OMX_COMMANDTYPE cmd, OMX_U32 nParam=0, void *pCmdData=nullptr, int ms=-1, OMXComponentAbstractCB *cb=nullptr)
Definition: omxcontext.cpp:493
const char * Coding2String(OMX_AUDIO_CODINGTYPE eEncoding)
Definition: omxcontext.cpp:850
unsigned Ports() const
Definition: omxcontext.h:49
void ShowFormats(unsigned index=0, LogLevel_t=LOG_INFO, uint64_t=VB_PLAYBACK) const
Definition: omxcontext.cpp:438
static OMX_ERRORTYPE FillBufferCB(OMX_IN OMX_HANDLETYPE, OMX_IN OMX_PTR, OMX_IN OMX_BUFFERHEADERTYPE *)
Definition: omxcontext.cpp:647
const char * Format2String(OMX_COLOR_FORMATTYPE eColorFormat)
Definition: omxcontext.cpp:922
#define OMX_VERSION
Definition: omxcontext.h:158
OMX_HANDLETYPE Handle() const
Definition: omxcontext.h:44
virtual OMX_ERRORTYPE Action(OMXComponent *)=0