Move VideoFrame and related declarations to webrtc/api/video.
Moves webrtc/common_video/rotation.h and parts of webrtc/common_video/include/video_frame_buffer.h and webrtc/video_frame.h, and adds to a new GN target api:video_frame_api. BUG=webrtc:5880 Review-Url: https://codereview.webrtc.org/2517173004 Cr-Commit-Position: refs/heads/master@{#15993}
This commit is contained in:
parent
658024ee92
commit
af916899cc
@ -11,7 +11,6 @@ include_rules = [
|
||||
# Individual headers that will be moved out of here, see webrtc:4243.
|
||||
"+webrtc/call.h",
|
||||
"+webrtc/common_types.h",
|
||||
"+webrtc/common_video/rotation.h",
|
||||
"+webrtc/config.h",
|
||||
"+webrtc/transport.h",
|
||||
"+webrtc/typedefs.h",
|
||||
|
||||
@ -177,11 +177,17 @@ rtc_source_set("transport_api") {
|
||||
|
||||
rtc_source_set("video_frame_api") {
|
||||
sources = [
|
||||
"video/i420_buffer.cc",
|
||||
"video/i420_buffer.h",
|
||||
"video/video_frame.cc",
|
||||
"video/video_frame.h",
|
||||
"video/video_frame_buffer.h",
|
||||
"video/video_rotation.h",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"../base:rtc_base_approved",
|
||||
"../system_wrappers",
|
||||
]
|
||||
|
||||
# TODO(nisse): This logic is duplicated in multiple places.
|
||||
|
||||
@ -22,13 +22,17 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
// TODO(nisse): Transition hack, Chrome expects that including this
|
||||
// file declares I420Buffer. Delete after users of I420Buffer are
|
||||
// fixed to include the new header.
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/base/refcount.h"
|
||||
#include "webrtc/base/scoped_ref_ptr.h"
|
||||
#include "webrtc/base/optional.h"
|
||||
#include "webrtc/media/base/mediachannel.h"
|
||||
#include "webrtc/media/base/videosinkinterface.h"
|
||||
#include "webrtc/media/base/videosourceinterface.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
||||
260
webrtc/api/video/i420_buffer.cc
Normal file
260
webrtc/api/video/i420_buffer.cc
Normal file
@ -0,0 +1,260 @@
|
||||
/*
|
||||
* Copyright (c) 2015 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.
|
||||
*/
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/keep_ref_until_done.h"
|
||||
#include "libyuv/convert.h"
|
||||
#include "libyuv/planar_functions.h"
|
||||
#include "libyuv/scale.h"
|
||||
|
||||
// Aligning pointer to 64 bytes for improved performance, e.g. use SIMD.
|
||||
static const int kBufferAlignment = 64;
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
namespace {
|
||||
|
||||
int I420DataSize(int height, int stride_y, int stride_u, int stride_v) {
|
||||
return stride_y * height + (stride_u + stride_v) * ((height + 1) / 2);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
I420Buffer::I420Buffer(int width, int height)
|
||||
: I420Buffer(width, height, width, (width + 1) / 2, (width + 1) / 2) {
|
||||
}
|
||||
|
||||
I420Buffer::I420Buffer(int width,
|
||||
int height,
|
||||
int stride_y,
|
||||
int stride_u,
|
||||
int stride_v)
|
||||
: width_(width),
|
||||
height_(height),
|
||||
stride_y_(stride_y),
|
||||
stride_u_(stride_u),
|
||||
stride_v_(stride_v),
|
||||
data_(static_cast<uint8_t*>(AlignedMalloc(
|
||||
I420DataSize(height, stride_y, stride_u, stride_v),
|
||||
kBufferAlignment))) {
|
||||
RTC_DCHECK_GT(width, 0);
|
||||
RTC_DCHECK_GT(height, 0);
|
||||
RTC_DCHECK_GE(stride_y, width);
|
||||
RTC_DCHECK_GE(stride_u, (width + 1) / 2);
|
||||
RTC_DCHECK_GE(stride_v, (width + 1) / 2);
|
||||
}
|
||||
|
||||
I420Buffer::~I420Buffer() {
|
||||
}
|
||||
|
||||
// static
|
||||
rtc::scoped_refptr<I420Buffer> I420Buffer::Create(int width, int height) {
|
||||
return new rtc::RefCountedObject<I420Buffer>(width, height);
|
||||
}
|
||||
|
||||
// static
|
||||
rtc::scoped_refptr<I420Buffer> I420Buffer::Create(int width,
|
||||
int height,
|
||||
int stride_y,
|
||||
int stride_u,
|
||||
int stride_v) {
|
||||
return new rtc::RefCountedObject<I420Buffer>(
|
||||
width, height, stride_y, stride_u, stride_v);
|
||||
}
|
||||
|
||||
// static
|
||||
rtc::scoped_refptr<I420Buffer> I420Buffer::Copy(
|
||||
const VideoFrameBuffer& source) {
|
||||
return Copy(source.width(), source.height(),
|
||||
source.DataY(), source.StrideY(),
|
||||
source.DataU(), source.StrideU(),
|
||||
source.DataV(), source.StrideV());
|
||||
}
|
||||
|
||||
// static
|
||||
rtc::scoped_refptr<I420Buffer> I420Buffer::Copy(
|
||||
int width, int height,
|
||||
const uint8_t* data_y, int stride_y,
|
||||
const uint8_t* data_u, int stride_u,
|
||||
const uint8_t* data_v, int stride_v) {
|
||||
// Note: May use different strides than the input data.
|
||||
rtc::scoped_refptr<I420Buffer> buffer = Create(width, height);
|
||||
RTC_CHECK_EQ(0, libyuv::I420Copy(data_y, stride_y,
|
||||
data_u, stride_u,
|
||||
data_v, stride_v,
|
||||
buffer->MutableDataY(), buffer->StrideY(),
|
||||
buffer->MutableDataU(), buffer->StrideU(),
|
||||
buffer->MutableDataV(), buffer->StrideV(),
|
||||
width, height));
|
||||
return buffer;
|
||||
}
|
||||
|
||||
// static
|
||||
rtc::scoped_refptr<I420Buffer> I420Buffer::Rotate(
|
||||
const VideoFrameBuffer& src, VideoRotation rotation) {
|
||||
RTC_CHECK(src.DataY());
|
||||
RTC_CHECK(src.DataU());
|
||||
RTC_CHECK(src.DataV());
|
||||
|
||||
int rotated_width = src.width();
|
||||
int rotated_height = src.height();
|
||||
if (rotation == webrtc::kVideoRotation_90 ||
|
||||
rotation == webrtc::kVideoRotation_270) {
|
||||
std::swap(rotated_width, rotated_height);
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<webrtc::I420Buffer> buffer =
|
||||
I420Buffer::Create(rotated_width, rotated_height);
|
||||
|
||||
RTC_CHECK_EQ(0, libyuv::I420Rotate(
|
||||
src.DataY(), src.StrideY(),
|
||||
src.DataU(), src.StrideU(),
|
||||
src.DataV(), src.StrideV(),
|
||||
buffer->MutableDataY(), buffer->StrideY(), buffer->MutableDataU(),
|
||||
buffer->StrideU(), buffer->MutableDataV(), buffer->StrideV(),
|
||||
src.width(), src.height(),
|
||||
static_cast<libyuv::RotationMode>(rotation)));
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
// static
|
||||
rtc::scoped_refptr<VideoFrameBuffer> I420Buffer::Rotate(
|
||||
rtc::scoped_refptr<VideoFrameBuffer> src,
|
||||
VideoRotation rotation) {
|
||||
if (rotation == webrtc::kVideoRotation_0) {
|
||||
return src;
|
||||
} else {
|
||||
return Rotate(*src, rotation);
|
||||
}
|
||||
}
|
||||
|
||||
void I420Buffer::InitializeData() {
|
||||
memset(data_.get(), 0,
|
||||
I420DataSize(height_, stride_y_, stride_u_, stride_v_));
|
||||
}
|
||||
|
||||
int I420Buffer::width() const {
|
||||
return width_;
|
||||
}
|
||||
|
||||
int I420Buffer::height() const {
|
||||
return height_;
|
||||
}
|
||||
|
||||
const uint8_t* I420Buffer::DataY() const {
|
||||
return data_.get();
|
||||
}
|
||||
const uint8_t* I420Buffer::DataU() const {
|
||||
return data_.get() + stride_y_ * height_;
|
||||
}
|
||||
const uint8_t* I420Buffer::DataV() const {
|
||||
return data_.get() + stride_y_ * height_ + stride_u_ * ((height_ + 1) / 2);
|
||||
}
|
||||
|
||||
int I420Buffer::StrideY() const {
|
||||
return stride_y_;
|
||||
}
|
||||
int I420Buffer::StrideU() const {
|
||||
return stride_u_;
|
||||
}
|
||||
int I420Buffer::StrideV() const {
|
||||
return stride_v_;
|
||||
}
|
||||
|
||||
void* I420Buffer::native_handle() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<VideoFrameBuffer> I420Buffer::NativeToI420Buffer() {
|
||||
RTC_NOTREACHED();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint8_t* I420Buffer::MutableDataY() {
|
||||
return const_cast<uint8_t*>(DataY());
|
||||
}
|
||||
uint8_t* I420Buffer::MutableDataU() {
|
||||
return const_cast<uint8_t*>(DataU());
|
||||
}
|
||||
uint8_t* I420Buffer::MutableDataV() {
|
||||
return const_cast<uint8_t*>(DataV());
|
||||
}
|
||||
|
||||
// static
|
||||
void I420Buffer::SetBlack(I420Buffer* buffer) {
|
||||
RTC_CHECK(libyuv::I420Rect(buffer->MutableDataY(), buffer->StrideY(),
|
||||
buffer->MutableDataU(), buffer->StrideU(),
|
||||
buffer->MutableDataV(), buffer->StrideV(),
|
||||
0, 0, buffer->width(), buffer->height(),
|
||||
0, 128, 128) == 0);
|
||||
}
|
||||
|
||||
void I420Buffer::CropAndScaleFrom(
|
||||
const VideoFrameBuffer& src,
|
||||
int offset_x,
|
||||
int offset_y,
|
||||
int crop_width,
|
||||
int crop_height) {
|
||||
RTC_CHECK_LE(crop_width, src.width());
|
||||
RTC_CHECK_LE(crop_height, src.height());
|
||||
RTC_CHECK_LE(crop_width + offset_x, src.width());
|
||||
RTC_CHECK_LE(crop_height + offset_y, src.height());
|
||||
RTC_CHECK_GE(offset_x, 0);
|
||||
RTC_CHECK_GE(offset_y, 0);
|
||||
|
||||
// Make sure offset is even so that u/v plane becomes aligned.
|
||||
const int uv_offset_x = offset_x / 2;
|
||||
const int uv_offset_y = offset_y / 2;
|
||||
offset_x = uv_offset_x * 2;
|
||||
offset_y = uv_offset_y * 2;
|
||||
|
||||
const uint8_t* y_plane =
|
||||
src.DataY() + src.StrideY() * offset_y + offset_x;
|
||||
const uint8_t* u_plane =
|
||||
src.DataU() + src.StrideU() * uv_offset_y + uv_offset_x;
|
||||
const uint8_t* v_plane =
|
||||
src.DataV() + src.StrideV() * uv_offset_y + uv_offset_x;
|
||||
int res = libyuv::I420Scale(y_plane, src.StrideY(),
|
||||
u_plane, src.StrideU(),
|
||||
v_plane, src.StrideV(),
|
||||
crop_width, crop_height,
|
||||
MutableDataY(), StrideY(),
|
||||
MutableDataU(), StrideU(),
|
||||
MutableDataV(), StrideV(),
|
||||
width(), height(), libyuv::kFilterBox);
|
||||
|
||||
RTC_DCHECK_EQ(res, 0);
|
||||
}
|
||||
|
||||
void I420Buffer::CropAndScaleFrom(
|
||||
const VideoFrameBuffer& src) {
|
||||
const int crop_width =
|
||||
std::min(src.width(), width() * src.height() / height());
|
||||
const int crop_height =
|
||||
std::min(src.height(), height() * src.width() / width());
|
||||
|
||||
CropAndScaleFrom(
|
||||
src,
|
||||
(src.width() - crop_width) / 2, (src.height() - crop_height) / 2,
|
||||
crop_width, crop_height);
|
||||
}
|
||||
|
||||
void I420Buffer::ScaleFrom(const VideoFrameBuffer& src) {
|
||||
CropAndScaleFrom(src, 0, 0, src.width(), src.height());
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
116
webrtc/api/video/i420_buffer.h
Normal file
116
webrtc/api/video/i420_buffer.h
Normal file
@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 2015 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_API_VIDEO_I420_BUFFER_H_
|
||||
#define WEBRTC_API_VIDEO_I420_BUFFER_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/api/video/video_rotation.h"
|
||||
#include "webrtc/api/video/video_frame_buffer.h"
|
||||
#include "webrtc/system_wrappers/include/aligned_malloc.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// Plain I420 buffer in standard memory.
|
||||
class I420Buffer : public VideoFrameBuffer {
|
||||
public:
|
||||
static rtc::scoped_refptr<I420Buffer> Create(int width, int height);
|
||||
static rtc::scoped_refptr<I420Buffer> Create(int width,
|
||||
int height,
|
||||
int stride_y,
|
||||
int stride_u,
|
||||
int stride_v);
|
||||
|
||||
// Create a new buffer and copy the pixel data.
|
||||
static rtc::scoped_refptr<I420Buffer> Copy(const VideoFrameBuffer& buffer);
|
||||
|
||||
static rtc::scoped_refptr<I420Buffer> Copy(
|
||||
int width, int height,
|
||||
const uint8_t* data_y, int stride_y,
|
||||
const uint8_t* data_u, int stride_u,
|
||||
const uint8_t* data_v, int stride_v);
|
||||
|
||||
// Returns a rotated copy of |src|.
|
||||
static rtc::scoped_refptr<I420Buffer> Rotate(const VideoFrameBuffer& src,
|
||||
VideoRotation rotation);
|
||||
|
||||
// Sets the buffer to all black.
|
||||
static void SetBlack(I420Buffer* buffer);
|
||||
|
||||
// Sets all three planes to all zeros. Used to work around for
|
||||
// quirks in memory checkers
|
||||
// (https://bugs.chromium.org/p/libyuv/issues/detail?id=377) and
|
||||
// ffmpeg (http://crbug.com/390941).
|
||||
// TODO(nisse): Deprecated. Should be deleted if/when those issues
|
||||
// are resolved in a better way. Or in the mean time, use SetBlack.
|
||||
void InitializeData();
|
||||
|
||||
// TODO(nisse): Deprecated, use static method instead.
|
||||
void SetToBlack() { SetBlack(this); }
|
||||
|
||||
int width() const override;
|
||||
int height() const override;
|
||||
const uint8_t* DataY() const override;
|
||||
const uint8_t* DataU() const override;
|
||||
const uint8_t* DataV() const override;
|
||||
|
||||
int StrideY() const override;
|
||||
int StrideU() const override;
|
||||
int StrideV() const override;
|
||||
|
||||
void* native_handle() const override;
|
||||
rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override;
|
||||
|
||||
uint8_t* MutableDataY();
|
||||
uint8_t* MutableDataU();
|
||||
uint8_t* MutableDataV();
|
||||
|
||||
// Scale the cropped area of |src| to the size of |this| buffer, and
|
||||
// write the result into |this|.
|
||||
void CropAndScaleFrom(const VideoFrameBuffer& src,
|
||||
int offset_x,
|
||||
int offset_y,
|
||||
int crop_width,
|
||||
int crop_height);
|
||||
|
||||
// The common case of a center crop, when needed to adjust the
|
||||
// aspect ratio without distorting the image.
|
||||
void CropAndScaleFrom(const VideoFrameBuffer& src);
|
||||
|
||||
// Scale all of |src| to the size of |this| buffer, with no cropping.
|
||||
void ScaleFrom(const VideoFrameBuffer& src);
|
||||
|
||||
// TODO(nisse): Deprecated, delete once downstream applications are updated.
|
||||
// Returns a rotated versions of |src|. Native buffers are not
|
||||
// supported. The reason this function doesn't return an I420Buffer,
|
||||
// is that it returns |src| unchanged in case |rotation| is zero.
|
||||
static rtc::scoped_refptr<VideoFrameBuffer> Rotate(
|
||||
rtc::scoped_refptr<VideoFrameBuffer> src,
|
||||
VideoRotation rotation);
|
||||
|
||||
protected:
|
||||
I420Buffer(int width, int height);
|
||||
I420Buffer(int width, int height, int stride_y, int stride_u, int stride_v);
|
||||
|
||||
~I420Buffer() override;
|
||||
|
||||
private:
|
||||
const int width_;
|
||||
const int height_;
|
||||
const int stride_y_;
|
||||
const int stride_u_;
|
||||
const int stride_v_;
|
||||
const std::unique_ptr<uint8_t, AlignedFreeDeleter> data_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_API_VIDEO_I420_BUFFER_H_
|
||||
66
webrtc/api/video/video_frame.cc
Normal file
66
webrtc/api/video/video_frame.cc
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2012 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.
|
||||
*/
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/timeutils.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
VideoFrame::VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
|
||||
webrtc::VideoRotation rotation,
|
||||
int64_t timestamp_us)
|
||||
: video_frame_buffer_(buffer),
|
||||
timestamp_rtp_(0),
|
||||
ntp_time_ms_(0),
|
||||
timestamp_us_(timestamp_us),
|
||||
rotation_(rotation) {}
|
||||
|
||||
VideoFrame::VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
|
||||
uint32_t timestamp,
|
||||
int64_t render_time_ms,
|
||||
VideoRotation rotation)
|
||||
: video_frame_buffer_(buffer),
|
||||
timestamp_rtp_(timestamp),
|
||||
ntp_time_ms_(0),
|
||||
timestamp_us_(render_time_ms * rtc::kNumMicrosecsPerMillisec),
|
||||
rotation_(rotation) {
|
||||
RTC_DCHECK(buffer);
|
||||
}
|
||||
|
||||
VideoFrame::~VideoFrame() = default;
|
||||
|
||||
VideoFrame::VideoFrame(const VideoFrame&) = default;
|
||||
VideoFrame::VideoFrame(VideoFrame&&) = default;
|
||||
VideoFrame& VideoFrame::operator=(const VideoFrame&) = default;
|
||||
VideoFrame& VideoFrame::operator=(VideoFrame&&) = default;
|
||||
|
||||
int VideoFrame::width() const {
|
||||
return video_frame_buffer_ ? video_frame_buffer_->width() : 0;
|
||||
}
|
||||
|
||||
int VideoFrame::height() const {
|
||||
return video_frame_buffer_ ? video_frame_buffer_->height() : 0;
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<VideoFrameBuffer> VideoFrame::video_frame_buffer() const {
|
||||
return video_frame_buffer_;
|
||||
}
|
||||
|
||||
void VideoFrame::set_render_time_ms(int64_t render_time_ms) {
|
||||
set_timestamp_us(render_time_ms * rtc::kNumMicrosecsPerMillisec);
|
||||
}
|
||||
|
||||
int64_t VideoFrame::render_time_ms() const {
|
||||
return timestamp_us() / rtc::kNumMicrosecsPerMillisec;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
119
webrtc/api/video/video_frame.h
Normal file
119
webrtc/api/video/video_frame.h
Normal file
@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (c) 2014 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_API_VIDEO_VIDEO_FRAME_H_
|
||||
#define WEBRTC_API_VIDEO_VIDEO_FRAME_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "webrtc/api/video/video_rotation.h"
|
||||
#include "webrtc/api/video/video_frame_buffer.h"
|
||||
|
||||
// TODO(nisse): Transition hack, some downstream applications expect
|
||||
// that including this file also defines base/timeutils.h constants.
|
||||
// Delete after applications are fixed to include the right headers.
|
||||
#include "webrtc/base/timeutils.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class VideoFrame {
|
||||
public:
|
||||
// TODO(nisse): This constructor is consistent with the now deleted
|
||||
// cricket::WebRtcVideoFrame. We should consider whether or not we
|
||||
// want to stick to this style and deprecate the other constructor.
|
||||
VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
|
||||
webrtc::VideoRotation rotation,
|
||||
int64_t timestamp_us);
|
||||
|
||||
// Preferred constructor.
|
||||
VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
|
||||
uint32_t timestamp,
|
||||
int64_t render_time_ms,
|
||||
VideoRotation rotation);
|
||||
|
||||
~VideoFrame();
|
||||
|
||||
// Support move and copy.
|
||||
VideoFrame(const VideoFrame&);
|
||||
VideoFrame(VideoFrame&&);
|
||||
VideoFrame& operator=(const VideoFrame&);
|
||||
VideoFrame& operator=(VideoFrame&&);
|
||||
|
||||
// Get frame width.
|
||||
int width() const;
|
||||
|
||||
// Get frame height.
|
||||
int height() const;
|
||||
|
||||
// System monotonic clock, same timebase as rtc::TimeMicros().
|
||||
int64_t timestamp_us() const { return timestamp_us_; }
|
||||
void set_timestamp_us(int64_t timestamp_us) { timestamp_us_ = timestamp_us; }
|
||||
|
||||
// TODO(nisse): After the cricket::VideoFrame and webrtc::VideoFrame
|
||||
// merge, timestamps other than timestamp_us will likely be
|
||||
// deprecated.
|
||||
|
||||
// Set frame timestamp (90kHz).
|
||||
void set_timestamp(uint32_t timestamp) { timestamp_rtp_ = timestamp; }
|
||||
|
||||
// Get frame timestamp (90kHz).
|
||||
uint32_t timestamp() const { return timestamp_rtp_; }
|
||||
|
||||
// For now, transport_frame_id and rtp timestamp are the same.
|
||||
// TODO(nisse): Must be handled differently for QUIC.
|
||||
uint32_t transport_frame_id() const { return timestamp(); }
|
||||
|
||||
// Set capture ntp time in milliseconds.
|
||||
void set_ntp_time_ms(int64_t ntp_time_ms) { ntp_time_ms_ = ntp_time_ms; }
|
||||
|
||||
// Get capture ntp time in milliseconds.
|
||||
int64_t ntp_time_ms() const { return ntp_time_ms_; }
|
||||
|
||||
// Naming convention for Coordination of Video Orientation. Please see
|
||||
// http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ts_126114v120700p.pdf
|
||||
//
|
||||
// "pending rotation" or "pending" = a frame that has a VideoRotation > 0.
|
||||
//
|
||||
// "not pending" = a frame that has a VideoRotation == 0.
|
||||
//
|
||||
// "apply rotation" = modify a frame from being "pending" to being "not
|
||||
// pending" rotation (a no-op for "unrotated").
|
||||
//
|
||||
VideoRotation rotation() const { return rotation_; }
|
||||
void set_rotation(VideoRotation rotation) { rotation_ = rotation; }
|
||||
|
||||
// Set render time in milliseconds.
|
||||
void set_render_time_ms(int64_t render_time_ms);
|
||||
|
||||
// Get render time in milliseconds.
|
||||
int64_t render_time_ms() const;
|
||||
|
||||
// Return the underlying buffer. Never nullptr for a properly
|
||||
// initialized VideoFrame.
|
||||
rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer() const;
|
||||
|
||||
// TODO(nisse): Deprecated.
|
||||
// Return true if the frame is stored in a texture.
|
||||
bool is_texture() const {
|
||||
return video_frame_buffer()->native_handle() != nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
// An opaque reference counted handle that stores the pixel data.
|
||||
rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_;
|
||||
uint32_t timestamp_rtp_;
|
||||
int64_t ntp_time_ms_;
|
||||
int64_t timestamp_us_;
|
||||
VideoRotation rotation_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_API_VIDEO_VIDEO_FRAME_H_
|
||||
55
webrtc/api/video/video_frame_buffer.h
Normal file
55
webrtc/api/video/video_frame_buffer.h
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2015 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_API_VIDEO_VIDEO_FRAME_BUFFER_H_
|
||||
#define WEBRTC_API_VIDEO_VIDEO_FRAME_BUFFER_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "webrtc/base/refcount.h"
|
||||
#include "webrtc/base/scoped_ref_ptr.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// Interface of a simple frame buffer containing pixel data. This interface does
|
||||
// not contain any frame metadata such as rotation, timestamp, pixel_width, etc.
|
||||
class VideoFrameBuffer : public rtc::RefCountInterface {
|
||||
public:
|
||||
// The resolution of the frame in pixels. For formats where some planes are
|
||||
// subsampled, this is the highest-resolution plane.
|
||||
virtual int width() const = 0;
|
||||
virtual int height() const = 0;
|
||||
|
||||
// Returns pointer to the pixel data for a given plane. The memory is owned by
|
||||
// the VideoFrameBuffer object and must not be freed by the caller.
|
||||
virtual const uint8_t* DataY() const = 0;
|
||||
virtual const uint8_t* DataU() const = 0;
|
||||
virtual const uint8_t* DataV() const = 0;
|
||||
|
||||
// Returns the number of bytes between successive rows for a given plane.
|
||||
virtual int StrideY() const = 0;
|
||||
virtual int StrideU() const = 0;
|
||||
virtual int StrideV() const = 0;
|
||||
|
||||
// Return the handle of the underlying video frame. This is used when the
|
||||
// frame is backed by a texture.
|
||||
virtual void* native_handle() const = 0;
|
||||
|
||||
// Returns a new memory-backed frame buffer converted from this buffer's
|
||||
// native handle.
|
||||
virtual rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() = 0;
|
||||
|
||||
protected:
|
||||
~VideoFrameBuffer() override {}
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_API_VIDEO_VIDEO_FRAME_BUFFER_H_
|
||||
@ -18,9 +18,9 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/api/video/video_rotation.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/optional.h"
|
||||
#include "webrtc/common_video/rotation.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
@ -60,12 +60,13 @@ rtc_static_library("common_video") {
|
||||
"../base:rtc_task_queue",
|
||||
"../system_wrappers",
|
||||
]
|
||||
public_deps = [
|
||||
"../api:video_frame_api",
|
||||
]
|
||||
|
||||
if (rtc_build_libyuv) {
|
||||
deps += [ "$rtc_libyuv_dir" ]
|
||||
public_deps = [
|
||||
"$rtc_libyuv_dir",
|
||||
]
|
||||
public_deps += [ "$rtc_libyuv_dir" ]
|
||||
} else {
|
||||
# Need to add a directory normally exported by libyuv.
|
||||
include_dirs += [ "$rtc_libyuv_dir/include" ]
|
||||
|
||||
@ -11,11 +11,12 @@
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/base/bind.h"
|
||||
#include "webrtc/base/timeutils.h"
|
||||
#include "webrtc/test/fake_texture_frame.h"
|
||||
#include "webrtc/test/frame_utils.h"
|
||||
#include "webrtc/test/gtest.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -280,7 +281,7 @@ class TestI420BufferRotate
|
||||
TEST_P(TestI420BufferRotate, Rotates) {
|
||||
rtc::scoped_refptr<VideoFrameBuffer> buffer = CreateGradient(640, 480);
|
||||
rtc::scoped_refptr<VideoFrameBuffer> rotated_buffer =
|
||||
I420Buffer::Rotate(buffer, GetParam());
|
||||
I420Buffer::Rotate(*buffer, GetParam());
|
||||
CheckRotate(640, 480, GetParam(), *rotated_buffer);
|
||||
}
|
||||
|
||||
@ -290,4 +291,20 @@ INSTANTIATE_TEST_CASE_P(Rotate, TestI420BufferRotate,
|
||||
kVideoRotation_180,
|
||||
kVideoRotation_270));
|
||||
|
||||
class TestI420BufferRotateOld
|
||||
: public ::testing::TestWithParam<webrtc::VideoRotation> {};
|
||||
|
||||
TEST_P(TestI420BufferRotateOld, Rotates) {
|
||||
rtc::scoped_refptr<VideoFrameBuffer> buffer = CreateGradient(640, 480);
|
||||
rtc::scoped_refptr<VideoFrameBuffer> rotated_buffer =
|
||||
I420Buffer::Rotate(buffer, GetParam());
|
||||
CheckRotate(640, 480, GetParam(), *rotated_buffer);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Rotate, TestI420BufferRotateOld,
|
||||
::testing::Values(kVideoRotation_0,
|
||||
kVideoRotation_90,
|
||||
kVideoRotation_180,
|
||||
kVideoRotation_270));
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -57,4 +57,3 @@ class CoreVideoFrameBuffer : public NativeHandleBuffer {
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_COMMON_VIDEO_INCLUDE_COREVIDEO_FRAME_BUFFER_H_
|
||||
|
||||
|
||||
@ -14,8 +14,8 @@
|
||||
#include <list>
|
||||
#include <limits>
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/base/race_checker.h"
|
||||
#include "webrtc/common_video/include/video_frame_buffer.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
||||
@ -11,135 +11,17 @@
|
||||
#ifndef WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_BUFFER_H_
|
||||
#define WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_BUFFER_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/api/video/video_frame_buffer.h"
|
||||
// TODO(nisse): For backwards compatibility, files including this file
|
||||
// expect it to declare I420Buffer. Delete after callers are updated.
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/base/callback.h"
|
||||
#include "webrtc/base/refcount.h"
|
||||
#include "webrtc/base/scoped_ref_ptr.h"
|
||||
#include "webrtc/common_video/rotation.h"
|
||||
#include "webrtc/system_wrappers/include/aligned_malloc.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// Interface of a simple frame buffer containing pixel data. This interface does
|
||||
// not contain any frame metadata such as rotation, timestamp, pixel_width, etc.
|
||||
class VideoFrameBuffer : public rtc::RefCountInterface {
|
||||
public:
|
||||
// The resolution of the frame in pixels. For formats where some planes are
|
||||
// subsampled, this is the highest-resolution plane.
|
||||
virtual int width() const = 0;
|
||||
virtual int height() const = 0;
|
||||
|
||||
// Returns pointer to the pixel data for a given plane. The memory is owned by
|
||||
// the VideoFrameBuffer object and must not be freed by the caller.
|
||||
virtual const uint8_t* DataY() const = 0;
|
||||
virtual const uint8_t* DataU() const = 0;
|
||||
virtual const uint8_t* DataV() const = 0;
|
||||
|
||||
// Returns the number of bytes between successive rows for a given plane.
|
||||
virtual int StrideY() const = 0;
|
||||
virtual int StrideU() const = 0;
|
||||
virtual int StrideV() const = 0;
|
||||
|
||||
// Return the handle of the underlying video frame. This is used when the
|
||||
// frame is backed by a texture.
|
||||
virtual void* native_handle() const = 0;
|
||||
|
||||
// Returns a new memory-backed frame buffer converted from this buffer's
|
||||
// native handle.
|
||||
virtual rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() = 0;
|
||||
|
||||
protected:
|
||||
virtual ~VideoFrameBuffer();
|
||||
};
|
||||
|
||||
// Plain I420 buffer in standard memory.
|
||||
class I420Buffer : public VideoFrameBuffer {
|
||||
public:
|
||||
static rtc::scoped_refptr<I420Buffer> Create(int width, int height);
|
||||
static rtc::scoped_refptr<I420Buffer> Create(int width,
|
||||
int height,
|
||||
int stride_y,
|
||||
int stride_u,
|
||||
int stride_v);
|
||||
|
||||
// Create a new buffer and copy the pixel data.
|
||||
static rtc::scoped_refptr<I420Buffer> Copy(const VideoFrameBuffer& buffer);
|
||||
|
||||
static rtc::scoped_refptr<I420Buffer> Copy(
|
||||
int width, int height,
|
||||
const uint8_t* data_y, int stride_y,
|
||||
const uint8_t* data_u, int stride_u,
|
||||
const uint8_t* data_v, int stride_v);
|
||||
|
||||
// Returns a rotated versions of |src|. Native buffers are not
|
||||
// supported. The reason this function doesn't return an I420Buffer,
|
||||
// is that it returns |src| unchanged in case |rotation| is zero.
|
||||
// TODO(nisse): Consider dropping the special handling of zero
|
||||
// rotation, and leave any optimizing that case to the caller.
|
||||
static rtc::scoped_refptr<VideoFrameBuffer> Rotate(
|
||||
rtc::scoped_refptr<VideoFrameBuffer> src,
|
||||
VideoRotation rotation);
|
||||
|
||||
// Sets all three planes to all zeros. Used to work around for
|
||||
// quirks in memory checkers
|
||||
// (https://bugs.chromium.org/p/libyuv/issues/detail?id=377) and
|
||||
// ffmpeg (http://crbug.com/390941).
|
||||
// TODO(nisse): Should be deleted if/when those issues are resolved
|
||||
// in a better way.
|
||||
void InitializeData();
|
||||
|
||||
// Sets the frame buffer to all black.
|
||||
void SetToBlack();
|
||||
|
||||
int width() const override;
|
||||
int height() const override;
|
||||
const uint8_t* DataY() const override;
|
||||
const uint8_t* DataU() const override;
|
||||
const uint8_t* DataV() const override;
|
||||
|
||||
uint8_t* MutableDataY();
|
||||
uint8_t* MutableDataU();
|
||||
uint8_t* MutableDataV();
|
||||
int StrideY() const override;
|
||||
int StrideU() const override;
|
||||
int StrideV() const override;
|
||||
|
||||
void* native_handle() const override;
|
||||
rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override;
|
||||
|
||||
// Scale the cropped area of |src| to the size of |this| buffer, and
|
||||
// write the result into |this|.
|
||||
void CropAndScaleFrom(const VideoFrameBuffer& src,
|
||||
int offset_x,
|
||||
int offset_y,
|
||||
int crop_width,
|
||||
int crop_height);
|
||||
|
||||
// The common case of a center crop, when needed to adjust the
|
||||
// aspect ratio without distorting the image.
|
||||
void CropAndScaleFrom(const VideoFrameBuffer& src);
|
||||
|
||||
// Scale all of |src| to the size of |this| buffer, with no cropping.
|
||||
void ScaleFrom(const VideoFrameBuffer& src);
|
||||
|
||||
protected:
|
||||
I420Buffer(int width, int height);
|
||||
I420Buffer(int width, int height, int stride_y, int stride_u, int stride_v);
|
||||
|
||||
~I420Buffer() override;
|
||||
|
||||
private:
|
||||
const int width_;
|
||||
const int height_;
|
||||
const int stride_y_;
|
||||
const int stride_u_;
|
||||
const int stride_v_;
|
||||
const std::unique_ptr<uint8_t, AlignedFreeDeleter> data_;
|
||||
};
|
||||
|
||||
// Base class for native-handle buffer is a wrapper around a |native_handle|.
|
||||
// This is used for convenience as most native-handle implementations can share
|
||||
// many VideoFrame implementations, but need to implement a few others (such
|
||||
|
||||
@ -18,13 +18,14 @@
|
||||
#include <stdio.h>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/common_types.h" // RawVideoTypes.
|
||||
#include "webrtc/common_video/rotation.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class I420Buffer;
|
||||
|
||||
// Supported video types.
|
||||
enum VideoType {
|
||||
kUnknown,
|
||||
@ -97,9 +98,10 @@ int ExtractBuffer(const VideoFrame& input_frame, size_t size, uint8_t* buffer);
|
||||
// Return value: 0 if OK, < 0 otherwise.
|
||||
|
||||
// TODO(nisse): Delete this wrapper, and let users call libyuv directly. Most
|
||||
// calls pass |src_video_type| == kI420, and should use libyuv::I420Copy. The
|
||||
// only exception at the time of this writing is
|
||||
// VideoCaptureImpl::IncomingFrame, which still needs libyuv::ConvertToI420.
|
||||
// calls pass |src_video_type| == kI420, and should use libyuv::I420Copy. Also
|
||||
// remember to delete the I420Buffer forward declaration above. The only
|
||||
// exception at the time of this writing is VideoCaptureImpl::IncomingFrame,
|
||||
// which still needs libyuv::ConvertToI420.
|
||||
int ConvertToI420(VideoType src_video_type,
|
||||
const uint8_t* src_frame,
|
||||
int crop_x,
|
||||
|
||||
@ -13,12 +13,13 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
||||
#include "webrtc/test/frame_utils.h"
|
||||
#include "webrtc/test/gmock.h"
|
||||
#include "webrtc/test/gtest.h"
|
||||
#include "webrtc/test/testsupport/fileutils.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
||||
@ -13,8 +13,10 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
// TODO(nisse): Only needed for the deprecated ConvertToI420.
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
|
||||
// NOTE(ajm): Path provided by gyp.
|
||||
// NOTE(ajm): Path provided by gn.
|
||||
#include "libyuv.h" // NOLINT
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -8,19 +8,11 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
// TODO(nisse): Delete this file, once downstream code is updated.
|
||||
|
||||
#ifndef WEBRTC_COMMON_VIDEO_ROTATION_H_
|
||||
#define WEBRTC_COMMON_VIDEO_ROTATION_H_
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// enum for clockwise rotation.
|
||||
enum VideoRotation {
|
||||
kVideoRotation_0 = 0,
|
||||
kVideoRotation_90 = 90,
|
||||
kVideoRotation_180 = 180,
|
||||
kVideoRotation_270 = 270
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
#include "webrtc/api/video/video_rotation.h"
|
||||
|
||||
#endif // WEBRTC_COMMON_VIDEO_ROTATION_H_
|
||||
|
||||
@ -23,39 +23,6 @@ namespace webrtc {
|
||||
// to optimized bitstream readers. See avcodec_decode_video2.
|
||||
const size_t EncodedImage::kBufferPaddingBytesH264 = 8;
|
||||
|
||||
VideoFrame::VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
|
||||
webrtc::VideoRotation rotation,
|
||||
int64_t timestamp_us)
|
||||
: video_frame_buffer_(buffer),
|
||||
timestamp_rtp_(0),
|
||||
ntp_time_ms_(0),
|
||||
timestamp_us_(timestamp_us),
|
||||
rotation_(rotation) {}
|
||||
|
||||
VideoFrame::VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
|
||||
uint32_t timestamp,
|
||||
int64_t render_time_ms,
|
||||
VideoRotation rotation)
|
||||
: video_frame_buffer_(buffer),
|
||||
timestamp_rtp_(timestamp),
|
||||
ntp_time_ms_(0),
|
||||
timestamp_us_(render_time_ms * rtc::kNumMicrosecsPerMillisec),
|
||||
rotation_(rotation) {
|
||||
RTC_DCHECK(buffer);
|
||||
}
|
||||
|
||||
int VideoFrame::width() const {
|
||||
return video_frame_buffer_ ? video_frame_buffer_->width() : 0;
|
||||
}
|
||||
|
||||
int VideoFrame::height() const {
|
||||
return video_frame_buffer_ ? video_frame_buffer_->height() : 0;
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<VideoFrameBuffer> VideoFrame::video_frame_buffer() const {
|
||||
return video_frame_buffer_;
|
||||
}
|
||||
|
||||
size_t EncodedImage::GetBufferPaddingBytes(VideoCodecType codec_type) {
|
||||
switch (codec_type) {
|
||||
case kVideoCodecVP8:
|
||||
|
||||
@ -19,238 +19,8 @@
|
||||
#include "libyuv/planar_functions.h"
|
||||
#include "libyuv/scale.h"
|
||||
|
||||
// Aligning pointer to 64 bytes for improved performance, e.g. use SIMD.
|
||||
static const int kBufferAlignment = 64;
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
namespace {
|
||||
|
||||
int I420DataSize(int height, int stride_y, int stride_u, int stride_v) {
|
||||
return stride_y * height + (stride_u + stride_v) * ((height + 1) / 2);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
VideoFrameBuffer::~VideoFrameBuffer() {}
|
||||
|
||||
I420Buffer::I420Buffer(int width, int height)
|
||||
: I420Buffer(width, height, width, (width + 1) / 2, (width + 1) / 2) {
|
||||
}
|
||||
|
||||
I420Buffer::I420Buffer(int width,
|
||||
int height,
|
||||
int stride_y,
|
||||
int stride_u,
|
||||
int stride_v)
|
||||
: width_(width),
|
||||
height_(height),
|
||||
stride_y_(stride_y),
|
||||
stride_u_(stride_u),
|
||||
stride_v_(stride_v),
|
||||
data_(static_cast<uint8_t*>(AlignedMalloc(
|
||||
I420DataSize(height, stride_y, stride_u, stride_v),
|
||||
kBufferAlignment))) {
|
||||
RTC_DCHECK_GT(width, 0);
|
||||
RTC_DCHECK_GT(height, 0);
|
||||
RTC_DCHECK_GE(stride_y, width);
|
||||
RTC_DCHECK_GE(stride_u, (width + 1) / 2);
|
||||
RTC_DCHECK_GE(stride_v, (width + 1) / 2);
|
||||
}
|
||||
|
||||
I420Buffer::~I420Buffer() {
|
||||
}
|
||||
|
||||
// static
|
||||
rtc::scoped_refptr<I420Buffer> I420Buffer::Create(int width, int height) {
|
||||
return new rtc::RefCountedObject<I420Buffer>(width, height);
|
||||
}
|
||||
|
||||
// static
|
||||
rtc::scoped_refptr<I420Buffer> I420Buffer::Create(int width,
|
||||
int height,
|
||||
int stride_y,
|
||||
int stride_u,
|
||||
int stride_v) {
|
||||
return new rtc::RefCountedObject<I420Buffer>(
|
||||
width, height, stride_y, stride_u, stride_v);
|
||||
}
|
||||
|
||||
// static
|
||||
rtc::scoped_refptr<I420Buffer> I420Buffer::Copy(
|
||||
const VideoFrameBuffer& source) {
|
||||
return Copy(source.width(), source.height(),
|
||||
source.DataY(), source.StrideY(),
|
||||
source.DataU(), source.StrideU(),
|
||||
source.DataV(), source.StrideV());
|
||||
}
|
||||
|
||||
// static
|
||||
rtc::scoped_refptr<I420Buffer> I420Buffer::Copy(
|
||||
int width, int height,
|
||||
const uint8_t* data_y, int stride_y,
|
||||
const uint8_t* data_u, int stride_u,
|
||||
const uint8_t* data_v, int stride_v) {
|
||||
// Note: May use different strides than the input data.
|
||||
rtc::scoped_refptr<I420Buffer> buffer = Create(width, height);
|
||||
RTC_CHECK_EQ(0, libyuv::I420Copy(data_y, stride_y,
|
||||
data_u, stride_u,
|
||||
data_v, stride_v,
|
||||
buffer->MutableDataY(), buffer->StrideY(),
|
||||
buffer->MutableDataU(), buffer->StrideU(),
|
||||
buffer->MutableDataV(), buffer->StrideV(),
|
||||
width, height));
|
||||
return buffer;
|
||||
}
|
||||
|
||||
// static
|
||||
rtc::scoped_refptr<VideoFrameBuffer> I420Buffer::Rotate(
|
||||
rtc::scoped_refptr<VideoFrameBuffer> src,
|
||||
VideoRotation rotation) {
|
||||
RTC_CHECK(src->DataY());
|
||||
RTC_CHECK(src->DataU());
|
||||
RTC_CHECK(src->DataV());
|
||||
|
||||
if (rotation == webrtc::kVideoRotation_0) {
|
||||
return src;
|
||||
}
|
||||
|
||||
int rotated_width = src->width();
|
||||
int rotated_height = src->height();
|
||||
if (rotation == webrtc::kVideoRotation_90 ||
|
||||
rotation == webrtc::kVideoRotation_270) {
|
||||
std::swap(rotated_width, rotated_height);
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<webrtc::I420Buffer> buffer =
|
||||
I420Buffer::Create(rotated_width, rotated_height);
|
||||
|
||||
RTC_CHECK_EQ(0, libyuv::I420Rotate(
|
||||
src->DataY(), src->StrideY(),
|
||||
src->DataU(), src->StrideU(),
|
||||
src->DataV(), src->StrideV(),
|
||||
buffer->MutableDataY(), buffer->StrideY(), buffer->MutableDataU(),
|
||||
buffer->StrideU(), buffer->MutableDataV(), buffer->StrideV(),
|
||||
src->width(), src->height(),
|
||||
static_cast<libyuv::RotationMode>(rotation)));
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void I420Buffer::InitializeData() {
|
||||
memset(data_.get(), 0,
|
||||
I420DataSize(height_, stride_y_, stride_u_, stride_v_));
|
||||
}
|
||||
|
||||
int I420Buffer::width() const {
|
||||
return width_;
|
||||
}
|
||||
|
||||
int I420Buffer::height() const {
|
||||
return height_;
|
||||
}
|
||||
|
||||
const uint8_t* I420Buffer::DataY() const {
|
||||
return data_.get();
|
||||
}
|
||||
const uint8_t* I420Buffer::DataU() const {
|
||||
return data_.get() + stride_y_ * height_;
|
||||
}
|
||||
const uint8_t* I420Buffer::DataV() const {
|
||||
return data_.get() + stride_y_ * height_ + stride_u_ * ((height_ + 1) / 2);
|
||||
}
|
||||
|
||||
uint8_t* I420Buffer::MutableDataY() {
|
||||
return const_cast<uint8_t*>(DataY());
|
||||
}
|
||||
uint8_t* I420Buffer::MutableDataU() {
|
||||
return const_cast<uint8_t*>(DataU());
|
||||
}
|
||||
uint8_t* I420Buffer::MutableDataV() {
|
||||
return const_cast<uint8_t*>(DataV());
|
||||
}
|
||||
|
||||
int I420Buffer::StrideY() const {
|
||||
return stride_y_;
|
||||
}
|
||||
int I420Buffer::StrideU() const {
|
||||
return stride_u_;
|
||||
}
|
||||
int I420Buffer::StrideV() const {
|
||||
return stride_v_;
|
||||
}
|
||||
|
||||
void* I420Buffer::native_handle() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<VideoFrameBuffer> I420Buffer::NativeToI420Buffer() {
|
||||
RTC_NOTREACHED();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void I420Buffer::SetToBlack() {
|
||||
RTC_CHECK(libyuv::I420Rect(MutableDataY(), StrideY(),
|
||||
MutableDataU(), StrideU(),
|
||||
MutableDataV(), StrideV(),
|
||||
0, 0, width(), height(),
|
||||
0, 128, 128) == 0);
|
||||
}
|
||||
|
||||
void I420Buffer::CropAndScaleFrom(
|
||||
const VideoFrameBuffer& src,
|
||||
int offset_x,
|
||||
int offset_y,
|
||||
int crop_width,
|
||||
int crop_height) {
|
||||
RTC_CHECK_LE(crop_width, src.width());
|
||||
RTC_CHECK_LE(crop_height, src.height());
|
||||
RTC_CHECK_LE(crop_width + offset_x, src.width());
|
||||
RTC_CHECK_LE(crop_height + offset_y, src.height());
|
||||
RTC_CHECK_GE(offset_x, 0);
|
||||
RTC_CHECK_GE(offset_y, 0);
|
||||
|
||||
// Make sure offset is even so that u/v plane becomes aligned.
|
||||
const int uv_offset_x = offset_x / 2;
|
||||
const int uv_offset_y = offset_y / 2;
|
||||
offset_x = uv_offset_x * 2;
|
||||
offset_y = uv_offset_y * 2;
|
||||
|
||||
const uint8_t* y_plane =
|
||||
src.DataY() + src.StrideY() * offset_y + offset_x;
|
||||
const uint8_t* u_plane =
|
||||
src.DataU() + src.StrideU() * uv_offset_y + uv_offset_x;
|
||||
const uint8_t* v_plane =
|
||||
src.DataV() + src.StrideV() * uv_offset_y + uv_offset_x;
|
||||
int res = libyuv::I420Scale(y_plane, src.StrideY(),
|
||||
u_plane, src.StrideU(),
|
||||
v_plane, src.StrideV(),
|
||||
crop_width, crop_height,
|
||||
MutableDataY(), StrideY(),
|
||||
MutableDataU(), StrideU(),
|
||||
MutableDataV(), StrideV(),
|
||||
width(), height(), libyuv::kFilterBox);
|
||||
|
||||
RTC_DCHECK_EQ(res, 0);
|
||||
}
|
||||
|
||||
void I420Buffer::CropAndScaleFrom(
|
||||
const VideoFrameBuffer& src) {
|
||||
const int crop_width =
|
||||
std::min(src.width(), width() * src.height() / height());
|
||||
const int crop_height =
|
||||
std::min(src.height(), height() * src.width() / width());
|
||||
|
||||
CropAndScaleFrom(
|
||||
src,
|
||||
(src.width() - crop_width) / 2, (src.height() - crop_height) / 2,
|
||||
crop_width, crop_height);
|
||||
}
|
||||
|
||||
void I420Buffer::ScaleFrom(const VideoFrameBuffer& src) {
|
||||
CropAndScaleFrom(src, 0, 0, src.width(), src.height());
|
||||
}
|
||||
|
||||
NativeHandleBuffer::NativeHandleBuffer(void* native_handle,
|
||||
int width,
|
||||
int height)
|
||||
|
||||
@ -15,8 +15,8 @@
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/base/optional.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#include <stddef.h>
|
||||
|
||||
#include "libyuv/convert_from.h"
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/examples/peerconnection/client/defaults.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
@ -523,9 +524,10 @@ void GtkMainWnd::VideoRenderer::OnFrame(
|
||||
gdk_threads_enter();
|
||||
|
||||
rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer(
|
||||
webrtc::I420Buffer::Rotate(video_frame.video_frame_buffer(),
|
||||
video_frame.rotation()));
|
||||
|
||||
video_frame.video_frame_buffer());
|
||||
if (video_frame.rotation() != webrtc::kVideoRotation_0) {
|
||||
buffer = webrtc::I420Buffer::Rotate(*buffer, video_frame.rotation());
|
||||
}
|
||||
SetSize(buffer->width(), buffer->height());
|
||||
|
||||
libyuv::I420ToRGBA(buffer->DataY(), buffer->StrideY(),
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "libyuv/convert_argb.h"
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/examples/peerconnection/client/defaults.h"
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/common.h"
|
||||
@ -606,8 +607,10 @@ void MainWnd::VideoRenderer::OnFrame(
|
||||
AutoLock<VideoRenderer> lock(this);
|
||||
|
||||
rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer(
|
||||
webrtc::I420Buffer::Rotate(video_frame.video_frame_buffer(),
|
||||
video_frame.rotation()));
|
||||
video_frame.video_frame_buffer());
|
||||
if (video_frame.rotation() != webrtc::kVideoRotation_0) {
|
||||
buffer = webrtc::I420Buffer::Rotate(*buffer, video_frame.rotation());
|
||||
}
|
||||
|
||||
SetSize(buffer->width(), buffer->height());
|
||||
|
||||
|
||||
@ -17,11 +17,11 @@
|
||||
#include <string>
|
||||
|
||||
#include "webrtc/api/mediastreaminterface.h"
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/base/win32.h"
|
||||
#include "webrtc/examples/peerconnection/client/peer_connection_client.h"
|
||||
#include "webrtc/media/base/mediachannel.h"
|
||||
#include "webrtc/media/base/videocommon.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
class MainWndCallback {
|
||||
public:
|
||||
|
||||
@ -10,6 +10,8 @@
|
||||
|
||||
#include "webrtc/media/base/adaptedvideotracksource.h"
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
AdaptedVideoTrackSource::AdaptedVideoTrackSource() {
|
||||
@ -48,7 +50,7 @@ void AdaptedVideoTrackSource::OnFrame(const webrtc::VideoFrame& frame) {
|
||||
!buffer->native_handle()) {
|
||||
/* Apply pending rotation. */
|
||||
broadcaster_.OnFrame(webrtc::VideoFrame(
|
||||
webrtc::I420Buffer::Rotate(buffer, frame.rotation()),
|
||||
webrtc::I420Buffer::Rotate(*buffer, frame.rotation()),
|
||||
webrtc::kVideoRotation_0, frame.timestamp_us()));
|
||||
} else {
|
||||
broadcaster_.OnFrame(frame);
|
||||
|
||||
@ -16,10 +16,11 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/base/timeutils.h"
|
||||
#include "webrtc/media/base/videocapturer.h"
|
||||
#include "webrtc/media/base/videocommon.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
namespace cricket {
|
||||
|
||||
|
||||
@ -11,9 +11,9 @@
|
||||
#ifndef WEBRTC_MEDIA_BASE_FAKEVIDEORENDERER_H_
|
||||
#define WEBRTC_MEDIA_BASE_FAKEVIDEORENDERER_H_
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/media/base/videosinkinterface.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
namespace cricket {
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/base/bytebuffer.h"
|
||||
#include "webrtc/base/fileutils.h"
|
||||
#include "webrtc/base/gunit.h"
|
||||
@ -23,7 +24,6 @@
|
||||
#include "webrtc/base/testutils.h"
|
||||
#include "webrtc/media/base/rtpdump.h"
|
||||
#include "webrtc/media/base/videocapturer.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
namespace cricket {
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
|
||||
@ -109,8 +110,8 @@ VideoBroadcaster::GetBlackFrameBuffer(int width, int height) {
|
||||
if (!black_frame_buffer_ || black_frame_buffer_->width() != width ||
|
||||
black_frame_buffer_->height() != height) {
|
||||
rtc::scoped_refptr<webrtc::I420Buffer> buffer =
|
||||
new RefCountedObject<webrtc::I420Buffer>(width, height);
|
||||
buffer->SetToBlack();
|
||||
webrtc::I420Buffer::Create(width, height);
|
||||
webrtc::I420Buffer::SetBlack(buffer.get());
|
||||
black_frame_buffer_ = buffer;
|
||||
}
|
||||
|
||||
|
||||
@ -15,11 +15,11 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/base/thread_checker.h"
|
||||
#include "webrtc/media/base/videosinkinterface.h"
|
||||
#include "webrtc/media/base/videosourcebase.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
|
||||
@ -8,10 +8,11 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/base/gunit.h"
|
||||
#include "webrtc/media/base/fakevideorenderer.h"
|
||||
#include "webrtc/media/base/videobroadcaster.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
using rtc::VideoBroadcaster;
|
||||
using rtc::VideoSinkWants;
|
||||
@ -43,7 +44,7 @@ TEST(VideoBroadcasterTest, OnFrame) {
|
||||
rtc::scoped_refptr<webrtc::I420Buffer> buffer(
|
||||
webrtc::I420Buffer::Create(kWidth, kHeight));
|
||||
// Initialize, to avoid warnings on use of initialized values.
|
||||
buffer->SetToBlack();
|
||||
webrtc::I420Buffer::SetBlack(buffer);
|
||||
|
||||
webrtc::VideoFrame frame(buffer, webrtc::kVideoRotation_0, 0);
|
||||
|
||||
@ -141,7 +142,7 @@ TEST(VideoBroadcasterTest, SinkWantsBlackFrames) {
|
||||
broadcaster.AddOrUpdateSink(&sink2, wants2);
|
||||
|
||||
rtc::scoped_refptr<webrtc::I420Buffer> buffer(
|
||||
new rtc::RefCountedObject<webrtc::I420Buffer>(100, 200));
|
||||
webrtc::I420Buffer::Create(100, 200));
|
||||
// Makes it not all black.
|
||||
buffer->InitializeData();
|
||||
|
||||
|
||||
@ -14,9 +14,10 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
namespace cricket {
|
||||
|
||||
@ -214,7 +215,7 @@ void VideoCapturer::OnFrame(const webrtc::VideoFrame& frame,
|
||||
return;
|
||||
}
|
||||
broadcaster_.OnFrame(webrtc::VideoFrame(
|
||||
webrtc::I420Buffer::Rotate(buffer, frame.rotation()),
|
||||
webrtc::I420Buffer::Rotate(*buffer, frame.rotation()),
|
||||
webrtc::kVideoRotation_0, frame.timestamp_us()));
|
||||
} else {
|
||||
broadcaster_.OnFrame(frame);
|
||||
|
||||
@ -20,6 +20,12 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// TODO(nisse): Transition hack, some downstream applications expect that
|
||||
// including this file declares I420Buffer and NativeHandleBuffer. Delete after
|
||||
// users of these classes are fixed to include the right headers.
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/common_video/include/video_frame_buffer.h"
|
||||
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/media/base/videosourceinterface.h"
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
// this file can be deleted.
|
||||
#include "webrtc/base/logging.h"
|
||||
|
||||
#include "webrtc/video_frame.h"
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
|
||||
// TODO(nisse): Similarly, some applications expect that including this file
|
||||
// implies a forward declaration of rtc::Thread.
|
||||
|
||||
@ -13,9 +13,9 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/base/thread_checker.h"
|
||||
#include "webrtc/media/base/videosourceinterface.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
|
||||
@ -10,8 +10,9 @@
|
||||
|
||||
// Implementation of GtkVideoRenderer
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/media/devices/gtkvideorenderer.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <glib.h>
|
||||
@ -82,8 +83,10 @@ bool GtkVideoRenderer::SetSize(int width, int height) {
|
||||
|
||||
void GtkVideoRenderer::OnFrame(const webrtc::VideoFrame& video_frame) {
|
||||
rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer(
|
||||
webrtc::I420Buffer::Rotate(video_frame.video_frame_buffer(),
|
||||
video_frame.rotation()));
|
||||
video_frame.video_frame_buffer());
|
||||
if (video_frame.rotation() != webrtc::kVideoRotation_0) {
|
||||
buffer = webrtc::I420Buffer::Rotate(*buffer, video_frame.rotation());
|
||||
}
|
||||
|
||||
// Need to set size as the frame might be rotated.
|
||||
if (!SetSize(buffer->width(), buffer->height())) {
|
||||
|
||||
@ -25,12 +25,12 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/base/buffer.h"
|
||||
#include "webrtc/call/audio_receive_stream.h"
|
||||
#include "webrtc/call/audio_send_stream.h"
|
||||
#include "webrtc/call/call.h"
|
||||
#include "webrtc/call/flexfec_receive_stream.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
#include "webrtc/video_receive_stream.h"
|
||||
#include "webrtc/video_send_stream.h"
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/media/base/testutils.h"
|
||||
#include "webrtc/media/engine/webrtcvideocapturer.h"
|
||||
|
||||
@ -65,7 +66,7 @@ class FakeWebRtcVideoCaptureModule : public webrtc::VideoCaptureModule {
|
||||
if (!running_) return;
|
||||
|
||||
rtc::scoped_refptr<webrtc::I420Buffer> buffer =
|
||||
new rtc::RefCountedObject<webrtc::I420Buffer>(w, h);
|
||||
webrtc::I420Buffer::Create(w, h);
|
||||
// Initialize memory to satisfy DrMemory tests. See
|
||||
// https://bugs.chromium.org/p/libyuv/issues/detail?id=377
|
||||
buffer->InitializeData();
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h"
|
||||
#include "webrtc/modules/video_coding/include/video_codec_interface.h"
|
||||
@ -126,7 +127,7 @@ class VideoEncoderSoftwareFallbackWrapperTest : public ::testing::Test {
|
||||
void VideoEncoderSoftwareFallbackWrapperTest::EncodeFrame() {
|
||||
rtc::scoped_refptr<I420Buffer> buffer = I420Buffer::Create(
|
||||
kWidth, kHeight, kWidth, (kWidth + 1) / 2, (kWidth + 1) / 2);
|
||||
buffer->SetToBlack();
|
||||
I420Buffer::SetBlack(buffer);
|
||||
std::vector<FrameType> types(1, kVideoFrameKey);
|
||||
|
||||
frame_.reset(new VideoFrame(buffer, 0, 0, webrtc::kVideoRotation_0));
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/base/copyonwritebuffer.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/stringutils.h"
|
||||
@ -1680,7 +1681,7 @@ bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetVideoSend(
|
||||
rtc::scoped_refptr<webrtc::I420Buffer> black_buffer(
|
||||
webrtc::I420Buffer::Create(last_frame_info_.width,
|
||||
last_frame_info_.height));
|
||||
black_buffer->SetToBlack();
|
||||
webrtc::I420Buffer::SetBlack(black_buffer);
|
||||
|
||||
encoder_sink_->OnFrame(webrtc::VideoFrame(
|
||||
black_buffer, last_frame_info_.rotation, last_frame_timestamp_us_));
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/api/call/transport.h"
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/base/asyncinvoker.h"
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/base/networkroute.h"
|
||||
@ -29,7 +30,6 @@
|
||||
#include "webrtc/media/base/mediaengine.h"
|
||||
#include "webrtc/media/engine/webrtcvideodecoderfactory.h"
|
||||
#include "webrtc/media/engine/webrtcvideoencoderfactory.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
#include "webrtc/video_receive_stream.h"
|
||||
#include "webrtc/video_send_stream.h"
|
||||
|
||||
|
||||
@ -84,7 +84,7 @@ rtc::scoped_refptr<webrtc::VideoFrameBuffer> CreateBlackFrameBuffer(
|
||||
int height) {
|
||||
rtc::scoped_refptr<webrtc::I420Buffer> buffer =
|
||||
webrtc::I420Buffer::Create(width, height);
|
||||
buffer->SetToBlack();
|
||||
webrtc::I420Buffer::SetBlack(buffer);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
@ -17,11 +17,11 @@
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
|
||||
#include "webrtc/api/video/video_rotation.h"
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/base/deprecation.h"
|
||||
#include "webrtc/base/safe_conversions.h"
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/common_video/rotation.h"
|
||||
#include "webrtc/modules/video_coding/codecs/vp8/include/vp8_globals.h"
|
||||
#include "webrtc/modules/video_coding/codecs/vp9/include/vp9_globals.h"
|
||||
#include "webrtc/modules/video_coding/codecs/h264/include/h264_globals.h"
|
||||
|
||||
@ -10,8 +10,8 @@
|
||||
#ifndef WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_CVO_H_
|
||||
#define WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_CVO_H_
|
||||
|
||||
#include "webrtc/api/video/video_rotation.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/common_video/rotation.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "webrtc/common_video/rotation.h"
|
||||
#include "webrtc/api/video/video_rotation.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -14,6 +14,8 @@
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/base/scoped_ref_ptr.h"
|
||||
#include "webrtc/base/timeutils.h"
|
||||
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
||||
@ -24,7 +26,6 @@
|
||||
#include "webrtc/system_wrappers/include/sleep.h"
|
||||
#include "webrtc/test/frame_utils.h"
|
||||
#include "webrtc/test/gtest.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
using webrtc::CriticalSectionWrapper;
|
||||
using webrtc::CriticalSectionScoped;
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
#ifndef WEBRTC_MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_H_
|
||||
#define WEBRTC_MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_H_
|
||||
|
||||
#include "webrtc/common_video/rotation.h"
|
||||
#include "webrtc/api/video/video_rotation.h"
|
||||
#include "webrtc/media/base/videosinkinterface.h"
|
||||
#include "webrtc/modules/include/module.h"
|
||||
#include "webrtc/modules/video_capture/video_capture_defines.h"
|
||||
|
||||
@ -11,9 +11,9 @@
|
||||
#ifndef WEBRTC_MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEFINES_H_
|
||||
#define WEBRTC_MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEFINES_H_
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/modules/include/module_common_types.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/base/refcount.h"
|
||||
#include "webrtc/base/timeutils.h"
|
||||
#include "webrtc/base/trace_event.h"
|
||||
|
||||
@ -15,12 +15,11 @@
|
||||
* video_capture_impl.h
|
||||
*/
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/base/scoped_ref_ptr.h"
|
||||
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
||||
#include "webrtc/common_video/rotation.h"
|
||||
#include "webrtc/modules/video_capture/video_capture.h"
|
||||
#include "webrtc/modules/video_capture/video_capture_config.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
|
||||
@ -20,10 +20,12 @@ extern "C" {
|
||||
#include "third_party/ffmpeg/libavutil/imgutils.h"
|
||||
} // extern "C"
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/base/keep_ref_until_done.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/common_video/include/video_frame_buffer.h"
|
||||
#include "webrtc/system_wrappers/include/metrics.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#include <limits>
|
||||
#include <string>
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@ -15,13 +15,13 @@
|
||||
"use video_coding/include")
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/modules/include/module_common_types.h"
|
||||
#include "webrtc/modules/video_coding/include/video_error_codes.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
#include "webrtc/video_decoder.h"
|
||||
#include "webrtc/video_encoder.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/timeutils.h"
|
||||
#include "webrtc/modules/video_coding/include/video_codec_initializer.h"
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
||||
#include "webrtc/modules/video_coding/include/video_codec_interface.h"
|
||||
@ -21,7 +22,6 @@
|
||||
#include "webrtc/modules/video_coding/codecs/test/stats.h"
|
||||
#include "webrtc/test/testsupport/frame_reader.h"
|
||||
#include "webrtc/test/testsupport/frame_writer.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/modules/video_coding/codecs/test/mock/mock_packet_manipulator.h"
|
||||
#include "webrtc/modules/video_coding/codecs/test/videoprocessor.h"
|
||||
#include "webrtc/modules/video_coding/include/mock/mock_video_codec_interface.h"
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
// NOTE(ajm): Path provided by gyp.
|
||||
#include "libyuv/scale.h" // NOLINT
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/modules/video_coding/codecs/vp8/screenshare_layers.h"
|
||||
#include "webrtc/modules/video_coding/utility/simulcast_rate_allocator.h"
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/common_video/include/video_frame_buffer.h"
|
||||
#include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h"
|
||||
#include "webrtc/modules/video_coding/codecs/vp8/simulcast_unittest.h"
|
||||
#include "webrtc/modules/video_coding/include/video_codec_interface.h"
|
||||
@ -502,6 +503,7 @@ TEST_F(TestSimulcastEncoderAdapterFake,
|
||||
EXPECT_TRUE(adapter_->SupportsNativeHandle());
|
||||
}
|
||||
|
||||
// TODO(nisse): Reuse definition in webrtc/test/fake_texture_handle.h.
|
||||
class FakeNativeHandleBuffer : public NativeHandleBuffer {
|
||||
public:
|
||||
FakeNativeHandleBuffer(void* native_handle, int width, int height)
|
||||
|
||||
@ -16,6 +16,8 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
||||
#include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/optional.h"
|
||||
#include "webrtc/base/timeutils.h"
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
#include "vpx/vp8cx.h"
|
||||
#include "vpx/vp8dx.h"
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/common_video/include/i420_buffer_pool.h"
|
||||
#include "webrtc/modules/video_coding/include/video_codec_interface.h"
|
||||
#include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/timeutils.h"
|
||||
#include "webrtc/common_video/include/video_image.h"
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
#include "webrtc/base/keep_ref_until_done.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/trace_event.h"
|
||||
#include "webrtc/common_video/include/video_frame_buffer.h"
|
||||
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
||||
#include "webrtc/modules/include/module_common_types.h"
|
||||
#include "webrtc/modules/video_coding/codecs/vp9/screenshare_layers.h"
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/trace_event.h"
|
||||
|
||||
@ -13,13 +13,13 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/modules/include/module_common_types.h"
|
||||
#include "webrtc/modules/video_coding/include/video_error_codes.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
#include "webrtc/video_decoder.h"
|
||||
#include "webrtc/video_encoder.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
||||
@ -21,11 +21,11 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/modules/include/module.h"
|
||||
#include "webrtc/modules/include/module_common_types.h"
|
||||
#include "webrtc/modules/video_coding/include/video_coding_defines.h"
|
||||
#include "webrtc/system_wrappers/include/event_wrapper.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
||||
@ -14,8 +14,10 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/modules/include/module_common_types.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
// For EncodedImage
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
|
||||
#include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h"
|
||||
#include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h"
|
||||
|
||||
@ -13,8 +13,8 @@
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "webrtc/api/video/video_rotation.h"
|
||||
#include "webrtc/common_video/include/video_frame_buffer.h"
|
||||
#include "webrtc/common_video/rotation.h"
|
||||
|
||||
namespace webrtc_jni {
|
||||
|
||||
|
||||
@ -15,9 +15,9 @@
|
||||
|
||||
#include "webrtc/sdk/android/src/jni/jni_helpers.h"
|
||||
#include "webrtc/sdk/android/src/jni/native_handle_impl.h"
|
||||
#include "webrtc/api/video/video_frame_buffer.h"
|
||||
#include "webrtc/base/refcount.h"
|
||||
#include "webrtc/base/scoped_ref_ptr.h"
|
||||
#include "webrtc/common_video/include/video_frame_buffer.h"
|
||||
|
||||
namespace webrtc_jni {
|
||||
|
||||
|
||||
@ -15,8 +15,8 @@
|
||||
#import "RTCShader+Private.h"
|
||||
#import "WebRTC/RTCVideoFrame.h"
|
||||
|
||||
#include "webrtc/api/video/video_rotation.h"
|
||||
#include "webrtc/base/optional.h"
|
||||
#include "webrtc/common_video/rotation.h"
|
||||
|
||||
// |kNumTextures| must not exceed 8, which is the limit in OpenGLES2. Two sets
|
||||
// of 3 textures are used here, one for each of the Y, U and V planes. Having
|
||||
|
||||
@ -19,9 +19,9 @@
|
||||
#import "RTCShader+Private.h"
|
||||
#import "WebRTC/RTCVideoFrame.h"
|
||||
|
||||
#include "webrtc/api/video/video_rotation.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/optional.h"
|
||||
#include "webrtc/common_video/rotation.h"
|
||||
|
||||
static const char kNV12FragmentShaderSource[] =
|
||||
SHADER_VERSION
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
#import <OpenGL/gl3.h>
|
||||
#endif
|
||||
|
||||
#include "webrtc/common_video/rotation.h"
|
||||
#include "webrtc/api/video/video_rotation.h"
|
||||
|
||||
RTC_EXTERN const char kRTCVertexShaderSource[];
|
||||
|
||||
|
||||
@ -10,8 +10,8 @@
|
||||
|
||||
#import "WebRTC/RTCVideoFrame.h"
|
||||
|
||||
#include "webrtc/common_video/include/video_frame_buffer.h"
|
||||
#include "webrtc/common_video/rotation.h"
|
||||
#include "webrtc/api/video/video_frame_buffer.h"
|
||||
#include "webrtc/api/video/video_rotation.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/common_video/rotation.h"
|
||||
#include "webrtc/api/video/video_rotation.h"
|
||||
|
||||
@implementation RTCVideoFrame {
|
||||
rtc::scoped_refptr<webrtc::VideoFrameBuffer> _videoBuffer;
|
||||
|
||||
@ -13,9 +13,9 @@
|
||||
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/common_video/include/i420_buffer_pool.h"
|
||||
#include "webrtc/media/base/videocapturer.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
@class RTCAVFoundationVideoCapturerInternal;
|
||||
|
||||
|
||||
@ -17,13 +17,13 @@
|
||||
#import "WebRTC/RTCLogging.h"
|
||||
|
||||
#include "avfoundationformatmapper.h"
|
||||
#include "libyuv/rotate.h"
|
||||
|
||||
#include "webrtc/api/video/video_rotation.h"
|
||||
#include "webrtc/base/bind.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/thread.h"
|
||||
#include "webrtc/common_video/include/corevideo_frame_buffer.h"
|
||||
#include "webrtc/common_video/rotation.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -160,25 +160,12 @@ void AVFoundationVideoCapturer::CaptureSampleBuffer(
|
||||
// Applying rotation is only supported for legacy reasons and performance is
|
||||
// not critical here.
|
||||
if (apply_rotation() && rotation != kVideoRotation_0) {
|
||||
buffer = buffer->NativeToI420Buffer();
|
||||
rtc::scoped_refptr<I420Buffer> rotated_buffer;
|
||||
if (rotation == kVideoRotation_0 || rotation == kVideoRotation_180) {
|
||||
rotated_buffer = I420Buffer::Create(adapted_width, adapted_height);
|
||||
} else {
|
||||
// Swap width and height.
|
||||
rotated_buffer = I420Buffer::Create(adapted_height, adapted_width);
|
||||
buffer = I420Buffer::Rotate(buffer->NativeToI420Buffer(),
|
||||
rotation);
|
||||
if (rotation == kVideoRotation_90 || rotation == kVideoRotation_270) {
|
||||
std::swap(captured_width, captured_height);
|
||||
}
|
||||
libyuv::I420Rotate(
|
||||
buffer->DataY(), buffer->StrideY(),
|
||||
buffer->DataU(), buffer->StrideU(),
|
||||
buffer->DataV(), buffer->StrideV(),
|
||||
rotated_buffer->MutableDataY(), rotated_buffer->StrideY(),
|
||||
rotated_buffer->MutableDataU(), rotated_buffer->StrideU(),
|
||||
rotated_buffer->MutableDataV(), rotated_buffer->StrideV(),
|
||||
buffer->width(), buffer->height(),
|
||||
static_cast<libyuv::RotationMode>(rotation));
|
||||
buffer = rotated_buffer;
|
||||
|
||||
rotation = kVideoRotation_0;
|
||||
}
|
||||
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
#include "RTCUIApplication.h"
|
||||
#endif
|
||||
#include "libyuv/convert.h"
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/common_video/include/corevideo_frame_buffer.h"
|
||||
|
||||
@ -12,10 +12,10 @@
|
||||
#ifndef WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_H264_VIDEO_TOOLBOX_ENCODER_H_
|
||||
#define WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_H264_VIDEO_TOOLBOX_ENCODER_H_
|
||||
|
||||
#include "webrtc/api/video/video_rotation.h"
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/common_video/h264/h264_bitstream_parser.h"
|
||||
#include "webrtc/common_video/include/bitrate_adjuster.h"
|
||||
#include "webrtc/common_video/rotation.h"
|
||||
#include "webrtc/media/base/codec.h"
|
||||
#include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
|
||||
#include "webrtc/modules/video_coding/utility/quality_scaler.h"
|
||||
|
||||
@ -10,6 +10,8 @@
|
||||
|
||||
#include "webrtc/test/fake_decoder.h"
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/base/timeutils.h"
|
||||
#include "webrtc/test/gtest.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -10,9 +10,9 @@
|
||||
#ifndef WEBRTC_TEST_FAKE_TEXTURE_FRAME_H_
|
||||
#define WEBRTC_TEST_FAKE_TEXTURE_FRAME_H_
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/common_video/include/video_frame_buffer.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
@ -39,11 +39,7 @@ class FakeNativeHandleBuffer : public NativeHandleBuffer {
|
||||
private:
|
||||
rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override {
|
||||
rtc::scoped_refptr<I420Buffer> buffer = I420Buffer::Create(width_, height_);
|
||||
int half_height = (height_ + 1) / 2;
|
||||
int half_width = (width_ + 1) / 2;
|
||||
memset(buffer->MutableDataY(), 0, height_ * width_);
|
||||
memset(buffer->MutableDataU(), 0, half_height * half_width);
|
||||
memset(buffer->MutableDataV(), 0, half_height * half_width);
|
||||
I420Buffer::SetBlack(buffer);
|
||||
return buffer;
|
||||
}
|
||||
};
|
||||
|
||||
@ -11,8 +11,8 @@
|
||||
#ifndef WEBRTC_TEST_FAKE_VIDEORENDERER_H_
|
||||
#define WEBRTC_TEST_FAKE_VIDEORENDERER_H_
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/media/base/videosinkinterface.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
@ -15,8 +15,10 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/keep_ref_until_done.h"
|
||||
#include "webrtc/common_video/include/video_frame_buffer.h"
|
||||
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
||||
#include "webrtc/system_wrappers/include/clock.h"
|
||||
#include "webrtc/test/frame_utils.h"
|
||||
|
||||
@ -13,10 +13,10 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/media/base/videosourceinterface.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
namespace webrtc {
|
||||
class Clock;
|
||||
|
||||
@ -13,12 +13,11 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/base/platform_thread.h"
|
||||
#include "webrtc/common_video/rotation.h"
|
||||
#include "webrtc/test/video_capturer.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
||||
@ -8,8 +8,12 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/test/frame_utils.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
@ -12,9 +12,9 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/test/frame_utils.h"
|
||||
#include "webrtc/test/testsupport/fileutils.h"
|
||||
#include "webrtc/common_video/include/video_frame_buffer.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
@ -10,9 +10,9 @@
|
||||
|
||||
#include "webrtc/test/testsupport/frame_reader.h"
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/test/gtest.h"
|
||||
#include "webrtc/test/testsupport/fileutils.h"
|
||||
#include "webrtc/common_video/include/video_frame_buffer.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
@ -16,9 +16,10 @@
|
||||
#include <algorithm> // min_element, max_element
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
||||
#include "webrtc/test/frame_utils.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
#include "libyuv/convert.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -12,8 +12,8 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/media/base/videosourceinterface.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
||||
@ -17,12 +17,12 @@
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/base/analytics/exp_filter.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/common_video/include/frame_callback.h"
|
||||
#include "webrtc/system_wrappers/include/clock.h"
|
||||
#include "webrtc/video_frame.h"
|
||||
|
||||
#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
|
||||
#include <mach/mach.h>
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/base/event.h"
|
||||
#include "webrtc/system_wrappers/include/clock.h"
|
||||
#include "webrtc/test/gmock.h"
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/api/video/video_rotation.h"
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/base/event.h"
|
||||
#include "webrtc/base/sequenced_task_checker.h"
|
||||
@ -22,7 +23,6 @@
|
||||
#include "webrtc/call/call.h"
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/common_video/include/video_bitrate_allocator.h"
|
||||
#include "webrtc/common_video/rotation.h"
|
||||
#include "webrtc/media/base/videosinkinterface.h"
|
||||
#include "webrtc/modules/video_coding/include/video_coding_defines.h"
|
||||
#include "webrtc/modules/video_coding/utility/quality_scaler.h"
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#include <limits>
|
||||
#include <utility>
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/system_wrappers/include/metrics_default.h"
|
||||
#include "webrtc/test/encoder_settings.h"
|
||||
|
||||
@ -11,117 +11,19 @@
|
||||
#ifndef WEBRTC_VIDEO_FRAME_H_
|
||||
#define WEBRTC_VIDEO_FRAME_H_
|
||||
|
||||
#include "webrtc/base/scoped_ref_ptr.h"
|
||||
#include "webrtc/base/timeutils.h"
|
||||
// TODO(nisse): This header file should eventually be deleted. For
|
||||
// declarations of classes related to unencoded video frame, use the
|
||||
// headers under api/video instead. The EncodedImage class stays in
|
||||
// this file until we have figured out how to refactor and clean up
|
||||
// related interfaces.
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/common_video/include/video_frame_buffer.h"
|
||||
#include "webrtc/common_video/rotation.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class VideoFrame {
|
||||
public:
|
||||
// TODO(nisse): This constructor is consistent with
|
||||
// cricket::WebRtcVideoFrame. After the class
|
||||
// cricket::WebRtcVideoFrame and its baseclass cricket::VideoFrame
|
||||
// are deleted, we should consider whether or not we want to stick
|
||||
// to this style and deprecate the other constructors.
|
||||
VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
|
||||
webrtc::VideoRotation rotation,
|
||||
int64_t timestamp_us);
|
||||
|
||||
// Preferred constructor.
|
||||
VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
|
||||
uint32_t timestamp,
|
||||
int64_t render_time_ms,
|
||||
VideoRotation rotation);
|
||||
|
||||
// Support move and copy.
|
||||
VideoFrame(const VideoFrame&) = default;
|
||||
VideoFrame(VideoFrame&&) = default;
|
||||
VideoFrame& operator=(const VideoFrame&) = default;
|
||||
VideoFrame& operator=(VideoFrame&&) = default;
|
||||
|
||||
// Get frame width.
|
||||
int width() const;
|
||||
|
||||
// Get frame height.
|
||||
int height() const;
|
||||
|
||||
// System monotonic clock, same timebase as rtc::TimeMicros().
|
||||
int64_t timestamp_us() const { return timestamp_us_; }
|
||||
void set_timestamp_us(int64_t timestamp_us) {
|
||||
timestamp_us_ = timestamp_us;
|
||||
}
|
||||
|
||||
// TODO(nisse): After the cricket::VideoFrame and webrtc::VideoFrame
|
||||
// merge, timestamps other than timestamp_us will likely be
|
||||
// deprecated.
|
||||
|
||||
// Set frame timestamp (90kHz).
|
||||
void set_timestamp(uint32_t timestamp) { timestamp_rtp_ = timestamp; }
|
||||
|
||||
// Get frame timestamp (90kHz).
|
||||
uint32_t timestamp() const { return timestamp_rtp_; }
|
||||
|
||||
// For now, transport_frame_id and rtp timestamp are the same.
|
||||
// TODO(nisse): Must be handled differently for QUIC.
|
||||
uint32_t transport_frame_id() const { return timestamp(); }
|
||||
|
||||
// Set capture ntp time in milliseconds.
|
||||
void set_ntp_time_ms(int64_t ntp_time_ms) {
|
||||
ntp_time_ms_ = ntp_time_ms;
|
||||
}
|
||||
|
||||
// Get capture ntp time in milliseconds.
|
||||
int64_t ntp_time_ms() const { return ntp_time_ms_; }
|
||||
|
||||
// Naming convention for Coordination of Video Orientation. Please see
|
||||
// http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ts_126114v120700p.pdf
|
||||
//
|
||||
// "pending rotation" or "pending" = a frame that has a VideoRotation > 0.
|
||||
//
|
||||
// "not pending" = a frame that has a VideoRotation == 0.
|
||||
//
|
||||
// "apply rotation" = modify a frame from being "pending" to being "not
|
||||
// pending" rotation (a no-op for "unrotated").
|
||||
//
|
||||
VideoRotation rotation() const { return rotation_; }
|
||||
void set_rotation(VideoRotation rotation) {
|
||||
rotation_ = rotation;
|
||||
}
|
||||
|
||||
// Set render time in milliseconds.
|
||||
void set_render_time_ms(int64_t render_time_ms) {
|
||||
set_timestamp_us(render_time_ms * rtc::kNumMicrosecsPerMillisec);;
|
||||
}
|
||||
|
||||
// Get render time in milliseconds.
|
||||
int64_t render_time_ms() const {
|
||||
return timestamp_us() / rtc::kNumMicrosecsPerMillisec;
|
||||
}
|
||||
|
||||
// Return the underlying buffer. Never nullptr for a properly
|
||||
// initialized VideoFrame.
|
||||
rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer() const;
|
||||
|
||||
// Return true if the frame is stored in a texture.
|
||||
bool is_texture() const {
|
||||
return video_frame_buffer() &&
|
||||
video_frame_buffer()->native_handle() != nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
// An opaque reference counted handle that stores the pixel data.
|
||||
rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_;
|
||||
uint32_t timestamp_rtp_;
|
||||
int64_t ntp_time_ms_;
|
||||
int64_t timestamp_us_;
|
||||
VideoRotation rotation_;
|
||||
};
|
||||
|
||||
|
||||
// TODO(pbos): Rename EncodedFrame and reformat this class' members.
|
||||
class EncodedImage {
|
||||
public:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user