jlmiller@webrtc.org | 5f93d0a | 2015-01-20 21:36:13 | [diff] [blame] | 1 | /* |
kjellander | 1afca73 | 2016-02-08 04:46:45 | [diff] [blame] | 2 | * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
jlmiller@webrtc.org | 5f93d0a | 2015-01-20 21:36:13 | [diff] [blame] | 3 | * |
kjellander | 1afca73 | 2016-02-08 04:46:45 | [diff] [blame] | 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
jlmiller@webrtc.org | 5f93d0a | 2015-01-20 21:36:13 | [diff] [blame] | 9 | */ |
buildbot@webrtc.org | 4f0d401 | 2014-08-07 04:47:36 | [diff] [blame] | 10 | |
kjellander | a96e2d7 | 2016-02-05 07:52:28 | [diff] [blame] | 11 | #ifndef WEBRTC_MEDIA_BASE_VIDEOFRAMEFACTORY_H_ |
| 12 | #define WEBRTC_MEDIA_BASE_VIDEOFRAMEFACTORY_H_ |
buildbot@webrtc.org | 4f0d401 | 2014-08-07 04:47:36 | [diff] [blame] | 13 | |
kwiberg | 686a8ef | 2016-02-26 11:00:35 | [diff] [blame] | 14 | #include <memory> |
| 15 | |
kjellander | a96e2d7 | 2016-02-05 07:52:28 | [diff] [blame] | 16 | #include "webrtc/media/base/videoframe.h" |
magjed@webrtc.org | f58b455 | 2014-11-19 18:09:14 | [diff] [blame] | 17 | |
buildbot@webrtc.org | 4f0d401 | 2014-08-07 04:47:36 | [diff] [blame] | 18 | namespace cricket { |
| 19 | |
| 20 | struct CapturedFrame; |
| 21 | class VideoFrame; |
| 22 | |
| 23 | // Creates cricket::VideoFrames, or a subclass of cricket::VideoFrame |
| 24 | // depending on the subclass of VideoFrameFactory. |
| 25 | class VideoFrameFactory { |
| 26 | public: |
deadbeef | f5629ad | 2016-03-18 18:38:26 | [diff] [blame] | 27 | VideoFrameFactory() : apply_rotation_(false) {} |
buildbot@webrtc.org | 4f0d401 | 2014-08-07 04:47:36 | [diff] [blame] | 28 | virtual ~VideoFrameFactory() {} |
| 29 | |
| 30 | // The returned frame aliases the aliased_frame if the input color |
| 31 | // space allows for aliasing, otherwise a color conversion will |
magjed@webrtc.org | 2386d6d | 2015-03-05 14:03:08 | [diff] [blame] | 32 | // occur. Returns NULL if conversion fails. |
magjed@webrtc.org | f58b455 | 2014-11-19 18:09:14 | [diff] [blame] | 33 | |
| 34 | // The returned frame will be a center crop of |input_frame| with |
| 35 | // size |cropped_width| x |cropped_height|. |
| 36 | virtual VideoFrame* CreateAliasedFrame(const CapturedFrame* input_frame, |
| 37 | int cropped_width, |
| 38 | int cropped_height) const = 0; |
| 39 | |
| 40 | // The returned frame will be a center crop of |input_frame| with size |
| 41 | // |cropped_width| x |cropped_height|, scaled to |output_width| x |
magjed@webrtc.org | 2386d6d | 2015-03-05 14:03:08 | [diff] [blame] | 42 | // |output_height|. |
magjed@webrtc.org | f58b455 | 2014-11-19 18:09:14 | [diff] [blame] | 43 | virtual VideoFrame* CreateAliasedFrame(const CapturedFrame* input_frame, |
| 44 | int cropped_input_width, |
| 45 | int cropped_input_height, |
| 46 | int output_width, |
| 47 | int output_height) const; |
| 48 | |
guoweis@webrtc.org | 1226e92 | 2015-02-11 18:37:54 | [diff] [blame] | 49 | void SetApplyRotation(bool enable) { apply_rotation_ = enable; } |
| 50 | |
| 51 | protected: |
| 52 | bool apply_rotation_; |
| 53 | |
magjed@webrtc.org | f58b455 | 2014-11-19 18:09:14 | [diff] [blame] | 54 | private: |
| 55 | // An internal frame buffer to avoid reallocations. It is mutable because it |
| 56 | // does not affect behaviour, only performance. |
kwiberg | 686a8ef | 2016-02-26 11:00:35 | [diff] [blame] | 57 | mutable std::unique_ptr<VideoFrame> output_frame_; |
buildbot@webrtc.org | 4f0d401 | 2014-08-07 04:47:36 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | } // namespace cricket |
| 61 | |
kjellander | a96e2d7 | 2016-02-05 07:52:28 | [diff] [blame] | 62 | #endif // WEBRTC_MEDIA_BASE_VIDEOFRAMEFACTORY_H_ |