OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_MEDIA_IMAGE_CAPTURE_FRAME_GRABBER_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_IMAGE_CAPTURE_FRAME_GRABBER_H_ |
| 7 |
| 8 #include "base/compiler_specific.h" |
| 9 #include "base/macros.h" |
| 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/threading/thread_checker.h" |
| 12 #include "content/child/scoped_web_callbacks.h" |
| 13 #include "content/common/content_export.h" |
| 14 #include "content/public/renderer/media_stream_video_sink.h" |
| 15 #include "third_party/WebKit/public/platform/WebImageCaptureFrameGrabber.h" |
| 16 |
| 17 namespace blink { |
| 18 class WebMediaStreamTrack; |
| 19 } |
| 20 |
| 21 namespace media { |
| 22 class VideoFrame; |
| 23 } |
| 24 |
| 25 namespace content { |
| 26 |
| 27 // This class grabs Video Frames from a given Media Stream Video Track, binding |
| 28 // a function every time grabFrame() is called. This function receives an |
| 29 // incoming VideoFrame on a background thread and converts it into the |
| 30 // appropriate SkBitmap which is sent back to OnSkBitmap(). This class is single |
| 31 // threaded throughout. |
| 32 class CONTENT_EXPORT ImageCaptureFrameGrabber final |
| 33 : NON_EXPORTED_BASE(public blink::WebImageCaptureFrameGrabber), |
| 34 NON_EXPORTED_BASE(public MediaStreamVideoSink) { |
| 35 public: |
| 36 using SkImageDeliverCB = base::Callback<void(sk_sp<SkImage>)>; |
| 37 |
| 38 ImageCaptureFrameGrabber(); |
| 39 ~ImageCaptureFrameGrabber() override; |
| 40 |
| 41 // blink::WebImageCaptureFrameGrabber implementation. |
| 42 void grabFrame(blink::WebMediaStreamTrack* track, |
| 43 blink::WebImageCaptureGrabFrameCallbacks* callbacks) override; |
| 44 |
| 45 private: |
| 46 void OnSkImage( |
| 47 ScopedWebCallbacks<blink::WebImageCaptureGrabFrameCallbacks> callbacks, |
| 48 sk_sp<SkImage> image); |
| 49 |
| 50 base::ThreadChecker thread_checker_; |
| 51 base::WeakPtrFactory<ImageCaptureFrameGrabber> weak_factory_; |
| 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(ImageCaptureFrameGrabber); |
| 54 }; |
| 55 |
| 56 } // namespace content |
| 57 |
| 58 #endif // CONTENT_RENDERER_MEDIA_IMAGE_CAPTURE_FRAME_GRABBER_H_ |
OLD | NEW |