• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef ANDROID_V4L2_CODEC2_COMPONENTS_VIDEO_FRAME_H
6 #define ANDROID_V4L2_CODEC2_COMPONENTS_VIDEO_FRAME_H
7 
8 #include <memory>
9 #include <vector>
10 
11 #include <C2Buffer.h>
12 
13 #include <rect.h>
14 
15 namespace android {
16 
17 // Wrap C2GraphicBlock and provide essiential information from C2GraphicBlock.
18 class VideoFrame {
19 public:
20     // Create the instance from C2GraphicBlock. return nullptr if any error occurs.
21     static std::unique_ptr<VideoFrame> Create(std::shared_ptr<C2GraphicBlock> block);
22     ~VideoFrame();
23 
24     // Return the file descriptors of the corresponding buffer.
25     const std::vector<int>& getFDs() const;
26 
27     // Getter and setter of the visible rectangle.
28     void setVisibleRect(const media::Rect& visibleRect);
29     const media::Rect& getVisibleRect() const;
30 
31     // Getter and setter of the bitstream ID of the corresponding input bitstream.
32     void setBitstreamId(int32_t bitstreamId);
33     int32_t getBitstreamId() const;
34 
35     // Get the read-only C2GraphicBlock, should be called after calling setVisibleRect().
36     C2ConstGraphicBlock getGraphicBlock();
37 
38 private:
39     VideoFrame(std::shared_ptr<C2GraphicBlock> block, std::vector<int> fds);
40 
41     std::shared_ptr<C2GraphicBlock> mGraphicBlock;
42     std::vector<int> mFds;
43     media::Rect mVisibleRect;
44     int32_t mBitstreamId = -1;
45 };
46 
47 }  // namespace android
48 
49 #endif  // ANDROID_V4L2_CODEC2_COMPONENTS_VIDEO_FRAME_H
50