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