load("@protobuf//bazel:cc_proto_library.bzl", "cc_proto_library")
load("@protobuf//bazel:proto_library.bzl", "proto_library")
load("//cuttlefish/bazel:rules.bzl", "cf_cc_binary", "cf_cc_library")

package(
    default_visibility = ["//:android_cuttlefish"],
)

proto_library(
    name = "webrtc_commands_proto",
    srcs = ["webrtc_commands.proto"],
    deps = ["@googleapis//google/rpc:status_proto"],
)

cc_proto_library(
    name = "libcuttlefish_webrtc_commands_proto",
    deps = [":webrtc_commands_proto"],
)

cf_cc_library(
    name = "libcuttlefish_webrtc_command_channel",
    srcs = ["webrtc_command_channel.cpp"],
    hdrs = ["webrtc_command_channel.h"],
    deps = [
        ":libcuttlefish_webrtc_commands_proto",
        "//cuttlefish/common/libs/transport",
        "//libbase",
    ],
)

cf_cc_library(
    name = "libcuttlefish_webrtc_adb_handler",
    srcs = ["adb_handler.cpp"],
    hdrs = ["adb_handler.h"],
    clang_format_enabled = False,
    deps = [
        "//cuttlefish/common/libs/fs",
        "//libbase",
        "@abseil-cpp//absl/log",
        "@abseil-cpp//absl/log:check",
        "@abseil-cpp//absl/strings",
        "@fmt",
        "@fruit",
        "@jsoncpp",
    ],
)

cf_cc_library(
    name = "libcuttlefish_webrtc_audio_handler",
    srcs = ["audio_handler.cpp"],
    hdrs = ["audio_handler.h"],
    clang_format_enabled = False,
    deps = [
        ":libcuttlefish_webrtc_audio_mixer",
        ":libcuttlefish_webrtc_audio_settings",
        "//cuttlefish/host/frontend/webrtc/libcommon:audio_source",
        "//cuttlefish/host/frontend/webrtc/libdevice:audio_sink",
        "//cuttlefish/host/libs/audio_connector",
        "//libbase",
        "@abseil-cpp//absl/log",
        "@abseil-cpp//absl/log:check",
        "@abseil-cpp//absl/strings",
        "@fmt",
        "@fruit",
        "@jsoncpp",
        "@libwebrtc",
    ],
)

cf_cc_library(
    name = "libcuttlefish_webrtc_audio_mixer",
    srcs = ["audio_mixer.cpp"],
    hdrs = ["audio_mixer.h"],
    clang_format_enabled = False,
    deps = [
        ":libcuttlefish_webrtc_audio_settings",
        "//cuttlefish/host/frontend/webrtc/libdevice:audio_sink",
        "//libbase",
        "@abseil-cpp//absl/log",
        "@abseil-cpp//absl/log:check",
        "@abseil-cpp//absl/strings",
        "@fmt",
        "@fruit",
        "@jsoncpp",
    ],
)

cf_cc_library(
    name = "libcuttlefish_webrtc_audio_settings",
    hdrs = ["audio_settings.h"],
)

cf_cc_library(
    name = "libcuttlefish_webrtc_bluetooth_handler",
    srcs = ["bluetooth_handler.cpp"],
    hdrs = ["bluetooth_handler.h"],
    clang_format_enabled = False,
    deps = [
        "//cuttlefish/common/libs/fs",
        "//libbase",
        "@abseil-cpp//absl/log",
        "@abseil-cpp//absl/log:check",
        "@abseil-cpp//absl/strings",
        "@fmt",
        "@fruit",
        "@jsoncpp",
    ],
)

cf_cc_library(
    name = "libcuttlefish_webrtc_client_server",
    srcs = ["client_server.cpp"],
    hdrs = ["client_server.h"],
    deps = [
        "//libbase",
        "@abseil-cpp//absl/log",
        "@abseil-cpp//absl/log:check",
        "@abseil-cpp//absl/strings",
        "@fmt",
        "@fruit",
        "@jsoncpp",
        "@libwebsockets",
    ],
)

cf_cc_library(
    name = "libcuttlefish_webrtc_connection_observer",
    srcs = ["connection_observer.cpp"],
    hdrs = ["connection_observer.h"],
    clang_format_enabled = False,
    deps = [
        ":libcuttlefish_webrtc_adb_handler",
        ":libcuttlefish_webrtc_bluetooth_handler",
        ":libcuttlefish_webrtc_display_handler",
        ":libcuttlefish_webrtc_gpx_locations_handler",
        ":libcuttlefish_webrtc_kernel_log_events_handler",
        ":libcuttlefish_webrtc_kml_locations_handler",
        ":libcuttlefish_webrtc_location_handler",
        ":libcuttlefish_webrtc_sensors_handler",
        "//cuttlefish/common/libs/fs",
        "//cuttlefish/common/libs/utils:json",
        "//cuttlefish/host/frontend/webrtc/libdevice:camera_controller",
        "//cuttlefish/host/frontend/webrtc/libdevice:connection_observer",
        "//cuttlefish/host/frontend/webrtc/libdevice:lights_observer",
        "//cuttlefish/host/libs/config:config_utils",
        "//cuttlefish/host/libs/config:cuttlefish_config",
        "//cuttlefish/host/libs/confui:host_confui",
        "//cuttlefish/host/libs/input_connector",
        "//cuttlefish/host/libs/vm_manager",
        "//cuttlefish/result",
        "//libbase",
        "@abseil-cpp//absl/log",
        "@abseil-cpp//absl/log:check",
        "@abseil-cpp//absl/strings",
        "@fmt",
        "@fruit",
        "@gflags",
        "@jsoncpp",
    ],
)

