syntax = "proto3";

package livekit;
option csharp_namespace = "LiveKit.Proto";

import "handle.proto";
import "track.proto";
import "room.proto";
import "participant.proto";
import "video_frame.proto";
import "audio_frame.proto";

/// This is the input of livekit_ffi_request function
/// We always expect a response (FFIResponse)
message FfiRequest {
  oneof message {
    InitializeRequest initialize = 1;
    DisposeRequest dispose = 2;

    // Room
    ConnectRequest connect = 3;
    DisconnectRequest disconnect = 4;
    PublishTrackRequest publish_track = 5;
    UnpublishTrackRequest unpublish_track = 6;
    PublishDataRequest publish_data = 7;

    // Track
    CreateVideoTrackRequest create_video_track = 8;
    CreateAudioTrackRequest create_audio_track = 9;

    // Video
    AllocVideoBufferRequest alloc_video_buffer = 10;
    NewVideoStreamRequest new_video_stream = 11;
    NewVideoSourceRequest new_video_source = 12;
    CaptureVideoFrameRequest capture_video_frame = 13;
    ToI420Request to_i420 = 14;
    ToArgbRequest to_argb = 15;

    // Audio
    AllocAudioBufferRequest alloc_audio_buffer = 16;
    NewAudioStreamRequest new_audio_stream = 17;
    NewAudioSourceRequest new_audio_source = 18;
    CaptureAudioFrameRequest capture_audio_frame = 19;
    NewAudioResamplerRequest new_audio_resampler = 20;
    RemixAndResampleRequest remix_and_resample = 21;
  }
}

/// This is the output of livekit_ffi_request function.
message FfiResponse {
  oneof message {
    InitializeResponse initialize = 1;
    DisposeResponse dispose = 2;

    // Room
    ConnectResponse connect = 3;
    DisconnectResponse disconnect = 4;
    PublishTrackResponse publish_track = 5;
    UnpublishTrackResponse unpublish_track = 6;
    PublishDataResponse publish_data = 7;

    // Track
    CreateVideoTrackResponse create_video_track = 8;
    CreateAudioTrackResponse create_audio_track = 9;

    // Video
    AllocVideoBufferResponse alloc_video_buffer = 10;
    NewVideoStreamResponse new_video_stream = 11;
    NewVideoSourceResponse new_video_source = 12;
    CaptureVideoFrameResponse capture_video_frame = 13;
    ToI420Response to_i420 = 14;
    ToArgbResponse to_argb = 15;

    // Audio
    AllocAudioBufferResponse alloc_audio_buffer = 16;
    NewAudioStreamResponse new_audio_stream = 17;
    NewAudioSourceResponse new_audio_source = 18;
    CaptureAudioFrameResponse capture_audio_frame = 19;
    NewAudioResamplerResponse new_audio_resampler = 20;
    RemixAndResampleResponse remix_and_resample = 21;
  }
}

message FfiEvent {
  oneof message {
    RoomEvent room_event = 1;
    TrackEvent track_event = 2;
    ParticipantEvent participant_event = 3;
    VideoStreamEvent video_stream_event = 4;
    AudioStreamEvent audio_stream_event = 5;
    ConnectCallback connect = 6;
    DisconnectCallback disconnect = 7;
    DisposeCallback dispose = 8;
    PublishTrackCallback publish_track = 9;
    PublishDataCallback publish_data = 10;
  }
}

// Setup the callback where the foreign language can receive events
// and responses to asynchronous requests
message InitializeRequest { uint64 event_callback_ptr = 1; }
message InitializeResponse {}

// Stop all rooms synchronously (Do we need async here?).
// e.g: This is used for the Unity Editor after each assemblies reload.
message DisposeRequest {
  bool async = 1;
}

message DisposeResponse {
  optional FfiAsyncId async_id = 1; // None if sync
}

message DisposeCallback {
  FfiAsyncId async_id = 1;
}

// TODO(theomonnom): Debug messages (Print handles, forward logs).

