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 #include "config.h" 32 #include "public/platform/WebRTCICECandidate.h" 33 34 #include "public/platform/WebString.h" 35 #include "wtf/PassRefPtr.h" 36 #include "wtf/RefCounted.h" 37 38 namespace blink { 39 40 class WebRTCICECandidatePrivate FINAL : public RefCounted<WebRTCICECandidatePrivate> { 41 public: 42 static PassRefPtr<WebRTCICECandidatePrivate> create(const WebString& candidate, const WebString& sdpMid, unsigned short sdpMLineIndex) 43 { 44 return adoptRef(new WebRTCICECandidatePrivate(candidate, sdpMid, sdpMLineIndex)); 45 } 46 47 const WebString& candidate() const { return m_candidate; } 48 const WebString& sdpMid() const { return m_sdpMid; } 49 unsigned short sdpMLineIndex() const { return m_sdpMLineIndex; } 50 51 BLINK_PLATFORM_EXPORT void setCandidate(WebString candidate) { m_candidate = candidate; } 52 BLINK_PLATFORM_EXPORT void setSdpMid(WebString sdpMid) { m_sdpMid = sdpMid; } 53 BLINK_PLATFORM_EXPORT void setSdpMLineIndex(unsigned short sdpMLineIndex) { m_sdpMLineIndex = sdpMLineIndex; } 54 55 private: 56 WebRTCICECandidatePrivate(const WebString& candidate, const WebString& sdpMid, unsigned short sdpMLineIndex); 57 58 WebString m_candidate; 59 WebString m_sdpMid; 60 unsigned short m_sdpMLineIndex; 61 }; 62 63 WebRTCICECandidatePrivate::WebRTCICECandidatePrivate(const WebString& candidate, const WebString& sdpMid, unsigned short sdpMLineIndex) 64 : m_candidate(candidate) 65 , m_sdpMid(sdpMid) 66 , m_sdpMLineIndex(sdpMLineIndex) 67 { 68 } 69 70 void WebRTCICECandidate::assign(const WebRTCICECandidate& other) 71 { 72 m_private = other.m_private; 73 } 74 75 void WebRTCICECandidate::reset() 76 { 77 m_private.reset(); 78 } 79 80 void WebRTCICECandidate::initialize(const WebString& candidate, const WebString& sdpMid, unsigned short sdpMLineIndex) 81 { 82 m_private = WebRTCICECandidatePrivate::create(candidate, sdpMid, sdpMLineIndex); 83 } 84 85 WebString WebRTCICECandidate::candidate() const 86 { 87 ASSERT(!m_private.isNull()); 88 return m_private->candidate(); 89 } 90 91 WebString WebRTCICECandidate::sdpMid() const 92 { 93 ASSERT(!m_private.isNull()); 94 return m_private->sdpMid(); 95 } 96 97 unsigned short WebRTCICECandidate::sdpMLineIndex() const 98 { 99 ASSERT(!m_private.isNull()); 100 return m_private->sdpMLineIndex(); 101 } 102 103 void WebRTCICECandidate::setCandidate(WebString candidate) 104 { 105 ASSERT(!m_private.isNull()); 106 m_private->setCandidate(candidate); 107 } 108 109 void WebRTCICECandidate::setSdpMid(WebString sdpMid) 110 { 111 ASSERT(!m_private.isNull()); 112 m_private->setSdpMid(sdpMid); 113 } 114 115 void WebRTCICECandidate::setSdpMLineIndex(unsigned short sdpMLineIndex) 116 { 117 ASSERT(!m_private.isNull()); 118 m_private->setSdpMLineIndex(sdpMLineIndex); 119 } 120 121 } // namespace blink 122