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() {} |
nisse-webrtc
2016/06/22 11:58:36
Why does it even have a constructor? It's an abstr
| |
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 |
32 // Returns the underlying video frame buffer. This function is ok to call | 36 // Returns the underlying video frame buffer. This function is ok to call |
33 // multiple times, but the returned object will refer to the same memory. | 37 // multiple times, but the returned object will refer to the same memory. |
34 virtual const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& | 38 virtual const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& |
(...skipping 12 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 // TODO(nisse): Should be deleted in the cricket::VideoFrame and | |
pbos-webrtc
2016/06/22 10:23:46
Mark more clearly that they're deprecated and expl
nisse-webrtc
2016/06/22 11:01:48
Problem is, that it's only clear that the methods
nisse-webrtc
2016/06/22 11:58:36
Done.
| |
62 // webrtc::VideoFrame merge. | |
57 virtual VideoFrame *Copy() const = 0; | 63 virtual VideoFrame *Copy() const = 0; |
58 | 64 |
59 // Return a copy of frame which has its pending rotation applied. The | 65 // Return a copy of frame which has its pending rotation applied. The |
60 // ownership of the returned frame is held by this frame. | 66 // ownership of the returned frame is held by this frame. |
67 | |
68 // TODO(nisse): Should be moved or deleted in the cricket::VideoFrame and | |
69 // webrtc::VideoFrame merge. | |
61 virtual const VideoFrame* GetCopyWithRotationApplied() const = 0; | 70 virtual const VideoFrame* GetCopyWithRotationApplied() const = 0; |
62 | 71 |
63 // Converts the I420 data to RGB of a certain type such as ARGB and ABGR. | 72 // 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 | 73 // 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. | 74 // not (like snprintf). Parameters size and stride_rgb are in units of bytes. |
66 // If there is insufficient space, nothing is written. | 75 // If there is insufficient space, nothing is written. |
76 // TODO(nisse): Should be moved or deleted in the cricket::VideoFrame and | |
77 // webrtc::VideoFrame merge. | |
67 virtual size_t ConvertToRgbBuffer(uint32_t to_fourcc, | 78 virtual size_t ConvertToRgbBuffer(uint32_t to_fourcc, |
68 uint8_t* buffer, | 79 uint8_t* buffer, |
69 size_t size, | 80 size_t size, |
70 int stride_rgb) const; | 81 int stride_rgb) const; |
71 | 82 |
72 // Tests if sample is valid. Returns true if valid. | 83 // Tests if sample is valid. Returns true if valid. |
84 // TODO(nisse): Should be deleted in the cricket::VideoFrame and | |
85 // webrtc::VideoFrame merge. Validation of sample_size possibly moved to | |
86 // libyuv::ConvertToI420. | |
73 static bool Validate(uint32_t fourcc, | 87 static bool Validate(uint32_t fourcc, |
nisse-webrtc
2016/06/22 11:58:36
This method could probably be moved from public to
| |
74 int w, | 88 int w, |
75 int h, | 89 int h, |
76 const uint8_t* sample, | 90 const uint8_t* sample, |
77 size_t sample_size); | 91 size_t sample_size); |
78 | 92 |
79 protected: | 93 protected: |
80 // Creates an empty frame. | 94 // Creates an empty frame. |
81 virtual VideoFrame* CreateEmptyFrame(int w, | 95 virtual VideoFrame* CreateEmptyFrame(int w, |
82 int h, | 96 int h, |
83 int64_t timestamp_us) const = 0; | 97 int64_t timestamp_us) const = 0; |
84 | 98 |
85 virtual void set_rotation(webrtc::VideoRotation rotation) = 0; | 99 virtual void set_rotation(webrtc::VideoRotation rotation) = 0; |
86 }; | 100 }; |
87 | 101 |
88 } // namespace cricket | 102 } // namespace cricket |
89 | 103 |
90 #endif // WEBRTC_MEDIA_BASE_VIDEOFRAME_H_ | 104 #endif // WEBRTC_MEDIA_BASE_VIDEOFRAME_H_ |
OLD | NEW |