Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: webrtc/libjingle/session/sessionmessages.h

Issue 1175243003: Remove webrtc/libjingle/{examples,session}. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2010 The WebRTC Project Authors. All rights reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef WEBRTC_LIBJINGLE_SESSION_SESSIONMESSAGES_H_
12 #define WEBRTC_LIBJINGLE_SESSION_SESSIONMESSAGES_H_
13
14 #include <map>
15 #include <string>
16 #include <vector>
17
18 #include "webrtc/base/basictypes.h"
19 #include "webrtc/libjingle/session/constants.h"
20 #include "webrtc/libjingle/session/parsing.h"
21 #include "webrtc/libjingle/session/transportparser.h"
22 #include "webrtc/libjingle/xmllite/xmlelement.h"
23 #include "webrtc/p2p/base/candidate.h"
24 #include "webrtc/p2p/base/constants.h"
25 #include "webrtc/p2p/base/sessiondescription.h" // Needed to delete contents.
26 #include "webrtc/p2p/base/transport.h"
27 #include "webrtc/p2p/base/transportinfo.h"
28
29 namespace cricket {
30
31 struct ParseError;
32 struct WriteError;
33 class Candidate;
34 class ContentParser;
35 class TransportParser;
36
37 typedef std::vector<Candidate> Candidates;
38 typedef std::map<std::string, ContentParser*> ContentParserMap;
39 typedef std::map<std::string, TransportParser*> TransportParserMap;
40
41 enum ActionType {
42 ACTION_UNKNOWN,
43
44 ACTION_SESSION_INITIATE,
45 ACTION_SESSION_INFO,
46 ACTION_SESSION_ACCEPT,
47 ACTION_SESSION_REJECT,
48 ACTION_SESSION_TERMINATE,
49
50 ACTION_TRANSPORT_INFO,
51 ACTION_TRANSPORT_ACCEPT,
52
53 ACTION_DESCRIPTION_INFO,
54 };
55
56 // Abstraction of a <jingle> element within an <iq> stanza, per XMPP
57 // standard XEP-166. Can be serialized into multiple protocols,
58 // including the standard (Jingle) and the draft standard (Gingle).
59 // In general, used to communicate actions related to a p2p session,
60 // such accept, initiate, terminate, etc.
61
62 struct SessionMessage {
63 SessionMessage() : action_elem(NULL), stanza(NULL) {}
64
65 SessionMessage(SignalingProtocol protocol, ActionType type,
66 const std::string& sid, const std::string& initiator) :
67 protocol(protocol), type(type), sid(sid), initiator(initiator),
68 action_elem(NULL), stanza(NULL) {}
69
70 std::string id;
71 std::string from;
72 std::string to;
73 SignalingProtocol protocol;
74 ActionType type;
75 std::string sid; // session id
76 std::string initiator;
77
78 // Used for further parsing when necessary.
79 // Represents <session> or <jingle>.
80 const buzz::XmlElement* action_elem;
81 // Mostly used for debugging.
82 const buzz::XmlElement* stanza;
83 };
84
85 // TODO: Break up this class so we don't have to typedef it into
86 // different classes.
87 struct ContentMessage {
88 ContentMessage() : owns_contents(false) {}
89
90 ~ContentMessage() {
91 if (owns_contents) {
92 for (ContentInfos::iterator content = contents.begin();
93 content != contents.end(); content++) {
94 delete content->description;
95 }
96 }
97 }
98
99 // Caller takes ownership of contents.
100 ContentInfos ClearContents() {
101 ContentInfos out;
102 contents.swap(out);
103 owns_contents = false;
104 return out;
105 }
106
107 bool owns_contents;
108 ContentInfos contents;
109 TransportInfos transports;
110 ContentGroups groups;
111 };
112
113 typedef ContentMessage SessionInitiate;
114 typedef ContentMessage SessionAccept;
115 // Note that a DescriptionInfo does not have TransportInfos.
116 typedef ContentMessage DescriptionInfo;
117
118 struct SessionTerminate {
119 SessionTerminate() {}
120
121 explicit SessionTerminate(const std::string& reason) :
122 reason(reason) {}
123
124 std::string reason;
125 std::string debug_reason;
126 };
127
128 struct SessionRedirect {
129 std::string target;
130 };
131
132 // Content name => translator
133 typedef std::map<std::string, CandidateTranslator*> CandidateTranslatorMap;
134
135 bool IsSessionMessage(const buzz::XmlElement* stanza);
136 bool ParseSessionMessage(const buzz::XmlElement* stanza,
137 SessionMessage* msg,
138 ParseError* error);
139 // Will return an error if there is more than one content type.
140 bool ParseContentType(SignalingProtocol protocol,
141 const buzz::XmlElement* action_elem,
142 std::string* content_type,
143 ParseError* error);
144 void WriteSessionMessage(const SessionMessage& msg,
145 const XmlElements& action_elems,
146 buzz::XmlElement* stanza);
147 bool ParseSessionInitiate(SignalingProtocol protocol,
148 const buzz::XmlElement* action_elem,
149 const ContentParserMap& content_parsers,
150 const TransportParserMap& transport_parsers,
151 const CandidateTranslatorMap& translators,
152 SessionInitiate* init,
153 ParseError* error);
154 bool WriteSessionInitiate(SignalingProtocol protocol,
155 const ContentInfos& contents,
156 const TransportInfos& tinfos,
157 const ContentParserMap& content_parsers,
158 const TransportParserMap& transport_parsers,
159 const CandidateTranslatorMap& translators,
160 const ContentGroups& groups,
161 XmlElements* elems,
162 WriteError* error);
163 bool ParseSessionAccept(SignalingProtocol protocol,
164 const buzz::XmlElement* action_elem,
165 const ContentParserMap& content_parsers,
166 const TransportParserMap& transport_parsers,
167 const CandidateTranslatorMap& translators,
168 SessionAccept* accept,
169 ParseError* error);
170 bool WriteSessionAccept(SignalingProtocol protocol,
171 const ContentInfos& contents,
172 const TransportInfos& tinfos,
173 const ContentParserMap& content_parsers,
174 const TransportParserMap& transport_parsers,
175 const CandidateTranslatorMap& translators,
176 const ContentGroups& groups,
177 XmlElements* elems,
178 WriteError* error);
179 bool ParseSessionTerminate(SignalingProtocol protocol,
180 const buzz::XmlElement* action_elem,
181 SessionTerminate* term,
182 ParseError* error);
183 void WriteSessionTerminate(SignalingProtocol protocol,
184 const SessionTerminate& term,
185 XmlElements* elems);
186 bool ParseDescriptionInfo(SignalingProtocol protocol,
187 const buzz::XmlElement* action_elem,
188 const ContentParserMap& content_parsers,
189 const TransportParserMap& transport_parsers,
190 const CandidateTranslatorMap& translators,
191 DescriptionInfo* description_info,
192 ParseError* error);
193 bool WriteDescriptionInfo(SignalingProtocol protocol,
194 const ContentInfos& contents,
195 const ContentParserMap& content_parsers,
196 XmlElements* elems,
197 WriteError* error);
198 // Since a TransportInfo is not a transport-info message, and a
199 // transport-info message is just a collection of TransportInfos, we
200 // say Parse/Write TransportInfos for transport-info messages.
201 bool ParseTransportInfos(SignalingProtocol protocol,
202 const buzz::XmlElement* action_elem,
203 const ContentInfos& contents,
204 const TransportParserMap& trans_parsers,
205 const CandidateTranslatorMap& translators,
206 TransportInfos* tinfos,
207 ParseError* error);
208 bool WriteTransportInfos(SignalingProtocol protocol,
209 const TransportInfos& tinfos,
210 const TransportParserMap& trans_parsers,
211 const CandidateTranslatorMap& translators,
212 XmlElements* elems,
213 WriteError* error);
214 // Handles both Gingle and Jingle syntax.
215 bool FindSessionRedirect(const buzz::XmlElement* stanza,
216 SessionRedirect* redirect);
217 } // namespace cricket
218
219 #endif // WEBRTC_LIBJINGLE_SESSION_SESSIONMESSAGES_H_
OLDNEW
« no previous file with comments | « webrtc/libjingle/session/sessionmanagertask.h ('k') | webrtc/libjingle/session/sessionmessages.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698