Android-cuttlefish cvd tool
sensors_handler.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2023 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 <chrono>
20#include <mutex>
21#include <thread>
22#include <unordered_map>
23
26
27namespace cuttlefish {
28namespace webrtc_streaming {
29
31 SensorsHandler(SharedFD sensors_fd);
33 void HandleMessage(const double x, const double y, const double z);
34 int Subscribe(std::function<void(const uint8_t*, size_t)> send_to_client);
35 void UnSubscribe(int subscriber_id);
36
37 private:
38 Result<void> RefreshSensors(const double x, const double y, const double z);
40 void UpdateSensorsUi();
41 std::unordered_map<int, std::function<void(const uint8_t*, size_t)>> client_channels_;
43 std::mutex subscribers_mtx_;
45};
46
47} // namespace webrtc_streaming
48} // namespace cuttlefish
Definition: expected.h:86
Definition: shared_fd.h:129
Definition: channel_sharedfd.h:25
Definition: alloc_utils.cpp:23
Definition: sensors_handler.h:30
Result< void > RefreshSensors(const double x, const double y, const double z)
Definition: sensors_handler.cpp:44
SensorsHandler(SharedFD sensors_fd)
Definition: sensors_handler.cpp:33
~SensorsHandler()
Definition: sensors_handler.cpp:42
void UnSubscribe(int subscriber_id)
Definition: sensors_handler.cpp:113
void UpdateSensorsUi()
Definition: sensors_handler.cpp:118
int Subscribe(std::function< void(const uint8_t *, size_t)> send_to_client)
Definition: sensors_handler.cpp:91
std::mutex subscribers_mtx_
Definition: sensors_handler.h:43
std::unordered_map< int, std::function< void(const uint8_t *, size_t)> > client_channels_
Definition: sensors_handler.h:41
Result< std::string > GetSensorsData()
Definition: sensors_handler.cpp:60
transport::SharedFdChannel channel_
Definition: sensors_handler.h:44
int last_client_channel_id_
Definition: sensors_handler.h:42
void HandleMessage(const double x, const double y, const double z)
Definition: sensors_handler.cpp:81