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
3 // found in the LICENSE file.
5 #ifndef REMOTING_PROTOCOL_JINGLE_MESSAGES_H_
6 #define REMOTING_PROTOCOL_JINGLE_MESSAGES_H_
11 #include "base/memory/scoped_ptr.h"
12 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h"
13 #include "third_party/webrtc/p2p/base/candidate.h"
18 class ContentDescription
;
20 struct JingleMessage
{
36 INCOMPATIBLE_PARAMETERS
,
39 struct NamedCandidate
{
40 NamedCandidate() = default;
41 NamedCandidate(const std::string
& name
,
42 const cricket::Candidate
& candidate
);
45 cricket::Candidate candidate
;
48 struct IceCredentials
{
49 IceCredentials() = default;
50 IceCredentials(std::string channel
,
52 std::string password
);
60 JingleMessage(const std::string
& to_value
,
61 ActionType action_value
,
62 const std::string
& sid_value
);
65 // Caller keeps ownership of |stanza|.
66 static bool IsJingleMessage(const buzz::XmlElement
* stanza
);
67 static std::string
GetActionName(ActionType action
);
69 // Caller keeps ownership of |stanza|. |error| is set to debug error
70 // message when parsing fails.
71 bool ParseXml(const buzz::XmlElement
* stanza
, std::string
* error
);
73 scoped_ptr
<buzz::XmlElement
> ToXml() const;
77 ActionType action
= UNKNOWN_ACTION
;
80 std::string initiator
;
82 scoped_ptr
<ContentDescription
> description
;
84 bool standard_ice
= true;
85 std::list
<IceCredentials
> ice_credentials
;
86 std::list
<NamedCandidate
> candidates
;
88 // Content of session-info messages.
89 scoped_ptr
<buzz::XmlElement
> info
;
91 // Value from the <reason> tag if it is present in the
92 // message. Useful mainly for session-terminate messages, but Jingle
93 // spec allows it in any message.
94 Reason reason
= UNKNOWN_REASON
;
97 struct JingleMessageReply
{
111 JingleMessageReply();
112 JingleMessageReply(ErrorType error
);
113 JingleMessageReply(ErrorType error
, const std::string
& text
);
114 ~JingleMessageReply();
116 // Formats reply stanza for the specified |request_stanza|. Id and
117 // recepient as well as other information needed to generate a valid
118 // reply are taken from |request_stanza|.
119 scoped_ptr
<buzz::XmlElement
> ToXml(
120 const buzz::XmlElement
* request_stanza
) const;
123 ErrorType error_type
;
130 #endif // REMOTING_PROTOCOL_JINGLE_MESSAGES_H_