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 <map> 20 #include <memory> 21 22 #include "common/libs/fs/shared_fd.h" 23 #include "host/frontend/webrtc/display_handler.h" 24 #include "host/frontend/webrtc/kernel_log_events_handler.h" 25 #include "host/frontend/webrtc/lib/connection_observer.h" 26 #include "host/libs/confui/host_virtual_input.h" 27 28 namespace cuttlefish { 29 30 struct InputSockets { 31 SharedFD touch_server; 32 SharedFD touch_client; 33 SharedFD keyboard_server; 34 SharedFD keyboard_client; 35 SharedFD switches_server; 36 SharedFD switches_client; 37 }; 38 39 class CfConnectionObserverFactory 40 : public webrtc_streaming::ConnectionObserverFactory { 41 public: 42 CfConnectionObserverFactory( 43 cuttlefish::InputSockets& input_sockets, 44 KernelLogEventsHandler* kernel_log_events_handler, 45 cuttlefish::confui::HostVirtualInput& confui_input); 46 ~CfConnectionObserverFactory() override = default; 47 48 std::shared_ptr<webrtc_streaming::ConnectionObserver> CreateObserver() 49 override; 50 51 void AddCustomActionServer(SharedFD custom_action_server_fd, 52 const std::vector<std::string>& commands); 53 54 void SetDisplayHandler(std::weak_ptr<DisplayHandler> display_handler); 55 56 private: 57 InputSockets& input_sockets_; 58 KernelLogEventsHandler* kernel_log_events_handler_; 59 std::map<std::string, SharedFD> 60 commands_to_custom_action_servers_; 61 std::weak_ptr<DisplayHandler> weak_display_handler_; 62 cuttlefish::confui::HostVirtualInput& confui_input_; 63 }; 64 65 } // namespace cuttlefish 66