syntax = "proto3";

import "cmvr/api/common.proto";

package cmvr.api;

message FrameData {
    enum FrameType {
        U8C1 = 0;
        U16C1 = 1;
        U8C3 = 2;
        U16C3 = 3;
        F16C1 = 4;
        F32C1 = 5;
    }
    bytes data = 1;
    int32 width = 2;
    int32 height = 3;
    FrameType type = 4;
    string codec = 5;
    bool is_key_frame = 6;
}

message CameraIntrinsics {
  float cx = 1;                           // 主点水平坐标（从左边缘的像素偏移）
  float cy = 2;                           // 主点垂直坐标（从上边缘的像素偏移）
  float fx = 3;                            // x方向焦距（像素宽度的倍数）
  float fy = 4;                            // y方向焦距（像素高度的倍数）
  repeated float coeffs = 5 [packed = true]; // 畸变系数（固定5个元素）
}

message CameraState {
    bool is_initialized = 1;
    bool is_opened = 2;
    bool is_streaming = 3;
    bool is_recording = 4;
    bool is_error = 5;
    string error_message = 6;
    int32 fps = 7;
    int32 width = 8;
    int32 height = 9;
}

message GetCameraStateCommand {
    message Request {
        CommandHeader.Request header = 1;
    }
    message Feedback {
        CommandHeader.Feedback header = 1;
        CameraState state = 2;
    }
}

message StartCameraCommand {
    message Request {
        CommandHeader.Request header = 1;
    }

    message Feedback {
        CommandHeader.Feedback header = 1;
    }
}

message StopCameraCommand {
    message Request {
        CommandHeader.Request header = 1;
    }

    message Feedback {
        CommandHeader.Feedback header = 1;
    }
}

message GetRGBImageCommand {
    message Request {
        CommandHeader.Request header = 1;
    }

    message Feedback {
        CommandHeader.Feedback header = 1;
        FrameData color_frame = 2;
        CameraIntrinsics intrinsics = 3;
    }
}

message GetDepthImageCommand {
    message Request {
        CommandHeader.Request header = 1;
    }

    message Feedback {
        CommandHeader.Feedback header = 1;
        FrameData depth_frame = 2;
        CameraIntrinsics intrinsics = 3;
    }
}

message GetRGBDImagesCommand {
    message Request {
        CommandHeader.Request header = 1;
    }

    message Feedback {
        CommandHeader.Feedback header = 1;
        FrameData color_frame = 2;
        FrameData depth_frame = 3;
        CameraIntrinsics intrinsics = 4;
    }
}

message StartCameraRecordingCommand {
    message Request {
        CommandHeader.Request header = 1;
        string video_path = 2;
    }
    message Feedback {
        CommandHeader.Feedback header = 1;
    }
}

message StopCameraRecordingCommand {
    message Request {
        CommandHeader.Request header = 1;
    }

    message Feedback {
        CommandHeader.Feedback header = 1;
    }
}

message GetRGBImageStreamCommand {
    message Request {
        CommandHeader.Request header = 1;
        bool eof = 2;
    }

    message Feedback {
        CommandHeader.Feedback header = 1;
        FrameData color_frame = 2;
        CameraIntrinsics intrinsics = 3;
        int32 seq_no = 4;
    }
}

message GetDepthImageStreamCommand {
    message Request {
        CommandHeader.Request header = 1;
        bool eof = 2;
    }

    message Feedback {
        CommandHeader.Feedback header = 1;
        FrameData depth_frame = 2;
        CameraIntrinsics intrinsics = 3;
        int32 seq_no = 4;
    }
}

message GetRGBDImagesStreamCommand {
    message Request {
        CommandHeader.Request header = 1;
        bool eof = 2;
    }

    message Feedback {
        CommandHeader.Feedback header = 1;
        FrameData color_frame = 2;
        FrameData depth_frame = 3;
        CameraIntrinsics intrinsics = 4;
        int32 seq_no = 5;
    }
}



