OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2004 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_BASE_VIDEOFRAME_H_ | 11 #ifndef WEBRTC_MEDIA_BASE_VIDEOFRAME_H_ |
12 #define WEBRTC_MEDIA_BASE_VIDEOFRAME_H_ | 12 #define WEBRTC_MEDIA_BASE_VIDEOFRAME_H_ |
13 | 13 |
14 #include "webrtc/base/basictypes.h" | 14 #include "webrtc/base/basictypes.h" |
15 #include "webrtc/base/stream.h" | 15 #include "webrtc/base/stream.h" |
16 #include "webrtc/common_video/include/video_frame_buffer.h" | 16 #include "webrtc/common_video/include/video_frame_buffer.h" |
17 #include "webrtc/common_video/rotation.h" | 17 #include "webrtc/common_video/rotation.h" |
18 | 18 |
19 namespace cricket { | 19 namespace cricket { |
20 | 20 |
21 // Represents a YUV420 (a.k.a. I420) video frame. | 21 // Represents a YUV420 (a.k.a. I420) video frame. |
| 22 |
| 23 // TODO(nisse): This class duplicates webrtc::VideoFrame. There's |
| 24 // ongoing work to merge the classes. See |
| 25 // https://bugs.chromium.org/p/webrtc/issues/detail?id=5682. |
22 class VideoFrame { | 26 class VideoFrame { |
23 public: | 27 public: |
24 VideoFrame() {} | 28 VideoFrame() {} |
25 virtual ~VideoFrame() {} | 29 virtual ~VideoFrame() {} |
26 | 30 |
27 // Basic accessors. | 31 // Basic accessors. |
28 // Note this is the width and height without rotation applied. | 32 // Note this is the width and height without rotation applied. |
29 virtual int width() const = 0; | 33 virtual int width() const = 0; |
30 virtual int height() const = 0; | 34 virtual int height() const = 0; |
31 | 35 |
(...skipping 15 matching lines...) Expand all Loading... |
47 virtual void SetTimeStamp(int64_t time_ns) { | 51 virtual void SetTimeStamp(int64_t time_ns) { |
48 set_timestamp_us(time_ns / rtc::kNumNanosecsPerMicrosec); | 52 set_timestamp_us(time_ns / rtc::kNumNanosecsPerMicrosec); |
49 } | 53 } |
50 | 54 |
51 // Indicates the rotation angle in degrees. | 55 // Indicates the rotation angle in degrees. |
52 virtual webrtc::VideoRotation rotation() const = 0; | 56 virtual webrtc::VideoRotation rotation() const = 0; |
53 | 57 |
54 // Make a shallow copy of the frame. The frame buffer itself is not copied. | 58 // Make a shallow copy of the frame. The frame buffer itself is not copied. |
55 // Both the current and new VideoFrame will share a single reference-counted | 59 // Both the current and new VideoFrame will share a single reference-counted |
56 // frame buffer. | 60 // frame buffer. |
| 61 |
| 62 // TODO(nisse): Deprecated, to be deleted in the cricket::VideoFrame and |
| 63 // webrtc::VideoFrame merge. To make a copy, use the cricket::WebRtcVideoFrame |
| 64 // constructor passing video_frame_buffer(), rotation() and timestamp_us() as |
| 65 // arguments. |
57 virtual VideoFrame *Copy() const = 0; | 66 virtual VideoFrame *Copy() const = 0; |
58 | 67 |
59 // Return a copy of frame which has its pending rotation applied. The | 68 // Return a copy of frame which has its pending rotation applied. The |
60 // ownership of the returned frame is held by this frame. | 69 // ownership of the returned frame is held by this frame. |
| 70 |
| 71 // TODO(nisse): Deprecated. Should be moved or deleted in the |
| 72 // cricket::VideoFrame and webrtc::VideoFrame merge, possibly with a helper |
| 73 // method on VideoFrameBuffer. |
61 virtual const VideoFrame* GetCopyWithRotationApplied() const = 0; | 74 virtual const VideoFrame* GetCopyWithRotationApplied() const = 0; |
62 | 75 |
63 // Converts the I420 data to RGB of a certain type such as ARGB and ABGR. | 76 // Converts the I420 data to RGB of a certain type such as ARGB and ABGR. |
64 // Returns the frame's actual size, regardless of whether it was written or | 77 // Returns the frame's actual size, regardless of whether it was written or |
65 // not (like snprintf). Parameters size and stride_rgb are in units of bytes. | 78 // not (like snprintf). Parameters size and stride_rgb are in units of bytes. |
66 // If there is insufficient space, nothing is written. | 79 // If there is insufficient space, nothing is written. |
| 80 |
| 81 // TODO(nisse): Deprecated. Should be moved or deleted in the |
| 82 // cricket::VideoFrame and webrtc::VideoFrame merge. Use |
| 83 // libyuv::ConvertFromI420 directly instead. |
67 virtual size_t ConvertToRgbBuffer(uint32_t to_fourcc, | 84 virtual size_t ConvertToRgbBuffer(uint32_t to_fourcc, |
68 uint8_t* buffer, | 85 uint8_t* buffer, |
69 size_t size, | 86 size_t size, |
70 int stride_rgb) const; | 87 int stride_rgb) const; |
71 | 88 |
72 // Tests if sample is valid. Returns true if valid. | 89 // Tests if sample is valid. Returns true if valid. |
| 90 |
| 91 // TODO(nisse): Deprecated. Should be deleted in the cricket::VideoFrame and |
| 92 // webrtc::VideoFrame merge. Validation of sample_size possibly moved to |
| 93 // libyuv::ConvertToI420. As an initial step, demote this method to protected |
| 94 // status. Used only by WebRtcVideoFrame::Reset. |
73 static bool Validate(uint32_t fourcc, | 95 static bool Validate(uint32_t fourcc, |
74 int w, | 96 int w, |
75 int h, | 97 int h, |
76 const uint8_t* sample, | 98 const uint8_t* sample, |
77 size_t sample_size); | 99 size_t sample_size); |
78 | 100 |
79 protected: | 101 protected: |
80 // Creates an empty frame. | 102 // Creates an empty frame. |
81 virtual VideoFrame* CreateEmptyFrame(int w, | 103 virtual VideoFrame* CreateEmptyFrame(int w, |
82 int h, | 104 int h, |
83 int64_t timestamp_us) const = 0; | 105 int64_t timestamp_us) const = 0; |
84 | 106 |
85 virtual void set_rotation(webrtc::VideoRotation rotation) = 0; | 107 virtual void set_rotation(webrtc::VideoRotation rotation) = 0; |
86 }; | 108 }; |
87 | 109 |
88 } // namespace cricket | 110 } // namespace cricket |
89 | 111 |
90 #endif // WEBRTC_MEDIA_BASE_VIDEOFRAME_H_ | 112 #endif // WEBRTC_MEDIA_BASE_VIDEOFRAME_H_ |
OLD | NEW |