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 <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
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 |
15 namespace remoting { | 16 namespace remoting { |
16 namespace protocol { | 17 namespace protocol { |
17 | 18 |
18 class ContentDescription; | 19 class ContentDescription; |
19 | 20 |
| 21 extern const char kJabberNamespace[]; |
| 22 extern const char kJingleNamespace[]; |
| 23 extern const char kP2PTransportNamespace[]; |
| 24 |
20 struct JingleMessage { | 25 struct JingleMessage { |
21 enum ActionType { | 26 enum ActionType { |
22 UNKNOWN_ACTION, | 27 UNKNOWN_ACTION, |
23 SESSION_INITIATE, | 28 SESSION_INITIATE, |
24 SESSION_ACCEPT, | 29 SESSION_ACCEPT, |
25 SESSION_TERMINATE, | 30 SESSION_TERMINATE, |
26 SESSION_INFO, | 31 SESSION_INFO, |
27 TRANSPORT_INFO, | 32 TRANSPORT_INFO, |
28 }; | 33 }; |
29 | 34 |
30 enum Reason { | 35 enum Reason { |
31 UNKNOWN_REASON, | 36 UNKNOWN_REASON, |
32 SUCCESS, | 37 SUCCESS, |
33 DECLINE, | 38 DECLINE, |
34 CANCEL, | 39 CANCEL, |
35 GENERAL_ERROR, | 40 GENERAL_ERROR, |
36 INCOMPATIBLE_PARAMETERS, | 41 INCOMPATIBLE_PARAMETERS, |
37 }; | 42 }; |
38 | 43 |
39 struct NamedCandidate { | 44 struct NamedCandidate { |
40 NamedCandidate() = default; | 45 NamedCandidate(); |
41 NamedCandidate(const std::string& name, | 46 NamedCandidate(const std::string& name, |
42 const cricket::Candidate& candidate); | 47 const cricket::Candidate& candidate); |
43 | 48 |
44 std::string name; | 49 std::string name; |
45 cricket::Candidate candidate; | 50 cricket::Candidate candidate; |
46 }; | 51 }; |
47 | 52 |
48 struct IceCredentials { | |
49 IceCredentials() = default; | |
50 IceCredentials(std::string channel, | |
51 std::string ufrag, | |
52 std::string password); | |
53 | |
54 std::string channel; | |
55 std::string ufrag; | |
56 std::string password; | |
57 }; | |
58 | |
59 JingleMessage(); | 53 JingleMessage(); |
60 JingleMessage(const std::string& to_value, | 54 JingleMessage(const std::string& to_value, |
61 ActionType action_value, | 55 ActionType action_value, |
62 const std::string& sid_value); | 56 const std::string& sid_value); |
63 ~JingleMessage(); | 57 ~JingleMessage(); |
64 | 58 |
65 // Caller keeps ownership of |stanza|. | 59 // Caller keeps ownership of |stanza|. |
66 static bool IsJingleMessage(const buzz::XmlElement* stanza); | 60 static bool IsJingleMessage(const buzz::XmlElement* stanza); |
67 static std::string GetActionName(ActionType action); | 61 static std::string GetActionName(ActionType action); |
68 | 62 |
69 // Caller keeps ownership of |stanza|. |error| is set to debug error | 63 // Caller keeps ownership of |stanza|. |error| is set to debug error |
70 // message when parsing fails. | 64 // message when parsing fails. |
71 bool ParseXml(const buzz::XmlElement* stanza, std::string* error); | 65 bool ParseXml(const buzz::XmlElement* stanza, std::string* error); |
72 | 66 |
73 scoped_ptr<buzz::XmlElement> ToXml() const; | 67 scoped_ptr<buzz::XmlElement> ToXml() const; |
74 | 68 |
75 std::string from; | 69 std::string from; |
76 std::string to; | 70 std::string to; |
77 ActionType action = UNKNOWN_ACTION; | 71 ActionType action; |
78 std::string sid; | 72 std::string sid; |
79 | 73 |
80 std::string initiator; | 74 std::string initiator; |
81 | 75 |
82 scoped_ptr<ContentDescription> description; | 76 scoped_ptr<ContentDescription> description; |
83 | |
84 bool standard_ice = true; | |
85 std::list<IceCredentials> ice_credentials; | |
86 std::list<NamedCandidate> candidates; | 77 std::list<NamedCandidate> candidates; |
87 | 78 |
88 // Content of session-info messages. | 79 // Content of session-info messages. |
89 scoped_ptr<buzz::XmlElement> info; | 80 scoped_ptr<buzz::XmlElement> info; |
90 | 81 |
91 // Value from the <reason> tag if it is present in the | 82 // Value from the <reason> tag if it is present in the |
92 // message. Useful mainly for session-terminate messages, but Jingle | 83 // message. Useful mainly for session-terminate messages, but Jingle |
93 // spec allows it in any message. | 84 // spec allows it in any message. |
94 Reason reason = UNKNOWN_REASON; | 85 Reason reason; |
95 }; | 86 }; |
96 | 87 |
97 struct JingleMessageReply { | 88 struct JingleMessageReply { |
98 enum ReplyType { | 89 enum ReplyType { |
99 REPLY_RESULT, | 90 REPLY_RESULT, |
100 REPLY_ERROR, | 91 REPLY_ERROR, |
101 }; | 92 }; |
102 enum ErrorType { | 93 enum ErrorType { |
103 NONE, | 94 NONE, |
104 BAD_REQUEST, | 95 BAD_REQUEST, |
(...skipping 16 matching lines...) Expand all Loading... |
121 | 112 |
122 ReplyType type; | 113 ReplyType type; |
123 ErrorType error_type; | 114 ErrorType error_type; |
124 std::string text; | 115 std::string text; |
125 }; | 116 }; |
126 | 117 |
127 } // protocol | 118 } // protocol |
128 } // remoting | 119 } // remoting |
129 | 120 |
130 #endif // REMOTING_PROTOCOL_JINGLE_MESSAGES_H_ | 121 #endif // REMOTING_PROTOCOL_JINGLE_MESSAGES_H_ |
OLD | NEW |