Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / third_party / webrtc / p2p / base / rawtransport.h
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 #ifndef WEBRTC_P2P_BASE_RAWTRANSPORT_H_
12 #define WEBRTC_P2P_BASE_RAWTRANSPORT_H_
13
14 #include <string>
15 #include "webrtc/p2p/base/transport.h"
16
17 #if defined(FEATURE_ENABLE_PSTN)
18 namespace cricket {
19
20 // Implements a transport that only sends raw packets, no STUN.  As a result,
21 // it cannot do pings to determine connectivity, so it only uses a single port
22 // that it thinks will work.
23 class RawTransport : public Transport, public TransportParser {
24  public:
25   RawTransport(rtc::Thread* signaling_thread,
26                rtc::Thread* worker_thread,
27                const std::string& content_name,
28                PortAllocator* allocator);
29   virtual ~RawTransport();
30
31   virtual bool ParseCandidates(SignalingProtocol protocol,
32                                const buzz::XmlElement* elem,
33                                const CandidateTranslator* translator,
34                                Candidates* candidates,
35                                ParseError* error);
36   virtual bool WriteCandidates(SignalingProtocol protocol,
37                                const Candidates& candidates,
38                                const CandidateTranslator* translator,
39                                XmlElements* candidate_elems,
40                                WriteError* error);
41
42  protected:
43   // Creates and destroys raw channels.
44   virtual TransportChannelImpl* CreateTransportChannel(int component);
45   virtual void DestroyTransportChannel(TransportChannelImpl* channel);
46
47  private:
48   // Parses the given element, which should describe the address to use for a
49   // given channel.  This will return false and signal an error if the address
50   // or channel name is bad.
51   bool ParseRawAddress(const buzz::XmlElement* elem,
52                        rtc::SocketAddress* addr,
53                        ParseError* error);
54
55   friend class RawTransportChannel;  // For ParseAddress.
56
57   DISALLOW_EVIL_CONSTRUCTORS(RawTransport);
58 };
59
60 }  // namespace cricket
61
62 #endif  // defined(FEATURE_ENABLE_PSTN)
63
64 #endif  // WEBRTC_P2P_BASE_RAWTRANSPORT_H_