OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MEDIA_BASE_VIDEOFRAMEFACTORY_H_ | 11 #ifndef WEBRTC_MEDIA_BASE_VIDEOFRAMEFACTORY_H_ |
12 #define WEBRTC_MEDIA_BASE_VIDEOFRAMEFACTORY_H_ | 12 #define WEBRTC_MEDIA_BASE_VIDEOFRAMEFACTORY_H_ |
13 | 13 |
14 #include <memory> | 14 #include <memory> |
15 | 15 |
16 #include "webrtc/media/base/videoframe.h" | 16 #include "webrtc/media/base/videoframe.h" |
17 | 17 |
18 namespace cricket { | 18 namespace cricket { |
19 | 19 |
20 struct CapturedFrame; | 20 struct CapturedFrame; |
21 class VideoFrame; | 21 class VideoFrame; |
22 | 22 |
23 // Creates cricket::VideoFrames, or a subclass of cricket::VideoFrame | 23 // Creates cricket::VideoFrames, or a subclass of cricket::VideoFrame |
24 // depending on the subclass of VideoFrameFactory. | 24 // depending on the subclass of VideoFrameFactory. |
25 class VideoFrameFactory { | 25 class VideoFrameFactory { |
26 public: | 26 public: |
27 VideoFrameFactory() : apply_rotation_(false) {} | 27 VideoFrameFactory() : apply_rotation_(false) {} |
28 virtual ~VideoFrameFactory() {} | 28 virtual ~VideoFrameFactory() {} |
29 | 29 |
| 30 virtual std::unique_ptr<VideoFrame> CreateScaledFrame( |
| 31 const CapturedFrame* input_frame, |
| 32 int width, |
| 33 int height) const; |
| 34 |
| 35 // The CreateAliasedFrame methods are deprecated, since cropping is |
| 36 // no longer supported, and we don't want raw pointer return types. |
| 37 // TODO(nisse): Delete when all users are updated. |
| 38 |
30 // The returned frame aliases the aliased_frame if the input color | 39 // The returned frame aliases the aliased_frame if the input color |
31 // space allows for aliasing, otherwise a color conversion will | 40 // space allows for aliasing, otherwise a color conversion will |
32 // occur. Returns NULL if conversion fails. | 41 // occur. Returns NULL if conversion fails. |
33 | 42 |
34 // The returned frame will be a center crop of |input_frame| with | 43 // The returned frame will be a center crop of |input_frame| with |
35 // size |cropped_width| x |cropped_height|. | 44 // size |cropped_width| x |cropped_height|. |
36 virtual VideoFrame* CreateAliasedFrame(const CapturedFrame* input_frame, | 45 virtual VideoFrame* CreateAliasedFrame(const CapturedFrame* input_frame, |
37 int cropped_width, | 46 int cropped_width, |
38 int cropped_height) const = 0; | 47 int cropped_height) const { |
39 | 48 // Dummy default implementation, to make it easier to delete in |
| 49 // subclasses. |
| 50 return NULL; |
| 51 } |
40 // The returned frame will be a center crop of |input_frame| with size | 52 // The returned frame will be a center crop of |input_frame| with size |
41 // |cropped_width| x |cropped_height|, scaled to |output_width| x | 53 // |cropped_width| x |cropped_height|, scaled to |output_width| x |
42 // |output_height|. | 54 // |output_height|. |
43 virtual VideoFrame* CreateAliasedFrame(const CapturedFrame* input_frame, | 55 virtual VideoFrame* CreateAliasedFrame(const CapturedFrame* input_frame, |
44 int cropped_input_width, | 56 int cropped_input_width, |
45 int cropped_input_height, | 57 int cropped_input_height, |
46 int output_width, | 58 int output_width, |
47 int output_height) const; | 59 int output_height) const; |
48 | 60 |
49 void SetApplyRotation(bool enable) { apply_rotation_ = enable; } | 61 void SetApplyRotation(bool enable) { apply_rotation_ = enable; } |
50 | 62 |
51 protected: | 63 protected: |
52 bool apply_rotation_; | 64 bool apply_rotation_; |
53 | 65 |
54 private: | 66 private: |
55 // An internal frame buffer to avoid reallocations. It is mutable because it | 67 // An internal frame buffer to avoid reallocations. It is mutable because it |
56 // does not affect behaviour, only performance. | 68 // does not affect behaviour, only performance. |
57 mutable std::unique_ptr<VideoFrame> output_frame_; | 69 mutable std::unique_ptr<VideoFrame> output_frame_; |
58 }; | 70 }; |
59 | 71 |
60 } // namespace cricket | 72 } // namespace cricket |
61 | 73 |
62 #endif // WEBRTC_MEDIA_BASE_VIDEOFRAMEFACTORY_H_ | 74 #endif // WEBRTC_MEDIA_BASE_VIDEOFRAMEFACTORY_H_ |
OLD | NEW |