123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- #include "pch.h"
- #include "GraphicsDevice/GraphicsDevice.h"
- #include "VideoFrame.h"
- namespace unity
- {
- namespace webrtc
- {
- VideoFrame::VideoFrame(
- const Size& size,
- rtc::scoped_refptr<GpuMemoryBufferInterface> buffer,
- ReturnBufferToPoolCallback returnBufferToPoolCallback,
- TimeDelta timestamp)
- : size_(size)
- , gpu_memory_buffer_(std::move(buffer))
- , returnBufferToPoolCallback_(returnBufferToPoolCallback)
- , timestamp_(timestamp)
- {
- }
- VideoFrame::~VideoFrame()
- {
- if (returnBufferToPoolCallback_)
- {
- returnBufferToPoolCallback_(std::move(gpu_memory_buffer_));
- }
- }
- rtc::scoped_refptr<VideoFrame> VideoFrame::WrapExternalGpuMemoryBuffer(
- const Size& size,
- rtc::scoped_refptr<GpuMemoryBufferInterface> buffer,
- ReturnBufferToPoolCallback returnBufferToPoolCallback,
- TimeDelta timestamp)
- {
- return new rtc::RefCountedObject<VideoFrame>(size, std::move(buffer), returnBufferToPoolCallback, timestamp);
- }
- bool VideoFrame::HasGpuMemoryBuffer() const { return gpu_memory_buffer_ != nullptr; }
- GpuMemoryBufferInterface* VideoFrame::GetGpuMemoryBuffer() const { return gpu_memory_buffer_.get(); }
- } // end namespace webrtc
- } // end namespace unity
|