syntax = "proto3";

package rv.data;

option cc_enable_arenas = true;
option csharp_namespace = "Pro.SerializationInterop.RVProtoData";
option swift_prefix = "RVData_";

import "applicationInfo.proto";
import "messages.proto";
import "proApiV1.proto";
import "timers.proto";
import "rvtimestamp.proto";
import "uuid.proto";

message ProApiIn {
  oneof MessageType {
    .rv.data.ProLink.HandlerIn handler_in = 1;
    .rv.data.NetworkAPI network_api = 2;
    .rv.data.NetworkAPI_v1 network_api_v1 = 3;
  }
}

message ProApiOut {
  oneof MessageType {
    .rv.data.ProLink.HandlerOut handler_out = 1;
    .rv.data.ProLink.ClientAction client_action = 2;
    .rv.data.NetworkAPI network_api = 3;
    .rv.data.NetworkAPI_v1 network_api_v1 = 4;
  }
}

message ProApiNetworkConfiguration {
  bool enable_network = 1;
  uint32 port = 2;
  string network_name = 3;
  bool remote_enable = 4;
  bool remote_control_enable = 5;
  string remote_control_password = 6;
  bool remote_observe_enable = 7;
  string remote_observe_password = 8;
  bool stage_enable = 9;
  string stage_password = 10;
  bool link_enable = 11;
  string web_resource_root = 12;
  uint32 tcp_stream_port = 13;
  bool tcp_stream_enable = 14;
}

