1 #pragma once 2 3 /* 4 * Copyright (C) 2017 The Android Open Source Project 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 #include <array> 20 #include <cstdint> 21 #include <utility> 22 #include <vector> 23 24 #include "common/libs/utils/size_utils.h" 25 #include "common/libs/tcp_socket/tcp_socket.h" 26 #include "host/libs/config/cuttlefish_config.h" 27 28 namespace cuttlefish { 29 namespace vnc { 30 31 // TODO(haining) when the hwcomposer gives a sequence number type, use that 32 // instead. It might just work to replace this class with a type alias 33 // using StripeSeqNumber = whatever_the_hwcomposer_uses; 34 class StripeSeqNumber { 35 public: 36 StripeSeqNumber() = default; StripeSeqNumber(std::uint64_t t)37 explicit StripeSeqNumber(std::uint64_t t) : t_{t} {} 38 bool operator<(const StripeSeqNumber& other) const { return t_ < other.t_; } 39 40 bool operator<=(const StripeSeqNumber& other) const { return t_ <= other.t_; } 41 42 private: 43 std::uint64_t t_{}; 44 }; 45 46 constexpr int32_t kJpegMaxQualityEncoding = -23; 47 constexpr int32_t kJpegMinQualityEncoding = -32; 48 49 enum class ScreenOrientation { Portrait, Landscape }; 50 constexpr int kNumOrientations = 2; 51 52 struct Stripe { 53 int index = -1; 54 std::uint64_t frame_id{}; 55 std::uint16_t x{}; 56 std::uint16_t y{}; 57 std::uint16_t width{}; 58 std::uint16_t stride{}; 59 std::uint16_t height{}; 60 Message raw_data{}; 61 Message jpeg_data{}; 62 StripeSeqNumber seq_number{}; 63 ScreenOrientation orientation{}; 64 }; 65 66 } // namespace vnc 67 } // namespace cuttlefish 68