2 * Copyright (C) 2011 Ericsson AB. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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
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.
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.
31 #ifndef UserMediaRequest_h
32 #define UserMediaRequest_h
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/Forward.h"
40 #include "wtf/PassRefPtr.h"
47 class MediaStreamDescriptor;
48 class UserMediaController;
50 class UserMediaRequest final : public GarbageCollectedFinalized<UserMediaRequest>, public ContextLifecycleObserver {
52 static UserMediaRequest* create(ExecutionContext*, UserMediaController*, const Dictionary& options, NavigatorUserMediaSuccessCallback*, NavigatorUserMediaErrorCallback*, ExceptionState&);
53 virtual ~UserMediaRequest();
55 NavigatorUserMediaSuccessCallback* successCallback() const { return m_successCallback.get(); }
56 NavigatorUserMediaErrorCallback* errorCallback() const { return m_errorCallback.get(); }
57 Document* ownerDocument();
61 void succeed(PassRefPtr<MediaStreamDescriptor>);
62 void failPermissionDenied(const String& message);
63 void failConstraint(const String& constraintName, const String& message);
64 void failUASpecific(const String& name, const String& message, const String& constraintName);
68 WebMediaConstraints audioConstraints() const;
69 WebMediaConstraints videoConstraints() const;
71 // ContextLifecycleObserver
72 virtual void contextDestroyed() override;
77 UserMediaRequest(ExecutionContext*, UserMediaController*, WebMediaConstraints audio, WebMediaConstraints video, NavigatorUserMediaSuccessCallback*, NavigatorUserMediaErrorCallback*);
79 WebMediaConstraints m_audio;
80 WebMediaConstraints m_video;
82 UserMediaController* m_controller;
84 Member<NavigatorUserMediaSuccessCallback> m_successCallback;
85 Member<NavigatorUserMediaErrorCallback> m_errorCallback;
90 #endif // UserMediaRequest_h