1 /* 2 * Copyright (C) 2014 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/WebMediaDeviceInfo.h" 29 30 #include "public/platform/WebString.h" 31 #include "wtf/PassRefPtr.h" 32 #include "wtf/RefCounted.h" 33 34 namespace blink { 35 36 class WebMediaDeviceInfoPrivate FINAL : public RefCounted<WebMediaDeviceInfoPrivate> { 37 public: 38 static PassRefPtr<WebMediaDeviceInfoPrivate> create(const WebString& deviceId, WebMediaDeviceInfo::MediaDeviceKind, const WebString& label, const WebString& groupId); 39 40 const WebString& deviceId() const { return m_deviceId; } 41 WebMediaDeviceInfo::MediaDeviceKind kind() const { return m_kind; } 42 const WebString& label() const { return m_label; } 43 const WebString& groupId() const { return m_groupId; } 44 45 private: 46 WebMediaDeviceInfoPrivate(const WebString& deviceId, WebMediaDeviceInfo::MediaDeviceKind, const WebString& label, const WebString& groupId); 47 48 WebString m_deviceId; 49 WebMediaDeviceInfo::MediaDeviceKind m_kind; 50 WebString m_label; 51 WebString m_groupId; 52 }; 53 54 PassRefPtr<WebMediaDeviceInfoPrivate> WebMediaDeviceInfoPrivate::create(const WebString& deviceId, WebMediaDeviceInfo::MediaDeviceKind kind, const WebString& label, const WebString& groupId) 55 { 56 return adoptRef(new WebMediaDeviceInfoPrivate(deviceId, kind, label, groupId)); 57 } 58 59 WebMediaDeviceInfoPrivate::WebMediaDeviceInfoPrivate(const WebString& deviceId, WebMediaDeviceInfo::MediaDeviceKind kind, const WebString& label, const WebString& groupId) 60 : m_deviceId(deviceId) 61 , m_kind(kind) 62 , m_label(label) 63 , m_groupId(groupId) 64 { 65 } 66 67 void WebMediaDeviceInfo::assign(const WebMediaDeviceInfo& other) 68 { 69 m_private = other.m_private; 70 } 71 72 void WebMediaDeviceInfo::reset() 73 { 74 m_private.reset(); 75 } 76 77 void WebMediaDeviceInfo::initialize(const WebString& deviceId, WebMediaDeviceInfo::MediaDeviceKind kind, const WebString& label, const WebString& groupId) 78 { 79 m_private = WebMediaDeviceInfoPrivate::create(deviceId, kind, label, groupId); 80 } 81 82 WebString WebMediaDeviceInfo::deviceId() const 83 { 84 ASSERT(!m_private.isNull()); 85 return m_private->deviceId(); 86 } 87 88 WebMediaDeviceInfo::MediaDeviceKind WebMediaDeviceInfo::kind() const 89 { 90 ASSERT(!m_private.isNull()); 91 return m_private->kind(); 92 } 93 94 WebString WebMediaDeviceInfo::label() const 95 { 96 ASSERT(!m_private.isNull()); 97 return m_private->label(); 98 } 99 100 WebString WebMediaDeviceInfo::groupId() const 101 { 102 ASSERT(!m_private.isNull()); 103 return m_private->groupId(); 104 } 105 106 } // namespace blink 107 108