| 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; | 25 using WebRtcVideoFrame = VideoFrame; |
| 26 | 26 #if 0 |
| 27 // TODO(nisse): This class will be deleted when the cricket::VideoFrame and | 27 // TODO(nisse): This class will be deleted when the cricket::VideoFrame and |
| 28 // webrtc::VideoFrame classes are merged. See | 28 // webrtc::VideoFrame classes are merged. See |
| 29 // https://bugs.chromium.org/p/webrtc/issues/detail?id=5682. Try to use only the | 29 // 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 | 30 // preferred constructor, and the non-deprecated methods of the VideoFrame base |
| 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(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 48 int64_t timestamp_us); | 48 int64_t timestamp_us); |
| 49 | 49 |
| 50 // TODO(nisse): Deprecated, delete as soon as all callers have switched to the | 50 // TODO(nisse): Deprecated, delete as soon as all callers have switched to the |
| 51 // above constructor with microsecond timestamp. | 51 // above constructor with microsecond timestamp. |
| 52 WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, | 52 WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, |
| 53 int64_t timestamp_ns, | 53 int64_t timestamp_ns, |
| 54 webrtc::VideoRotation rotation); | 54 webrtc::VideoRotation rotation); |
| 55 | 55 |
| 56 ~WebRtcVideoFrame(); | 56 ~WebRtcVideoFrame(); |
| 57 | 57 |
| 58 // TODO(nisse): Init (and its helpers Reset and Validate) are used |
| 59 // only by the LoadFrame function used in the VideoFrame unittests. |
| 60 // Rewrite tests, and delete this function. |
| 61 |
| 58 // Creates a frame from a raw sample with FourCC "format" and size "w" x "h". | 62 // Creates a frame from a raw sample with FourCC "format" and size "w" x "h". |
| 59 // "h" can be negative indicating a vertically flipped image. | 63 // "h" can be negative indicating a vertically flipped image. |
| 60 // "dh" is destination height if cropping is desired and is always positive. | 64 // "dh" is destination height if cropping is desired and is always positive. |
| 61 // Returns "true" if successful. | 65 // Returns "true" if successful. |
| 62 bool Init(uint32_t format, | 66 bool Init(uint32_t format, |
| 63 int w, | 67 int w, |
| 64 int h, | 68 int h, |
| 65 int dw, | 69 int dw, |
| 66 int dh, | 70 int dh, |
| 67 uint8_t* sample, | 71 uint8_t* sample, |
| 68 size_t sample_size, | 72 size_t sample_size, |
| 69 int64_t timestamp_ns, | 73 int64_t timestamp_ns, |
| 70 webrtc::VideoRotation rotation); | 74 webrtc::VideoRotation rotation); |
| 71 | 75 |
| 72 // TODO(nisse): We're moving to have all timestamps use the same | |
| 73 // time scale as rtc::TimeMicros. However, this method is used by | |
| 74 // WebRtcVideoFrameFactory::CreateAliasedFrame this code path | |
| 75 // currently does not conform to the new timestamp conventions and | |
| 76 // may use the camera's own clock instead. It's unclear if this | |
| 77 // should be fixed, or if instead all of the VideoFrameFactory | |
| 78 // abstraction should be eliminated. | |
| 79 bool Init(const CapturedFrame* frame, int dw, int dh, bool apply_rotation); | |
| 80 | |
| 81 void InitToEmptyBuffer(int w, int h); | 76 void InitToEmptyBuffer(int w, int h); |
| 82 | 77 |
| 83 int width() const override; | 78 int width() const override; |
| 84 int height() const override; | 79 int height() const override; |
| 85 | 80 |
| 86 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& video_frame_buffer() | 81 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& video_frame_buffer() |
| 87 const override; | 82 const override; |
| 88 | 83 |
| 89 uint32_t transport_frame_id() const override; | 84 uint32_t transport_frame_id() const override; |
| 90 | 85 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 117 // An opaque reference counted handle that stores the pixel data. | 112 // An opaque reference counted handle that stores the pixel data. |
| 118 rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_; | 113 rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_; |
| 119 int64_t timestamp_us_; | 114 int64_t timestamp_us_; |
| 120 uint32_t transport_frame_id_; | 115 uint32_t transport_frame_id_; |
| 121 webrtc::VideoRotation rotation_; | 116 webrtc::VideoRotation rotation_; |
| 122 | 117 |
| 123 // This is mutable as the calculation is expensive but once calculated, it | 118 // This is mutable as the calculation is expensive but once calculated, it |
| 124 // remains const. | 119 // remains const. |
| 125 mutable std::unique_ptr<VideoFrame> rotated_frame_; | 120 mutable std::unique_ptr<VideoFrame> rotated_frame_; |
| 126 }; | 121 }; |
| 122 #endif |
| 127 | 123 |
| 128 } // namespace cricket | 124 } // namespace cricket |
| 129 | 125 |
| 130 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOFRAME_H_ | 126 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOFRAME_H_ |
| OLD | NEW |