Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / modules / mediastream / UserMediaRequest.h
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/Forward.h"
40 #include "wtf/PassRefPtr.h"
41
42 namespace blink {
43
44 class Dictionary;
45 class Document;
46 class ExceptionState;
47 class MediaStreamDescriptor;
48 class UserMediaController;
49
50 class UserMediaRequest final : public GarbageCollectedFinalized<UserMediaRequest>, public ContextLifecycleObserver {
51 public:
52     static UserMediaRequest* create(ExecutionContext*, UserMediaController*, const Dictionary& options, NavigatorUserMediaSuccessCallback*, NavigatorUserMediaErrorCallback*, ExceptionState&);
53     virtual ~UserMediaRequest();
54
55     NavigatorUserMediaSuccessCallback* successCallback() const { return m_successCallback.get(); }
56     NavigatorUserMediaErrorCallback* errorCallback() const { return m_errorCallback.get(); }
57     Document* ownerDocument();
58
59     void start();
60
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);
65
66     bool audio() const;
67     bool video() const;
68     WebMediaConstraints audioConstraints() const;
69     WebMediaConstraints videoConstraints() const;
70
71     // ContextLifecycleObserver
72     virtual void contextDestroyed() override;
73
74     void trace(Visitor*);
75
76 private:
77     UserMediaRequest(ExecutionContext*, UserMediaController*, WebMediaConstraints audio, WebMediaConstraints video, NavigatorUserMediaSuccessCallback*, NavigatorUserMediaErrorCallback*);
78
79     WebMediaConstraints m_audio;
80     WebMediaConstraints m_video;
81
82     UserMediaController* m_controller;
83
84     Member<NavigatorUserMediaSuccessCallback> m_successCallback;
85     Member<NavigatorUserMediaErrorCallback> m_errorCallback;
86 };
87
88 } // namespace blink
89
90 #endif // UserMediaRequest_h