| 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 #include "content/renderer/media/image_capture_frame_grabber.h" | 5 #include "content/renderer/media/image_capture_frame_grabber.h" |
| 6 | 6 |
| 7 #include "media/base/bind_to_current_loop.h" | 7 #include "media/base/bind_to_current_loop.h" |
| 8 #include "media/base/video_frame.h" | 8 #include "media/base/video_frame.h" |
| 9 #include "media/base/video_util.h" | 9 #include "media/base/video_util.h" |
| 10 #include "skia/ext/platform_canvas.h" | 10 #include "skia/ext/platform_canvas.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 make_scoped_web_callbacks(callbacks, base::Bind(&OnError)); | 95 make_scoped_web_callbacks(callbacks, base::Bind(&OnError)); |
| 96 | 96 |
| 97 // ConnectToTrack() must happen on render's Main Thread, whereas VideoFrames | 97 // ConnectToTrack() must happen on render's Main Thread, whereas VideoFrames |
| 98 // are delivered on a background thread though, so we Bind the callback to our | 98 // are delivered on a background thread though, so we Bind the callback to our |
| 99 // current thread. | 99 // current thread. |
| 100 MediaStreamVideoSink::ConnectToTrack( | 100 MediaStreamVideoSink::ConnectToTrack( |
| 101 *track, | 101 *track, |
| 102 base::Bind(&OnVideoFrame, media::BindToCurrentLoop(base::Bind( | 102 base::Bind(&OnVideoFrame, media::BindToCurrentLoop(base::Bind( |
| 103 &ImageCaptureFrameGrabber::OnSkImage, | 103 &ImageCaptureFrameGrabber::OnSkImage, |
| 104 weak_factory_.GetWeakPtr(), | 104 weak_factory_.GetWeakPtr(), |
| 105 base::Passed(&scoped_callbacks))))); | 105 base::Passed(&scoped_callbacks)))), |
| 106 false); |
| 106 } | 107 } |
| 107 | 108 |
| 108 void ImageCaptureFrameGrabber::OnSkImage( | 109 void ImageCaptureFrameGrabber::OnSkImage( |
| 109 ScopedWebCallbacks<WebImageCaptureGrabFrameCallbacks> callbacks, | 110 ScopedWebCallbacks<WebImageCaptureGrabFrameCallbacks> callbacks, |
| 110 sk_sp<SkImage> image) { | 111 sk_sp<SkImage> image) { |
| 111 DVLOG(1) << __FUNCTION__; | 112 DVLOG(1) << __FUNCTION__; |
| 112 DCHECK(thread_checker_.CalledOnValidThread()); | 113 DCHECK(thread_checker_.CalledOnValidThread()); |
| 113 | 114 |
| 114 MediaStreamVideoSink::DisconnectFromTrack(); | 115 MediaStreamVideoSink::DisconnectFromTrack(); |
| 115 if (image) | 116 if (image) |
| 116 callbacks.PassCallbacks()->onSuccess(image); | 117 callbacks.PassCallbacks()->onSuccess(image); |
| 117 else | 118 else |
| 118 callbacks.PassCallbacks()->onError(); | 119 callbacks.PassCallbacks()->onError(); |
| 119 } | 120 } |
| 120 | 121 |
| 121 } // namespace content | 122 } // namespace content |
| OLD | NEW |