• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <vector>
20 
21 #include "host/frontend/webrtc/lib/video_frame_buffer.h"
22 
23 namespace cuttlefish {
24 
25 class CvdVideoFrameBuffer : public webrtc_streaming::VideoFrameBuffer {
26  public:
27   CvdVideoFrameBuffer(int width, int height);
28   CvdVideoFrameBuffer(CvdVideoFrameBuffer&& cvd_frame_buf) = default;
29   CvdVideoFrameBuffer(const CvdVideoFrameBuffer& cvd_frame_buf) = default;
30   CvdVideoFrameBuffer& operator=(CvdVideoFrameBuffer&& cvd_frame_buf) = default;
31   CvdVideoFrameBuffer& operator=(const CvdVideoFrameBuffer& cvd_frame_buf) = default;
32   CvdVideoFrameBuffer() = delete;
33 
34   ~CvdVideoFrameBuffer() override;
35 
36   int width() const override;
37   int height() const override;
38 
39   int StrideY() const override;
40   int StrideU() const override;
41   int StrideV() const override;
42 
43   const uint8_t *DataY() const override;
44   const uint8_t *DataU() const override;
45   const uint8_t *DataV() const override;
46 
DataY()47   uint8_t *DataY() { return y_.data(); }
DataU()48   uint8_t *DataU() { return u_.data(); }
DataV()49   uint8_t *DataV() { return v_.data(); }
50 
51  private:
52   const int width_;
53   const int height_;
54   std::vector<std::uint8_t> y_;
55   std::vector<std::uint8_t> u_;
56   std::vector<std::uint8_t> v_;
57 };
58 
59 }
60