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