Projektarbeit Line Following Robot bei Prof. Chowanetz im WS22/23
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mmalomx_registry.c 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. Copyright (c) 2012, Broadcom Europe Ltd
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are met:
  6. * Redistributions of source code must retain the above copyright
  7. notice, this list of conditions and the following disclaimer.
  8. * Redistributions in binary form must reproduce the above copyright
  9. notice, this list of conditions and the following disclaimer in the
  10. documentation and/or other materials provided with the distribution.
  11. * Neither the name of the copyright holder nor the
  12. names of its contributors may be used to endorse or promote products
  13. derived from this software without specific prior written permission.
  14. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  15. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
  18. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #include "mmalomx.h"
  26. #include "mmalomx_roles.h"
  27. #include "mmalomx_registry.h"
  28. #include "mmalomx_logging.h"
  29. #include <util/mmal_default_components.h>
  30. #ifndef ENABLE_MMALOMX_AUDIO_HW_DECODER
  31. # define ENABLE_MMALOMX_AUDIO_HW_DECODER 0
  32. #endif
  33. #ifndef ENABLE_MMALOMX_AUDIO_SPDIF
  34. # define ENABLE_MMALOMX_AUDIO_SPDIF 1
  35. #endif
  36. static const struct {
  37. const char *omx;
  38. const char *omx_prefix;
  39. const char *mmal;
  40. MMALOMX_ROLE_T roles[MMALOMX_ROLE_MAX];
  41. } mmalomx_components[] =
  42. {
  43. {"video.hw.decoder", 0, MMAL_COMPONENT_DEFAULT_VIDEO_DECODER,
  44. {MMALOMX_ROLE_VIDEO_DECODER_H263, MMALOMX_ROLE_VIDEO_DECODER_MPEG2,
  45. MMALOMX_ROLE_VIDEO_DECODER_MPEG4, MMALOMX_ROLE_VIDEO_DECODER_AVC,
  46. MMALOMX_ROLE_VIDEO_DECODER_WMV, MMALOMX_ROLE_VIDEO_DECODER_VPX,
  47. MMALOMX_ROLE_UNDEFINED}},
  48. {"video.hw.decoder.secure", 0, "drm_alloc.video_decode",
  49. {MMALOMX_ROLE_VIDEO_DECODER_H263, MMALOMX_ROLE_VIDEO_DECODER_MPEG2,
  50. MMALOMX_ROLE_VIDEO_DECODER_MPEG4, MMALOMX_ROLE_VIDEO_DECODER_AVC,
  51. MMALOMX_ROLE_VIDEO_DECODER_WMV, MMALOMX_ROLE_VIDEO_DECODER_VPX,
  52. MMALOMX_ROLE_UNDEFINED}},
  53. {"video.hw.decoder.divx_drm", 0, "aggregator.pipeline:divx_drm:vc.video_decode",
  54. {MMALOMX_ROLE_VIDEO_DECODER_MPEG4, MMALOMX_ROLE_UNDEFINED}},
  55. {"video.vpx.decoder", 0, "libvpx",
  56. {MMALOMX_ROLE_VIDEO_DECODER_VPX, MMALOMX_ROLE_UNDEFINED}},
  57. {"video.hw.encoder", 0, MMAL_COMPONENT_DEFAULT_VIDEO_ENCODER,
  58. {MMALOMX_ROLE_VIDEO_ENCODER_H263, MMALOMX_ROLE_VIDEO_ENCODER_MPEG4,
  59. MMALOMX_ROLE_VIDEO_ENCODER_AVC, MMALOMX_ROLE_UNDEFINED}},
  60. {"AIV.play", "", "aivplay",
  61. {MMALOMX_ROLE_AIV_PLAY_101, MMALOMX_ROLE_AIV_PLAY_AVCDDP, MMALOMX_ROLE_UNDEFINED}},
  62. {"AIV.play.avcddp", "", "aivplay.ddp",
  63. {MMALOMX_ROLE_AIV_PLAY_AVCDDP, MMALOMX_ROLE_AIV_PLAY_101, MMALOMX_ROLE_UNDEFINED}},
  64. #if ENABLE_MMALOMX_AUDIO_HW_DECODER
  65. {"audio.hw.decoder", 0, "vc.ril.audio_decode",
  66. {MMALOMX_ROLE_AUDIO_DECODER_AAC, MMALOMX_ROLE_AUDIO_DECODER_MPGA_L1,
  67. MMALOMX_ROLE_AUDIO_DECODER_MPGA_L2, MMALOMX_ROLE_AUDIO_DECODER_MPGA_L3,
  68. MMALOMX_ROLE_AUDIO_DECODER_DDP, MMALOMX_ROLE_UNDEFINED}},
  69. #endif
  70. #if ENABLE_MMALOMX_AUDIO_SPDIF
  71. {"audio.spdif", 0, "spdif",
  72. {MMALOMX_ROLE_AUDIO_DECODER_DDP, MMALOMX_ROLE_UNDEFINED}},
  73. #endif
  74. {0, 0, 0, {MMALOMX_ROLE_UNDEFINED}}
  75. };
  76. int mmalomx_registry_find_component(const char *name)
  77. {
  78. int i, prefix_size;
  79. const char *prefix;
  80. for (i = 0; mmalomx_components[i].omx; i++)
  81. {
  82. /* Check the prefix first */
  83. prefix = mmalomx_components[i].omx_prefix;
  84. if (!prefix)
  85. prefix = MMALOMX_COMPONENT_PREFIX;
  86. prefix_size = strlen(prefix);
  87. if (strncmp(name, prefix, prefix_size))
  88. continue;
  89. /* Check the rest of the name */
  90. if (!strcmp(name + prefix_size, mmalomx_components[i].omx))
  91. break;
  92. }
  93. return mmalomx_components[i].mmal ? i : -1;
  94. }
  95. const char *mmalomx_registry_component_mmal(int id)
  96. {
  97. if (id >= (int)MMAL_COUNTOF(mmalomx_components) || id < 0)
  98. id = MMAL_COUNTOF(mmalomx_components) - 1;
  99. return mmalomx_components[id].mmal;
  100. }
  101. MMALOMX_ROLE_T mmalomx_registry_component_roles(int id, unsigned int index)
  102. {
  103. unsigned int i;
  104. if (id >= (int)MMAL_COUNTOF(mmalomx_components) || id < 0)
  105. id = MMAL_COUNTOF(mmalomx_components) - 1;
  106. for (i = 0; i < index; i++)
  107. if (mmalomx_components[id].roles[i] == MMALOMX_ROLE_UNDEFINED)
  108. break;
  109. return mmalomx_components[id].roles[i];
  110. }
  111. MMAL_BOOL_T mmalomx_registry_component_supports_role(int id, MMALOMX_ROLE_T role)
  112. {
  113. unsigned int i;
  114. if (id >= (int)MMAL_COUNTOF(mmalomx_components) || id < 0)
  115. id = MMAL_COUNTOF(mmalomx_components) - 1;
  116. for (i = 0; mmalomx_components[id].roles[i] != MMALOMX_ROLE_UNDEFINED; i++)
  117. if (mmalomx_components[id].roles[i] == role)
  118. return MMAL_TRUE;
  119. return MMAL_FALSE;
  120. }
  121. const char *mmalomx_registry_component_name(int id, const char **prefix)
  122. {
  123. if (id >= (int)MMAL_COUNTOF(mmalomx_components) || id < 0)
  124. id = MMAL_COUNTOF(mmalomx_components) - 1;
  125. if (prefix)
  126. {
  127. *prefix = mmalomx_components[id].omx_prefix;
  128. if (!*prefix)
  129. *prefix = MMALOMX_COMPONENT_PREFIX;
  130. }
  131. return mmalomx_components[id].omx;
  132. }