| 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 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 struct CapturedFrame; | 25 struct CapturedFrame; |
| 26 | 26 |
| 27 class WebRtcVideoFrame : public VideoFrame { | 27 class WebRtcVideoFrame : public VideoFrame { |
| 28 public: | 28 public: |
| 29 WebRtcVideoFrame(); | 29 WebRtcVideoFrame(); |
| 30 | 30 |
| 31 // Preferred construction, with microsecond timestamp. | 31 // Preferred construction, with microsecond timestamp. |
| 32 WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, | 32 WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, |
| 33 webrtc::VideoRotation rotation, | 33 webrtc::VideoRotation rotation, |
| 34 int64_t timestamp_us); | 34 int64_t timestamp_us, |
| 35 uint32_t frame_id); |
| 35 | 36 |
| 36 // TODO(nisse): Deprecate/delete. | 37 // TODO(nisse): Deprecate/delete. |
| 37 WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, | 38 WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, |
| 38 int64_t time_stamp_ns, | 39 int64_t timestamp_ns, |
| 39 webrtc::VideoRotation rotation); | 40 webrtc::VideoRotation rotation); |
| 40 | 41 |
| 41 ~WebRtcVideoFrame(); | 42 ~WebRtcVideoFrame(); |
| 42 | 43 |
| 43 // Creates a frame from a raw sample with FourCC "format" and size "w" x "h". | 44 // Creates a frame from a raw sample with FourCC "format" and size "w" x "h". |
| 44 // "h" can be negative indicating a vertically flipped image. | 45 // "h" can be negative indicating a vertically flipped image. |
| 45 // "dh" is destination height if cropping is desired and is always positive. | 46 // "dh" is destination height if cropping is desired and is always positive. |
| 46 // Returns "true" if successful. | 47 // Returns "true" if successful. |
| 47 bool Init(uint32_t format, | 48 bool Init(uint32_t format, |
| 48 int w, | 49 int w, |
| 49 int h, | 50 int h, |
| 50 int dw, | 51 int dw, |
| 51 int dh, | 52 int dh, |
| 52 uint8_t* sample, | 53 uint8_t* sample, |
| 53 size_t sample_size, | 54 size_t sample_size, |
| 54 int64_t time_stamp_ns, | 55 int64_t timestamp_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 void InitToEmptyBuffer(int w, int h, int64_t time_stamp_ns); |
| 65 | 66 |
| 66 int width() const override; | 67 int width() const override; |
| 67 int height() const override; | 68 int height() const override; |
| 68 | 69 |
| 69 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& video_frame_buffer() | 70 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& video_frame_buffer() |
| 70 const override; | 71 const override; |
| 71 | 72 |
| 72 /* System monotonic clock */ | 73 uint32_t frame_id() const override; |
| 73 int64_t timestamp_us() const override { return timestamp_us_; } | |
| 74 void set_timestamp_us(int64_t time_us) override { timestamp_us_ = time_us; }; | |
| 75 | 74 |
| 76 webrtc::VideoRotation rotation() const override { return rotation_; } | 75 int64_t timestamp_us() const override; |
| 76 void set_timestamp_us(int64_t time_us) override; |
| 77 |
| 78 webrtc::VideoRotation rotation() const override; |
| 77 | 79 |
| 78 VideoFrame* Copy() const override; | 80 VideoFrame* Copy() const override; |
| 79 | 81 |
| 80 size_t ConvertToRgbBuffer(uint32_t to_fourcc, | 82 size_t ConvertToRgbBuffer(uint32_t to_fourcc, |
| 81 uint8_t* buffer, | 83 uint8_t* buffer, |
| 82 size_t size, | 84 size_t size, |
| 83 int stride_rgb) const override; | 85 int stride_rgb) const override; |
| 84 | 86 |
| 85 const VideoFrame* GetCopyWithRotationApplied() const override; | 87 const VideoFrame* GetCopyWithRotationApplied() const override; |
| 86 | 88 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 104 webrtc::VideoRotation rotation, | 106 webrtc::VideoRotation rotation, |
| 105 bool apply_rotation); | 107 bool apply_rotation); |
| 106 | 108 |
| 107 private: | 109 private: |
| 108 VideoFrame* CreateEmptyFrame(int w, int h, | 110 VideoFrame* CreateEmptyFrame(int w, int h, |
| 109 int64_t time_stamp_ns) const override; | 111 int64_t time_stamp_ns) const override; |
| 110 | 112 |
| 111 // An opaque reference counted handle that stores the pixel data. | 113 // An opaque reference counted handle that stores the pixel data. |
| 112 rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_; | 114 rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_; |
| 113 int64_t timestamp_us_; | 115 int64_t timestamp_us_; |
| 116 uint32_t frame_id_; |
| 114 webrtc::VideoRotation rotation_; | 117 webrtc::VideoRotation rotation_; |
| 115 | 118 |
| 116 // This is mutable as the calculation is expensive but once calculated, it | 119 // This is mutable as the calculation is expensive but once calculated, it |
| 117 // remains const. | 120 // remains const. |
| 118 mutable std::unique_ptr<VideoFrame> rotated_frame_; | 121 mutable std::unique_ptr<VideoFrame> rotated_frame_; |
| 119 }; | 122 }; |
| 120 | 123 |
| 121 } // namespace cricket | 124 } // namespace cricket |
| 122 | 125 |
| 123 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOFRAME_H_ | 126 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOFRAME_H_ |
| OLD | NEW |