VideoFrameUtils.h (1677B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set sw=2 ts=8 et ft=cpp : */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_VideoFrameUtil_h 8 #define mozilla_VideoFrameUtil_h 9 10 #include "mozilla/camera/PCameras.h" 11 12 namespace webrtc { 13 class VideoFrame; 14 } 15 16 namespace mozilla { 17 class ShmemBuffer; 18 19 // Util methods for working with webrtc::VideoFrame(s) and 20 // the IPC classes that are used to deliver their contents to the 21 // MediaEnginge 22 23 class VideoFrameUtils { 24 public: 25 // Returns the total number of bytes necessary to copy a VideoFrame's buffer 26 // across all planes. 27 static uint32_t TotalRequiredBufferSize(const webrtc::VideoFrame& frame); 28 29 // Initializes a camera::VideoFrameProperties from a VideoFrameBuffer 30 static void InitFrameBufferProperties( 31 const webrtc::VideoFrame& aVideoFrame, 32 camera::VideoFrameProperties& aDestProperties); 33 34 // Copies the buffers out of a VideoFrameBuffer into a buffer. 35 // Attempts to make as few memcopies as possible. 36 static void CopyVideoFrameBuffers(uint8_t* aDestBuffer, 37 const size_t aDestBufferSize, 38 const webrtc::VideoFrame& aVideoFrame); 39 40 // Copies the buffers in a VideoFrameBuffer into a Shmem 41 // returns the eno from the underlying memcpy. 42 static void CopyVideoFrameBuffers(ShmemBuffer& aDestShmem, 43 const webrtc::VideoFrame& aVideoFrame); 44 }; 45 46 } /* namespace mozilla */ 47 48 #endif