Reason for revert: Chrome has been updated, cl https://codereview.chromium.org/1919283005/ Original issue's description: > Revert of Delete cricket::VideoFrame methods GetYPlane and GetYPitch. (patchset #5 id:80001 of https://codereview.webrtc.org/1901973002/ ) > > Reason for revert: > GetYPlane, GetYPitch etc is used by Chromium. > > Original issue's description: > > Delete cricket::VideoFrame methods GetYPlane and GetYPitch. > > > > (And similarly for U and V). Also change video_frame_buffer method to > > return a const ref to a scoped_ref_ptr. > > > > This cl is analogous to https://codereview.webrtc.org/1900673002/, > > which delete corresponding methods in webrtc::VideoFrame. > > > > BUG=webrtc:5682 > > > > Committed: https://crrev.com/1c27c6bf4cf0476dd2f09425509afaae4cdfe599 > > Cr-Commit-Position: refs/heads/master@{#12492} > > TBR=magjed@webrtc.org,perkj@webrtc.org,pbos@webrtc.org,pthatcher@webrtc.org,nisse@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:5682 > > Committed: https://crrev.com/b05f994bb6f3055c852891c8acb531aee916a668 > Cr-Commit-Position: refs/heads/master@{#12494} TBR=magjed@webrtc.org,perkj@webrtc.org,pbos@webrtc.org,pthatcher@webrtc.org,terelius@webrtc.org # Not skipping CQ checks because original CL landed more than 1 days ago. BUG=webrtc:5682 Review-Url: https://codereview.webrtc.org/1923903002 Cr-Commit-Position: refs/heads/master@{#12559}
127 lines
4.3 KiB
C++
127 lines
4.3 KiB
C++
/*
|
|
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#ifndef WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOFRAME_H_
|
|
#define WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOFRAME_H_
|
|
|
|
#include <memory>
|
|
|
|
#include "webrtc/base/buffer.h"
|
|
#include "webrtc/base/refcount.h"
|
|
#include "webrtc/base/scoped_ref_ptr.h"
|
|
#include "webrtc/common_types.h"
|
|
#include "webrtc/common_video/include/video_frame_buffer.h"
|
|
#include "webrtc/media/base/videoframe.h"
|
|
|
|
namespace cricket {
|
|
|
|
struct CapturedFrame;
|
|
|
|
class WebRtcVideoFrame : public VideoFrame {
|
|
public:
|
|
WebRtcVideoFrame();
|
|
|
|
// Preferred construction, with microsecond timestamp.
|
|
WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer,
|
|
webrtc::VideoRotation rotation,
|
|
int64_t timestamp_us);
|
|
|
|
// TODO(nisse): Deprecate/delete.
|
|
WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer,
|
|
int64_t time_stamp_ns,
|
|
webrtc::VideoRotation rotation);
|
|
|
|
~WebRtcVideoFrame();
|
|
|
|
// Creates a frame from a raw sample with FourCC "format" and size "w" x "h".
|
|
// "h" can be negative indicating a vertically flipped image.
|
|
// "dh" is destination height if cropping is desired and is always positive.
|
|
// Returns "true" if successful.
|
|
bool Init(uint32_t format,
|
|
int w,
|
|
int h,
|
|
int dw,
|
|
int dh,
|
|
uint8_t* sample,
|
|
size_t sample_size,
|
|
int64_t time_stamp_ns,
|
|
webrtc::VideoRotation rotation);
|
|
|
|
// The timestamp of the captured frame is expected to use the same
|
|
// timescale and epoch as rtc::Time.
|
|
// TODO(nisse): Consider adding a warning message, or even an RTC_DCHECK, if
|
|
// the time is too far off.
|
|
bool Init(const CapturedFrame* frame, int dw, int dh, bool apply_rotation);
|
|
|
|
void InitToEmptyBuffer(int w, int h);
|
|
void InitToEmptyBuffer(int w, int h, int64_t time_stamp_ns);
|
|
|
|
bool InitToBlack(int w, int h, int64_t time_stamp_ns);
|
|
|
|
int width() const override;
|
|
int height() const override;
|
|
|
|
void* GetNativeHandle() const override;
|
|
const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& video_frame_buffer()
|
|
const override;
|
|
|
|
/* System monotonic clock */
|
|
int64_t timestamp_us() const override { return timestamp_us_; }
|
|
void set_timestamp_us(int64_t time_us) override { timestamp_us_ = time_us; };
|
|
|
|
webrtc::VideoRotation rotation() const override { return rotation_; }
|
|
|
|
VideoFrame* Copy() const override;
|
|
bool IsExclusive() const override;
|
|
size_t ConvertToRgbBuffer(uint32_t to_fourcc,
|
|
uint8_t* buffer,
|
|
size_t size,
|
|
int stride_rgb) const override;
|
|
|
|
const VideoFrame* GetCopyWithRotationApplied() const override;
|
|
|
|
protected:
|
|
void set_rotation(webrtc::VideoRotation rotation) override {
|
|
rotation_ = rotation;
|
|
}
|
|
// Creates a frame from a raw sample with FourCC |format| and size |w| x |h|.
|
|
// |h| can be negative indicating a vertically flipped image.
|
|
// |dw| is destination width; can be less than |w| if cropping is desired.
|
|
// |dh| is destination height, like |dw|, but must be a positive number.
|
|
// Returns whether the function succeeded or failed.
|
|
bool Reset(uint32_t format,
|
|
int w,
|
|
int h,
|
|
int dw,
|
|
int dh,
|
|
uint8_t* sample,
|
|
size_t sample_size,
|
|
int64_t timestamp_us,
|
|
webrtc::VideoRotation rotation,
|
|
bool apply_rotation);
|
|
|
|
private:
|
|
VideoFrame* CreateEmptyFrame(int w, int h,
|
|
int64_t time_stamp_ns) const override;
|
|
|
|
// An opaque reference counted handle that stores the pixel data.
|
|
rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_;
|
|
int64_t timestamp_us_;
|
|
webrtc::VideoRotation rotation_;
|
|
|
|
// This is mutable as the calculation is expensive but once calculated, it
|
|
// remains const.
|
|
mutable std::unique_ptr<VideoFrame> rotated_frame_;
|
|
};
|
|
|
|
} // namespace cricket
|
|
|
|
#endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOFRAME_H_
|