| 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 "modules/mediastream/MediaTrackConstraintSet.h" |
| 17 #include "platform/AsyncMethodRunner.h" | 18 #include "platform/AsyncMethodRunner.h" |
| 18 | 19 |
| 19 namespace blink { | 20 namespace blink { |
| 20 | 21 |
| 21 class ExceptionState; | 22 class ExceptionState; |
| 22 class MediaStreamTrack; | 23 class MediaStreamTrack; |
| 23 class MediaTrackConstraintSet; | |
| 24 class PhotoSettings; | 24 class PhotoSettings; |
| 25 class ScriptPromiseResolver; | 25 class ScriptPromiseResolver; |
| 26 class WebImageCaptureFrameGrabber; | 26 class WebImageCaptureFrameGrabber; |
| 27 | 27 |
| 28 // TODO(mcasas): Consideradding a LayoutTest checking that this class is not | 28 // TODO(mcasas): Consideradding a LayoutTest checking that this class is not |
| 29 // garbage collected while it has event listeners. | 29 // garbage collected while it has event listeners. |
| 30 class MODULES_EXPORT ImageCapture final | 30 class MODULES_EXPORT ImageCapture final |
| 31 : public EventTargetWithInlineData, | 31 : public EventTargetWithInlineData, |
| 32 public ActiveScriptWrappable<ImageCapture>, | 32 public ActiveScriptWrappable<ImageCapture>, |
| 33 public ContextLifecycleObserver { | 33 public ContextLifecycleObserver { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 57 ScriptPromise setOptions(ScriptState*, const PhotoSettings&); | 57 ScriptPromise setOptions(ScriptState*, const PhotoSettings&); |
| 58 | 58 |
| 59 ScriptPromise takePhoto(ScriptState*); | 59 ScriptPromise takePhoto(ScriptState*); |
| 60 | 60 |
| 61 ScriptPromise grabFrame(ScriptState*); | 61 ScriptPromise grabFrame(ScriptState*); |
| 62 | 62 |
| 63 MediaTrackCapabilities& getMediaTrackCapabilities(); | 63 MediaTrackCapabilities& getMediaTrackCapabilities(); |
| 64 | 64 |
| 65 void setMediaTrackConstraints(ScriptPromiseResolver*, | 65 void setMediaTrackConstraints(ScriptPromiseResolver*, |
| 66 const MediaTrackConstraintSet&); | 66 const MediaTrackConstraintSet&); |
| 67 const MediaTrackConstraintSet& getMediaTrackConstraints() const; |
| 67 | 68 |
| 68 DECLARE_VIRTUAL_TRACE(); | 69 DECLARE_VIRTUAL_TRACE(); |
| 69 | 70 |
| 70 private: | 71 private: |
| 71 ImageCapture(ExecutionContext*, MediaStreamTrack*); | 72 ImageCapture(ExecutionContext*, MediaStreamTrack*); |
| 72 | 73 |
| 73 void onCapabilities(ScriptPromiseResolver*, | 74 void onCapabilities(ScriptPromiseResolver*, |
| 74 media::mojom::blink::PhotoCapabilitiesPtr); | 75 media::mojom::blink::PhotoCapabilitiesPtr); |
| 75 void onSetOptions(ScriptPromiseResolver*, bool); | 76 void onSetOptions(ScriptPromiseResolver*, bool); |
| 76 void onTakePhoto(ScriptPromiseResolver*, media::mojom::blink::BlobPtr); | 77 void onTakePhoto(ScriptPromiseResolver*, media::mojom::blink::BlobPtr); |
| 77 void onCapabilitiesBootstrap(media::mojom::blink::PhotoCapabilitiesPtr); | 78 void onCapabilitiesBootstrap(media::mojom::blink::PhotoCapabilitiesPtr); |
| 78 void onServiceConnectionError(); | 79 void onServiceConnectionError(); |
| 79 | 80 |
| 80 Member<MediaStreamTrack> m_streamTrack; | 81 Member<MediaStreamTrack> m_streamTrack; |
| 81 std::unique_ptr<WebImageCaptureFrameGrabber> m_frameGrabber; | 82 std::unique_ptr<WebImageCaptureFrameGrabber> m_frameGrabber; |
| 82 media::mojom::blink::ImageCapturePtr m_service; | 83 media::mojom::blink::ImageCapturePtr m_service; |
| 83 MediaTrackCapabilities m_capabilities; | 84 MediaTrackCapabilities m_capabilities; |
| 84 | 85 |
| 86 MediaTrackConstraintSet m_currentConstraints; |
| 87 |
| 85 HeapHashSet<Member<ScriptPromiseResolver>> m_serviceRequests; | 88 HeapHashSet<Member<ScriptPromiseResolver>> m_serviceRequests; |
| 86 }; | 89 }; |
| 87 | 90 |
| 88 } // namespace blink | 91 } // namespace blink |
| 89 | 92 |
| 90 #endif // ImageCapture_h | 93 #endif // ImageCapture_h |
| OLD | NEW |