1 /*
2  * Copyright (C) 2012 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_PEERCONNECTION_RTC_ICE_CANDIDATE_PLATFORM_H_
32 #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_PEERCONNECTION_RTC_ICE_CANDIDATE_PLATFORM_H_
33 
34 #include "base/optional.h"
35 #include "third_party/blink/renderer/platform/heap/heap.h"
36 #include "third_party/blink/renderer/platform/platform_export.h"
37 #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
38 
39 namespace blink {
40 
41 class PLATFORM_EXPORT RTCIceCandidatePlatform final
42     : public GarbageCollected<RTCIceCandidatePlatform> {
43  public:
44   // Creates a new RTCIceCandidatePlatform using |candidate|, |sdp_mid| and
45   // |sdp_m_line_index|. If |sdp_m_line_index| is negative, it is
46   // considered as having no value.
47   RTCIceCandidatePlatform(String candidate,
48                           String sdp_mid,
49                           base::Optional<uint16_t> sdp_m_line_index);
50 
51   // Creates a new RTCIceCandidatePlatform using |candidate|, |sdp_mid|,
52   // |sdp_m_line_index|, and |username_fragment|.
53   RTCIceCandidatePlatform(String candidate,
54                           String sdp_mid,
55                           base::Optional<uint16_t> sdp_m_line_index,
56                           String username_fragment);
57   ~RTCIceCandidatePlatform() = default;
58 
Candidate()59   const String& Candidate() const { return candidate_; }
SdpMid()60   const String& SdpMid() const { return sdp_mid_; }
SdpMLineIndex()61   const base::Optional<uint16_t>& SdpMLineIndex() const {
62     return sdp_m_line_index_;
63   }
Foundation()64   const String& Foundation() const { return foundation_; }
Component()65   const String& Component() const { return component_; }
Priority()66   const base::Optional<uint32_t>& Priority() const { return priority_; }
Address()67   const String& Address() const { return address_; }
Protocol()68   const String Protocol() const { return protocol_; }
Port()69   const base::Optional<uint16_t>& Port() const { return port_; }
Type()70   const String& Type() const { return type_; }
TcpType()71   const String& TcpType() const { return tcp_type_; }
RelatedAddress()72   const String& RelatedAddress() const { return related_address_; }
RelatedPort()73   const base::Optional<uint16_t>& RelatedPort() const { return related_port_; }
UsernameFragment()74   const String& UsernameFragment() const { return username_fragment_; }
75 
Trace(Visitor *)76   void Trace(Visitor*) {}
77 
78  private:
79   void PopulateFields(bool use_username_from_candidate);
80 
81   String candidate_;
82   String sdp_mid_;
83   base::Optional<uint16_t> sdp_m_line_index_;
84   String foundation_;
85   String component_;
86   base::Optional<uint32_t> priority_;
87   String address_;
88   String protocol_;
89   base::Optional<uint16_t> port_;
90   String type_;
91   String tcp_type_;
92   String related_address_;
93   base::Optional<uint16_t> related_port_;
94   String username_fragment_;
95 
96   DISALLOW_COPY_AND_ASSIGN(RTCIceCandidatePlatform);
97 };
98 
99 }  // namespace blink
100 
101 #endif  // THIRD_PARTY_BLINK_RENDERER_PLATFORM_PEERCONNECTION_RTC_ICE_CANDIDATE_PLATFORM_H_
102