Chromium Code Reviews| Index: content/browser/renderer_host/media/screen_capturer.h |
| diff --git a/content/browser/renderer_host/media/screen_capturer.h b/content/browser/renderer_host/media/screen_capturer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c3a9bb51bc3b28d1118448f4bd44bf58b5058fbe |
| --- /dev/null |
| +++ b/content/browser/renderer_host/media/screen_capturer.h |
| @@ -0,0 +1,81 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_SCREEN_CAPTURER_H_ |
| +#define CONTENT_BROWSER_RENDERER_HOST_MEDIA_SCREEN_CAPTURER_H_ |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/threading/thread.h" |
| +#include "base/timer.h" |
| +#include "content/common/content_export.h" |
| +#include "media/video/capture/video_capture_device.h" |
| +#include "remoting/capturer/video_frame_capturer.h" |
| +#include "third_party/skia/include/core/SkBitmap.h" |
| + |
| +namespace content { |
| + |
| +class CONTENT_EXPORT ScreenCapturer |
| + : public media::VideoCaptureDevice, |
| + public NON_EXPORTED_BASE(remoting::VideoFrameCapturer::Delegate) { |
| + public: |
| + |
| + ScreenCapturer(); |
| + virtual ~ScreenCapturer(); |
| + |
| + // Helper used in tests to supply a fake capturer. |
| + void set_test_frame_capturer( |
| + scoped_ptr<remoting::VideoFrameCapturer> capturer) { |
| + video_frame_capturer_ = capturer.Pass(); |
| + } |
| + |
| + // media::VideoCaptureDevice interface. |
| + virtual void Allocate(int width, int height, |
| + int frame_rate, |
| + EventHandler* event_handler) OVERRIDE; |
| + virtual void Start() OVERRIDE; |
| + virtual void Stop() OVERRIDE; |
| + virtual void DeAllocate() OVERRIDE; |
| + virtual const Name& device_name() OVERRIDE; |
| + |
| + // VideoFrameCapturer::Delegate interface. |
|
Wez
2013/01/10 00:58:14
nit: Add a comment to clarify that these run on th
Sergey Ulanov
2013/01/11 23:46:20
Done.
|
| + virtual void OnCaptureCompleted( |
| + scoped_refptr<remoting::CaptureData> capture_data) OVERRIDE; |
| + virtual void OnCursorShapeChanged( |
| + scoped_ptr<remoting::MouseCursorShape> cursor_shape) OVERRIDE; |
| + |
| + private: |
| + // Helper methods that run on the |capture_thread_|. |
| + void DoAllocate(int frame_rate, EventHandler* event_handler); |
|
Wez
2013/01/10 00:58:14
Could you fold these helpers into the calls themse
Sergey Ulanov
2013/01/11 23:46:20
Don't think I can use trampoline approach with wor
|
| + void DoStart(); |
| + void DoStop(); |
| + void DoDeAllocate(); |
| + void DoCapture(); |
|
Wez
2013/01/10 00:58:14
Add a separate comment for DoCapture() to explain
Sergey Ulanov
2013/01/11 23:46:20
Done.
|
| + |
| + base::Thread capture_thread_; |
|
Wez
2013/01/10 00:58:14
You're relying on |capture_thread_| stopping durin
Sergey Ulanov
2013/01/11 23:46:20
Removed the thread. Now using worker pool.
|
| + |
| + Name name_; |
| + EventHandler* event_handler_; |
| + int frame_rate_; |
|
Wez
2013/01/10 00:58:14
Add a comment to indicate that these are parameter
Sergey Ulanov
2013/01/11 23:46:20
Done.
|
| + |
| + scoped_ptr<remoting::VideoFrameCapturer> video_frame_capturer_; |
| + bool capture_pending_; |
|
Wez
2013/01/10 00:58:14
Add comments to state explicitly what these are fo
Sergey Ulanov
2013/01/11 23:46:20
Done.
|
| + |
| + // After Allocate() is called we need to call OnFrameInfo() method of the |
| + // |evant_handler_| to specify the size of the frames this capturer will |
|
Wez
2013/01/10 00:58:14
typo: event_handler
Sergey Ulanov
2013/01/11 23:46:20
Done.
|
| + // produce. In order to get screen size from |video_frame_capturer_| we need |
| + // to capture at least one frame. Once screen size is known it's stored in |
| + // |frame_size_|. |
| + bool waiting_frame_size_; |
|
Wez
2013/01/10 00:58:14
Can't you indicate this implicitly via |frame_size
Sergey Ulanov
2013/01/11 23:46:20
It's better to have an explicit flag, e.g. for the
|
| + SkISize frame_size_; |
| + SkBitmap resized_bitmap_; |
| + |
| + scoped_ptr<base::RepeatingTimer<ScreenCapturer> > timer_; |
|
Wez
2013/01/10 00:58:14
Add comment to explain this, e.g. why it needs to
Sergey Ulanov
2013/01/11 23:46:20
Not using timer anymore.
|
| + bool started_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ScreenCapturer); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_SCREEN_CAPTURER_H_ |