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