Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(773)

Unified Diff: third_party/WebKit/Source/modules/imagecapture/ImageCapture.cpp

Issue 1899403002: MediaStream Image Capture (2): Platform::ImageCaptureFrameGrabber and grabFrame() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reillyg@ comments and made SkBitmap immutable Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/imagecapture/ImageCapture.cpp
diff --git a/third_party/WebKit/Source/modules/imagecapture/ImageCapture.cpp b/third_party/WebKit/Source/modules/imagecapture/ImageCapture.cpp
index b900c515a35b7254993b5b328094b64835464a21..a819ee0b95e3fbcf59542f8f6ffc8e72487bd578 100644
--- a/third_party/WebKit/Source/modules/imagecapture/ImageCapture.cpp
+++ b/third_party/WebKit/Source/modules/imagecapture/ImageCapture.cpp
@@ -4,12 +4,17 @@
#include "modules/imagecapture/ImageCapture.h"
+#include "bindings/core/v8/CallbackPromiseAdapter.h"
#include "bindings/core/v8/ScriptPromiseResolver.h"
#include "core/dom/DOMException.h"
#include "core/dom/ExceptionCode.h"
+#include "core/frame/ImageBitmap.h"
#include "modules/EventTargetModules.h"
#include "modules/mediastream/MediaStreamTrack.h"
+#include "platform/graphics/StaticBitmapImage.h"
emircan 2016/04/26 19:19:31 Extra?
mcasas 2016/04/27 00:51:29 Done.
#include "public/platform/Platform.h"
+#include "public/platform/WebImageCaptureFrameGrabber.h"
+#include "public/platform/WebMediaStreamTrack.h"
namespace blink {
@@ -60,7 +65,19 @@ ScriptPromise ImageCapture::grabFrame(ScriptState* scriptState, ExceptionState&
return promise;
}
- resolver->reject(DOMException::create(NotSupportedError, "Not implemented yet"));
+ // Create |m_frameGrabber| the first time.
+ if (!m_frameGrabber)
+ m_frameGrabber = adoptPtr(Platform::current()->createImageCaptureFrameGrabber());
+
+ if (!m_frameGrabber) {
emircan 2016/04/26 19:19:31 Can you move this inside the if on l.69? I dont th
mcasas 2016/04/27 00:51:29 This a get-or-create snippet, right? The first ti
+ resolver->reject(DOMException::create(UnknownError, "Couldn't create platform resources"));
+ return promise;
+ }
+
+ // The platform does not know about MediaStreamTrack, so we wrap it up.
+ WebMediaStreamTrack track(m_streamTrack->component());
+ m_frameGrabber->grabFrame(&track, new CallbackPromiseAdapter<ImageBitmap, void>(resolver));
+
return promise;
}

Powered by Google App Engine
This is Rietveld 408576698