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_PORT_BROWSER_RENDER_WIDGET_HOST_VIEW_FRAME_SUBSCRIBER_H_ |
| 6 #define CONTENT_PORT_BROWSER_RENDER_WIDGET_HOST_VIEW_FRAME_SUBSCRIBER_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/time.h" |
| 10 |
| 11 namespace gfx { |
| 12 class Rect; |
| 13 class Size; |
| 14 } // namespace gfx |
| 15 |
| 16 namespace media { |
| 17 class VideoFrame; |
| 18 } // namespace media |
| 19 |
| 20 namespace content { |
| 21 |
| 22 // Defines an interface for listening to events of frame presentation and to |
| 23 // instruct the platform layer (i.e. RenderWidgetHostViewPort) to copy a frame. |
| 24 // |
| 25 // Further processing is possible (e.g. scale and color space conversion) |
| 26 // through this interface. See ShouldCaptureFrame() for details. |
| 27 // |
| 28 // It is platform dependent which thread this object lives on, but it is |
| 29 // guaranteed to be used on a single thread. |
| 30 class RenderWidgetHostViewFrameSubscriber { |
| 31 public: |
| 32 virtual ~RenderWidgetHostViewFrameSubscriber() {} |
| 33 |
| 34 // Called when a captured frame is available or the frame is no longer |
| 35 // needed by the platform layer. |
| 36 // |
| 37 // If |frame_captured| is true then frame provided contains valid content and |
| 38 // |timestamp| is the time when the frame was painted. |
| 39 // |
| 40 // If |frame_captured| is false then the content in frame provided is |
| 41 // invalid. There was an error during the process of frame capture or the |
| 42 // platform layer is shutting down. |timestamp| is also invalid in this case. |
| 43 typedef base::Callback<void( |
| 44 base::Time /* timestamp */, |
| 45 bool /* frame_captured */)> DeliverFrameCallback; |
| 46 |
| 47 // Called when a new frame is going to be presented. Implementation can |
| 48 // decide whether the current frame should be captured or not. |
| 49 // |
| 50 // Return true if the current frame should be captured. If so, |storage| |
| 51 // should will be set to hold an appropriately sized and allocated buffer |
| 52 // into which to copy the frame. The platform presenter will perform scaling |
| 53 // and color space conversion to fit into the output frame. |
| 54 // |
| 55 // Destination format is determined by |storage|, currently only |
| 56 // media::VideoFrame::YV12 is supported. Platform layer will perform color |
| 57 // space conversion if needed. |
| 58 // |
| 59 // When the frame is available |callback| will be called. It is up to the |
| 60 // platform layer to decide when to deliver a captured frame. |
| 61 // |
| 62 // Return false if the current frame should not be captured. |
| 63 virtual bool ShouldCaptureFrame( |
| 64 scoped_refptr<media::VideoFrame>* storage, |
| 65 DeliverFrameCallback* callback) = 0; |
| 66 }; |
| 67 |
| 68 } // namespace content |
| 69 |
| 70 #endif // CONTENT_PORT_BROWSER_RENDER_WIDGET_HOST_VIEW_FRAME_SUBSCRIBER_H_ |
OLD | NEW |