OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ImageCapture_h | 5 #ifndef ImageCapture_h |
6 #define ImageCapture_h | 6 #define ImageCapture_h |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include "bindings/core/v8/ActiveScriptWrappable.h" | 9 #include "bindings/core/v8/ActiveScriptWrappable.h" |
10 #include "bindings/core/v8/ScriptPromise.h" | 10 #include "bindings/core/v8/ScriptPromise.h" |
11 #include "core/dom/ContextLifecycleObserver.h" | 11 #include "core/dom/ContextLifecycleObserver.h" |
12 #include "core/events/EventTarget.h" | 12 #include "core/events/EventTarget.h" |
13 #include "media/capture/mojo/image_capture.mojom-blink.h" | 13 #include "media/capture/mojo/image_capture.mojom-blink.h" |
14 #include "modules/EventTargetModules.h" | 14 #include "modules/EventTargetModules.h" |
15 #include "modules/ModulesExport.h" | 15 #include "modules/ModulesExport.h" |
16 #include "modules/mediastream/MediaTrackCapabilities.h" | 16 #include "modules/mediastream/MediaTrackCapabilities.h" |
17 #include "platform/AsyncMethodRunner.h" | 17 #include "platform/AsyncMethodRunner.h" |
18 | 18 |
19 namespace blink { | 19 namespace blink { |
20 | 20 |
21 class ExceptionState; | 21 class ExceptionState; |
22 class MediaStreamTrack; | 22 class MediaStreamTrack; |
| 23 class MediaTrackConstraintSet; |
23 class PhotoSettings; | 24 class PhotoSettings; |
24 class ScriptPromiseResolver; | 25 class ScriptPromiseResolver; |
25 class WebImageCaptureFrameGrabber; | 26 class WebImageCaptureFrameGrabber; |
26 | 27 |
27 // TODO(mcasas): Consideradding a LayoutTest checking that this class is not | 28 // TODO(mcasas): Consideradding a LayoutTest checking that this class is not |
28 // garbage collected while it has event listeners. | 29 // garbage collected while it has event listeners. |
29 class MODULES_EXPORT ImageCapture final | 30 class MODULES_EXPORT ImageCapture final |
30 : public EventTargetWithInlineData, | 31 : public EventTargetWithInlineData, |
31 public ActiveScriptWrappable<ImageCapture>, | 32 public ActiveScriptWrappable<ImageCapture>, |
32 public ContextLifecycleObserver { | 33 public ContextLifecycleObserver { |
(...skipping 11 matching lines...) Expand all Loading... |
44 ExecutionContext* getExecutionContext() const override; | 45 ExecutionContext* getExecutionContext() const override; |
45 | 46 |
46 // ScriptWrappable implementation. | 47 // ScriptWrappable implementation. |
47 bool hasPendingActivity() const final; | 48 bool hasPendingActivity() const final; |
48 | 49 |
49 // ContextLifecycleObserver | 50 // ContextLifecycleObserver |
50 void contextDestroyed(ExecutionContext*) override; | 51 void contextDestroyed(ExecutionContext*) override; |
51 | 52 |
52 MediaStreamTrack* videoStreamTrack() const { return m_streamTrack.get(); } | 53 MediaStreamTrack* videoStreamTrack() const { return m_streamTrack.get(); } |
53 | 54 |
54 ScriptPromise getPhotoCapabilities(ScriptState*, ExceptionState&); | 55 ScriptPromise getPhotoCapabilities(ScriptState*); |
55 | 56 |
56 ScriptPromise setOptions(ScriptState*, const PhotoSettings&, ExceptionState&); | 57 ScriptPromise setOptions(ScriptState*, const PhotoSettings&); |
57 | 58 |
58 ScriptPromise takePhoto(ScriptState*, ExceptionState&); | 59 ScriptPromise takePhoto(ScriptState*); |
59 | 60 |
60 ScriptPromise grabFrame(ScriptState*, ExceptionState&); | 61 ScriptPromise grabFrame(ScriptState*); |
61 | 62 |
62 MediaTrackCapabilities& getMediaTrackCapabilities(); | 63 MediaTrackCapabilities& getMediaTrackCapabilities(); |
63 | 64 |
| 65 void setMediaTrackConstraints(ScriptPromiseResolver*, |
| 66 const MediaTrackConstraintSet&); |
| 67 |
64 DECLARE_VIRTUAL_TRACE(); | 68 DECLARE_VIRTUAL_TRACE(); |
65 | 69 |
66 private: | 70 private: |
67 ImageCapture(ExecutionContext*, MediaStreamTrack*); | 71 ImageCapture(ExecutionContext*, MediaStreamTrack*); |
68 | 72 |
69 void onCapabilities(ScriptPromiseResolver*, | 73 void onCapabilities(ScriptPromiseResolver*, |
70 media::mojom::blink::PhotoCapabilitiesPtr); | 74 media::mojom::blink::PhotoCapabilitiesPtr); |
71 void onSetOptions(ScriptPromiseResolver*, bool); | 75 void onSetOptions(ScriptPromiseResolver*, bool); |
72 void onTakePhoto(ScriptPromiseResolver*, media::mojom::blink::BlobPtr); | 76 void onTakePhoto(ScriptPromiseResolver*, media::mojom::blink::BlobPtr); |
73 void onCapabilitiesBootstrap(media::mojom::blink::PhotoCapabilitiesPtr); | 77 void onCapabilitiesBootstrap(media::mojom::blink::PhotoCapabilitiesPtr); |
74 void onServiceConnectionError(); | 78 void onServiceConnectionError(); |
75 | 79 |
76 Member<MediaStreamTrack> m_streamTrack; | 80 Member<MediaStreamTrack> m_streamTrack; |
77 std::unique_ptr<WebImageCaptureFrameGrabber> m_frameGrabber; | 81 std::unique_ptr<WebImageCaptureFrameGrabber> m_frameGrabber; |
78 media::mojom::blink::ImageCapturePtr m_service; | 82 media::mojom::blink::ImageCapturePtr m_service; |
79 MediaTrackCapabilities m_capabilities; | 83 MediaTrackCapabilities m_capabilities; |
80 | 84 |
81 HeapHashSet<Member<ScriptPromiseResolver>> m_serviceRequests; | 85 HeapHashSet<Member<ScriptPromiseResolver>> m_serviceRequests; |
82 }; | 86 }; |
83 | 87 |
84 } // namespace blink | 88 } // namespace blink |
85 | 89 |
86 #endif // ImageCapture_h | 90 #endif // ImageCapture_h |
OLD | NEW |