cf_cc_library(
    name = "libcuttlefish_webrtc_cvd_video_frame_buffer",
    srcs = ["cvd_video_frame_buffer.cpp"],
    hdrs = ["cvd_video_frame_buffer.h"],
    clang_format_enabled = False,
    deps = [
        "//cuttlefish/common/libs/utils:size_utils",
        "//cuttlefish/host/libs/screen_connector:video_frame_buffer",
        "//libbase",
        "@abseil-cpp//absl/log",
        "@abseil-cpp//absl/log:check",
        "@abseil-cpp//absl/strings",
        "@fmt",
        "@fruit",
        "@jsoncpp",
    ],
)

cf_cc_library(
    name = "libcuttlefish_webrtc_display_handler",
    srcs = ["display_handler.cpp"],
    hdrs = ["display_handler.h"],
    deps = [
        ":libcuttlefish_webrtc_cvd_video_frame_buffer",
        ":libcuttlefish_webrtc_screenshot_handler",
        "//cuttlefish/host/frontend/webrtc/libdevice:streamer",
        "//cuttlefish/host/frontend/webrtc/libdevice:video_sink",
        "//cuttlefish/host/libs/screen_connector",
        "//cuttlefish/host/libs/screen_connector:video_frame_buffer",
        "//libbase",
        "@abseil-cpp//absl/log",
        "@abseil-cpp//absl/log:check",
        "@abseil-cpp//absl/strings",
        "@fmt",
        "@fruit",
        "@jsoncpp",
        "@libdrm//:libdrm_fourcc",
        "@libyuv",
    ],
)

cf_cc_library(
    name = "libcuttlefish_webrtc_gpx_locations_handler",
    srcs = ["gpx_locations_handler.cpp"],
    hdrs = ["gpx_locations_handler.h"],
    clang_format_enabled = False,
    deps = [
        "//cuttlefish/host/libs/config:cuttlefish_config",
        "//cuttlefish/host/libs/location",
        "//cuttlefish/result",
        "//libbase",
        "@abseil-cpp//absl/log",
        "@abseil-cpp//absl/log:check",
        "@abseil-cpp//absl/strings",
        "@fmt",
        "@fruit",
        "@grpc//:grpc++",
        "@jsoncpp",
    ],
)

cf_cc_library(
    name = "libcuttlefish_webrtc_kernel_log_events_handler",
    srcs = ["kernel_log_events_handler.cpp"],
    hdrs = ["kernel_log_events_handler.h"],
    clang_format_enabled = False,
    deps = [
        "//cuttlefish/common/libs/fs",
        "//cuttlefish/host/commands/kernel_log_monitor:kernel_log_monitor_utils",
        "//cuttlefish/host/libs/config:config_constants",
        "//cuttlefish/host/libs/config:cuttlefish_config",
        "//cuttlefish/result",
        "//libbase",
        "@abseil-cpp//absl/log",
        "@abseil-cpp//absl/log:check",
        "@abseil-cpp//absl/strings",
        "@fmt",
        "@fruit",
        "@jsoncpp",
    ],
)

cf_cc_library(
    name = "libcuttlefish_webrtc_kml_locations_handler",
    srcs = ["kml_locations_handler.cpp"],
    hdrs = ["kml_locations_handler.h"],
    clang_format_enabled = False,
    deps = [
        "//cuttlefish/host/libs/config:cuttlefish_config",
        "//cuttlefish/host/libs/location",
        "//libbase",
        "@abseil-cpp//absl/log",
        "@abseil-cpp//absl/log:check",
        "@abseil-cpp//absl/strings",
        "@fmt",
        "@fruit",
        "@grpc//:grpc++",
        "@jsoncpp",
    ],
)

cf_cc_library(
    name = "libcuttlefish_webrtc_location_handler",
    srcs = ["location_handler.cpp"],
    hdrs = ["location_handler.h"],
    clang_format_enabled = False,
    deps = [
        "//cuttlefish/host/libs/config:cuttlefish_config",
        "//cuttlefish/host/libs/location",
        "//cuttlefish/result",
        "//libbase",
        "@abseil-cpp//absl/log",
        "@abseil-cpp//absl/log:check",
        "@abseil-cpp//absl/strings",
        "@fmt",
        "@fruit",
        "@grpc//:grpc++",
        "@jsoncpp",
    ],
)

