#include "third_party/blink/renderer/platform/webrtc/convert_to_webrtc_video_frame_buffer.h"
#include "base/containers/contains.h"
#include "base/containers/span.h"
#include "base/logging.h"
#include "media/base/video_frame_converter.h"
#include "media/base/video_util.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/platform/modules/webrtc/webrtc_logging.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread.h"
#include "third_party/blink/renderer/platform/webrtc/webrtc_video_frame_adapter.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "third_party/libyuv/include/libyuv/convert.h"
#include "third_party/libyuv/include/libyuv/convert_from_argb.h"
#include "third_party/libyuv/include/libyuv/scale.h"
#include "third_party/webrtc/api/video/i420_buffer.h"
#include "third_party/webrtc/common_video/include/video_frame_buffer.h"
#include "third_party/webrtc/rtc_base/ref_counted_object.h"
#include "ui/gfx/gpu_memory_buffer.h"
namespace WTF {
template <>
struct CrossThreadCopier<scoped_refptr<webrtc::VideoFrameBuffer>>
: public CrossThreadCopierPassThrough<
scoped_refptr<webrtc::VideoFrameBuffer>> { … };
}
namespace {
class I420FrameAdapter : public webrtc::I420BufferInterface { … };
class I420AFrameAdapter : public webrtc::I420ABufferInterface { … };
class NV12FrameAdapter : public webrtc::NV12BufferInterface { … };
rtc::scoped_refptr<webrtc::VideoFrameBuffer> MakeFrameAdapter(
scoped_refptr<media::VideoFrame> video_frame) { … }
scoped_refptr<media::VideoFrame> MakeScaledVideoFrame(
scoped_refptr<media::VideoFrame> source_frame,
scoped_refptr<blink::WebRtcVideoFrameAdapter::SharedResources>
shared_resources,
bool source_is_nv12) { … }
scoped_refptr<media::VideoFrame> MaybeConvertAndScaleFrame(
scoped_refptr<media::VideoFrame> source_frame,
scoped_refptr<blink::WebRtcVideoFrameAdapter::SharedResources>
shared_resources) { … }
}
namespace blink {
bool CanConvertToWebRtcVideoFrameBuffer(const media::VideoFrame* frame) { … }
base::span<const media::VideoPixelFormat>
GetPixelFormatsMappableToWebRtcVideoFrameBuffer() { … }
rtc::scoped_refptr<webrtc::VideoFrameBuffer> ConvertToWebRtcVideoFrameBuffer(
scoped_refptr<media::VideoFrame> video_frame,
scoped_refptr<WebRtcVideoFrameAdapter::SharedResources> shared_resources) { … }
scoped_refptr<media::VideoFrame> ConvertFromMappedWebRtcVideoFrameBuffer(
rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer,
base::TimeDelta timestamp) { … }
}