OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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_ENGINE_WEBRTCVIDEOFRAME_H_ | 11 #ifndef WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOFRAME_H_ |
12 #define WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOFRAME_H_ | 12 #define WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOFRAME_H_ |
13 | 13 |
14 #include <memory> | 14 #include <memory> |
15 | 15 |
16 #include "webrtc/base/buffer.h" | 16 #include "webrtc/base/buffer.h" |
17 #include "webrtc/base/refcount.h" | 17 #include "webrtc/base/refcount.h" |
18 #include "webrtc/base/scoped_ref_ptr.h" | 18 #include "webrtc/base/scoped_ref_ptr.h" |
19 #include "webrtc/common_types.h" | 19 #include "webrtc/common_types.h" |
20 #include "webrtc/common_video/include/video_frame_buffer.h" | 20 #include "webrtc/common_video/include/video_frame_buffer.h" |
21 #include "webrtc/media/base/videoframe.h" | 21 #include "webrtc/media/base/videoframe.h" |
22 #include "webrtc/base/gtest_prod_util.h" | |
Taylor Brandstetter
2016/06/23 23:39:51
It looks like this broke the FYI bot, because Chro
Sergey Ulanov
2016/06/24 00:30:03
yep. I'm going to revert to the previous version o
| |
22 | 23 |
23 namespace cricket { | 24 namespace cricket { |
24 | 25 |
25 struct CapturedFrame; | 26 struct CapturedFrame; |
26 | 27 |
27 class WebRtcVideoFrame : public VideoFrame { | 28 class WebRtcVideoFrame : public VideoFrame { |
28 public: | 29 public: |
29 WebRtcVideoFrame(); | 30 WebRtcVideoFrame(); |
30 | 31 |
31 // Preferred construction, with microsecond timestamp. | 32 // Preferred construction, with microsecond timestamp. |
(...skipping 22 matching lines...) Expand all Loading... | |
54 int64_t time_stamp_ns, | 55 int64_t time_stamp_ns, |
55 webrtc::VideoRotation rotation); | 56 webrtc::VideoRotation rotation); |
56 | 57 |
57 // The timestamp of the captured frame is expected to use the same | 58 // The timestamp of the captured frame is expected to use the same |
58 // timescale and epoch as rtc::Time. | 59 // timescale and epoch as rtc::Time. |
59 // TODO(nisse): Consider adding a warning message, or even an RTC_DCHECK, if | 60 // TODO(nisse): Consider adding a warning message, or even an RTC_DCHECK, if |
60 // the time is too far off. | 61 // the time is too far off. |
61 bool Init(const CapturedFrame* frame, int dw, int dh, bool apply_rotation); | 62 bool Init(const CapturedFrame* frame, int dw, int dh, bool apply_rotation); |
62 | 63 |
63 void InitToEmptyBuffer(int w, int h); | 64 void InitToEmptyBuffer(int w, int h); |
64 void InitToEmptyBuffer(int w, int h, int64_t time_stamp_ns); | |
65 | 65 |
66 int width() const override; | 66 int width() const override; |
67 int height() const override; | 67 int height() const override; |
68 | 68 |
69 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& video_frame_buffer() | 69 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& video_frame_buffer() |
70 const override; | 70 const override; |
71 | 71 |
72 /* System monotonic clock */ | 72 /* System monotonic clock */ |
73 int64_t timestamp_us() const override { return timestamp_us_; } | 73 int64_t timestamp_us() const override { return timestamp_us_; } |
74 void set_timestamp_us(int64_t time_us) override { timestamp_us_ = time_us; }; | 74 void set_timestamp_us(int64_t time_us) override { timestamp_us_ = time_us; }; |
75 | 75 |
76 webrtc::VideoRotation rotation() const override { return rotation_; } | 76 webrtc::VideoRotation rotation() const override { return rotation_; } |
77 | 77 |
78 VideoFrame* Copy() const override; | 78 VideoFrame* Copy() const override; |
79 | 79 |
80 size_t ConvertToRgbBuffer(uint32_t to_fourcc, | 80 size_t ConvertToRgbBuffer(uint32_t to_fourcc, |
81 uint8_t* buffer, | 81 uint8_t* buffer, |
82 size_t size, | 82 size_t size, |
83 int stride_rgb) const override; | 83 int stride_rgb) const override; |
84 | 84 |
85 const VideoFrame* GetCopyWithRotationApplied() const override; | 85 const VideoFrame* GetCopyWithRotationApplied() const override; |
86 | 86 |
87 protected: | 87 protected: |
88 void set_rotation(webrtc::VideoRotation rotation) override { | |
89 rotation_ = rotation; | |
90 } | |
91 // Creates a frame from a raw sample with FourCC |format| and size |w| x |h|. | 88 // Creates a frame from a raw sample with FourCC |format| and size |w| x |h|. |
92 // |h| can be negative indicating a vertically flipped image. | 89 // |h| can be negative indicating a vertically flipped image. |
93 // |dw| is destination width; can be less than |w| if cropping is desired. | 90 // |dw| is destination width; can be less than |w| if cropping is desired. |
94 // |dh| is destination height, like |dw|, but must be a positive number. | 91 // |dh| is destination height, like |dw|, but must be a positive number. |
95 // Returns whether the function succeeded or failed. | 92 // Returns whether the function succeeded or failed. |
96 bool Reset(uint32_t format, | 93 bool Reset(uint32_t format, |
97 int w, | 94 int w, |
98 int h, | 95 int h, |
99 int dw, | 96 int dw, |
100 int dh, | 97 int dh, |
101 uint8_t* sample, | 98 uint8_t* sample, |
102 size_t sample_size, | 99 size_t sample_size, |
103 int64_t timestamp_us, | 100 int64_t timestamp_us, |
104 webrtc::VideoRotation rotation, | 101 webrtc::VideoRotation rotation, |
105 bool apply_rotation); | 102 bool apply_rotation); |
106 | 103 |
107 private: | 104 private: |
108 VideoFrame* CreateEmptyFrame(int w, int h, | 105 // The test mutates |rotation_|, so it needs to be a friend. |
109 int64_t time_stamp_ns) const override; | 106 FRIEND_TEST_ALL_PREFIXES(WebRtcVideoFrameTest, ApplyRotationToFrame); |
110 | 107 |
111 // An opaque reference counted handle that stores the pixel data. | 108 // An opaque reference counted handle that stores the pixel data. |
112 rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_; | 109 rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_; |
113 int64_t timestamp_us_; | 110 int64_t timestamp_us_; |
114 webrtc::VideoRotation rotation_; | 111 webrtc::VideoRotation rotation_; |
115 | 112 |
116 // This is mutable as the calculation is expensive but once calculated, it | 113 // This is mutable as the calculation is expensive but once calculated, it |
117 // remains const. | 114 // remains const. |
118 mutable std::unique_ptr<VideoFrame> rotated_frame_; | 115 mutable std::unique_ptr<VideoFrame> rotated_frame_; |
119 }; | 116 }; |
120 | 117 |
121 } // namespace cricket | 118 } // namespace cricket |
122 | 119 |
123 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOFRAME_H_ | 120 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOFRAME_H_ |
OLD | NEW |