Home | History | Annotate | Download | only in vnc_server
      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 <string>
     20 #include <thread>
     21 #include <utility>
     22 
     23 #include "common/libs/tcp_socket/tcp_socket.h"
     24 #include "host/frontend/vnc_server/blackboard.h"
     25 #include "host/frontend/vnc_server/frame_buffer_watcher.h"
     26 #include "host/frontend/vnc_server/jpeg_compressor.h"
     27 #include "host/frontend/vnc_server/virtual_inputs.h"
     28 #include "host/frontend/vnc_server/vnc_client_connection.h"
     29 #include "host/frontend/vnc_server/vnc_utils.h"
     30 
     31 namespace cvd {
     32 namespace vnc {
     33 
     34 class VncServer {
     35  public:
     36   explicit VncServer(int port, bool aggressive);
     37 
     38   VncServer(const VncServer&) = delete;
     39   VncServer& operator=(const VncServer&) = delete;
     40 
     41   [[noreturn]] void MainLoop();
     42 
     43  private:
     44   void StartClient(ClientSocket sock);
     45 
     46   void StartClientThread(ClientSocket sock);
     47 
     48   ServerSocket server_;
     49   VirtualInputs virtual_inputs_;
     50   BlackBoard bb_;
     51   FrameBufferWatcher frame_buffer_watcher_;
     52   bool aggressive_{};
     53 };
     54 
     55 }  // namespace vnc
     56 }  // namespace cvd
     57