include!("relay_service/media_v2.rs");

#[cfg(not(coverage))]
include!("relay_service/input_stream_rpc.rs");
#[cfg(not(coverage))]
include!("relay_service/upstream_media_rpc.rs");
#[cfg(not(coverage))]
include!("relay_service/output_delay_probe_rpc.rs");
#[cfg(not(coverage))]
include!("relay_service/microphone_stream_rpc.rs");
#[cfg(not(coverage))]
include!("relay_service/camera_stream_rpc.rs");
#[cfg(not(coverage))]
include!("relay_service/state_control_rpc.rs");

#[cfg(not(coverage))]
#[tonic::async_trait]
impl Relay for Handler {
    type StreamKeyboardStream = ReceiverStream<Result<KeyboardReport, Status>>;
    type StreamMouseStream = ReceiverStream<Result<MouseReport, Status>>;
    type CaptureVideoStream = VideoStream;
    type CaptureAudioStream = AudioStream;
    type StreamMicrophoneStream = ReceiverStream<Result<Empty, Status>>;
    type StreamCameraStream = ReceiverStream<Result<Empty, Status>>;
    type StreamWebcamMediaStream = ReceiverStream<Result<Empty, Status>>;
    type RunOutputDelayProbeStream = ReceiverStream<Result<OutputDelayProbeReply, Status>>;

    async fn stream_keyboard(
        &self,
        req: Request<tonic::Streaming<KeyboardReport>>,
    ) -> Result<Response<Self::StreamKeyboardStream>, Status> {
        self.stream_keyboard_rpc(req).await
    }

    async fn stream_mouse(
        &self,
        req: Request<tonic::Streaming<MouseReport>>,
    ) -> Result<Response<Self::StreamMouseStream>, Status> {
        self.stream_mouse_rpc(req).await
    }

    async fn stream_webcam_media(
        &self,
        req: Request<tonic::Streaming<UpstreamMediaBundle>>,
    ) -> Result<Response<Self::StreamWebcamMediaStream>, Status> {
        self.stream_webcam_media_rpc(req).await
    }

    async fn run_output_delay_probe(
        &self,
        req: Request<OutputDelayProbeRequest>,
    ) -> Result<Response<Self::RunOutputDelayProbeStream>, Status> {
        self.run_output_delay_probe_rpc(req).await
    }

    async fn stream_microphone(
        &self,
        req: Request<tonic::Streaming<AudioPacket>>,
    ) -> Result<Response<Self::StreamMicrophoneStream>, Status> {
        self.stream_microphone_rpc(req).await
    }

    async fn stream_camera(
        &self,
        req: Request<tonic::Streaming<VideoPacket>>,
    ) -> Result<Response<Self::StreamCameraStream>, Status> {
        self.stream_camera_rpc(req).await
    }

    async fn capture_video(
        &self,
        req: Request<MonitorRequest>,
    ) -> Result<Response<Self::CaptureVideoStream>, Status> {
        self.capture_video_rpc(req).await
    }

    async fn capture_audio(
        &self,
        req: Request<MonitorRequest>,
    ) -> Result<Response<Self::CaptureAudioStream>, Status> {
        self.capture_audio_rpc(req).await
    }

    async fn paste_text(&self, req: Request<PasteRequest>) -> Result<Response<PasteReply>, Status> {
        self.paste_text_rpc(req).await
    }

    async fn recover_usb(&self, req: Request<Empty>) -> ResetReply {
        self.recover_usb_rpc(req).await
    }

    async fn recover_uac(&self, req: Request<Empty>) -> ResetReply {
        self.recover_uac_rpc(req).await
    }

    async fn recover_uvc(&self, req: Request<Empty>) -> ResetReply {
        self.recover_uvc_rpc(req).await
    }

    async fn reset_usb(&self, req: Request<Empty>) -> ResetReply {
        self.reset_usb_rpc(req).await
    }

    async fn get_capture_power(
        &self,
        req: Request<Empty>,
    ) -> Result<Response<CapturePowerState>, Status> {
        self.get_capture_power_rpc(req).await
    }

    async fn set_capture_power(
        &self,
        req: Request<SetCapturePowerRequest>,
    ) -> Result<Response<CapturePowerState>, Status> {
        self.set_capture_power_rpc(req).await
    }

    async fn get_calibration(
        &self,
        req: Request<Empty>,
    ) -> Result<Response<CalibrationState>, Status> {
        self.get_calibration_rpc(req).await
    }

    async fn calibrate(
        &self,
        req: Request<CalibrationRequest>,
    ) -> Result<Response<CalibrationState>, Status> {
        self.calibrate_rpc(req).await
    }

    async fn get_upstream_sync(
        &self,
        req: Request<Empty>,
    ) -> Result<Response<UpstreamSyncState>, Status> {
        self.get_upstream_sync_rpc(req).await
    }
}

#[cfg(test)]
include!("relay_service_tests.rs");