cf_cc_library(
    name = "libcuttlefish_webrtc_screenshot_handler",
    srcs = ["screenshot_handler.cpp"],
    hdrs = ["screenshot_handler.h"],
    deps = [
        "//cuttlefish/host/libs/screen_connector:video_frame_buffer",
        "//cuttlefish/posix:strerror",
        "//cuttlefish/result",
        "//libbase",
        "@abseil-cpp//absl/cleanup",
        "@abseil-cpp//absl/log",
        "@abseil-cpp//absl/log:check",
        "@abseil-cpp//absl/strings",
        "@fmt",
        "@fruit",
        "@jsoncpp",
        "@libjpeg_turbo//:jpeg",
        "@libpng",
        "@libyuv",
    ],
)

cf_cc_library(
    name = "libcuttlefish_webrtc_sensors_handler",
    srcs = ["sensors_handler.cpp"],
    hdrs = ["sensors_handler.h"],
    clang_format_enabled = False,
    deps = [
        "//cuttlefish/common/libs/sensors",
        "//cuttlefish/common/libs/transport",
        "//libbase",
        "@abseil-cpp//absl/log",
        "@abseil-cpp//absl/log:check",
        "@abseil-cpp//absl/strings",
        "@fmt",
        "@fruit",
        "@jsoncpp",
    ],
)

cf_cc_binary(
    name = "webRTC",
    srcs = [
        "main.cpp",
    ],
    deps = [
        ":libcuttlefish_webrtc_adb_handler",
        ":libcuttlefish_webrtc_audio_handler",
        ":libcuttlefish_webrtc_audio_mixer",
        ":libcuttlefish_webrtc_audio_settings",
        ":libcuttlefish_webrtc_bluetooth_handler",
        ":libcuttlefish_webrtc_client_server",
        ":libcuttlefish_webrtc_command_channel",
        ":libcuttlefish_webrtc_commands_proto",
        ":libcuttlefish_webrtc_connection_observer",
        ":libcuttlefish_webrtc_cvd_video_frame_buffer",
        ":libcuttlefish_webrtc_display_handler",
        ":libcuttlefish_webrtc_gpx_locations_handler",
        ":libcuttlefish_webrtc_kernel_log_events_handler",
        ":libcuttlefish_webrtc_kml_locations_handler",
        ":libcuttlefish_webrtc_location_handler",
        ":libcuttlefish_webrtc_screenshot_handler",
        ":libcuttlefish_webrtc_sensors_handler",
        "//cuttlefish/common/libs/fs",
        "//cuttlefish/common/libs/sensors",
        "//cuttlefish/common/libs/transport",
        "//cuttlefish/common/libs/utils:files",
        "//cuttlefish/common/libs/utils:json",
        "//cuttlefish/common/libs/utils:size_utils",
        "//cuttlefish/host/commands/assemble_cvd:guest_config_cc_proto",
        "//cuttlefish/host/commands/kernel_log_monitor:kernel_log_monitor_utils",
        "//cuttlefish/host/frontend/webrtc/libcommon:audio_source",
        "//cuttlefish/host/frontend/webrtc/libdevice:audio_sink",
        "//cuttlefish/host/frontend/webrtc/libdevice:camera_controller",
        "//cuttlefish/host/frontend/webrtc/libdevice:connection_observer",
        "//cuttlefish/host/frontend/webrtc/libdevice:lights_observer",
        "//cuttlefish/host/frontend/webrtc/libdevice:local_recorder",
        "//cuttlefish/host/frontend/webrtc/libdevice:streamer",
        "//cuttlefish/host/frontend/webrtc/libdevice:video_sink",
        "//cuttlefish/host/libs/audio_connector",
        "//cuttlefish/host/libs/config:config_constants",
        "//cuttlefish/host/libs/config:config_utils",
        "//cuttlefish/host/libs/config:cuttlefish_config",
        "//cuttlefish/host/libs/config:gpu_mode",
        "//cuttlefish/host/libs/config:logging",
        "//cuttlefish/host/libs/config:openwrt_args",
        "//cuttlefish/host/libs/confui:host_confui",
        "//cuttlefish/host/libs/input_connector",
        "//cuttlefish/host/libs/location",
        "//cuttlefish/host/libs/screen_connector",
        "//cuttlefish/host/libs/screen_connector:video_frame_buffer",
        "//cuttlefish/host/libs/vm_manager",
        "//cuttlefish/posix:strerror",
        "//cuttlefish/result",
        "//libbase",
        "@abseil-cpp//absl/cleanup",
        "@abseil-cpp//absl/log",
        "@abseil-cpp//absl/log:check",
        "@abseil-cpp//absl/strings",
        "@fmt",
        "@fruit",
        "@gflags",
        "@googleapis//google/rpc:code_cc_proto",
        "@googleapis//google/rpc:status_cc_proto",
        "@grpc//:grpc++",
        "@jsoncpp",
        "@libdrm//:libdrm_fourcc",
        "@libjpeg_turbo//:jpeg",
        "@libpng",
        "@libwebrtc",
        "@libwebsockets",
        "@libyuv",
        "@protobuf",
    ],
)
