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 std::list
<IceCredentials
> ice_credentials
;
85 std::list
<NamedCandidate
> candidates
;
87 // Content of session-info messages.
88 scoped_ptr
<buzz::XmlElement
> info
;
90 // Value from the <reason> tag if it is present in the
91 // message. Useful mainly for session-terminate messages, but Jingle
92 // spec allows it in any message.
93 Reason reason
= UNKNOWN_REASON
;
96 struct JingleMessageReply
{
110 JingleMessageReply();
111 JingleMessageReply(ErrorType error
);
112 JingleMessageReply(ErrorType error
, const std::string
& text
);
113 ~JingleMessageReply();
115 // Formats reply stanza for the specified |request_stanza|. Id and
116 // recepient as well as other information needed to generate a valid
117 // reply are taken from |request_stanza|.
118 scoped_ptr
<buzz::XmlElement
> ToXml(
119 const buzz::XmlElement
* request_stanza
) const;
122 ErrorType error_type
;
129 #endif // REMOTING_PROTOCOL_JINGLE_MESSAGES_H_