Index: webrtc/media/base/videoframefactory.h |
diff --git a/webrtc/media/base/videoframefactory.h b/webrtc/media/base/videoframefactory.h |
index 6aa2ce51733b0c01ea8d5187ace63865a2d32571..eae40af71c06c56bbe2bd4fa787ad412c64c9d39 100644 |
--- a/webrtc/media/base/videoframefactory.h |
+++ b/webrtc/media/base/videoframefactory.h |
@@ -27,6 +27,21 @@ class VideoFrameFactory { |
VideoFrameFactory() : apply_rotation_(false) {} |
virtual ~VideoFrameFactory() {} |
+ // Convert a CapturedFrame to a VideoFrame. |width| and |height| |
+ // give the desired size, and the factory is expected to first crop |
+ // the frame to get a matching aspect ratio, and then scale it to |
+ // the right size. The size refers the the image before application |
+ // of |input_frame->rotation|. Subclasses usually only need to |
+ // override CreateCroppedAndScaledFrame, see below. |
+ virtual std::unique_ptr<VideoFrame> CreateScaledFrame( |
+ const CapturedFrame* input_frame, |
+ int width, |
+ int height) const; |
+ |
+ // The CreateAliasedFrame methods are deprecated, because we don't |
+ // want raw pointer return types. TODO(nisse): Delete when all users |
+ // are updated. |
+ |
// The returned frame aliases the aliased_frame if the input color |
// space allows for aliasing, otherwise a color conversion will |
// occur. Returns NULL if conversion fails. |
@@ -35,8 +50,11 @@ class VideoFrameFactory { |
// size |cropped_width| x |cropped_height|. |
virtual VideoFrame* CreateAliasedFrame(const CapturedFrame* input_frame, |
int cropped_width, |
- int cropped_height) const = 0; |
- |
+ int cropped_height) const { |
+ // Dummy default implementation, to make it easier to delete in |
+ // subclasses. |
+ return nullptr; |
+ } |
// The returned frame will be a center crop of |input_frame| with size |
// |cropped_width| x |cropped_height|, scaled to |output_width| x |
// |output_height|. |
@@ -49,6 +67,20 @@ class VideoFrameFactory { |
void SetApplyRotation(bool enable) { apply_rotation_ = enable; } |
protected: |
+ // Similar to CreateScaledFrame, but gets cropping parameters as |
+ // inputs, and relies on the caller to choose them so that aspect |
+ // ratio is preserved. Extracts a rectangle of size |crop_width| x |
+ // |crop_height| in the input frame, with lower left corner at |
+ // |crop_x|, |crop_y|. |
+ virtual std::unique_ptr<VideoFrame> CreateCroppedAndScaledFrame( |
+ const CapturedFrame* input_frame, |
+ int crop_x, |
+ int crop_y, |
+ int crop_width, |
+ int crop_height, |
+ int dst_width, |
+ int dst_height) const; |
+ |
bool apply_rotation_; |
private: |