1/*
2 * Copyright (C) 2013 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
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 *    notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 *    notice, this list of conditions and the following disclaimer in the
11 *    documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL GOOGLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include "config.h"
27
28#include "public/platform/WebSourceInfo.h"
29
30#include "public/platform/WebString.h"
31#include "wtf/PassRefPtr.h"
32#include "wtf/RefCounted.h"
33
34namespace blink {
35
36class WebSourceInfoPrivate FINAL : public RefCounted<WebSourceInfoPrivate> {
37public:
38    static PassRefPtr<WebSourceInfoPrivate> create(const WebString& id, WebSourceInfo::SourceKind, const WebString& label, WebSourceInfo::VideoFacingMode);
39
40    const WebString& id() const { return m_id; }
41    WebSourceInfo::SourceKind kind() const { return m_kind; }
42    const WebString& label() const { return m_label; }
43    WebSourceInfo::VideoFacingMode facing() const { return m_facing; }
44
45private:
46    WebSourceInfoPrivate(const WebString& id, WebSourceInfo::SourceKind, const WebString& label, WebSourceInfo::VideoFacingMode);
47
48    WebString m_id;
49    WebSourceInfo::SourceKind m_kind;
50    WebString m_label;
51    WebSourceInfo::VideoFacingMode m_facing;
52};
53
54PassRefPtr<WebSourceInfoPrivate> WebSourceInfoPrivate::create(const WebString& id, WebSourceInfo::SourceKind kind, const WebString& label, WebSourceInfo::VideoFacingMode facing)
55{
56    return adoptRef(new WebSourceInfoPrivate(id, kind, label, facing));
57}
58
59WebSourceInfoPrivate::WebSourceInfoPrivate(const WebString& id, WebSourceInfo::SourceKind kind, const WebString& label, WebSourceInfo::VideoFacingMode facing)
60    : m_id(id)
61    , m_kind(kind)
62    , m_label(label)
63    , m_facing(facing)
64{
65}
66
67void WebSourceInfo::assign(const WebSourceInfo& other)
68{
69    m_private = other.m_private;
70}
71
72void WebSourceInfo::reset()
73{
74    m_private.reset();
75}
76
77void WebSourceInfo::initialize(const WebString& id, WebSourceInfo::SourceKind kind, const WebString& label, WebSourceInfo::VideoFacingMode facing)
78{
79    m_private = WebSourceInfoPrivate::create(id, kind, label, facing);
80}
81
82WebString WebSourceInfo::id() const
83{
84    ASSERT(!m_private.isNull());
85    return m_private->id();
86}
87
88WebSourceInfo::SourceKind WebSourceInfo::kind() const
89{
90    ASSERT(!m_private.isNull());
91    return m_private->kind();
92}
93
94WebString WebSourceInfo::label() const
95{
96    ASSERT(!m_private.isNull());
97    return m_private->label();
98}
99
100WebSourceInfo::VideoFacingMode WebSourceInfo::facing() const
101{
102    ASSERT(!m_private.isNull());
103    return m_private->facing();
104}
105
106} // namespace blink
107
108