message ProLink {
  message GroupDefinition {
    message Member {
      string ip = 1;
      uint32 port = 2;
    }

    .rv.data.Timestamp timestamp = 1;
    string secret = 2;
    string name = 3;
    repeated .rv.data.ProLink.GroupDefinition.Member members = 4;
    .rv.data.UUID group_identifier = 5;
  }

  message ZeroConfig {
    message NetworkEnvironment {
      repeated .rv.data.ProLink.GroupDefinition available_groups = 1;
      repeated .rv.data.ProLink.MemberStatus available_devices = 2;
    }

    message MulticastPacket {
      .rv.data.ProLink.GroupDefinition group = 1;
      .rv.data.ProLink.MemberStatus device = 2;
    }

  }

  message TowerMessage {
    message TowerStatusRequest {
    }

    message TowerStatusResponse {
      string member_name = 2;
      oneof Response {
        .rv.data.ProLink.GroupDefinition group_definition = 1;
      }
    }

    message TowerAddMemberRequest {
      oneof Request {
        .rv.data.ProLink.GroupDefinition group_definition = 1;
        .rv.data.ProLink.GroupDefinition.Member joining_member = 2;
      }
    }

    message TowerRemoveMemberRequest {
      .rv.data.ProLink.GroupDefinition.Member removing_member = 1;
    }

    message TowerAddMemberResponse {
      message Accept {
      }

      enum DeclineReason {
        ALREADY_IN_GROUP = 0;
        USER_DECLINED = 1;
      }

      oneof Response {
        .rv.data.ProLink.GroupDefinition group_definition = 1;
        .rv.data.ProLink.TowerMessage.TowerAddMemberResponse.Accept accept = 2;
        .rv.data.ProLink.TowerMessage.TowerAddMemberResponse.DeclineReason decline_reason = 3;
      }
    }

    message TowerHeartbeatRequest {
    }

    message TowerHeartbeatResponse {
      .rv.data.ProLink.GroupDefinition group_definition = 1;
    }

  }

  message MemberStatus {
    enum ConnectionStatus {
      CONNECTION_STATUS_UNKNOWN = 0;
      CONNECTION_STATUS_CONNECTED = 1;
      CONNECTION_STATUS_DISCONNECTED = 2;
    }

    string ip = 1;
    uint32 port = 2;
    string name = 3;
    .rv.data.ApplicationInfo.Platform platform = 4;
    string os_version = 5;
    string host_description = 6;
    string api_version = 7;
    .rv.data.ProLink.MemberStatus.ConnectionStatus connection_status = 8;
  }

  message ClientAction {
    message AddConnection {
      string ip = 1;
      uint32 port = 2;
      string group_name = 3;
    }

    message RemoveConnection {
      string ip = 1;
      uint32 port = 2;
    }

    message CancelAction {
    }

    message RenderTime {
      uint64 latency = 1;
      uint64 render_time = 2;
    }

    oneof ActionType {
      .rv.data.ProLink.ClientAction.AddConnection add_connection = 1;
      .rv.data.ProLink.ClientAction.RemoveConnection remove_connection = 2;
      .rv.data.ProLink.ClientAction.CancelAction cancel_action = 3;
      .rv.data.ProLink.ClientAction.RenderTime render_time = 4;
    }
  }

  message HandlerIn {
    message GroupName {
    }

    message GroupDefinitionRequest {
    }

    message GroupJoinConfirmation {
      string name = 1;
    }

    message GroupJoinPassword {
      string name = 1;
    }

    message AddConnectionResult {
      message Success {
        .rv.data.ProLink.GroupDefinition new_group_definition = 1;
      }

      message Failure {
        message Unexpected {
        }

        message Declined {
        }

        message Timeout {
        }

        message LinkDisabled {
        }

        message InOtherGroup {
          string member_name = 1;
          string group_name = 2;
        }

        message InvalidIpAddress {
        }

        message AlreadyInGroup {
          string member_name = 1;
          string group_name = 2;
        }

        message CouldNotAdd {
          string member_name = 1;
        }

        message CouldNotJoin {
          string group_name = 1;
        }

        oneof Reason {
          .rv.data.ProLink.HandlerIn.AddConnectionResult.Failure.Unexpected unexpected = 1;
          .rv.data.ProLink.HandlerIn.AddConnectionResult.Failure.Declined declined = 2;
          .rv.data.ProLink.HandlerIn.AddConnectionResult.Failure.Timeout timeout = 3;
          .rv.data.ProLink.HandlerIn.AddConnectionResult.Failure.LinkDisabled link_disabled = 4;
          .rv.data.ProLink.HandlerIn.AddConnectionResult.Failure.InOtherGroup in_other_group = 5;
          .rv.data.ProLink.HandlerIn.AddConnectionResult.Failure.InvalidIpAddress invalid_ip_address = 6;
          .rv.data.ProLink.HandlerIn.AddConnectionResult.Failure.AlreadyInGroup already_in_group = 7;
          .rv.data.ProLink.HandlerIn.AddConnectionResult.Failure.CouldNotAdd could_not_add = 8;
          .rv.data.ProLink.HandlerIn.AddConnectionResult.Failure.CouldNotJoin could_not_join = 9;
        }
      }

      oneof Result {
        .rv.data.ProLink.HandlerIn.AddConnectionResult.Success success = 1;
        .rv.data.ProLink.HandlerIn.AddConnectionResult.Failure failure = 2;
      }
    }

    message MemberStatusChange {
      repeated .rv.data.ProLink.MemberStatus members = 1;
    }

    message ProPresenterInfo {
    }

    message ServerState {
      string local_ip = 1;
      string public_ip = 2;
      uint32 port = 3;
      bool success = 4;
      uint32 tcp_stream_port = 5;
      bool tcp_stream_success = 6;
    }

    message ConfigurationRequest {
    }

    message LogRequest {
      enum Severity {
        SEVERITY_DEBUG = 0;
        SEVERITY_DEBUG_WARNING = 1;
        SEVERITY_INFO = 2;
        SEVERITY_WARNING = 3;
        SEVERITY_ERROR = 4;
        SEVERITY_FATAL_ERROR = 5;
      }

      .rv.data.ProLink.HandlerIn.LogRequest.Severity severity = 1;
      string message = 2;
    }

    oneof Request {
      .rv.data.ProLink.HandlerIn.GroupName group_name = 1;
      .rv.data.ProLink.HandlerIn.GroupDefinitionRequest group_definition_request = 2;
      .rv.data.ProLink.HandlerIn.GroupJoinConfirmation group_join_confirmation = 3;
      .rv.data.ProLink.HandlerIn.GroupJoinPassword group_join_password = 4;
      .rv.data.ProLink.HandlerIn.AddConnectionResult add_connection_result = 5;
      .rv.data.ProLink.GroupDefinition group_update = 6;
      .rv.data.ProLink.HandlerIn.MemberStatusChange member_status_change = 7;
      .rv.data.ProLink.HandlerIn.ProPresenterInfo propresenter_info = 8;
      .rv.data.ProLink.HandlerIn.ServerState server_state = 9;
      .rv.data.ProLink.HandlerIn.ConfigurationRequest configuration_request = 10;
      .rv.data.ProLink.ZeroConfig.NetworkEnvironment zeroconfig_network_environment_change = 11;
      .rv.data.ProLink.HandlerIn.LogRequest log_request = 12;
    }
  }

  message HandlerOut {
    message GroupName {
      string name = 1;
    }

    message GroupJoinConfirmation {
      bool accept = 1;
    }

    message GroupJoinPassword {
      string password = 1;
    }

    message ProPresenterInfo {
      .rv.data.ApplicationInfo.Platform platform = 1;
      string os_version = 2;
      string host_description = 3;
    }

    oneof Response {
      .rv.data.ProLink.HandlerOut.GroupName group_name = 1;
      .rv.data.ProLink.GroupDefinition group_definition = 2;
      .rv.data.ProLink.HandlerOut.GroupJoinConfirmation group_join_confirmation = 3;
      .rv.data.ProLink.HandlerOut.GroupJoinPassword group_join_password = 4;
      .rv.data.ProLink.HandlerOut.ProPresenterInfo propresenter_info = 5;
      .rv.data.ProApiNetworkConfiguration configuration = 6;
    }
  }

}

