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 20 matching lines...) Expand all Loading... |
31 // class. | 31 // class. |
32 class WebRtcVideoFrame : public VideoFrame { | 32 class WebRtcVideoFrame : public VideoFrame { |
33 public: | 33 public: |
34 // TODO(nisse): Deprecated. Using the default constructor violates the | 34 // TODO(nisse): Deprecated. Using the default constructor violates the |
35 // reasonable assumption that video_frame_buffer() returns a valid buffer. | 35 // reasonable assumption that video_frame_buffer() returns a valid buffer. |
36 WebRtcVideoFrame(); | 36 WebRtcVideoFrame(); |
37 | 37 |
38 // Preferred constructor. | 38 // Preferred constructor. |
39 WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, | 39 WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, |
40 webrtc::VideoRotation rotation, | 40 webrtc::VideoRotation rotation, |
41 int64_t timestamp_us); | 41 int64_t timestamp_us, |
| 42 uint32_t transport_frame_id); |
42 | 43 |
43 // TODO(nisse): Deprecated, delete as soon as all callers have switched to the | 44 // TODO(nisse): Deprecated, delete as soon as all callers have switched to the |
44 // above constructor with microsecond timestamp. | 45 // above constructor with microsecond timestamp. |
45 WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, | 46 WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, |
46 int64_t time_stamp_ns, | 47 int64_t timestamp_ns, |
47 webrtc::VideoRotation rotation); | 48 webrtc::VideoRotation rotation); |
48 | 49 |
49 ~WebRtcVideoFrame(); | 50 ~WebRtcVideoFrame(); |
50 | 51 |
51 // Creates a frame from a raw sample with FourCC "format" and size "w" x "h". | 52 // Creates a frame from a raw sample with FourCC "format" and size "w" x "h". |
52 // "h" can be negative indicating a vertically flipped image. | 53 // "h" can be negative indicating a vertically flipped image. |
53 // "dh" is destination height if cropping is desired and is always positive. | 54 // "dh" is destination height if cropping is desired and is always positive. |
54 // Returns "true" if successful. | 55 // Returns "true" if successful. |
55 bool Init(uint32_t format, | 56 bool Init(uint32_t format, |
56 int w, | 57 int w, |
57 int h, | 58 int h, |
58 int dw, | 59 int dw, |
59 int dh, | 60 int dh, |
60 uint8_t* sample, | 61 uint8_t* sample, |
61 size_t sample_size, | 62 size_t sample_size, |
62 int64_t time_stamp_ns, | 63 int64_t timestamp_ns, |
63 webrtc::VideoRotation rotation); | 64 webrtc::VideoRotation rotation); |
64 | 65 |
65 // TODO(nisse): We're moving to have all timestamps use the same | 66 // TODO(nisse): We're moving to have all timestamps use the same |
66 // time scale as rtc::TimeMicros. However, this method is used by | 67 // time scale as rtc::TimeMicros. However, this method is used by |
67 // WebRtcVideoFrameFactory::CreateAliasedFrame this code path | 68 // WebRtcVideoFrameFactory::CreateAliasedFrame this code path |
68 // currently does not conform to the new timestamp conventions and | 69 // currently does not conform to the new timestamp conventions and |
69 // may use the camera's own clock instead. It's unclear if this | 70 // may use the camera's own clock instead. It's unclear if this |
70 // should be fixed, or if instead all of the VideoFrameFactory | 71 // should be fixed, or if instead all of the VideoFrameFactory |
71 // abstraction should be eliminated. | 72 // abstraction should be eliminated. |
72 bool Init(const CapturedFrame* frame, int dw, int dh, bool apply_rotation); | 73 bool Init(const CapturedFrame* frame, int dw, int dh, bool apply_rotation); |
73 | 74 |
74 void InitToEmptyBuffer(int w, int h); | 75 void InitToEmptyBuffer(int w, int h); |
75 | 76 |
76 int width() const override; | 77 int width() const override; |
77 int height() const override; | 78 int height() const override; |
78 | 79 |
79 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& video_frame_buffer() | 80 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& video_frame_buffer() |
80 const override; | 81 const override; |
81 | 82 |
82 /* System monotonic clock */ | 83 uint32_t transport_frame_id() const override; |
83 int64_t timestamp_us() const override { return timestamp_us_; } | |
84 void set_timestamp_us(int64_t time_us) override { timestamp_us_ = time_us; }; | |
85 | 84 |
86 webrtc::VideoRotation rotation() const override { return rotation_; } | 85 int64_t timestamp_us() const override; |
| 86 void set_timestamp_us(int64_t time_us) override; |
| 87 |
| 88 webrtc::VideoRotation rotation() const override; |
87 | 89 |
88 VideoFrame* Copy() const override; | 90 VideoFrame* Copy() const override; |
89 | 91 |
90 size_t ConvertToRgbBuffer(uint32_t to_fourcc, | 92 size_t ConvertToRgbBuffer(uint32_t to_fourcc, |
91 uint8_t* buffer, | 93 uint8_t* buffer, |
92 size_t size, | 94 size_t size, |
93 int stride_rgb) const override; | 95 int stride_rgb) const override; |
94 | 96 |
95 const VideoFrame* GetCopyWithRotationApplied() const override; | 97 const VideoFrame* GetCopyWithRotationApplied() const override; |
96 | 98 |
(...skipping 14 matching lines...) Expand all Loading... |
111 webrtc::VideoRotation rotation, | 113 webrtc::VideoRotation rotation, |
112 bool apply_rotation); | 114 bool apply_rotation); |
113 | 115 |
114 private: | 116 private: |
115 // Tests mutate |rotation_|, so the base test class is a friend. | 117 // Tests mutate |rotation_|, so the base test class is a friend. |
116 friend class WebRtcVideoFrameTest; | 118 friend class WebRtcVideoFrameTest; |
117 | 119 |
118 // An opaque reference counted handle that stores the pixel data. | 120 // An opaque reference counted handle that stores the pixel data. |
119 rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_; | 121 rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_; |
120 int64_t timestamp_us_; | 122 int64_t timestamp_us_; |
| 123 uint32_t transport_frame_id_; |
121 webrtc::VideoRotation rotation_; | 124 webrtc::VideoRotation rotation_; |
122 | 125 |
123 // This is mutable as the calculation is expensive but once calculated, it | 126 // This is mutable as the calculation is expensive but once calculated, it |
124 // remains const. | 127 // remains const. |
125 mutable std::unique_ptr<VideoFrame> rotated_frame_; | 128 mutable std::unique_ptr<VideoFrame> rotated_frame_; |
126 }; | 129 }; |
127 | 130 |
128 } // namespace cricket | 131 } // namespace cricket |
129 | 132 |
130 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOFRAME_H_ | 133 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOFRAME_H_ |
OLD | NEW |