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

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

Issue 1884863004: Revert of Use microsecond timestamp in cricket::VideoFrame. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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.
37 WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, 30 WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer,
38 int64_t time_stamp_ns, 31 int64_t time_stamp_ns,
39 webrtc::VideoRotation rotation); 32 webrtc::VideoRotation rotation);
40 33
41 ~WebRtcVideoFrame(); 34 ~WebRtcVideoFrame();
42 35
43 // Creates a frame from a raw sample with FourCC "format" and size "w" x "h". 36 // 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. 37 // "h" can be negative indicating a vertically flipped image.
45 // "dh" is destination height if cropping is desired and is always positive. 38 // "dh" is destination height if cropping is desired and is always positive.
46 // Returns "true" if successful. 39 // Returns "true" if successful.
47 bool Init(uint32_t format, 40 bool Init(uint32_t format,
48 int w, 41 int w,
49 int h, 42 int h,
50 int dw, 43 int dw,
51 int dh, 44 int dh,
52 uint8_t* sample, 45 uint8_t* sample,
53 size_t sample_size, 46 size_t sample_size,
54 int64_t time_stamp_ns, 47 int64_t time_stamp_ns,
55 webrtc::VideoRotation rotation); 48 webrtc::VideoRotation rotation);
56 49
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.
61 bool Init(const CapturedFrame* frame, int dw, int dh, bool apply_rotation); 50 bool Init(const CapturedFrame* frame, int dw, int dh, bool apply_rotation);
62 51
63 void InitToEmptyBuffer(int w, int h);
64 void InitToEmptyBuffer(int w, int h, int64_t time_stamp_ns); 52 void InitToEmptyBuffer(int w, int h, int64_t time_stamp_ns);
65 53
66 bool InitToBlack(int w, int h, int64_t time_stamp_ns); 54 bool InitToBlack(int w, int h, int64_t time_stamp_ns);
67 55
68 int width() const override; 56 int width() const override;
69 int height() const override; 57 int height() const override;
70 58
71 const uint8_t* GetYPlane() const override; 59 const uint8_t* GetYPlane() const override;
72 const uint8_t* GetUPlane() const override; 60 const uint8_t* GetUPlane() const override;
73 const uint8_t* GetVPlane() const override; 61 const uint8_t* GetVPlane() const override;
74 uint8_t* GetYPlane() override; 62 uint8_t* GetYPlane() override;
75 uint8_t* GetUPlane() override; 63 uint8_t* GetUPlane() override;
76 uint8_t* GetVPlane() override; 64 uint8_t* GetVPlane() override;
77 int32_t GetYPitch() const override; 65 int32_t GetYPitch() const override;
78 int32_t GetUPitch() const override; 66 int32_t GetUPitch() const override;
79 int32_t GetVPitch() const override; 67 int32_t GetVPitch() const override;
80 void* GetNativeHandle() const override; 68 void* GetNativeHandle() const override;
81 rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer() 69 rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer()
82 const override; 70 const override;
83 71
84 /* System monotonic clock */ 72 int64_t GetTimeStamp() const override { return time_stamp_ns_; }
85 int64_t timestamp_us() const override { return timestamp_us_; } 73 void SetTimeStamp(int64_t time_stamp_ns) override {
86 void set_timestamp_us(int64_t time_us) { timestamp_us_ = time_us; }; 74 time_stamp_ns_ = time_stamp_ns;
75 }
87 76
88 webrtc::VideoRotation rotation() const override { return rotation_; } 77 webrtc::VideoRotation rotation() const override { return rotation_; }
89 78
90 VideoFrame* Copy() const override; 79 VideoFrame* Copy() const override;
91 bool IsExclusive() const override; 80 bool IsExclusive() const override;
92 size_t ConvertToRgbBuffer(uint32_t to_fourcc, 81 size_t ConvertToRgbBuffer(uint32_t to_fourcc,
93 uint8_t* buffer, 82 uint8_t* buffer,
94 size_t size, 83 size_t size,
95 int stride_rgb) const override; 84 int stride_rgb) const override;
96 85
97 const VideoFrame* GetCopyWithRotationApplied() const override; 86 const VideoFrame* GetCopyWithRotationApplied() const override;
98 87
99 protected: 88 protected:
100 void set_rotation(webrtc::VideoRotation rotation) override { 89 void set_rotation(webrtc::VideoRotation rotation) override {
101 rotation_ = rotation; 90 rotation_ = rotation;
102 } 91 }
103 // Creates a frame from a raw sample with FourCC |format| and size |w| x |h|. 92 // Creates a frame from a raw sample with FourCC |format| and size |w| x |h|.
104 // |h| can be negative indicating a vertically flipped image. 93 // |h| can be negative indicating a vertically flipped image.
105 // |dw| is destination width; can be less than |w| if cropping is desired. 94 // |dw| is destination width; can be less than |w| if cropping is desired.
106 // |dh| is destination height, like |dw|, but must be a positive number. 95 // |dh| is destination height, like |dw|, but must be a positive number.
107 // Returns whether the function succeeded or failed. 96 // Returns whether the function succeeded or failed.
108 bool Reset(uint32_t format, 97 bool Reset(uint32_t format,
109 int w, 98 int w,
110 int h, 99 int h,
111 int dw, 100 int dw,
112 int dh, 101 int dh,
113 uint8_t* sample, 102 uint8_t* sample,
114 size_t sample_size, 103 size_t sample_size,
115 int64_t timestamp_us, 104 int64_t time_stamp_ns,
116 webrtc::VideoRotation rotation, 105 webrtc::VideoRotation rotation,
117 bool apply_rotation); 106 bool apply_rotation);
118 107
119 private: 108 private:
120 VideoFrame* CreateEmptyFrame(int w, int h, 109 VideoFrame* CreateEmptyFrame(int w, int h,
121 int64_t time_stamp_ns) const override; 110 int64_t time_stamp_ns) const override;
122 111
123 // An opaque reference counted handle that stores the pixel data. 112 // An opaque reference counted handle that stores the pixel data.
124 rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_; 113 rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_;
125 int64_t timestamp_us_; 114 int64_t time_stamp_ns_;
126 webrtc::VideoRotation rotation_; 115 webrtc::VideoRotation rotation_;
127 116
128 // This is mutable as the calculation is expensive but once calculated, it 117 // This is mutable as the calculation is expensive but once calculated, it
129 // remains const. 118 // remains const.
130 mutable std::unique_ptr<VideoFrame> rotated_frame_; 119 mutable std::unique_ptr<VideoFrame> rotated_frame_;
131 }; 120 };
132 121
133 } // namespace cricket 122 } // namespace cricket
134 123
135 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOFRAME_H_ 124 #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