1 /*
2  * libjingle
3  * Copyright 2004--2005, Google Inc.
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  *
8  *  1. Redistributions of source code must retain the above copyright notice,
9  *     this list of conditions and the following disclaimer.
10  *  2. Redistributions in binary form must reproduce the above copyright notice,
11  *     this list of conditions and the following disclaimer in the documentation
12  *     and/or other materials provided with the distribution.
13  *  3. The name of the author may not 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 AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19  * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #include "talk/p2p/base/constants.h"
29 
30 #include <string>
31 
32 #include "talk/xmllite/qname.h"
33 
34 namespace cricket {
35 
36 const char NS_EMPTY[] = "";
37 const char NS_JINGLE[] = "urn:xmpp:jingle:1";
38 const char NS_JINGLE_DRAFT[] = "google:jingle";
39 const char NS_GINGLE[] = "http://www.google.com/session";
40 
41 // actions (aka <session> or <jingle>)
42 const buzz::StaticQName QN_ACTION = { NS_EMPTY, "action" };
43 const char LN_INITIATOR[] = "initiator";
44 const buzz::StaticQName QN_INITIATOR = { NS_EMPTY, LN_INITIATOR };
45 const buzz::StaticQName QN_CREATOR = { NS_EMPTY, "creator" };
46 
47 const buzz::StaticQName QN_JINGLE = { NS_JINGLE, "jingle" };
48 const buzz::StaticQName QN_JINGLE_CONTENT = { NS_JINGLE, "content" };
49 const buzz::StaticQName QN_JINGLE_CONTENT_NAME = { NS_EMPTY, "name" };
50 const buzz::StaticQName QN_JINGLE_CONTENT_MEDIA = { NS_EMPTY, "media" };
51 const buzz::StaticQName QN_JINGLE_REASON = { NS_JINGLE, "reason" };
52 const buzz::StaticQName QN_JINGLE_DRAFT_GROUP = { NS_JINGLE_DRAFT, "group" };
53 const buzz::StaticQName QN_JINGLE_DRAFT_GROUP_TYPE = { NS_EMPTY, "type" };
54 const char JINGLE_CONTENT_MEDIA_AUDIO[] = "audio";
55 const char JINGLE_CONTENT_MEDIA_VIDEO[] = "video";
56 const char JINGLE_CONTENT_MEDIA_DATA[] = "data";
57 const char JINGLE_ACTION_SESSION_INITIATE[] = "session-initiate";
58 const char JINGLE_ACTION_SESSION_INFO[] = "session-info";
59 const char JINGLE_ACTION_SESSION_ACCEPT[] = "session-accept";
60 const char JINGLE_ACTION_SESSION_TERMINATE[] = "session-terminate";
61 const char JINGLE_ACTION_TRANSPORT_INFO[] = "transport-info";
62 const char JINGLE_ACTION_TRANSPORT_ACCEPT[] = "transport-accept";
63 const char JINGLE_ACTION_DESCRIPTION_INFO[] = "description-info";
64 
65 const buzz::StaticQName QN_GINGLE_SESSION = { NS_GINGLE, "session" };
66 const char GINGLE_ACTION_INITIATE[] = "initiate";
67 const char GINGLE_ACTION_INFO[] = "info";
68 const char GINGLE_ACTION_ACCEPT[] = "accept";
69 const char GINGLE_ACTION_REJECT[] = "reject";
70 const char GINGLE_ACTION_TERMINATE[] = "terminate";
71 const char GINGLE_ACTION_CANDIDATES[] = "candidates";
72 const char GINGLE_ACTION_UPDATE[] = "update";
73 
74 const char LN_ERROR[] = "error";
75 const buzz::StaticQName QN_GINGLE_REDIRECT = { NS_GINGLE, "redirect" };
76 const char STR_REDIRECT_PREFIX[] = "xmpp:";
77 
78 // Session Contents (aka Gingle <session><description>
79 //                   or Jingle <content><description>)
80 const char LN_DESCRIPTION[] = "description";
81 const char LN_PAYLOADTYPE[] = "payload-type";
82 const buzz::StaticQName QN_ID = { NS_EMPTY, "id" };
83 const buzz::StaticQName QN_SID = { NS_EMPTY, "sid" };
84 const buzz::StaticQName QN_NAME = { NS_EMPTY, "name" };
85 const buzz::StaticQName QN_CLOCKRATE = { NS_EMPTY, "clockrate" };
86 const buzz::StaticQName QN_BITRATE = { NS_EMPTY, "bitrate" };
87 const buzz::StaticQName QN_CHANNELS = { NS_EMPTY, "channels" };
88 const buzz::StaticQName QN_WIDTH = { NS_EMPTY, "width" };
89 const buzz::StaticQName QN_HEIGHT = { NS_EMPTY, "height" };
90 const buzz::StaticQName QN_FRAMERATE = { NS_EMPTY, "framerate" };
91 const char LN_NAME[] = "name";
92 const char LN_VALUE[] = "value";
93 const buzz::StaticQName QN_PAYLOADTYPE_PARAMETER_NAME = { NS_EMPTY, LN_NAME };
94 const buzz::StaticQName QN_PAYLOADTYPE_PARAMETER_VALUE = { NS_EMPTY, LN_VALUE };
95 const char PAYLOADTYPE_PARAMETER_BITRATE[] = "bitrate";
96 const char PAYLOADTYPE_PARAMETER_HEIGHT[] = "height";
97 const char PAYLOADTYPE_PARAMETER_WIDTH[] = "width";
98 const char PAYLOADTYPE_PARAMETER_FRAMERATE[] = "framerate";
99 const char LN_BANDWIDTH[] = "bandwidth";
100 
101 const char CN_AUDIO[] = "audio";
102 const char CN_VIDEO[] = "video";
103 const char CN_DATA[] = "data";
104 const char CN_OTHER[] = "main";
105 // other SDP related strings
106 const char GROUP_TYPE_BUNDLE[] = "BUNDLE";
107 
108 const char NS_JINGLE_RTP[] = "urn:xmpp:jingle:apps:rtp:1";
109 const buzz::StaticQName QN_JINGLE_RTP_CONTENT =
110     { NS_JINGLE_RTP, LN_DESCRIPTION };
111 const buzz::StaticQName QN_SSRC = { NS_EMPTY, "ssrc" };
112 const buzz::StaticQName QN_JINGLE_RTP_PAYLOADTYPE =
113     { NS_JINGLE_RTP, LN_PAYLOADTYPE };
114 const buzz::StaticQName QN_JINGLE_RTP_BANDWIDTH =
115     { NS_JINGLE_RTP, LN_BANDWIDTH };
116 const buzz::StaticQName QN_JINGLE_RTCP_MUX = { NS_JINGLE_RTP, "rtcp-mux" };
117 const buzz::StaticQName QN_PARAMETER = { NS_JINGLE_RTP, "parameter" };
118 
119 const char NS_GINGLE_AUDIO[] = "http://www.google.com/session/phone";
120 const buzz::StaticQName QN_GINGLE_AUDIO_CONTENT =
121     { NS_GINGLE_AUDIO, LN_DESCRIPTION };
122 const buzz::StaticQName QN_GINGLE_AUDIO_PAYLOADTYPE =
123     { NS_GINGLE_AUDIO, LN_PAYLOADTYPE };
124 const buzz::StaticQName QN_GINGLE_AUDIO_SRCID = { NS_GINGLE_AUDIO, "src-id" };
125 const char NS_GINGLE_VIDEO[] = "http://www.google.com/session/video";
126 const buzz::StaticQName QN_GINGLE_VIDEO_CONTENT =
127     { NS_GINGLE_VIDEO, LN_DESCRIPTION };
128 const buzz::StaticQName QN_GINGLE_VIDEO_PAYLOADTYPE =
129     { NS_GINGLE_VIDEO, LN_PAYLOADTYPE };
130 const buzz::StaticQName QN_GINGLE_VIDEO_SRCID = { NS_GINGLE_VIDEO, "src-id" };
131 const buzz::StaticQName QN_GINGLE_VIDEO_BANDWIDTH =
132     { NS_GINGLE_VIDEO, LN_BANDWIDTH };
133 
134 // Crypto support.
135 const buzz::StaticQName QN_ENCRYPTION = { NS_JINGLE_RTP, "encryption" };
136 const buzz::StaticQName QN_ENCRYPTION_REQUIRED = { NS_EMPTY, "required" };
137 const buzz::StaticQName QN_CRYPTO = { NS_JINGLE_RTP, "crypto" };
138 const buzz::StaticQName QN_GINGLE_AUDIO_CRYPTO_USAGE =
139     { NS_GINGLE_AUDIO, "usage" };
140 const buzz::StaticQName QN_GINGLE_VIDEO_CRYPTO_USAGE =
141     { NS_GINGLE_VIDEO, "usage" };
142 const buzz::StaticQName QN_CRYPTO_SUITE = { NS_EMPTY, "crypto-suite" };
143 const buzz::StaticQName QN_CRYPTO_KEY_PARAMS = { NS_EMPTY, "key-params" };
144 const buzz::StaticQName QN_CRYPTO_TAG = { NS_EMPTY, "tag" };
145 const buzz::StaticQName QN_CRYPTO_SESSION_PARAMS =
146     { NS_EMPTY, "session-params" };
147 
148 // transports and candidates
149 const char LN_TRANSPORT[] = "transport";
150 const char LN_CANDIDATE[] = "candidate";
151 const buzz::StaticQName QN_UFRAG = { cricket::NS_EMPTY, "ufrag" };
152 const buzz::StaticQName QN_PWD = { cricket::NS_EMPTY, "pwd" };
153 const buzz::StaticQName QN_COMPONENT = { cricket::NS_EMPTY, "component" };
154 const buzz::StaticQName QN_IP = { cricket::NS_EMPTY, "ip" };
155 const buzz::StaticQName QN_PORT = { cricket::NS_EMPTY, "port" };
156 const buzz::StaticQName QN_NETWORK = { cricket::NS_EMPTY, "network" };
157 const buzz::StaticQName QN_GENERATION = { cricket::NS_EMPTY, "generation" };
158 const buzz::StaticQName QN_PRIORITY = { cricket::NS_EMPTY, "priority" };
159 const buzz::StaticQName QN_PROTOCOL = { cricket::NS_EMPTY, "protocol" };
160 const char JINGLE_CANDIDATE_TYPE_PEER_STUN[] = "prflx";
161 const char JINGLE_CANDIDATE_TYPE_SERVER_STUN[] = "srflx";
162 const char JINGLE_CANDIDATE_NAME_RTP[] = "1";
163 const char JINGLE_CANDIDATE_NAME_RTCP[] = "2";
164 
165 // TODO Once we are full ICE-UDP compliant, use this namespace.
166 // For now, just use the same as NS_GINGLE_P2P.
167 // const char NS_JINGLE_ICE_UDP[] = "urn:xmpp:jingle:transports:ice-udp:1";
168 const char NS_GINGLE_P2P[] = "http://www.google.com/transport/p2p";
169 const buzz::StaticQName QN_GINGLE_P2P_TRANSPORT =
170     { NS_GINGLE_P2P, LN_TRANSPORT };
171 const buzz::StaticQName QN_GINGLE_P2P_CANDIDATE =
172     { NS_GINGLE_P2P, LN_CANDIDATE };
173 const buzz::StaticQName QN_GINGLE_P2P_UNKNOWN_CHANNEL_NAME =
174     { NS_GINGLE_P2P, "unknown-channel-name" };
175 const buzz::StaticQName QN_GINGLE_CANDIDATE = { NS_GINGLE, LN_CANDIDATE };
176 const buzz::StaticQName QN_ADDRESS = { cricket::NS_EMPTY, "address" };
177 const buzz::StaticQName QN_USERNAME = { cricket::NS_EMPTY, "username" };
178 const buzz::StaticQName QN_PASSWORD = { cricket::NS_EMPTY, "password" };
179 const buzz::StaticQName QN_PREFERENCE = { cricket::NS_EMPTY, "preference" };
180 const char GINGLE_CANDIDATE_TYPE_STUN[] = "stun";
181 const char GINGLE_CANDIDATE_NAME_RTP[] = "rtp";
182 const char GINGLE_CANDIDATE_NAME_RTCP[] = "rtcp";
183 const char GINGLE_CANDIDATE_NAME_VIDEO_RTP[] = "video_rtp";
184 const char GINGLE_CANDIDATE_NAME_VIDEO_RTCP[] = "video_rtcp";
185 const char GINGLE_CANDIDATE_NAME_DATA_RTP[] = "data_rtp";
186 const char GINGLE_CANDIDATE_NAME_DATA_RTCP[] = "data_rtcp";
187 
188 // terminate reasons and errors
189 const char JINGLE_ERROR_BAD_REQUEST[] = "bad-request";
190 const char JINGLE_ERROR_OUT_OF_ORDER[] = "out-of-order";
191 const char JINGLE_ERROR_UNKNOWN_SESSION[] = "unknown-session";
192 
193 // Call terminate reasons from XEP-166
194 const char STR_TERMINATE_DECLINE[] = "decline";
195 const char STR_TERMINATE_SUCCESS[] = "success";
196 const char STR_TERMINATE_ERROR[] = "general-error";
197 const char STR_TERMINATE_INCOMPATIBLE_PARAMETERS[] = "incompatible-parameters";
198 
199 // Old terminate reasons used by cricket
200 const char STR_TERMINATE_CALL_ENDED[] = "call-ended";
201 const char STR_TERMINATE_RECIPIENT_UNAVAILABLE[] = "recipient-unavailable";
202 const char STR_TERMINATE_RECIPIENT_BUSY[] = "recipient-busy";
203 const char STR_TERMINATE_INSUFFICIENT_FUNDS[] = "insufficient-funds";
204 const char STR_TERMINATE_NUMBER_MALFORMED[] = "number-malformed";
205 const char STR_TERMINATE_NUMBER_DISALLOWED[] = "number-disallowed";
206 const char STR_TERMINATE_PROTOCOL_ERROR[] = "protocol-error";
207 const char STR_TERMINATE_INTERNAL_SERVER_ERROR[] = "internal-server-error";
208 const char STR_TERMINATE_UNKNOWN_ERROR[] = "unknown-error";
209 
210 // Draft view and notify messages.
211 const char STR_JINGLE_DRAFT_CONTENT_NAME_VIDEO[] = "video";
212 const char STR_JINGLE_DRAFT_CONTENT_NAME_AUDIO[] = "audio";
213 const buzz::StaticQName QN_NICK = { cricket::NS_EMPTY, "nick" };
214 const buzz::StaticQName QN_TYPE = { cricket::NS_EMPTY, "type" };
215 const buzz::StaticQName QN_JINGLE_DRAFT_VIEW = { NS_JINGLE_DRAFT, "view" };
216 const char STR_JINGLE_DRAFT_VIEW_TYPE_NONE[] = "none";
217 const char STR_JINGLE_DRAFT_VIEW_TYPE_STATIC[] = "static";
218 const buzz::StaticQName QN_JINGLE_DRAFT_PARAMS = { NS_JINGLE_DRAFT, "params" };
219 const buzz::StaticQName QN_JINGLE_DRAFT_STREAMS = { NS_JINGLE_DRAFT, "streams" };
220 const buzz::StaticQName QN_JINGLE_DRAFT_STREAM = { NS_JINGLE_DRAFT, "stream" };
221 const buzz::StaticQName QN_DISPLAY = { cricket::NS_EMPTY, "display" };
222 const buzz::StaticQName QN_CNAME = { cricket::NS_EMPTY, "cname" };
223 const buzz::StaticQName QN_JINGLE_DRAFT_SSRC = { NS_JINGLE_DRAFT, "ssrc" };
224 const buzz::StaticQName QN_JINGLE_DRAFT_SSRC_GROUP =
225     { NS_JINGLE_DRAFT, "ssrc-group" };
226 const buzz::StaticQName QN_SEMANTICS = { cricket::NS_EMPTY, "semantics" };
227 const buzz::StaticQName QN_JINGLE_LEGACY_NOTIFY = { NS_JINGLE_DRAFT, "notify" };
228 const buzz::StaticQName QN_JINGLE_LEGACY_SOURCE = { NS_JINGLE_DRAFT, "source" };
229 
230 const char NS_GINGLE_RAW[] = "http://www.google.com/transport/raw-udp";
231 const buzz::StaticQName QN_GINGLE_RAW_TRANSPORT = { NS_GINGLE_RAW, "transport" };
232 const buzz::StaticQName QN_GINGLE_RAW_CHANNEL = { NS_GINGLE_RAW, "channel" };
233 
234 // old stuff
235 #ifdef FEATURE_ENABLE_VOICEMAIL
236 const char NS_VOICEMAIL[] = "http://www.google.com/session/voicemail";
237 const buzz::StaticQName QN_VOICEMAIL_REGARDING = { NS_VOICEMAIL, "regarding" };
238 #endif
239 
240 }  // namespace cricket
241