Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Side by Side Diff: webrtc/media/engine/webrtcvideoframe.h

Issue 1865283002: Use microsecond timestamp in cricket::VideoFrame. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Add missing override, intending to reland. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 22
23 namespace cricket { 23 namespace cricket {
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
31 // Preferred construction, with microsecond timestamp.
32 WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer,
33 webrtc::VideoRotation rotation,
34 int64_t timestamp_us);
35
36 // TODO(nisse): Deprecate/delete.
30 WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, 37 WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer,
31 int64_t time_stamp_ns, 38 int64_t time_stamp_ns,
32 webrtc::VideoRotation rotation); 39 webrtc::VideoRotation rotation);
33 40
34 ~WebRtcVideoFrame(); 41 ~WebRtcVideoFrame();
35 42
36 // Creates a frame from a raw sample with FourCC "format" and size "w" x "h". 43 // Creates a frame from a raw sample with FourCC "format" and size "w" x "h".
37 // "h" can be negative indicating a vertically flipped image. 44 // "h" can be negative indicating a vertically flipped image.
38 // "dh" is destination height if cropping is desired and is always positive. 45 // "dh" is destination height if cropping is desired and is always positive.
39 // Returns "true" if successful. 46 // Returns "true" if successful.
40 bool Init(uint32_t format, 47 bool Init(uint32_t format,
41 int w, 48 int w,
42 int h, 49 int h,
43 int dw, 50 int dw,
44 int dh, 51 int dh,
45 uint8_t* sample, 52 uint8_t* sample,
46 size_t sample_size, 53 size_t sample_size,
47 int64_t time_stamp_ns, 54 int64_t time_stamp_ns,
48 webrtc::VideoRotation rotation); 55 webrtc::VideoRotation rotation);
49 56
57 // The timestamp of the captured frame is expected to use the same
58 // timescale and epoch as rtc::Time.
59 // TODO(nisse): Consider adding a warning message, or even an RTC_DCHECK, if
60 // the time is too far off.
50 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);
51 62
63 void InitToEmptyBuffer(int w, int h);
52 void InitToEmptyBuffer(int w, int h, int64_t time_stamp_ns); 64 void InitToEmptyBuffer(int w, int h, int64_t time_stamp_ns);
53 65
54 bool InitToBlack(int w, int h, int64_t time_stamp_ns); 66 bool InitToBlack(int w, int h, int64_t time_stamp_ns);
55 67
56 int width() const override; 68 int width() const override;
57 int height() const override; 69 int height() const override;
58 70
59 const uint8_t* GetYPlane() const override; 71 const uint8_t* GetYPlane() const override;
60 const uint8_t* GetUPlane() const override; 72 const uint8_t* GetUPlane() const override;
61 const uint8_t* GetVPlane() const override; 73 const uint8_t* GetVPlane() const override;
62 uint8_t* GetYPlane() override; 74 uint8_t* GetYPlane() override;
63 uint8_t* GetUPlane() override; 75 uint8_t* GetUPlane() override;
64 uint8_t* GetVPlane() override; 76 uint8_t* GetVPlane() override;
65 int32_t GetYPitch() const override; 77 int32_t GetYPitch() const override;
66 int32_t GetUPitch() const override; 78 int32_t GetUPitch() const override;
67 int32_t GetVPitch() const override; 79 int32_t GetVPitch() const override;
68 void* GetNativeHandle() const override; 80 void* GetNativeHandle() const override;
69 rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer() 81 rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer()
70 const override; 82 const override;
71 83
72 int64_t GetTimeStamp() const override { return time_stamp_ns_; } 84 /* System monotonic clock */
73 void SetTimeStamp(int64_t time_stamp_ns) override { 85 int64_t timestamp_us() const override { return timestamp_us_; }
74 time_stamp_ns_ = time_stamp_ns; 86 void set_timestamp_us(int64_t time_us) override { timestamp_us_ = time_us; };
75 }
76 87
77 webrtc::VideoRotation rotation() const override { return rotation_; } 88 webrtc::VideoRotation rotation() const override { return rotation_; }
78 89
79 VideoFrame* Copy() const override; 90 VideoFrame* Copy() const override;
80 bool IsExclusive() const override; 91 bool IsExclusive() const override;
81 size_t ConvertToRgbBuffer(uint32_t to_fourcc, 92 size_t ConvertToRgbBuffer(uint32_t to_fourcc,
82 uint8_t* buffer, 93 uint8_t* buffer,
83 size_t size, 94 size_t size,
84 int stride_rgb) const override; 95 int stride_rgb) const override;
85 96
86 const VideoFrame* GetCopyWithRotationApplied() const override; 97 const VideoFrame* GetCopyWithRotationApplied() const override;
87 98
88 protected: 99 protected:
89 void set_rotation(webrtc::VideoRotation rotation) override { 100 void set_rotation(webrtc::VideoRotation rotation) override {
90 rotation_ = rotation; 101 rotation_ = rotation;
91 } 102 }
92 // Creates a frame from a raw sample with FourCC |format| and size |w| x |h|. 103 // Creates a frame from a raw sample with FourCC |format| and size |w| x |h|.
93 // |h| can be negative indicating a vertically flipped image. 104 // |h| can be negative indicating a vertically flipped image.
94 // |dw| is destination width; can be less than |w| if cropping is desired. 105 // |dw| is destination width; can be less than |w| if cropping is desired.
95 // |dh| is destination height, like |dw|, but must be a positive number. 106 // |dh| is destination height, like |dw|, but must be a positive number.
96 // Returns whether the function succeeded or failed. 107 // Returns whether the function succeeded or failed.
97 bool Reset(uint32_t format, 108 bool Reset(uint32_t format,
98 int w, 109 int w,
99 int h, 110 int h,
100 int dw, 111 int dw,
101 int dh, 112 int dh,
102 uint8_t* sample, 113 uint8_t* sample,
103 size_t sample_size, 114 size_t sample_size,
104 int64_t time_stamp_ns, 115 int64_t timestamp_us,
105 webrtc::VideoRotation rotation, 116 webrtc::VideoRotation rotation,
106 bool apply_rotation); 117 bool apply_rotation);
107 118
108 private: 119 private:
109 VideoFrame* CreateEmptyFrame(int w, int h, 120 VideoFrame* CreateEmptyFrame(int w, int h,
110 int64_t time_stamp_ns) const override; 121 int64_t time_stamp_ns) const override;
111 122
112 // An opaque reference counted handle that stores the pixel data. 123 // An opaque reference counted handle that stores the pixel data.
113 rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_; 124 rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_;
114 int64_t time_stamp_ns_; 125 int64_t timestamp_us_;
115 webrtc::VideoRotation rotation_; 126 webrtc::VideoRotation rotation_;
116 127
117 // This is mutable as the calculation is expensive but once calculated, it 128 // This is mutable as the calculation is expensive but once calculated, it
118 // remains const. 129 // remains const.
119 mutable std::unique_ptr<VideoFrame> rotated_frame_; 130 mutable std::unique_ptr<VideoFrame> rotated_frame_;
120 }; 131 };
121 132
122 } // namespace cricket 133 } // namespace cricket
123 134
124 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOFRAME_H_ 135 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOFRAME_H_
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2_unittest.cc ('k') | webrtc/media/engine/webrtcvideoframe.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698