blob: 6aa2ce51733b0c01ea8d5187ace63865a2d32571 [file] [log] [blame]
jlmiller@webrtc.org5f93d0a2015-01-20 21:36:131/*
kjellander1afca732016-02-08 04:46:452 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
jlmiller@webrtc.org5f93d0a2015-01-20 21:36:133 *
kjellander1afca732016-02-08 04:46:454 * 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.org5f93d0a2015-01-20 21:36:139 */
buildbot@webrtc.org4f0d4012014-08-07 04:47:3610
kjellandera96e2d72016-02-05 07:52:2811#ifndef WEBRTC_MEDIA_BASE_VIDEOFRAMEFACTORY_H_
12#define WEBRTC_MEDIA_BASE_VIDEOFRAMEFACTORY_H_
buildbot@webrtc.org4f0d4012014-08-07 04:47:3613
kwiberg686a8ef2016-02-26 11:00:3514#include <memory>
15
kjellandera96e2d72016-02-05 07:52:2816#include "webrtc/media/base/videoframe.h"
magjed@webrtc.orgf58b4552014-11-19 18:09:1417
buildbot@webrtc.org4f0d4012014-08-07 04:47:3618namespace cricket {
19
20struct CapturedFrame;
21class VideoFrame;
22
23// Creates cricket::VideoFrames, or a subclass of cricket::VideoFrame
24// depending on the subclass of VideoFrameFactory.
25class VideoFrameFactory {
26 public:
deadbeeff5629ad2016-03-18 18:38:2627 VideoFrameFactory() : apply_rotation_(false) {}
buildbot@webrtc.org4f0d4012014-08-07 04:47:3628 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.org2386d6d2015-03-05 14:03:0832 // occur. Returns NULL if conversion fails.
magjed@webrtc.orgf58b4552014-11-19 18:09:1433
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.org2386d6d2015-03-05 14:03:0842 // |output_height|.
magjed@webrtc.orgf58b4552014-11-19 18:09:1443 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.org1226e922015-02-11 18:37:5449 void SetApplyRotation(bool enable) { apply_rotation_ = enable; }
50
51 protected:
52 bool apply_rotation_;
53
magjed@webrtc.orgf58b4552014-11-19 18:09:1454 private:
55 // An internal frame buffer to avoid reallocations. It is mutable because it
56 // does not affect behaviour, only performance.
kwiberg686a8ef2016-02-26 11:00:3557 mutable std::unique_ptr<VideoFrame> output_frame_;
buildbot@webrtc.org4f0d4012014-08-07 04:47:3658};
59
60} // namespace cricket
61
kjellandera96e2d72016-02-05 07:52:2862#endif // WEBRTC_MEDIA_BASE_VIDEOFRAMEFACTORY_H_