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 <functional> 20 21 #include <json/json.h> 22 23 namespace cuttlefish { 24 namespace webrtc_streaming { 25 26 class ConnectionObserver { 27 public: 28 ConnectionObserver() = default; 29 virtual ~ConnectionObserver() = default; 30 31 virtual void OnConnected( 32 std::function<void(const uint8_t*, size_t, bool)> ctrl_msg_sender) = 0; 33 virtual void OnTouchEvent(const std::string& display_label, int x, int y, 34 bool down) = 0; 35 virtual void OnMultiTouchEvent(const std::string& label, Json::Value id, Json::Value slot, 36 Json::Value x, Json::Value y, bool down, int size) = 0; 37 virtual void OnKeyboardEvent(uint16_t keycode, bool down) = 0; 38 virtual void OnSwitchEvent(uint16_t code, bool state) = 0; 39 virtual void OnAdbChannelOpen( 40 std::function<bool(const uint8_t*, size_t)> adb_message_sender) = 0; 41 virtual void OnAdbMessage(const uint8_t* msg, size_t size) = 0; 42 virtual void OnControlChannelOpen( 43 std::function<bool(const Json::Value)> control_message_sender) = 0; 44 virtual void OnControlMessage(const uint8_t* msg, size_t size) = 0; 45 virtual void OnBluetoothChannelOpen( 46 std::function<bool(const uint8_t*, size_t)> bluetooth_message_sender) = 0; 47 virtual void OnBluetoothMessage(const uint8_t* msg, size_t size) = 0; 48 virtual void OnCameraData(const std::vector<char>& data) = 0; 49 }; 50 51 class ConnectionObserverFactory { 52 public: 53 virtual ~ConnectionObserverFactory() = default; 54 // Called when a new connection is requested 55 virtual std::shared_ptr<ConnectionObserver> CreateObserver() = 0; 56 }; 57 58 } // namespace webrtc_streaming 59 } // namespace cuttlefish 60