// Copyright 2023 LiveKit, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

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

import "e2ee.proto";
import "handle.proto";
import "stats.proto";

// Create a new VideoTrack from a VideoSource
message CreateVideoTrackRequest {
  string name = 1;
  uint64 source_handle = 2;
}
message CreateVideoTrackResponse {
  OwnedTrack track = 1;
}

// Create a new AudioTrack from a AudioSource
message CreateAudioTrackRequest {
  string name = 1;
  uint64 source_handle = 2;
}
message CreateAudioTrackResponse {
  OwnedTrack track = 1;
}

message GetStatsRequest {
  uint64 track_handle = 1;
}
message GetStatsResponse {
  uint64 async_id = 1;
}
message GetStatsCallback {
  uint64 async_id = 1;
  optional string error = 2;
  repeated RtcStats stats = 3;
}

//
// Track
//

message TrackEvent {}

enum TrackKind {
  KIND_UNKNOWN = 0;
  KIND_AUDIO = 1;
  KIND_VIDEO = 2;
}

enum TrackSource {
  SOURCE_UNKNOWN = 0;
  SOURCE_CAMERA = 1;
  SOURCE_MICROPHONE = 2;
  SOURCE_SCREENSHARE = 3;
  SOURCE_SCREENSHARE_AUDIO = 4;
}

enum StreamState {
  STATE_UNKNOWN = 0;
  STATE_ACTIVE = 1;
  STATE_PAUSED = 2;
}

message TrackPublicationInfo {
  string sid = 1;
  string name = 2;
  TrackKind kind = 3;
  TrackSource source = 4;
  bool simulcasted = 5;
  uint32 width = 6;
  uint32 height = 7;
  string mime_type = 8;
  bool muted = 9;
  bool remote = 10;
  EncryptionType encryption_type = 11;
}

message OwnedTrackPublication {
  FfiOwnedHandle handle = 1;
  TrackPublicationInfo info = 2;
}

message TrackInfo {
  string sid = 1;
  string name = 2;
  TrackKind kind = 3;
  StreamState stream_state = 4;
  bool muted = 5;
  bool remote = 6;
}

message OwnedTrack {
  FfiOwnedHandle handle = 1;
  TrackInfo info = 2;
}

// Mute/UnMute a track
message LocalTrackMuteRequest {
  uint64 track_handle = 1;
  bool mute = 2;
}

message LocalTrackMuteResponse {
  bool muted = 1;
}

// Enable/Disable a remote track
message EnableRemoteTrackRequest {
  uint64 track_handle = 1;
  bool enabled = 2;
}

message EnableRemoteTrackResponse {
  bool enabled = 1;
}
