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