message NetworkAPI {
  message LinkStatus {
    .rv.data.ApplicationInfo.Platform platform = 1;
    string os_version = 2;
    string version = 3;
    string description = 4;
    .rv.data.NetworkAPI.Group group_info = 5;
  }

  message Group {
    message Member {
      string ip_address = 1;
      int32 port = 2;
    }

    string name = 1;
    repeated .rv.data.NetworkAPI.Group.Member members = 2;
  }

  message GroupChange {
    oneof Change {
      .rv.data.NetworkAPI.GroupInvite invite = 1;
      .rv.data.NetworkAPI.GroupJoin join = 2;
      .rv.data.NetworkAPI.GroupKick kick = 3;
      .rv.data.NetworkAPI.GroupStatus status = 4;
    }
  }

  message GroupResponse {
    message Success {
    }

    message Status {
      string member_name = 1;
      string group_name = 2;
    }

    oneof Response {
      .rv.data.NetworkAPI.GroupResponse.Success success = 1;
      .rv.data.NetworkAPI.GroupResponse.Status status = 2;
    }
  }

  message GroupStatus {
    .rv.data.NetworkAPI.Group.Member member = 1;
  }

  message GroupInvite {
    .rv.data.NetworkAPI.Group group_info = 1;
    string secret = 2;
    .rv.data.NetworkAPI.Group.Member prospect = 3;
  }

  message GroupJoin {
    .rv.data.NetworkAPI.Group.Member sponsor = 1;
    .rv.data.NetworkAPI.Group.Member prospect = 2;
  }

  message GroupKick {
    .rv.data.NetworkAPI.Group.Member member = 1;
  }

  message ServerState {
    string local_ip = 1;
    string public_ip = 2;
    int32 port = 3;
  }

  message Action {
    message API_Clear {
      enum Layer {
        LAYER_UNKNOWN = 0;
        LAYER_VIDEO_INPUT = 1;
        LAYER_MEDIA = 2;
        LAYER_PRESENTATION = 3;
        LAYER_ANNOUNCEMENT = 4;
        LAYER_PROP = 5;
        LAYER_MESSAGE = 6;
        LAYER_AUDIO = 7;
      }

      oneof ClearInfo {
        .rv.data.NetworkAPI.Action.API_Clear.Layer layer = 1;
        .rv.data.NetworkAPI.IndexOrNameIdentifier group_identifier = 2;
      }
    }

    message API_TwoStepTrigger {
      enum Operation {
        OPERATION_PREROLL = 0;
        OPERATION_ACTIVATE = 1;
      }

      uint64 id = 1;
      .rv.data.NetworkAPI.Action.API_TwoStepTrigger.Operation operation = 2;
      uint64 render_time = 3;
      oneof TriggerData {
        .rv.data.NetworkAPI.Action.API_Trigger.Presentation presentation = 4;
        .rv.data.NetworkAPI.Action.API_Trigger.Media media = 5;
        .rv.data.NetworkAPI.Action.API_Trigger.VideoInput video_input = 6;
        .rv.data.NetworkAPI.Action.API_Trigger.Audio audio = 7;
        .rv.data.NetworkAPI.Action.API_Prop.TriggerProp prop = 8;
        .rv.data.NetworkAPI.Action.API_Message.TriggerMessage message = 9;
      }
    }

    message API_PrerollComplete {
      uint64 id = 1;
      bool failed = 2;
      uint64 latency = 3;
    }

    message API_Trigger {
      message Presentation {
        reserved 1;
        message PlaylistPresentation {
          repeated .rv.data.NetworkAPI.IndexOrNameIdentifier index_path_components = 1;
        }

        message LibraryPresentation {
          .rv.data.NetworkAPI.IndexOrNameIdentifier library_component = 1;
          .rv.data.NetworkAPI.IndexOrNameIdentifier presentation_component = 2;
          .rv.data.NetworkAPI.IndexOrNameIdentifier cue_component = 3;
        }

        oneof PresentationSource {
          .rv.data.NetworkAPI.Action.API_Trigger.Presentation.PlaylistPresentation playlist_index_path = 2;
          .rv.data.NetworkAPI.Action.API_Trigger.Presentation.LibraryPresentation library_index_path = 3;
        }
      }

      message Media {
        repeated .rv.data.NetworkAPI.IndexOrNameIdentifier index_path_components = 1;
      }

      message VideoInput {
        .rv.data.NetworkAPI.IndexOrNameIdentifier video_input_id = 1;
      }

      message Audio {
        repeated .rv.data.NetworkAPI.IndexOrNameIdentifier index_path_components = 1;
      }

      oneof TriggerData {
        .rv.data.NetworkAPI.Action.API_Trigger.Presentation presentation = 1;
        .rv.data.NetworkAPI.Action.API_Trigger.Media media = 2;
        .rv.data.NetworkAPI.Action.API_Trigger.VideoInput video_input = 3;
        .rv.data.NetworkAPI.Action.API_Trigger.Audio audio = 4;
      }
    }

    message API_Transport {
      message Play {
      }

      message Pause {
      }

      message SkipBackward {
        int32 seconds = 1;
      }

      message SkipForward {
        int32 seconds = 1;
      }

      message GoToEnd {
        int32 seconds_to_end = 1;
      }

      enum TransportLayer {
        TRANSPORT_LAYER_UNKNOWN = 0;
        TRANSPORT_LAYER_PRESENTATION = 1;
        TRANSPORT_LAYER_ANNOUNCEMENT = 2;
        TRANSPORT_LAYER_AUDIO = 3;
      }

      .rv.data.NetworkAPI.Action.API_Transport.TransportLayer layer = 1;
      oneof TransportAction {
        .rv.data.NetworkAPI.Action.API_Transport.Play play = 2;
        .rv.data.NetworkAPI.Action.API_Transport.Pause pause = 3;
        .rv.data.NetworkAPI.Action.API_Transport.SkipBackward skip_backward = 4;
        .rv.data.NetworkAPI.Action.API_Transport.SkipForward skip_forward = 5;
        .rv.data.NetworkAPI.Action.API_Transport.GoToEnd go_to_end = 6;
      }
    }

    message API_Prop {
      message TriggerProp {
        .rv.data.NetworkAPI.IndexOrNameIdentifier identifier = 1;
      }

      message ClearProp {
        .rv.data.NetworkAPI.IndexOrNameIdentifier identifier = 1;
      }

      oneof PropAction {
        .rv.data.NetworkAPI.Action.API_Prop.TriggerProp trigger = 1;
        .rv.data.NetworkAPI.Action.API_Prop.ClearProp clear = 2;
      }
    }

    message API_Timer {
      message StartTimer {
        .rv.data.NetworkAPI.IndexOrNameIdentifier identifier = 1;
      }

      message StopTimer {
        .rv.data.NetworkAPI.IndexOrNameIdentifier identifier = 1;
      }

      message ResetTimer {
        .rv.data.NetworkAPI.IndexOrNameIdentifier identifier = 1;
      }

      message ConfigureTimer {
        .rv.data.NetworkAPI.IndexOrNameIdentifier identifier = 1;
        .rv.data.Timer.Configuration configuration = 2;
      }

      oneof TimerAction {
        .rv.data.NetworkAPI.Action.API_Timer.StartTimer start = 1;
        .rv.data.NetworkAPI.Action.API_Timer.StopTimer stop = 2;
        .rv.data.NetworkAPI.Action.API_Timer.ResetTimer reset = 3;
        .rv.data.NetworkAPI.Action.API_Timer.ConfigureTimer configure = 4;
      }
    }

    message API_Message {
      message TriggerMessage {
        .rv.data.NetworkAPI.IndexOrNameIdentifier identifier = 1;
        repeated .rv.data.Message.TokenValue token_values = 2;
      }

      message ClearMessage {
        .rv.data.NetworkAPI.IndexOrNameIdentifier identifier = 1;
      }

      oneof MessageAction {
        .rv.data.NetworkAPI.Action.API_Message.TriggerMessage trigger = 1;
        .rv.data.NetworkAPI.Action.API_Message.ClearMessage clear = 2;
      }
    }

    message API_Macro {
      .rv.data.NetworkAPI.IndexOrNameIdentifier identifier = 1;
      repeated .rv.data.NetworkAPI.IndexOrNameIdentifier index_path_components = 2;
    }

    message API_Look {
      .rv.data.NetworkAPI.IndexOrNameIdentifier identifier = 1;
    }

    message API_Stage {
      message StageLayouts {
        repeated .rv.data.NetworkAPI.IndexOrNameIdentifierPair layouts = 1;
      }

      message StageMessage {
        message ShowMessage {
          string message = 1;
        }

        message ClearMessage {
        }

        message HideMessage {
        }

        oneof Action {
          .rv.data.NetworkAPI.Action.API_Stage.StageMessage.ShowMessage show_message = 1;
          .rv.data.NetworkAPI.Action.API_Stage.StageMessage.ClearMessage clear_message = 2;
          .rv.data.NetworkAPI.Action.API_Stage.StageMessage.HideMessage hide_message = 3;
        }
      }

      oneof StageAction {
        .rv.data.NetworkAPI.Action.API_Stage.StageLayouts layouts = 1;
        .rv.data.NetworkAPI.Action.API_Stage.StageMessage message = 2;
      }
    }

    message StatusRequest {
    }

    message API_Status {
    }

    message API_StatusResponse {
      .rv.data.ProLink.GroupDefinition group_definition = 1;
      .rv.data.ProLink.MemberStatus status = 2;
    }

    oneof Command {
      .rv.data.NetworkAPI.Action.API_Clear clear = 1;
      .rv.data.NetworkAPI.Action.API_Trigger trigger = 2;
      .rv.data.NetworkAPI.Action.API_Transport transport = 3;
      .rv.data.NetworkAPI.Action.API_Prop prop = 4;
      .rv.data.NetworkAPI.Action.API_Timer timer = 5;
      .rv.data.NetworkAPI.Action.API_Message message_ = 6;
      .rv.data.NetworkAPI.Action.API_Macro macro = 7;
      .rv.data.NetworkAPI.Action.API_Look look = 8;
      .rv.data.NetworkAPI.Action.API_Stage stage = 9;
      .rv.data.NetworkAPI.Action.API_Status status = 10;
      .rv.data.NetworkAPI.Action.API_StatusResponse status_response = 11;
      .rv.data.NetworkAPI.Action.API_TwoStepTrigger two_step_trigger = 12;
      .rv.data.NetworkAPI.Action.API_PrerollComplete preroll_complete = 13;
    }
  }

  message IndexOrNameIdentifier {
    oneof Component {
      int32 index = 1;
      string name = 2;
    }
  }

  message IndexOrNameIdentifierPair {
    .rv.data.NetworkAPI.IndexOrNameIdentifier key = 1;
    .rv.data.NetworkAPI.IndexOrNameIdentifier value = 2;
  }

  oneof Command {
    .rv.data.NetworkAPI.Action action = 1;
    .rv.data.NetworkAPI.ServerState server_state = 2;
    .rv.data.NetworkAPI.GroupChange group_change = 5;
    .rv.data.NetworkAPI.GroupResponse group_response = 6;
  }
}

