signatures.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. /*
  2. * Copyright (C) 2011-2011 Teluu Inc. (http://www.teluu.com)
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. #ifndef __PJMEDIA_SIGNATURES_H__
  19. #define __PJMEDIA_SIGNATURES_H__
  20. /**
  21. * @file pjmedia/signatures.h
  22. * @brief Standard PJMEDIA object signatures
  23. */
  24. #include <pjmedia/types.h>
  25. PJ_BEGIN_DECL
  26. /**
  27. * @defgroup PJMEDIA_SIG Object Signatures
  28. * @ingroup PJMEDIA_BASE
  29. * @brief Standard PJMEDIA object signatures
  30. * @{
  31. *
  32. * Object signature is a 32-bit integral value similar to FOURCC to help
  33. * identify PJMEDIA objects such as media ports, transports, codecs, etc.
  34. * There are several uses of this signature, for example a media port can
  35. * use the port object signature to verify that the given port instance
  36. * is the one that it created, and a receiver of \ref PJMEDIA_EVENT can
  37. * use the signature of the publisher to know which object emitted the
  38. * event.
  39. *
  40. * The 32-bit value of an object signature is generated by the following
  41. * macro:
  42. *
  43. * \verbatim
  44. #define PJMEDIA_SIGNATURE(a,b,c,d) (a<<24 | b<<16 | c<<8 | d)
  45. * \endverbatim
  46. *
  47. * The following convention is used to maintain order to the signature
  48. * values so that application can make use of it more effectively, and to
  49. * avoid conflict between the values themselves. For each object type or
  50. * class, a specific prefix will be assigned as signature, and a macro
  51. * is created to build a signature for such object:
  52. *
  53. * \verbatim
  54. Class Signature Signature creation and test macros
  55. ---------------------------------------------------------------
  56. Codec Cxxx PJMEDIA_SIG_CLASS_CODEC(b,c,d)
  57. PJMEDIA_SIG_IS_CLASS_CODEC(sig)
  58. Audio codec CAxx PJMEDIA_SIG_CLASS_AUD_CODEC(c,d)
  59. PJMEDIA_SIG_IS_CLASS_AUD_CODEC(sig)
  60. Video codec CVxx PJMEDIA_SIG_CLASS_VID_CODEC(c,d)
  61. PJMEDIA_SIG_IS_CLASS_VID_CODEC(sig)
  62. Media port Pxxx PJMEDIA_SIG_CLASS_PORT(b,c,d)
  63. PJMEDIA_SIG_IS_CLASS_PORT(sig)
  64. Audio media port PAxx PJMEDIA_SIG_CLASS_PORT_AUD(c,d)
  65. PJMEDIA_SIG_IS_CLASS_PORT_AUD(sig)
  66. Video media port PVxx PJMEDIA_SIG_CLASS_PORT_VID(c,d)
  67. PJMEDIA_SIG_IS_CLASS_PORT_VID(sig)
  68. Video device VDxx PJMEDIA_SIG_CLASS_VID_DEV(c,d)
  69. PJMEDIA_SIG_IS_CLASS_VID_DEV(sig)
  70. Video other VOxx PJMEDIA_SIG_CLASS_VID_OTHER(c,d)
  71. PJMEDIA_SIG_IS_CLASS_VID_OTHER(sig)
  72. Application object Axxx PJMEDIA_SIG_CLASS_APP(b,c,d)
  73. PJMEDIA_SIG_IS_CLASS_APP(sig)
  74. * \endverbatim
  75. *
  76. * In addition, signatures created in application code should have lowercase
  77. * letters to avoid conflict with built-in objects.
  78. */
  79. /**
  80. * Type to store object signature.
  81. */
  82. typedef pj_uint32_t pjmedia_obj_sig;
  83. /**
  84. * A utility function to convert signature to four letters string.
  85. *
  86. * @param sig The signature value.
  87. * @param buf Buffer to store the string, which MUST be at least
  88. * five bytes long.
  89. *
  90. * @return The string.
  91. */
  92. PJ_INLINE(const char*) pjmedia_sig_name(pjmedia_obj_sig sig, char buf[])
  93. {
  94. return pjmedia_fourcc_name(sig, buf);
  95. }
  96. /**
  97. * Macro to generate signature from four ASCII letters.
  98. */
  99. #define PJMEDIA_SIGNATURE(a,b,c,d) PJMEDIA_FOURCC(d,c,b,a)
  100. /*************************************************************************
  101. * Codec signature ('Cxxx'). Please keep the constant names sorted.
  102. */
  103. #define PJMEDIA_SIG_CLASS_CODEC(b,c,d) PJMEDIA_SIGNATURE('C',b,c,d)
  104. #define PJMEDIA_SIG_IS_CLASS_CODEC(sig) ((sig) >> 24 == 'C')
  105. /*************************************************************************
  106. * Audio codec signatures ('CAxx'). Please keep the constant names sorted.
  107. */
  108. #define PJMEDIA_SIG_CLASS_AUD_CODEC(c,d) PJMEDIA_SIG_CLASS_CODEC('A',c,d)
  109. #define PJMEDIA_SIG_IS_CLASS_AUD_CODEC(s) ((s)>>24=='C' && (((s)>>16)&0xff)=='A')
  110. /*************************************************************************
  111. * Video codec signatures ('CVxx'). Please keep the constant names sorted.
  112. */
  113. #define PJMEDIA_SIG_CLASS_VID_CODEC(c,d) PJMEDIA_SIG_CLASS_CODEC('V',c,d)
  114. #define PJMEDIA_SIG_IS_CLASS_VID_CODEC(sig) ((s)>>24=='C' && (((s)>>16)&0xff)=='V')
  115. #define PJMEDIA_SIG_VID_CODEC_FFMPEG PJMEDIA_SIG_CLASS_VID_CODEC('F','F')
  116. /*************************************************************************
  117. * Port signatures ('Pxxx'). Please keep the constant names sorted.
  118. */
  119. #define PJMEDIA_SIG_CLASS_PORT(b,c,d) PJMEDIA_SIGNATURE('P',b,c,d)
  120. #define PJMEDIA_SIG_IS_CLASS_PORT(sig) ((sig) >> 24 == 'P')
  121. /*************************************************************************
  122. * Audio ports signatures ('PAxx'). Please keep the constant names sorted.
  123. */
  124. #define PJMEDIA_SIG_CLASS_PORT_AUD(c,d) PJMEDIA_SIG_CLASS_PORT('A',c,d)
  125. #define PJMEDIA_SIG_IS_CLASS_PORT_AUD(s) ((s)>>24=='P' && (((s)>>16)&0xff)=='A')
  126. #define PJMEDIA_SIG_PORT_BIDIR PJMEDIA_SIG_CLASS_PORT_AUD('B','D')
  127. #define PJMEDIA_SIG_PORT_CONF PJMEDIA_SIG_CLASS_PORT_AUD('C','F')
  128. #define PJMEDIA_SIG_PORT_CONF_PASV PJMEDIA_SIG_CLASS_PORT_AUD('C','P')
  129. #define PJMEDIA_SIG_PORT_CONF_SWITCH PJMEDIA_SIG_CLASS_PORT_AUD('C','S')
  130. #define PJMEDIA_SIG_PORT_ECHO PJMEDIA_SIG_CLASS_PORT_AUD('E','C')
  131. #define PJMEDIA_SIG_PORT_MEM_CAPTURE PJMEDIA_SIG_CLASS_PORT_AUD('M','C')
  132. #define PJMEDIA_SIG_PORT_MEM_PLAYER PJMEDIA_SIG_CLASS_PORT_AUD('M','P')
  133. #define PJMEDIA_SIG_PORT_NULL PJMEDIA_SIG_CLASS_PORT_AUD('N','U')
  134. #define PJMEDIA_SIG_PORT_RESAMPLE PJMEDIA_SIG_CLASS_PORT_AUD('R','E')
  135. #define PJMEDIA_SIG_PORT_SPLIT_COMB PJMEDIA_SIG_CLASS_PORT_AUD('S','C')
  136. #define PJMEDIA_SIG_PORT_SPLIT_COMB_P PJMEDIA_SIG_CLASS_PORT_AUD('S','P')
  137. #define PJMEDIA_SIG_PORT_STEREO PJMEDIA_SIG_CLASS_PORT_AUD('S','R')
  138. #define PJMEDIA_SIG_PORT_STREAM PJMEDIA_SIG_CLASS_PORT_AUD('S','T')
  139. #define PJMEDIA_SIG_PORT_TONEGEN PJMEDIA_SIG_CLASS_PORT_AUD('T','O')
  140. #define PJMEDIA_SIG_PORT_WAV_PLAYER PJMEDIA_SIG_CLASS_PORT_AUD('W','P')
  141. #define PJMEDIA_SIG_PORT_WAV_PLAYLIST PJMEDIA_SIG_CLASS_PORT_AUD('W','Y')
  142. #define PJMEDIA_SIG_PORT_WAV_WRITER PJMEDIA_SIG_CLASS_PORT_AUD('W','W')
  143. /*************************************************************************
  144. * Video ports signatures ('PVxx'). Please keep the constant names sorted.
  145. */
  146. #define PJMEDIA_SIG_CLASS_PORT_VID(c,d) PJMEDIA_SIG_CLASS_PORT('V',c,d)
  147. #define PJMEDIA_SIG_IS_CLASS_PORT_VID(s) ((s)>>24=='P' && (((s)>>16)&0xff)=='V')
  148. /** AVI player signature. */
  149. #define PJMEDIA_SIG_PORT_VID_AVI_PLAYER PJMEDIA_SIG_CLASS_PORT_VID('A','V')
  150. #define PJMEDIA_SIG_PORT_VID_STREAM PJMEDIA_SIG_CLASS_PORT_VID('S','T')
  151. #define PJMEDIA_SIG_PORT_VID_TEE PJMEDIA_SIG_CLASS_PORT_VID('T','E')
  152. /**************************************************************************
  153. * Video device signatures ('VDxx'). Please keep the constant names sorted.
  154. */
  155. #define PJMEDIA_SIG_CLASS_VID_DEV(c,d) PJMEDIA_SIGNATURE('V','D',c,d)
  156. #define PJMEDIA_SIG_IS_CLASS_VID_DEV(s) ((s)>>24=='V' && (((s)>>16)&0xff)=='D')
  157. #define PJMEDIA_SIG_VID_DEV_COLORBAR PJMEDIA_SIG_CLASS_VID_DEV('C','B')
  158. #define PJMEDIA_SIG_VID_DEV_SDL PJMEDIA_SIG_CLASS_VID_DEV('S','D')
  159. #define PJMEDIA_SIG_VID_DEV_V4L2 PJMEDIA_SIG_CLASS_VID_DEV('V','2')
  160. #define PJMEDIA_SIG_VID_DEV_DSHOW PJMEDIA_SIG_CLASS_VID_DEV('D','S')
  161. #define PJMEDIA_SIG_VID_DEV_QT PJMEDIA_SIG_CLASS_VID_DEV('Q','T')
  162. #define PJMEDIA_SIG_VID_DEV_IOS PJMEDIA_SIG_CLASS_VID_DEV('I','P')
  163. /*********************************************************************
  164. * Other video objects ('VOxx'). Please keep the constant names sorted.
  165. */
  166. #define PJMEDIA_SIG_CLASS_VID_OTHER(c,d) PJMEDIA_SIGNATURE('V','O',c,d)
  167. #define PJMEDIA_SIG_IS_CLASS_VID_OTHER(s) ((s)>>24=='V' && (((s)>>16)&0xff)=='O')
  168. #define PJMEDIA_SIG_VID_CONF PJMEDIA_SIG_CLASS_VID_OTHER('C','F')
  169. #define PJMEDIA_SIG_VID_PORT PJMEDIA_SIG_CLASS_VID_OTHER('P','O')
  170. /*********************************************************************
  171. * Application class ('Axxx').
  172. */
  173. #define PJMEDIA_SIG_CLASS_APP(b,c,d) PJMEDIA_SIGNATURE('A',b,c,d)
  174. #define PJMEDIA_SIG_IS_CLASS_APP(s) ((s)>>24=='A')
  175. /**
  176. * @} PJSIP_MSG
  177. */
  178. PJ_END_DECL
  179. #endif /* __PJMEDIA_SIGNATURES_H__ */