From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- dom/media/webrtc/libwebrtcglue/WebrtcImageBuffer.h | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 dom/media/webrtc/libwebrtcglue/WebrtcImageBuffer.h (limited to 'dom/media/webrtc/libwebrtcglue/WebrtcImageBuffer.h') diff --git a/dom/media/webrtc/libwebrtcglue/WebrtcImageBuffer.h b/dom/media/webrtc/libwebrtcglue/WebrtcImageBuffer.h new file mode 100644 index 0000000000..305f4df577 --- /dev/null +++ b/dom/media/webrtc/libwebrtcglue/WebrtcImageBuffer.h @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef WebrtcImageBuffer_h__ +#define WebrtcImageBuffer_h__ + +#include "common_video/include/video_frame_buffer.h" + +namespace mozilla { +namespace layers { +class Image; +} + +class ImageBuffer : public webrtc::VideoFrameBuffer { + public: + explicit ImageBuffer(RefPtr&& aImage) + : mImage(std::move(aImage)) {} + + rtc::scoped_refptr ToI420() override { + RefPtr image = mImage->AsPlanarYCbCrImage(); + MOZ_ASSERT(image); + if (!image) { + // TODO. YUV420 ReadBack, Image only provides a RGB readback. + return nullptr; + } + const layers::PlanarYCbCrData* data = image->GetData(); + rtc::scoped_refptr buf = + webrtc::WrapI420Buffer( + data->mPictureRect.width, data->mPictureRect.height, + data->mYChannel, data->mYStride, data->mCbChannel, + data->mCbCrStride, data->mCrChannel, data->mCbCrStride, + [image] { /* keep reference alive*/ }); + return buf; + } + + Type type() const override { return Type::kNative; } + + int width() const override { return mImage->GetSize().width; } + + int height() const override { return mImage->GetSize().height; } + + RefPtr GetNativeImage() const { return mImage; } + + private: + const RefPtr mImage; +}; + +} // namespace mozilla + +#endif // WebrtcImageBuffer_h__ -- cgit v1.2.3