Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 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_BROWSER_RENDERER_HOST_MEDIA_SCREEN_CAPTURER_H_ | |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_SCREEN_CAPTURER_H_ | |
| 7 | |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "base/threading/thread.h" | |
| 10 #include "base/timer.h" | |
| 11 #include "content/common/content_export.h" | |
| 12 #include "media/video/capture/video_capture_device.h" | |
| 13 #include "remoting/capturer/video_frame_capturer.h" | |
| 14 #include "third_party/skia/include/core/SkBitmap.h" | |
| 15 | |
| 16 namespace content { | |
| 17 | |
| 18 class CONTENT_EXPORT ScreenCapturer | |
| 19 : public media::VideoCaptureDevice, | |
| 20 public NON_EXPORTED_BASE(remoting::VideoFrameCapturer::Delegate) { | |
| 21 public: | |
| 22 | |
| 23 ScreenCapturer(); | |
| 24 virtual ~ScreenCapturer(); | |
| 25 | |
| 26 // Helper used in tests to supply a fake capturer. | |
| 27 void set_test_frame_capturer( | |
| 28 scoped_ptr<remoting::VideoFrameCapturer> capturer) { | |
| 29 video_frame_capturer_ = capturer.Pass(); | |
| 30 } | |
| 31 | |
| 32 // media::VideoCaptureDevice interface. | |
| 33 virtual void Allocate(int width, int height, | |
| 34 int frame_rate, | |
| 35 EventHandler* event_handler) OVERRIDE; | |
| 36 virtual void Start() OVERRIDE; | |
| 37 virtual void Stop() OVERRIDE; | |
| 38 virtual void DeAllocate() OVERRIDE; | |
| 39 virtual const Name& device_name() OVERRIDE; | |
| 40 | |
| 41 // 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.
| |
| 42 virtual void OnCaptureCompleted( | |
| 43 scoped_refptr<remoting::CaptureData> capture_data) OVERRIDE; | |
| 44 virtual void OnCursorShapeChanged( | |
| 45 scoped_ptr<remoting::MouseCursorShape> cursor_shape) OVERRIDE; | |
| 46 | |
| 47 private: | |
| 48 // Helper methods that run on the |capture_thread_|. | |
| 49 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
| |
| 50 void DoStart(); | |
| 51 void DoStop(); | |
| 52 void DoDeAllocate(); | |
| 53 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.
| |
| 54 | |
| 55 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.
| |
| 56 | |
| 57 Name name_; | |
| 58 EventHandler* event_handler_; | |
| 59 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.
| |
| 60 | |
| 61 scoped_ptr<remoting::VideoFrameCapturer> video_frame_capturer_; | |
| 62 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.
| |
| 63 | |
| 64 // After Allocate() is called we need to call OnFrameInfo() method of the | |
| 65 // |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.
| |
| 66 // produce. In order to get screen size from |video_frame_capturer_| we need | |
| 67 // to capture at least one frame. Once screen size is known it's stored in | |
| 68 // |frame_size_|. | |
| 69 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
| |
| 70 SkISize frame_size_; | |
| 71 SkBitmap resized_bitmap_; | |
| 72 | |
| 73 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.
| |
| 74 bool started_; | |
| 75 | |
| 76 DISALLOW_COPY_AND_ASSIGN(ScreenCapturer); | |
| 77 }; | |
| 78 | |
| 79 } // namespace content | |
| 80 | |
| 81 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_SCREEN_CAPTURER_H_ | |
| OLD | NEW |