15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)/*
25c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) 2012 Google Inc. All rights reserved.
35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *
45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without
55c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * modification, are permitted provided that the following conditions are
65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * met:
75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *
85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *     * Redistributions of source code must retain the above copyright
95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * notice, this list of conditions and the following disclaimer.
105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *     * Redistributions in binary form must reproduce the above
115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * copyright notice, this list of conditions and the following disclaimer
125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * in the documentation and/or other materials provided with the
135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * distribution.
145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *     * Neither the name of Google Inc. nor the names of its
155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * contributors may be used to endorse or promote products derived from
165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * this software without specific prior written permission.
175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *
185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) */
305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "config.h"
325267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)#include "public/platform/WebRTCICECandidate.h"
335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
34f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles)#include "public/platform/WebString.h"
3593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#include "wtf/PassRefPtr.h"
3693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#include "wtf/RefCounted.h"
375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
3851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)namespace blink {
395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
40f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles)class WebRTCICECandidatePrivate FINAL : public RefCounted<WebRTCICECandidatePrivate> {
4193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)public:
4293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    static PassRefPtr<WebRTCICECandidatePrivate> create(const WebString& candidate, const WebString& sdpMid, unsigned short sdpMLineIndex)
4393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    {
4493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        return adoptRef(new WebRTCICECandidatePrivate(candidate, sdpMid, sdpMLineIndex));
4593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    }
4693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
4793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    const WebString& candidate() const { return m_candidate; }
4893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    const WebString& sdpMid() const { return m_sdpMid; }
4993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    unsigned short sdpMLineIndex() const { return m_sdpMLineIndex; }
5093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
51d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    BLINK_PLATFORM_EXPORT void setCandidate(WebString candidate) { m_candidate = candidate; }
52d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    BLINK_PLATFORM_EXPORT void setSdpMid(WebString sdpMid) { m_sdpMid = sdpMid; }
53d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    BLINK_PLATFORM_EXPORT void setSdpMLineIndex(unsigned short sdpMLineIndex) { m_sdpMLineIndex = sdpMLineIndex; }
54d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)
5593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)private:
5693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    WebRTCICECandidatePrivate(const WebString& candidate, const WebString& sdpMid, unsigned short sdpMLineIndex);
5793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
5893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    WebString m_candidate;
5993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    WebString m_sdpMid;
6093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    unsigned short m_sdpMLineIndex;
6193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)};
6293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
6393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)WebRTCICECandidatePrivate::WebRTCICECandidatePrivate(const WebString& candidate, const WebString& sdpMid, unsigned short sdpMLineIndex)
6493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    : m_candidate(candidate)
6593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    , m_sdpMid(sdpMid)
6693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    , m_sdpMLineIndex(sdpMLineIndex)
675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)void WebRTCICECandidate::assign(const WebRTCICECandidate& other)
715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    m_private = other.m_private;
735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)void WebRTCICECandidate::reset()
765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    m_private.reset();
785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)void WebRTCICECandidate::initialize(const WebString& candidate, const WebString& sdpMid, unsigned short sdpMLineIndex)
815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
8293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    m_private = WebRTCICECandidatePrivate::create(candidate, sdpMid, sdpMLineIndex);
835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)WebString WebRTCICECandidate::candidate() const
865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    ASSERT(!m_private.isNull());
885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    return m_private->candidate();
895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)WebString WebRTCICECandidate::sdpMid() const
925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    ASSERT(!m_private.isNull());
945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    return m_private->sdpMid();
955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)unsigned short WebRTCICECandidate::sdpMLineIndex() const
985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    ASSERT(!m_private.isNull());
1005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    return m_private->sdpMLineIndex();
1015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
1025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
103d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)void WebRTCICECandidate::setCandidate(WebString candidate)
104d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles){
105d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    ASSERT(!m_private.isNull());
106d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    m_private->setCandidate(candidate);
107d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)}
108d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)
109d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)void WebRTCICECandidate::setSdpMid(WebString sdpMid)
110d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles){
111d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    ASSERT(!m_private.isNull());
112d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    m_private->setSdpMid(sdpMid);
113d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)}
114d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)
115d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)void WebRTCICECandidate::setSdpMLineIndex(unsigned short sdpMLineIndex)
116d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles){
117d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    ASSERT(!m_private.isNull());
118d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    m_private->setSdpMLineIndex(sdpMLineIndex);
119d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)}
120d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)
12151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} // namespace blink
122