OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef REMOTING_PROTOCOL_JINGLE_MESSAGES_H_ | 5 #ifndef REMOTING_PROTOCOL_JINGLE_MESSAGES_H_ |
6 #define REMOTING_PROTOCOL_JINGLE_MESSAGES_H_ | 6 #define REMOTING_PROTOCOL_JINGLE_MESSAGES_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" | 12 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" |
13 #include "third_party/webrtc/p2p/base/candidate.h" | 13 #include "third_party/webrtc/p2p/base/candidate.h" |
14 | 14 |
15 namespace remoting { | 15 namespace remoting { |
16 namespace protocol { | 16 namespace protocol { |
17 | 17 |
18 class ContentDescription; | 18 class ContentDescription; |
19 | 19 |
| 20 // Represents an address of a Chromoting endpoint and its routing channel. |
| 21 // TODO(kelvinp): Move the struct to remoting/signaling. Potentially we could |
| 22 // update SignalStrategy interface to use this instead of jid for addressing. |
| 23 struct SignalingAddress { |
| 24 enum class Channel { LCS, XMPP }; |
| 25 |
| 26 SignalingAddress(); |
| 27 SignalingAddress(const std::string& jid); |
| 28 SignalingAddress(const std::string& jid, |
| 29 const std::string& endpoint_id, |
| 30 Channel channel); |
| 31 |
| 32 // Represents the |to| or |from| field in an IQ stanza. |
| 33 std::string jid; |
| 34 |
| 35 // Represents the identifier of an endpoint. In LCS, this is the LCS address |
| 36 // encoded in a JID like format. In XMPP, it is empty. |
| 37 std::string endpoint_id; |
| 38 |
| 39 Channel channel; |
| 40 |
| 41 inline const std::string& id() const { |
| 42 return (channel == Channel::LCS) ? endpoint_id : jid; |
| 43 } |
| 44 |
| 45 inline bool empty() const { return jid.empty(); } |
| 46 |
| 47 bool operator==(const SignalingAddress& other); |
| 48 bool operator!=(const SignalingAddress& other); |
| 49 }; |
| 50 |
20 struct JingleMessage { | 51 struct JingleMessage { |
21 enum ActionType { | 52 enum ActionType { |
22 UNKNOWN_ACTION, | 53 UNKNOWN_ACTION, |
23 SESSION_INITIATE, | 54 SESSION_INITIATE, |
24 SESSION_ACCEPT, | 55 SESSION_ACCEPT, |
25 SESSION_TERMINATE, | 56 SESSION_TERMINATE, |
26 SESSION_INFO, | 57 SESSION_INFO, |
27 TRANSPORT_INFO, | 58 TRANSPORT_INFO, |
28 }; | 59 }; |
29 | 60 |
30 enum Reason { | 61 enum Reason { |
31 UNKNOWN_REASON, | 62 UNKNOWN_REASON, |
32 SUCCESS, | 63 SUCCESS, |
33 DECLINE, | 64 DECLINE, |
34 CANCEL, | 65 CANCEL, |
35 EXPIRED, | 66 EXPIRED, |
36 GENERAL_ERROR, | 67 GENERAL_ERROR, |
37 FAILED_APPLICATION, | 68 FAILED_APPLICATION, |
38 INCOMPATIBLE_PARAMETERS, | 69 INCOMPATIBLE_PARAMETERS, |
39 }; | 70 }; |
40 | 71 |
41 | 72 |
42 JingleMessage(); | 73 JingleMessage(); |
43 JingleMessage(const std::string& to_value, | 74 JingleMessage(const SignalingAddress& to, |
44 ActionType action_value, | 75 ActionType action_value, |
45 const std::string& sid_value); | 76 const std::string& sid_value); |
46 ~JingleMessage(); | 77 ~JingleMessage(); |
47 | 78 |
48 // Caller keeps ownership of |stanza|. | 79 // Caller keeps ownership of |stanza|. |
49 static bool IsJingleMessage(const buzz::XmlElement* stanza); | 80 static bool IsJingleMessage(const buzz::XmlElement* stanza); |
50 static std::string GetActionName(ActionType action); | 81 static std::string GetActionName(ActionType action); |
51 | 82 |
52 // Caller keeps ownership of |stanza|. |error| is set to debug error | 83 // Caller keeps ownership of |stanza|. |error| is set to debug error |
53 // message when parsing fails. | 84 // message when parsing fails. |
54 bool ParseXml(const buzz::XmlElement* stanza, std::string* error); | 85 bool ParseXml(const buzz::XmlElement* stanza, std::string* error); |
55 | 86 |
56 std::unique_ptr<buzz::XmlElement> ToXml() const; | 87 std::unique_ptr<buzz::XmlElement> ToXml() const; |
57 | 88 |
58 std::string from; | 89 SignalingAddress from; |
59 std::string to; | 90 SignalingAddress to; |
60 ActionType action = UNKNOWN_ACTION; | 91 ActionType action = UNKNOWN_ACTION; |
61 std::string sid; | 92 std::string sid; |
62 | 93 |
63 std::string initiator; | 94 std::string initiator; |
64 | 95 |
65 std::unique_ptr<ContentDescription> description; | 96 std::unique_ptr<ContentDescription> description; |
66 | 97 |
67 std::unique_ptr<buzz::XmlElement> transport_info; | 98 std::unique_ptr<buzz::XmlElement> transport_info; |
68 | 99 |
69 // Content of session-info messages. | 100 // Content of session-info messages. |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 std::unique_ptr<buzz::XmlElement> ToXml() const; | 165 std::unique_ptr<buzz::XmlElement> ToXml() const; |
135 | 166 |
136 std::list<IceCredentials> ice_credentials; | 167 std::list<IceCredentials> ice_credentials; |
137 std::list<NamedCandidate> candidates; | 168 std::list<NamedCandidate> candidates; |
138 }; | 169 }; |
139 | 170 |
140 } // protocol | 171 } // protocol |
141 } // remoting | 172 } // remoting |
142 | 173 |
143 #endif // REMOTING_PROTOCOL_JINGLE_MESSAGES_H_ | 174 #endif // REMOTING_PROTOCOL_JINGLE_MESSAGES_H_ |
OLD | NEW |