| 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 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 int64_t time_stamp_ns, | 54 int64_t time_stamp_ns, |
| 55 webrtc::VideoRotation rotation); | 55 webrtc::VideoRotation rotation); |
| 56 | 56 |
| 57 // The timestamp of the captured frame is expected to use the same | 57 // The timestamp of the captured frame is expected to use the same |
| 58 // timescale and epoch as rtc::Time. | 58 // timescale and epoch as rtc::Time. |
| 59 // TODO(nisse): Consider adding a warning message, or even an RTC_DCHECK, if | 59 // TODO(nisse): Consider adding a warning message, or even an RTC_DCHECK, if |
| 60 // the time is too far off. | 60 // the time is too far off. |
| 61 bool Init(const CapturedFrame* frame, int dw, int dh, bool apply_rotation); | 61 bool Init(const CapturedFrame* frame, int dw, int dh, bool apply_rotation); |
| 62 | 62 |
| 63 void InitToEmptyBuffer(int w, int h); | 63 void InitToEmptyBuffer(int w, int h); |
| 64 void InitToEmptyBuffer(int w, int h, int64_t time_stamp_ns); | |
| 65 | 64 |
| 66 int width() const override; | 65 int width() const override; |
| 67 int height() const override; | 66 int height() const override; |
| 68 | 67 |
| 69 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& video_frame_buffer() | 68 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& video_frame_buffer() |
| 70 const override; | 69 const override; |
| 71 | 70 |
| 72 /* System monotonic clock */ | 71 /* System monotonic clock */ |
| 73 int64_t timestamp_us() const override { return timestamp_us_; } | 72 int64_t timestamp_us() const override { return timestamp_us_; } |
| 74 void set_timestamp_us(int64_t time_us) override { timestamp_us_ = time_us; }; | 73 void set_timestamp_us(int64_t time_us) override { timestamp_us_ = time_us; }; |
| 75 | 74 |
| 76 webrtc::VideoRotation rotation() const override { return rotation_; } | 75 webrtc::VideoRotation rotation() const override { return rotation_; } |
| 77 | 76 |
| 78 VideoFrame* Copy() const override; | 77 VideoFrame* Copy() const override; |
| 79 | 78 |
| 80 size_t ConvertToRgbBuffer(uint32_t to_fourcc, | 79 size_t ConvertToRgbBuffer(uint32_t to_fourcc, |
| 81 uint8_t* buffer, | 80 uint8_t* buffer, |
| 82 size_t size, | 81 size_t size, |
| 83 int stride_rgb) const override; | 82 int stride_rgb) const override; |
| 84 | 83 |
| 85 const VideoFrame* GetCopyWithRotationApplied() const override; | 84 const VideoFrame* GetCopyWithRotationApplied() const override; |
| 86 | 85 |
| 87 protected: | 86 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|. | 87 // 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. | 88 // |h| can be negative indicating a vertically flipped image. |
| 93 // |dw| is destination width; can be less than |w| if cropping is desired. | 89 // |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. | 90 // |dh| is destination height, like |dw|, but must be a positive number. |
| 95 // Returns whether the function succeeded or failed. | 91 // Returns whether the function succeeded or failed. |
| 96 bool Reset(uint32_t format, | 92 bool Reset(uint32_t format, |
| 97 int w, | 93 int w, |
| 98 int h, | 94 int h, |
| 99 int dw, | 95 int dw, |
| 100 int dh, | 96 int dh, |
| 101 uint8_t* sample, | 97 uint8_t* sample, |
| 102 size_t sample_size, | 98 size_t sample_size, |
| 103 int64_t timestamp_us, | 99 int64_t timestamp_us, |
| 104 webrtc::VideoRotation rotation, | 100 webrtc::VideoRotation rotation, |
| 105 bool apply_rotation); | 101 bool apply_rotation); |
| 106 | 102 |
| 107 private: | 103 private: |
| 108 VideoFrame* CreateEmptyFrame(int w, int h, | 104 // Tests mutate |rotation_|, so the base test class is a friend. |
| 109 int64_t time_stamp_ns) const override; | 105 friend class WebRtcVideoFrameTest; |
| 110 | 106 |
| 111 // An opaque reference counted handle that stores the pixel data. | 107 // An opaque reference counted handle that stores the pixel data. |
| 112 rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_; | 108 rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_; |
| 113 int64_t timestamp_us_; | 109 int64_t timestamp_us_; |
| 114 webrtc::VideoRotation rotation_; | 110 webrtc::VideoRotation rotation_; |
| 115 | 111 |
| 116 // This is mutable as the calculation is expensive but once calculated, it | 112 // This is mutable as the calculation is expensive but once calculated, it |
| 117 // remains const. | 113 // remains const. |
| 118 mutable std::unique_ptr<VideoFrame> rotated_frame_; | 114 mutable std::unique_ptr<VideoFrame> rotated_frame_; |
| 119 }; | 115 }; |
| 120 | 116 |
| 121 } // namespace cricket | 117 } // namespace cricket |
| 122 | 118 |
| 123 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOFRAME_H_ | 119 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOFRAME_H_ |
| OLD | NEW |