// Copyright 2020 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. //#define LOG_NDEBUG 0 #define LOG_TAG "VideoFrame" #include #include #include namespace android { // static std::unique_ptr VideoFrame::Create(std::shared_ptr block) { if (!block) return nullptr; std::vector fds; const C2Handle* const handle = block->handle(); for (int i = 0; i < handle->numFds; i++) { fds.emplace_back(handle->data[i]); } return std::unique_ptr(new VideoFrame(std::move(block), std::move(fds))); } VideoFrame::VideoFrame(std::shared_ptr block, std::vector fds) : mGraphicBlock(std::move(block)), mFds(fds) {} VideoFrame::~VideoFrame() = default; const std::vector& VideoFrame::getFDs() const { return mFds; } void VideoFrame::setVisibleRect(const Rect& visibleRect) { mVisibleRect = visibleRect; } const Rect& VideoFrame::getVisibleRect() const { return mVisibleRect; } void VideoFrame::setBitstreamId(int32_t bitstreamId) { mBitstreamId = bitstreamId; } int32_t VideoFrame::getBitstreamId() const { return mBitstreamId; } C2ConstGraphicBlock VideoFrame::getGraphicBlock() { return mGraphicBlock->share(C2Rect(mVisibleRect.width(), mVisibleRect.height()), C2Fence()); } } // namespace android