Revert "VideoFrame: Store a reference to an encoded frame"
This reverts commit e6eded31e642b3b986fef478315603b5f398c227. Reason for revert: A better method for communicating encoded frames in VideoTrackSourceInterface surfaced. Original change's description: > VideoFrame: Store a reference to an encoded frame > > Enable webrtc::VideoFrame to store a reference to an encoded frame. > > Bug: chromium:1013590 > Change-Id: Id5a06f1c7249f104dfd328f08677cf8001958f0d > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/158788 > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Philip Eliasson <philipel@webrtc.org> > Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> > Reviewed-by: Niels Moller <nisse@webrtc.org> > Commit-Queue: Markus Handell <handellm@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#29809} TBR=ilnik@webrtc.org,nisse@webrtc.org,stefan@webrtc.org,philipel@webrtc.org,handellm@webrtc.org # Not skipping CQ checks because original CL landed > 1 day ago. Bug: chromium:1013590 Change-Id: I46384b7997e7b1cd3a2a2042cf17890fc977cca3 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160204 Reviewed-by: Markus Handell <handellm@webrtc.org> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Reviewed-by: Niels Moller <nisse@webrtc.org> Commit-Queue: Markus Handell <handellm@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29863}
This commit is contained in:
parent
038fd99780
commit
026f64fc54
@ -47,7 +47,6 @@ rtc_library("video_frame") {
|
||||
deps = [
|
||||
":video_rtp_headers",
|
||||
"..:array_view",
|
||||
"..:refcountedbase",
|
||||
"..:rtp_packet_info",
|
||||
"..:scoped_refptr",
|
||||
"../../rtc_base:checks",
|
||||
|
||||
@ -23,7 +23,6 @@ specific_include_rules = {
|
||||
],
|
||||
|
||||
"video_frame\.h": [
|
||||
"+rtc_base/ref_count.h",
|
||||
],
|
||||
|
||||
"video_frame_buffer\.h": [
|
||||
|
||||
@ -165,7 +165,7 @@ VideoFrame VideoFrame::Builder::build() {
|
||||
RTC_CHECK(video_frame_buffer_ != nullptr);
|
||||
return VideoFrame(id_, video_frame_buffer_, timestamp_us_, timestamp_rtp_,
|
||||
ntp_time_ms_, rotation_, color_space_, update_rect_,
|
||||
packet_infos_, encoded_frame_buffer_);
|
||||
packet_infos_);
|
||||
}
|
||||
|
||||
VideoFrame::Builder& VideoFrame::Builder::set_video_frame_buffer(
|
||||
@ -232,13 +232,6 @@ VideoFrame::Builder& VideoFrame::Builder::set_packet_infos(
|
||||
return *this;
|
||||
}
|
||||
|
||||
VideoFrame::Builder& VideoFrame::Builder::set_encoded_video_frame_buffer(
|
||||
rtc::scoped_refptr<VideoFrame::EncodedVideoFrameBuffer>
|
||||
encoded_frame_buffer) {
|
||||
encoded_frame_buffer_ = std::move(encoded_frame_buffer);
|
||||
return *this;
|
||||
}
|
||||
|
||||
VideoFrame::VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
|
||||
webrtc::VideoRotation rotation,
|
||||
int64_t timestamp_us)
|
||||
@ -260,8 +253,7 @@ VideoFrame::VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
|
||||
RTC_DCHECK(buffer);
|
||||
}
|
||||
|
||||
VideoFrame::VideoFrame(
|
||||
uint16_t id,
|
||||
VideoFrame::VideoFrame(uint16_t id,
|
||||
const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
|
||||
int64_t timestamp_us,
|
||||
uint32_t timestamp_rtp,
|
||||
@ -269,11 +261,9 @@ VideoFrame::VideoFrame(
|
||||
VideoRotation rotation,
|
||||
const absl::optional<ColorSpace>& color_space,
|
||||
const absl::optional<UpdateRect>& update_rect,
|
||||
RtpPacketInfos packet_infos,
|
||||
const rtc::scoped_refptr<EncodedVideoFrameBuffer>& encoded_frame_buffer)
|
||||
RtpPacketInfos packet_infos)
|
||||
: id_(id),
|
||||
video_frame_buffer_(buffer),
|
||||
encoded_frame_buffer_(encoded_frame_buffer),
|
||||
timestamp_rtp_(timestamp_rtp),
|
||||
ntp_time_ms_(ntp_time_ms),
|
||||
timestamp_us_(timestamp_us),
|
||||
@ -322,14 +312,4 @@ int64_t VideoFrame::render_time_ms() const {
|
||||
return timestamp_us() / rtc::kNumMicrosecsPerMillisec;
|
||||
}
|
||||
|
||||
void VideoFrame::set_encoded_video_frame_buffer(
|
||||
rtc::scoped_refptr<EncodedVideoFrameBuffer> encoded_frame_buffer) {
|
||||
encoded_frame_buffer_ = std::move(encoded_frame_buffer);
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<VideoFrame::EncodedVideoFrameBuffer>
|
||||
VideoFrame::encoded_video_frame_buffer() const {
|
||||
return encoded_frame_buffer_;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -13,20 +13,16 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/array_view.h"
|
||||
#include "api/rtp_packet_infos.h"
|
||||
#include "api/scoped_refptr.h"
|
||||
#include "api/video/color_space.h"
|
||||
#include "api/video/hdr_metadata.h"
|
||||
#include "api/video/video_codec_type.h"
|
||||
#include "api/video/video_frame_buffer.h"
|
||||
#include "api/video/video_rotation.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/ref_count.h"
|
||||
#include "rtc_base/system/rtc_export.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -76,23 +72,6 @@ class RTC_EXPORT VideoFrame {
|
||||
int scaled_height) const;
|
||||
};
|
||||
|
||||
// Interface for accessing elements of the encoded frame that was the base for
|
||||
// the rest of the VideoFrame.
|
||||
class EncodedVideoFrameBuffer : public rtc::RefCountInterface {
|
||||
public:
|
||||
// Returns a span of the bitstream data.
|
||||
virtual rtc::ArrayView<const uint8_t> data() const = 0;
|
||||
|
||||
// Returns the colorspace of the encoded frame, or nullptr if not present
|
||||
virtual const webrtc::ColorSpace* color_space() const = 0;
|
||||
|
||||
// Returns the codec of the encoded frame
|
||||
virtual VideoCodecType codec() const = 0;
|
||||
|
||||
// Returns wether the encoded frame is a keyframe
|
||||
virtual bool is_key_frame() const = 0;
|
||||
};
|
||||
|
||||
// Preferred way of building VideoFrame objects.
|
||||
class RTC_EXPORT Builder {
|
||||
public:
|
||||
@ -112,8 +91,6 @@ class RTC_EXPORT VideoFrame {
|
||||
Builder& set_id(uint16_t id);
|
||||
Builder& set_update_rect(const UpdateRect& update_rect);
|
||||
Builder& set_packet_infos(RtpPacketInfos packet_infos);
|
||||
Builder& set_encoded_video_frame_buffer(
|
||||
rtc::scoped_refptr<EncodedVideoFrameBuffer> encoded_frame_buffer);
|
||||
|
||||
private:
|
||||
uint16_t id_ = 0;
|
||||
@ -125,7 +102,6 @@ class RTC_EXPORT VideoFrame {
|
||||
absl::optional<ColorSpace> color_space_;
|
||||
absl::optional<UpdateRect> update_rect_;
|
||||
RtpPacketInfos packet_infos_;
|
||||
rtc::scoped_refptr<EncodedVideoFrameBuffer> encoded_frame_buffer_;
|
||||
};
|
||||
|
||||
// To be deprecated. Migrate all use to Builder.
|
||||
@ -215,12 +191,6 @@ class RTC_EXPORT VideoFrame {
|
||||
void set_video_frame_buffer(
|
||||
const rtc::scoped_refptr<VideoFrameBuffer>& buffer);
|
||||
|
||||
void set_encoded_video_frame_buffer(
|
||||
rtc::scoped_refptr<EncodedVideoFrameBuffer> encoded_frame_buffer);
|
||||
|
||||
rtc::scoped_refptr<EncodedVideoFrameBuffer> encoded_video_frame_buffer()
|
||||
const;
|
||||
|
||||
// TODO(nisse): Deprecated.
|
||||
// Return true if the frame is stored in a texture.
|
||||
bool is_texture() const {
|
||||
@ -262,14 +232,11 @@ class RTC_EXPORT VideoFrame {
|
||||
VideoRotation rotation,
|
||||
const absl::optional<ColorSpace>& color_space,
|
||||
const absl::optional<UpdateRect>& update_rect,
|
||||
RtpPacketInfos packet_infos,
|
||||
const rtc::scoped_refptr<EncodedVideoFrameBuffer>& encoded_frame);
|
||||
RtpPacketInfos packet_infos);
|
||||
|
||||
uint16_t id_;
|
||||
// A reference counted handle that stores the pixel data.
|
||||
// An opaque reference counted handle that stores the pixel data.
|
||||
rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_;
|
||||
// A reference counted handle that points to an encoded frame
|
||||
rtc::scoped_refptr<EncodedVideoFrameBuffer> encoded_frame_buffer_;
|
||||
uint32_t timestamp_rtp_;
|
||||
int64_t ntp_time_ms_;
|
||||
int64_t timestamp_us_;
|
||||
|
||||
@ -99,7 +99,6 @@ if (rtc_include_tests) {
|
||||
"../:webrtc_common",
|
||||
"../api:scoped_refptr",
|
||||
"../api/units:time_delta",
|
||||
"../api/video:encoded_frame",
|
||||
"../api/video:video_frame",
|
||||
"../api/video:video_frame_i010",
|
||||
"../api/video:video_frame_i420",
|
||||
|
||||
@ -362,39 +362,6 @@ TEST(TestVideoFrame, TextureInitialValues) {
|
||||
EXPECT_EQ(20, frame.timestamp_us());
|
||||
}
|
||||
|
||||
class TestEncodedFrame : public VideoFrame::EncodedVideoFrameBuffer {
|
||||
public:
|
||||
rtc::ArrayView<const uint8_t> data() const override {
|
||||
return rtc::ArrayView<const uint8_t>();
|
||||
}
|
||||
webrtc::ColorSpace* color_space() const override { return nullptr; }
|
||||
VideoCodecType codec() const override { return kVideoCodecGeneric; }
|
||||
bool is_key_frame() const { return false; }
|
||||
};
|
||||
|
||||
TEST(TestVideoFrame, AcceptsEncodedFrameSource) {
|
||||
VideoFrame frame =
|
||||
VideoFrame::Builder()
|
||||
.set_video_frame_buffer(I420Buffer::Create(10, 10, 10, 14, 90))
|
||||
.build();
|
||||
EXPECT_EQ(frame.encoded_video_frame_buffer(), nullptr);
|
||||
auto encoded_frame = new rtc::RefCountedObject<TestEncodedFrame>();
|
||||
frame.set_encoded_video_frame_buffer(encoded_frame);
|
||||
EXPECT_EQ(frame.encoded_video_frame_buffer(), encoded_frame);
|
||||
}
|
||||
|
||||
TEST(TestVideoFrame, CopiesWithSameEncodedFrameSource) {
|
||||
VideoFrame frame =
|
||||
VideoFrame::Builder()
|
||||
.set_video_frame_buffer(I420Buffer::Create(10, 10, 10, 14, 90))
|
||||
.set_encoded_video_frame_buffer(
|
||||
new rtc::RefCountedObject<TestEncodedFrame>())
|
||||
.build();
|
||||
VideoFrame frame2 = frame;
|
||||
EXPECT_EQ(frame.encoded_video_frame_buffer().get(),
|
||||
frame2.encoded_video_frame_buffer().get());
|
||||
}
|
||||
|
||||
class TestPlanarYuvBuffer
|
||||
: public ::testing::TestWithParam<VideoFrameBuffer::Type> {};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user