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

Side by Side Diff: webrtc/libjingle/session/rawtransportparser.cc

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 2004 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 #include "webrtc/libjingle/session/rawtransportparser.h"
12
13 #include <string>
14 #include <vector>
15
16 #include "webrtc/libjingle/session/parsing.h"
17 #include "webrtc/libjingle/xmllite/qname.h"
18 #include "webrtc/libjingle/xmllite/xmlelement.h"
19 #include "webrtc/libjingle/xmpp/constants.h"
20 #include "webrtc/p2p/base/constants.h"
21
22 #if defined(FEATURE_ENABLE_PSTN)
23 namespace cricket {
24
25 bool RawTransportParser::ParseCandidates(SignalingProtocol protocol,
26 const buzz::XmlElement* elem,
27 const CandidateTranslator* translator,
28 Candidates* candidates,
29 ParseError* error) {
30 for (const buzz::XmlElement* cand_elem = elem->FirstElement();
31 cand_elem != NULL;
32 cand_elem = cand_elem->NextElement()) {
33 if (cand_elem->Name() == QN_GINGLE_RAW_CHANNEL) {
34 if (!cand_elem->HasAttr(buzz::QN_NAME)) {
35 return BadParse("no channel name given", error);
36 }
37 if (NS_GINGLE_RAW != cand_elem->Attr(buzz::QN_NAME)) {
38 return BadParse("channel named does not exist", error);
39 }
40 rtc::SocketAddress addr;
41 if (!ParseRawAddress(cand_elem, &addr, error))
42 return false;
43
44 Candidate candidate;
45 candidate.set_component(1);
46 candidate.set_address(addr);
47 candidates->push_back(candidate);
48 }
49 }
50 return true;
51 }
52
53 bool RawTransportParser::WriteCandidates(SignalingProtocol protocol,
54 const Candidates& candidates,
55 const CandidateTranslator* translator,
56 XmlElements* candidate_elems,
57 WriteError* error) {
58 for (std::vector<Candidate>::const_iterator
59 cand = candidates.begin();
60 cand != candidates.end();
61 ++cand) {
62 ASSERT(cand->component() == 1);
63 ASSERT(cand->protocol() == "udp");
64 rtc::SocketAddress addr = cand->address();
65
66 buzz::XmlElement* elem = new buzz::XmlElement(QN_GINGLE_RAW_CHANNEL);
67 elem->SetAttr(buzz::QN_NAME, NS_GINGLE_RAW);
68 elem->SetAttr(QN_ADDRESS, addr.ipaddr().ToString());
69 elem->SetAttr(QN_PORT, addr.PortAsString());
70 candidate_elems->push_back(elem);
71 }
72 return true;
73 }
74
75 bool RawTransportParser::ParseRawAddress(const buzz::XmlElement* elem,
76 rtc::SocketAddress* addr,
77 ParseError* error) {
78 // Make sure the required attributes exist
79 if (!elem->HasAttr(QN_ADDRESS) ||
80 !elem->HasAttr(QN_PORT)) {
81 return BadParse("channel missing required attribute", error);
82 }
83
84 // Parse the address.
85 if (!ParseAddress(elem, QN_ADDRESS, QN_PORT, addr, error))
86 return false;
87
88 return true;
89 }
90
91 } // namespace cricket
92 #endif // defined(FEATURE_ENABLE_PSTN)
OLDNEW
« no previous file with comments | « webrtc/libjingle/session/rawtransportparser.h ('k') | webrtc/libjingle/session/session_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698