Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions base/cvd/cuttlefish/common/libs/utils/files.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <sys/types.h>

#include <chrono>
#include <functional>
#include <optional>
#include <string>
#include <string_view>
Expand Down
1 change: 1 addition & 0 deletions base/cvd/cuttlefish/host/frontend/webrtc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ cf_cc_binary(
"@gflags",
"@googleapis//google/rpc:code_cc_proto",
"@googleapis//google/rpc:status_cc_proto",
"@grpc//:grpc++",
"@jsoncpp",
"@libdrm//:libdrm_fourcc",
"@libjpeg_turbo//:jpeg",
Expand Down
8 changes: 7 additions & 1 deletion base/cvd/cuttlefish/host/frontend/webrtc/adb_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@

#include "cuttlefish/host/frontend/webrtc/adb_handler.h"

#include <stddef.h>
#include <stdint.h>
#include <unistd.h>

#include <functional>
#include <string>

#include "absl/log/log.h"

#include "cuttlefish/posix/strerror.h"
#include "cuttlefish/common/libs/fs/shared_fd.h"
#include "cuttlefish/common/libs/fs/shared_select.h"

using namespace android;

Expand Down
5 changes: 4 additions & 1 deletion base/cvd/cuttlefish/host/frontend/webrtc/adb_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

#pragma once

#include <memory>
#include <stddef.h>
#include <stdint.h>

#include <functional>
#include <thread>

#include "cuttlefish/common/libs/fs/shared_fd.h"
Expand Down
9 changes: 6 additions & 3 deletions base/cvd/cuttlefish/host/frontend/webrtc/bluetooth_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

#pragma once

#include <memory>
#include <stddef.h>
#include <stdint.h>

#include <functional>
#include <thread>

#include "cuttlefish/common/libs/fs/shared_fd.h"
Expand All @@ -27,8 +30,8 @@ namespace webrtc_streaming {

struct BluetoothHandler {
explicit BluetoothHandler(
const int rootCanalTestPort,
std::function<void(const uint8_t *, size_t)> send_to_client);
int rootCanalTestPort,
std::function<void(const uint8_t*, size_t)> send_to_client);

~BluetoothHandler();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,21 @@

#include "cuttlefish/host/frontend/webrtc/gpx_locations_handler.h"

#include <stddef.h>
#include <stdint.h>
#include <unistd.h>

#include <iostream>
#include <string>

#include "absl/log/log.h"
#include "fmt/format.h"
#include "grpcpp/create_channel.h"

#include "cuttlefish/host/libs/config/cuttlefish_config.h"
#include "cuttlefish/host/libs/location/GnssClient.h"
#include "cuttlefish/host/libs/location/GpxParser.h"
#include "cuttlefish/result/result.h"

namespace cuttlefish::webrtc_streaming {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

#pragma once

#include "cuttlefish/common/libs/fs/shared_select.h"
#include <stddef.h>
#include <stdint.h>

#include <functional>

namespace cuttlefish {
namespace webrtc_streaming {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@

#include "absl/log/check.h"
#include "absl/log/log.h"
#include "json/value.h"

#include "cuttlefish/common/libs/fs/shared_fd.h"
#include "cuttlefish/common/libs/fs/shared_select.h"
#include "cuttlefish/host/commands/kernel_log_monitor/kernel_log_server.h"
#include "cuttlefish/host/commands/kernel_log_monitor/utils.h"
#include "cuttlefish/host/libs/config/cuttlefish_config.h"
#include "cuttlefish/result/result.h"

using namespace android;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
#pragma once

#include <atomic>
#include <functional>
#include <list>
#include <map>
#include <memory>
#include <mutex>
#include <thread>

#include <json/json.h>
#include "json/value.h"

#include "cuttlefish/common/libs/fs/shared_fd.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@

#include "cuttlefish/host/frontend/webrtc/kml_locations_handler.h"

#include <stddef.h>
#include <stdint.h>
#include <unistd.h>

#include <iostream>
#include <string>

#include "absl/log/log.h"
#include "fmt/format.h"
#include "grpcpp/create_channel.h"

#include "cuttlefish/host/libs/config/cuttlefish_config.h"
#include "cuttlefish/host/libs/location/GnssClient.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

#pragma once

#include "cuttlefish/common/libs/fs/shared_select.h"
#include <stddef.h>
#include <stdint.h>

#include <functional>

namespace cuttlefish {
namespace webrtc_streaming {
Expand Down
11 changes: 7 additions & 4 deletions base/cvd/cuttlefish/host/frontend/webrtc/location_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@

#include "cuttlefish/host/frontend/webrtc/location_handler.h"

#include <stddef.h>
#include <stdint.h>
#include <unistd.h>

#include <fmt/format.h>
#include "absl/log/log.h"
#include "fmt/format.h"
#include "grpcpp/create_channel.h"

#include "cuttlefish/host/libs/config/cuttlefish_config.h"
#include "cuttlefish/host/libs/location/GnssClient.h"
#include "cuttlefish/result/result.h"

namespace cuttlefish::webrtc_streaming {

Expand All @@ -31,9 +35,8 @@ LocationHandler::LocationHandler(

LocationHandler::~LocationHandler() {}

void LocationHandler::HandleMessage(const float longitude,
const float latitude,
const float elevation) {
void LocationHandler::HandleMessage(const float longitude, const float latitude,
const float elevation) {
auto config = CuttlefishConfig::Get();
if (!config) {
LOG(ERROR) << "Failed to obtain config object";
Expand Down
10 changes: 6 additions & 4 deletions base/cvd/cuttlefish/host/frontend/webrtc/location_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

#pragma once

#include "cuttlefish/common/libs/fs/shared_select.h"
#include <stddef.h>
#include <stdint.h>

#include <functional>

namespace cuttlefish {
namespace webrtc_streaming {
Expand All @@ -27,9 +30,8 @@ struct LocationHandler {

~LocationHandler();

void HandleMessage(const float longitude,
const float latitude,
const float elevation);
void HandleMessage(float longitude, float latitude, float elevation);
};

} // namespace webrtc_streaming
} // namespace cuttlefish
14 changes: 8 additions & 6 deletions base/cvd/cuttlefish/host/frontend/webrtc/screenshot_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@

#pragma once

#include <stdint.h>

#include <future>
#include <memory>
#include <mutex>

#include <fmt/format.h>
#include <string>
#include <unordered_map>

#include "cuttlefish/host/libs/screen_connector/video_frame_buffer.h"
#include "cuttlefish/result/result.h"
Expand All @@ -35,17 +38,16 @@ class ScreenshotHandler {
using SharedFrameFuture = std::shared_future<SharedFrame>;
using SharedFramePromise = std::promise<SharedFrame>;

Result<void> Screenshot(std::uint32_t display_number,
Result<void> Screenshot(uint32_t display_number,
const std::string& screenshot_path);

void OnFrame(std::uint32_t display_number, SharedFrame& frame);
void OnFrame(uint32_t display_number, SharedFrame& frame);

private:
std::mutex pending_screenshot_displays_mutex_;
// Promises used to share a frame for a given display from the display handler
// thread to the snapshot thread for processing.
std::unordered_map<std::uint32_t, SharedFramePromise>
pending_screenshot_displays_;
std::unordered_map<uint32_t, SharedFramePromise> pending_screenshot_displays_;
};

} // namespace cuttlefish
11 changes: 8 additions & 3 deletions base/cvd/cuttlefish/host/frontend/webrtc/sensors_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@

#include "cuttlefish/host/frontend/webrtc/sensors_handler.h"

#include "absl/log/log.h"
#include <string.h>

#include <mutex>
#include <sstream>
#include <string>

#include "absl/log/log.h"

#include "cuttlefish/common/libs/sensors/sensors.h"

namespace cuttlefish {
namespace webrtc_streaming {

Expand Down Expand Up @@ -50,7 +55,7 @@ Result<void> SensorsHandler::RefreshSensors(const double x, const double y,
auto request = CF_EXPECT(transport::CreateMessage(cmd, size),
"Failed to allocate message for cmd: "
<< cmd << " with size: " << size << " bytes. ");
std::memcpy(request->payload, msg.data(), size);
memcpy(request->payload, msg.data(), size);
CF_EXPECT(channel_.SendRequest(*request),
"Can't send request for cmd: " << cmd);
return {};
Expand All @@ -63,7 +68,7 @@ Result<std::string> SensorsHandler::GetSensorsData() {
auto request = CF_EXPECT(transport::CreateMessage(cmd, size),
"Failed to allocate message for cmd: "
<< cmd << " with size: " << size << " bytes. ");
std::memcpy(request->payload, msg.data(), size);
memcpy(request->payload, msg.data(), size);
CF_EXPECT(channel_.SendRequest(*request),
"Can't send request for cmd: " << cmd);
auto response =
Expand Down
15 changes: 8 additions & 7 deletions base/cvd/cuttlefish/host/frontend/webrtc/sensors_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,29 @@

#pragma once

#include <chrono>
#include <functional>
#include <mutex>
#include <thread>
#include <unordered_map>

#include "cuttlefish/common/libs/sensors/sensors.h"
#include "cuttlefish/common/libs/transport/channel_sharedfd.h"

namespace cuttlefish {
namespace webrtc_streaming {

struct SensorsHandler {
SensorsHandler(SharedFD sensors_fd);
class SensorsHandler {
public:
explicit SensorsHandler(SharedFD sensors_fd);
~SensorsHandler();
void HandleMessage(const double x, const double y, const double z);

void HandleMessage(double x, double y, double z);
int Subscribe(std::function<void(const uint8_t*, size_t)> send_to_client);
void UnSubscribe(int subscriber_id);

private:
Result<void> RefreshSensors(const double x, const double y, const double z);
Result<void> RefreshSensors(double x, double y, double z);
Result<std::string> GetSensorsData();
void UpdateSensorsUi();

std::unordered_map<int, std::function<void(const uint8_t*, size_t)>> client_channels_;
int last_client_channel_id_ = -1;
std::mutex subscribers_mtx_;
Expand Down
Loading