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;

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

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

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

/// 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;

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

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

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

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;
    DisposeCallback dispose = 7;
    PublishTrackCallback publish_track = 8;
  }
}

// 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).

