blob: 974832d33d0c78757d45678bded6e79ed69869b2 [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <fuchsia/camera3/cpp/fidl.h>
#include <fuchsia/factory/camera/cpp/fidl.h>
#include <lib/async-loop/cpp/loop.h>
#include <lib/async-loop/default.h>
#include <lib/fidl/cpp/binding.h>
#include "src/camera/bin/factory/streamer.h"
#include "src/camera/bin/factory/web_ui.h"
namespace camera {
// The server-side implementation for the factory API. It maintains connections to scenic,
// camera3 and other services via other classes as needed.
// More specifically, it acts as a stream client and serves as the middle layer between calls
// from the factory host and several layers in the camera stack.
class FactoryServer : public fuchsia::factory::camera::Controller, WebUIControl {
// Factory method that creates a FactoryServer and connects it to the Camera Manager and ISP
// driver.
// Returns:
// A FactoryServer object which provides an interface to the factory API.
static fpromise::result<std::unique_ptr<FactoryServer>, zx_status_t> Create(
fuchsia::sysmem::AllocatorHandle allocator, fuchsia::camera3::DeviceWatcherHandle watcher,
fit::closure stop_callback = nullptr);
// Returns the class request handler.
fidl::InterfaceRequestHandler<fuchsia::factory::camera::Controller> GetHandler();
void Capture();
// Requests a new camera-factory Controller.
void OnNewRequest(fidl::InterfaceRequest<fuchsia::factory::camera::Controller> request);
// ||
void IsIspBypassModeEnabled(bool enabled) override;
void CaptureFrames(std::string dir_path, CaptureFramesCallback cb) override;
void DisplayToScreen(uint32_t stream_index, DisplayToScreenCallback cb) override {}
// |WebUIControl|
void RequestCaptureData(uint32_t stream_index, CaptureResponse callback) override;
async::Loop loop_;
fit::closure stop_callback_;
fidl::Binding<fuchsia::factory::camera::Controller> controller_binding_;
std::unique_ptr<Streamer> streamer_;
std::unique_ptr<WebUI> webui_;
bool bypass_ = false;
} // namespace camera