1 /* 2 * Copyright (C) 2011 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 33 #include "public/web/WebUserMediaRequest.h" 34 35 #include "core/dom/Document.h" 36 #include "modules/mediastream/UserMediaRequest.h" 37 #include "platform/mediastream/MediaStreamDescriptor.h" 38 #include "platform/mediastream/MediaStreamSource.h" 39 #include "platform/weborigin/SecurityOrigin.h" 40 #include "public/platform/WebMediaConstraints.h" 41 #include "public/platform/WebMediaStream.h" 42 #include "public/platform/WebMediaStreamSource.h" 43 #include "public/platform/WebString.h" 44 #include "public/platform/WebVector.h" 45 #include "public/web/WebDocument.h" 46 #include "public/web/WebSecurityOrigin.h" 47 #include "wtf/Vector.h" 48 49 using namespace WebCore; 50 51 namespace blink { 52 53 WebUserMediaRequest::WebUserMediaRequest(const PassRefPtrWillBeRawPtr<UserMediaRequest>& request) 54 : m_private(request) 55 { 56 } 57 58 WebUserMediaRequest::WebUserMediaRequest(UserMediaRequest* request) 59 : m_private(request) 60 { 61 } 62 63 void WebUserMediaRequest::reset() 64 { 65 m_private.reset(); 66 } 67 68 bool WebUserMediaRequest::audio() const 69 { 70 ASSERT(!isNull()); 71 return m_private->audio(); 72 } 73 74 bool WebUserMediaRequest::video() const 75 { 76 ASSERT(!isNull()); 77 return m_private->video(); 78 } 79 80 WebMediaConstraints WebUserMediaRequest::audioConstraints() const 81 { 82 ASSERT(!isNull()); 83 return m_private->audioConstraints(); 84 } 85 86 WebMediaConstraints WebUserMediaRequest::videoConstraints() const 87 { 88 ASSERT(!isNull()); 89 return m_private->videoConstraints(); 90 } 91 92 WebSecurityOrigin WebUserMediaRequest::securityOrigin() const 93 { 94 ASSERT(!isNull() && m_private->executionContext()); 95 return WebSecurityOrigin(m_private->executionContext()->securityOrigin()); 96 } 97 98 WebDocument WebUserMediaRequest::ownerDocument() const 99 { 100 ASSERT(!isNull()); 101 return WebDocument(m_private->ownerDocument()); 102 } 103 104 void WebUserMediaRequest::requestSucceeded(const WebMediaStream& streamDescriptor) 105 { 106 ASSERT(!isNull() && !streamDescriptor.isNull()); 107 m_private->succeed(streamDescriptor); 108 } 109 110 void WebUserMediaRequest::requestDenied(const WebString& description) 111 { 112 ASSERT(!isNull()); 113 m_private->failPermissionDenied(description); 114 } 115 116 void WebUserMediaRequest::requestFailedConstraint(const WebString& constraintName, const WebString& description) 117 { 118 ASSERT(!isNull()); 119 m_private->failConstraint(constraintName, description); 120 } 121 122 void WebUserMediaRequest::requestFailedUASpecific(const WebString& name, const WebString& constraintName, const WebString& description) 123 { 124 ASSERT(!isNull()); 125 m_private->failUASpecific(name, constraintName, description); 126 } 127 128 bool WebUserMediaRequest::equals(const WebUserMediaRequest& other) const 129 { 130 if (isNull() || other.isNull()) 131 return false; 132 return m_private.get() == other.m_private.get(); 133 } 134 135 void WebUserMediaRequest::assign(const WebUserMediaRequest& other) 136 { 137 m_private = other.m_private; 138 } 139 140 WebUserMediaRequest::operator UserMediaRequest*() const 141 { 142 return m_private.get(); 143 } 144 145 } // namespace blink 146