1 /* 2 * Copyright (C) 2011 Ericsson AB. 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 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * 3. Neither the name of Ericsson nor the names of its contributors 15 * may be used to endorse or promote products derived from this 16 * 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 #ifndef UserMediaRequest_h 32 #define UserMediaRequest_h 33 34 #include "core/dom/ActiveDOMObject.h" 35 #include "modules/mediastream/NavigatorUserMediaErrorCallback.h" 36 #include "modules/mediastream/NavigatorUserMediaSuccessCallback.h" 37 #include "platform/mediastream/MediaStreamSource.h" 38 #include "public/platform/WebMediaConstraints.h" 39 #include "wtf/PassRefPtr.h" 40 #include "wtf/RefCounted.h" 41 #include "wtf/text/WTFString.h" 42 43 namespace WebCore { 44 45 class Dictionary; 46 class Document; 47 class ExceptionState; 48 class MediaStreamDescriptor; 49 class UserMediaController; 50 51 class UserMediaRequest FINAL : public RefCountedWillBeGarbageCollectedFinalized<UserMediaRequest>, public ContextLifecycleObserver { 52 public: 53 static PassRefPtrWillBeRawPtr<UserMediaRequest> create(ExecutionContext*, UserMediaController*, const Dictionary& options, PassOwnPtr<NavigatorUserMediaSuccessCallback>, PassOwnPtr<NavigatorUserMediaErrorCallback>, ExceptionState&); 54 virtual ~UserMediaRequest(); 55 successCallback()56 NavigatorUserMediaSuccessCallback* successCallback() const { return m_successCallback.get(); } errorCallback()57 NavigatorUserMediaErrorCallback* errorCallback() const { return m_errorCallback.get(); } 58 Document* ownerDocument(); 59 60 void start(); 61 62 void succeed(PassRefPtr<MediaStreamDescriptor>); 63 void failPermissionDenied(const String& message); 64 void failConstraint(const String& constraintName, const String& message); 65 void failUASpecific(const String& name, const String& message, const String& constraintName); 66 67 bool audio() const; 68 bool video() const; 69 blink::WebMediaConstraints audioConstraints() const; 70 blink::WebMediaConstraints videoConstraints() const; 71 72 // ContextLifecycleObserver 73 virtual void contextDestroyed() OVERRIDE; 74 trace(Visitor *)75 void trace(Visitor*) { } 76 77 private: 78 UserMediaRequest(ExecutionContext*, UserMediaController*, blink::WebMediaConstraints audio, blink::WebMediaConstraints video, PassOwnPtr<NavigatorUserMediaSuccessCallback>, PassOwnPtr<NavigatorUserMediaErrorCallback>); 79 80 blink::WebMediaConstraints m_audio; 81 blink::WebMediaConstraints m_video; 82 83 UserMediaController* m_controller; 84 85 OwnPtr<NavigatorUserMediaSuccessCallback> m_successCallback; 86 OwnPtr<NavigatorUserMediaErrorCallback> m_errorCallback; 87 }; 88 89 } // namespace WebCore 90 91 #endif // UserMediaRequest_h 92