Home | History | Annotate | Download | only in base
      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_JINGLE_RTCP_FB = { NS_JINGLE_RTP, "rtcp-fb" };
    118 const buzz::StaticQName QN_SUBTYPE = { NS_EMPTY, "subtype" };
    119 const buzz::StaticQName QN_PARAMETER = { NS_JINGLE_RTP, "parameter" };
    120 const buzz::StaticQName QN_JINGLE_RTP_HDREXT =
    121     { NS_JINGLE_RTP, "rtp-hdrext" };
    122 const buzz::StaticQName QN_URI = { NS_EMPTY, "uri" };
    123 
    124 const char NS_JINGLE_DRAFT_SCTP[] = "google:jingle:sctp";
    125 const buzz::StaticQName QN_JINGLE_DRAFT_SCTP_CONTENT =
    126     { NS_JINGLE_DRAFT_SCTP, LN_DESCRIPTION };
    127 const buzz::StaticQName QN_JINGLE_DRAFT_SCTP_STREAM =
    128     { NS_JINGLE_DRAFT_SCTP, "stream" };
    129 
    130 const char NS_GINGLE_AUDIO[] = "http://www.google.com/session/phone";
    131 const buzz::StaticQName QN_GINGLE_AUDIO_CONTENT =
    132     { NS_GINGLE_AUDIO, LN_DESCRIPTION };
    133 const buzz::StaticQName QN_GINGLE_AUDIO_PAYLOADTYPE =
    134     { NS_GINGLE_AUDIO, LN_PAYLOADTYPE };
    135 const buzz::StaticQName QN_GINGLE_AUDIO_SRCID = { NS_GINGLE_AUDIO, "src-id" };
    136 const char NS_GINGLE_VIDEO[] = "http://www.google.com/session/video";
    137 const buzz::StaticQName QN_GINGLE_VIDEO_CONTENT =
    138     { NS_GINGLE_VIDEO, LN_DESCRIPTION };
    139 const buzz::StaticQName QN_GINGLE_VIDEO_PAYLOADTYPE =
    140     { NS_GINGLE_VIDEO, LN_PAYLOADTYPE };
    141 const buzz::StaticQName QN_GINGLE_VIDEO_SRCID = { NS_GINGLE_VIDEO, "src-id" };
    142 const buzz::StaticQName QN_GINGLE_VIDEO_BANDWIDTH =
    143     { NS_GINGLE_VIDEO, LN_BANDWIDTH };
    144 
    145 // Crypto support.
    146 const buzz::StaticQName QN_ENCRYPTION = { NS_JINGLE_RTP, "encryption" };
    147 const buzz::StaticQName QN_ENCRYPTION_REQUIRED = { NS_EMPTY, "required" };
    148 const buzz::StaticQName QN_CRYPTO = { NS_JINGLE_RTP, "crypto" };
    149 const buzz::StaticQName QN_GINGLE_AUDIO_CRYPTO_USAGE =
    150     { NS_GINGLE_AUDIO, "usage" };
    151 const buzz::StaticQName QN_GINGLE_VIDEO_CRYPTO_USAGE =
    152     { NS_GINGLE_VIDEO, "usage" };
    153 const buzz::StaticQName QN_CRYPTO_SUITE = { NS_EMPTY, "crypto-suite" };
    154 const buzz::StaticQName QN_CRYPTO_KEY_PARAMS = { NS_EMPTY, "key-params" };
    155 const buzz::StaticQName QN_CRYPTO_TAG = { NS_EMPTY, "tag" };
    156 const buzz::StaticQName QN_CRYPTO_SESSION_PARAMS =
    157     { NS_EMPTY, "session-params" };
    158 
    159 // Transports and candidates.
    160 const char LN_TRANSPORT[] = "transport";
    161 const char LN_CANDIDATE[] = "candidate";
    162 const buzz::StaticQName QN_UFRAG = { cricket::NS_EMPTY, "ufrag" };
    163 const buzz::StaticQName QN_PWD = { cricket::NS_EMPTY, "pwd" };
    164 const buzz::StaticQName QN_COMPONENT = { cricket::NS_EMPTY, "component" };
    165 const buzz::StaticQName QN_IP = { cricket::NS_EMPTY, "ip" };
    166 const buzz::StaticQName QN_PORT = { cricket::NS_EMPTY, "port" };
    167 const buzz::StaticQName QN_NETWORK = { cricket::NS_EMPTY, "network" };
    168 const buzz::StaticQName QN_GENERATION = { cricket::NS_EMPTY, "generation" };
    169 const buzz::StaticQName QN_PRIORITY = { cricket::NS_EMPTY, "priority" };
    170 const buzz::StaticQName QN_PROTOCOL = { cricket::NS_EMPTY, "protocol" };
    171 const char ICE_CANDIDATE_TYPE_PEER_STUN[] = "prflx";
    172 const char ICE_CANDIDATE_TYPE_SERVER_STUN[] = "srflx";
    173 // Minimum ufrag length is 4 characters as per RFC5245. We chose 16 because
    174 // some internal systems expect username to be 16 bytes.
    175 const int ICE_UFRAG_LENGTH = 16;
    176 // Minimum password length of 22 characters as per RFC5245. We chose 24 because
    177 // some internal systems expect password to be multiple of 4.
    178 const int ICE_PWD_LENGTH = 24;
    179 // TODO: This is media-specific, so might belong
    180 // somewhere like media/base/constants.h
    181 const int ICE_CANDIDATE_COMPONENT_RTP = 1;
    182 const int ICE_CANDIDATE_COMPONENT_RTCP = 2;
    183 const int ICE_CANDIDATE_COMPONENT_DEFAULT = 1;
    184 
    185 const buzz::StaticQName QN_FINGERPRINT = { cricket::NS_EMPTY, "fingerprint" };
    186 const buzz::StaticQName QN_FINGERPRINT_ALGORITHM =
    187     { cricket::NS_EMPTY, "algorithm" };
    188 const buzz::StaticQName QN_FINGERPRINT_DIGEST = { cricket::NS_EMPTY, "digest" };
    189 
    190 const char NS_JINGLE_ICE_UDP[] = "urn:xmpp:jingle:transports:ice-udp:1";
    191 
    192 const char ICE_OPTION_GICE[] = "google-ice";
    193 const char NS_GINGLE_P2P[] = "http://www.google.com/transport/p2p";
    194 const buzz::StaticQName QN_GINGLE_P2P_TRANSPORT =
    195     { NS_GINGLE_P2P, LN_TRANSPORT };
    196 const buzz::StaticQName QN_GINGLE_P2P_CANDIDATE =
    197     { NS_GINGLE_P2P, LN_CANDIDATE };
    198 const buzz::StaticQName QN_GINGLE_P2P_UNKNOWN_CHANNEL_NAME =
    199     { NS_GINGLE_P2P, "unknown-channel-name" };
    200 const buzz::StaticQName QN_GINGLE_CANDIDATE = { NS_GINGLE, LN_CANDIDATE };
    201 const buzz::StaticQName QN_ADDRESS = { cricket::NS_EMPTY, "address" };
    202 const buzz::StaticQName QN_USERNAME = { cricket::NS_EMPTY, "username" };
    203 const buzz::StaticQName QN_PASSWORD = { cricket::NS_EMPTY, "password" };
    204 const buzz::StaticQName QN_PREFERENCE = { cricket::NS_EMPTY, "preference" };
    205 const char GICE_CANDIDATE_TYPE_STUN[] = "stun";
    206 const char GICE_CHANNEL_NAME_RTP[] = "rtp";
    207 const char GICE_CHANNEL_NAME_RTCP[] = "rtcp";
    208 const char GICE_CHANNEL_NAME_VIDEO_RTP[] = "video_rtp";
    209 const char GICE_CHANNEL_NAME_VIDEO_RTCP[] = "video_rtcp";
    210 const char GICE_CHANNEL_NAME_DATA_RTP[] = "data_rtp";
    211 const char GICE_CHANNEL_NAME_DATA_RTCP[] = "data_rtcp";
    212 
    213 // terminate reasons and errors
    214 const char JINGLE_ERROR_BAD_REQUEST[] = "bad-request";
    215 const char JINGLE_ERROR_OUT_OF_ORDER[] = "out-of-order";
    216 const char JINGLE_ERROR_UNKNOWN_SESSION[] = "unknown-session";
    217 
    218 // Call terminate reasons from XEP-166
    219 const char STR_TERMINATE_DECLINE[] = "decline";
    220 const char STR_TERMINATE_SUCCESS[] = "success";
    221 const char STR_TERMINATE_ERROR[] = "general-error";
    222 const char STR_TERMINATE_INCOMPATIBLE_PARAMETERS[] = "incompatible-parameters";
    223 
    224 // Old terminate reasons used by cricket
    225 const char STR_TERMINATE_CALL_ENDED[] = "call-ended";
    226 const char STR_TERMINATE_RECIPIENT_UNAVAILABLE[] = "recipient-unavailable";
    227 const char STR_TERMINATE_RECIPIENT_BUSY[] = "recipient-busy";
    228 const char STR_TERMINATE_INSUFFICIENT_FUNDS[] = "insufficient-funds";
    229 const char STR_TERMINATE_NUMBER_MALFORMED[] = "number-malformed";
    230 const char STR_TERMINATE_NUMBER_DISALLOWED[] = "number-disallowed";
    231 const char STR_TERMINATE_PROTOCOL_ERROR[] = "protocol-error";
    232 const char STR_TERMINATE_INTERNAL_SERVER_ERROR[] = "internal-server-error";
    233 const char STR_TERMINATE_UNKNOWN_ERROR[] = "unknown-error";
    234 
    235 // Draft view and notify messages.
    236 const char STR_JINGLE_DRAFT_CONTENT_NAME_VIDEO[] = "video";
    237 const char STR_JINGLE_DRAFT_CONTENT_NAME_AUDIO[] = "audio";
    238 const buzz::StaticQName QN_NICK = { cricket::NS_EMPTY, "nick" };
    239 const buzz::StaticQName QN_TYPE = { cricket::NS_EMPTY, "type" };
    240 const buzz::StaticQName QN_JINGLE_DRAFT_VIEW = { NS_JINGLE_DRAFT, "view" };
    241 const char STR_JINGLE_DRAFT_VIEW_TYPE_NONE[] = "none";
    242 const char STR_JINGLE_DRAFT_VIEW_TYPE_STATIC[] = "static";
    243 const buzz::StaticQName QN_JINGLE_DRAFT_PARAMS = { NS_JINGLE_DRAFT, "params" };
    244 const buzz::StaticQName QN_JINGLE_DRAFT_STREAMS = { NS_JINGLE_DRAFT, "streams" };
    245 const buzz::StaticQName QN_JINGLE_DRAFT_STREAM = { NS_JINGLE_DRAFT, "stream" };
    246 const buzz::StaticQName QN_DISPLAY = { cricket::NS_EMPTY, "display" };
    247 const buzz::StaticQName QN_CNAME = { cricket::NS_EMPTY, "cname" };
    248 const buzz::StaticQName QN_JINGLE_DRAFT_SSRC = { NS_JINGLE_DRAFT, "ssrc" };
    249 const buzz::StaticQName QN_JINGLE_DRAFT_SSRC_GROUP =
    250     { NS_JINGLE_DRAFT, "ssrc-group" };
    251 const buzz::StaticQName QN_SEMANTICS = { cricket::NS_EMPTY, "semantics" };
    252 const buzz::StaticQName QN_JINGLE_LEGACY_NOTIFY = { NS_JINGLE_DRAFT, "notify" };
    253 const buzz::StaticQName QN_JINGLE_LEGACY_SOURCE = { NS_JINGLE_DRAFT, "source" };
    254 
    255 const char NS_GINGLE_RAW[] = "http://www.google.com/transport/raw-udp";
    256 const buzz::StaticQName QN_GINGLE_RAW_TRANSPORT = { NS_GINGLE_RAW, "transport" };
    257 const buzz::StaticQName QN_GINGLE_RAW_CHANNEL = { NS_GINGLE_RAW, "channel" };
    258 
    259 // old stuff
    260 #ifdef FEATURE_ENABLE_VOICEMAIL
    261 const char NS_VOICEMAIL[] = "http://www.google.com/session/voicemail";
    262 const buzz::StaticQName QN_VOICEMAIL_REGARDING = { NS_VOICEMAIL, "regarding" };
    263 #endif
    264 
    265 // From RFC 4145, SDP setup attribute values.
    266 const char CONNECTIONROLE_ACTIVE_STR[] = "active";
    267 const char CONNECTIONROLE_PASSIVE_STR[] = "passive";
    268 const char CONNECTIONROLE_ACTPASS_STR[] = "actpass";
    269 const char CONNECTIONROLE_HOLDCONN_STR[] = "holdconn";
    270 
    271 }  // namespace cricket
    272