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/libdevice/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) = delete;
31   CvdVideoFrameBuffer& operator=(const CvdVideoFrameBuffer& cvd_frame_buf) =
32       delete;
33   CvdVideoFrameBuffer() = delete;
34 
35   ~CvdVideoFrameBuffer() override;
36 
37   int width() const override;
38   int height() const override;
39 
40   int StrideY() const override;
41   int StrideU() const override;
42   int StrideV() const override;
43 
44   const uint8_t *DataY() const override;
45   const uint8_t *DataU() const override;
46   const uint8_t *DataV() const override;
47 
DataY()48   uint8_t *DataY() { return y_.data(); }
DataU()49   uint8_t *DataU() { return u_.data(); }
DataV()50   uint8_t *DataV() { return v_.data(); }
51 
52  private:
53   const int width_;
54   const int height_;
55   std::vector<std::uint8_t> y_;
56   std::vector<std::uint8_t> u_;
57   std::vector<std::uint8_t> v_;
58 };
59 
60 }
61