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 |
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; | |
26 | |
27 // TODO(nisse): This class will be deleted when the cricket::VideoFrame and | 25 // TODO(nisse): This class will be deleted when the cricket::VideoFrame and |
28 // webrtc::VideoFrame classes are merged. See | 26 // webrtc::VideoFrame classes are merged. See |
29 // https://bugs.chromium.org/p/webrtc/issues/detail?id=5682. Try to use only the | 27 // https://bugs.chromium.org/p/webrtc/issues/detail?id=5682. Try to use only the |
30 // preferred constructor, and the non-deprecated methods of the VideoFrame base | 28 // preferred constructor, and the non-deprecated methods of the VideoFrame base |
31 // class. | 29 // class. |
32 class WebRtcVideoFrame : public VideoFrame { | 30 class WebRtcVideoFrame : public VideoFrame { |
33 public: | 31 public: |
34 // TODO(nisse): Deprecated. Using the default constructor violates the | 32 // TODO(nisse): Deprecated. Using the default constructor violates the |
35 // reasonable assumption that video_frame_buffer() returns a valid buffer. | 33 // reasonable assumption that video_frame_buffer() returns a valid buffer. |
36 WebRtcVideoFrame(); | 34 WebRtcVideoFrame(); |
37 | 35 |
38 // Preferred constructor. | 36 // Preferred constructor. |
39 WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, | 37 WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, |
40 webrtc::VideoRotation rotation, | 38 webrtc::VideoRotation rotation, |
41 int64_t timestamp_us, | 39 int64_t timestamp_us, |
42 uint32_t transport_frame_id); | 40 uint32_t transport_frame_id); |
43 | 41 |
44 // TODO(nisse): Deprecated, delete as soon as all callers have switched to the | 42 // TODO(nisse): Deprecated, delete as soon as all callers have switched to the |
45 // above constructor with microsecond timestamp. | 43 // above constructor with microsecond timestamp. |
46 WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, | 44 WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, |
47 int64_t timestamp_ns, | 45 int64_t timestamp_ns, |
48 webrtc::VideoRotation rotation); | 46 webrtc::VideoRotation rotation); |
49 | 47 |
50 ~WebRtcVideoFrame(); | 48 ~WebRtcVideoFrame(); |
51 | 49 |
| 50 // TODO(nisse): Init (and its helpers Reset and Validate) are used |
| 51 // only by the LoadFrame function used in the VideoFrame unittests. |
| 52 // Rewrite tests, and delete this function. |
| 53 |
52 // Creates a frame from a raw sample with FourCC "format" and size "w" x "h". | 54 // Creates a frame from a raw sample with FourCC "format" and size "w" x "h". |
53 // "h" can be negative indicating a vertically flipped image. | 55 // "h" can be negative indicating a vertically flipped image. |
54 // "dh" is destination height if cropping is desired and is always positive. | 56 // "dh" is destination height if cropping is desired and is always positive. |
55 // Returns "true" if successful. | 57 // Returns "true" if successful. |
56 bool Init(uint32_t format, | 58 bool Init(uint32_t format, |
57 int w, | 59 int w, |
58 int h, | 60 int h, |
59 int dw, | 61 int dw, |
60 int dh, | 62 int dh, |
61 uint8_t* sample, | 63 uint8_t* sample, |
62 size_t sample_size, | 64 size_t sample_size, |
63 int64_t timestamp_ns, | 65 int64_t timestamp_ns, |
64 webrtc::VideoRotation rotation); | 66 webrtc::VideoRotation rotation); |
65 | 67 |
66 // TODO(nisse): We're moving to have all timestamps use the same | |
67 // time scale as rtc::TimeMicros. However, this method is used by | |
68 // WebRtcVideoFrameFactory::CreateAliasedFrame this code path | |
69 // currently does not conform to the new timestamp conventions and | |
70 // may use the camera's own clock instead. It's unclear if this | |
71 // should be fixed, or if instead all of the VideoFrameFactory | |
72 // abstraction should be eliminated. | |
73 bool Init(const CapturedFrame* frame, int dw, int dh, bool apply_rotation); | |
74 | |
75 void InitToEmptyBuffer(int w, int h); | 68 void InitToEmptyBuffer(int w, int h); |
76 | 69 |
77 int width() const override; | 70 int width() const override; |
78 int height() const override; | 71 int height() const override; |
79 | 72 |
80 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& video_frame_buffer() | 73 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& video_frame_buffer() |
81 const override; | 74 const override; |
82 | 75 |
83 uint32_t transport_frame_id() const override; | 76 uint32_t transport_frame_id() const override; |
84 | 77 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 webrtc::VideoRotation rotation_; | 117 webrtc::VideoRotation rotation_; |
125 | 118 |
126 // 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 |
127 // remains const. | 120 // remains const. |
128 mutable std::unique_ptr<VideoFrame> rotated_frame_; | 121 mutable std::unique_ptr<VideoFrame> rotated_frame_; |
129 }; | 122 }; |
130 | 123 |
131 } // namespace cricket | 124 } // namespace cricket |
132 | 125 |
133 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOFRAME_H_ | 126 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOFRAME_H_ |
OLD | NEW |