// Copyright 2021 Google LLC
//
// 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 cast.v2;

import "proto/common/application_state.proto";
import "proto/v2/url_rewrite.proto";

option optimize_for = LITE_RUNTIME;

// Cast application Service
//
// This service is implemented by the Runtime and represents services
// specific to a Cast application.
service RuntimeApplicationService {
  // Sets the URL rewrite rules that the Runtime will use to contact the MSP
  // This is called when the rewrite rules are changed
  // A non streaming API for simplicity
  rpc SetUrlRewriteRules(SetUrlRewriteRulesRequest)
      returns (SetUrlRewriteRulesResponse);

  // Sets application media state. Runtime must support this API if application
  // preloading is supported.
  rpc SetMediaState(SetMediaStateRequest) returns (SetMediaStateResponse);

  // Sets application visibility. Runtime must support this API if application
  // preloading is supported.
  rpc SetVisibility(SetVisibilityRequest) returns (SetVisibilityResponse);

  // Sets application touch input capability.
  rpc SetTouchInput(SetTouchInputRequest) returns (SetTouchInputResponse);
}

message SetUrlRewriteRulesRequest {
  UrlRequestRewriteRules rules = 1;
}

message SetUrlRewriteRulesResponse {}

message SetMediaStateRequest {
  cast.common.MediaState.Type media_state = 1;
}

message SetMediaStateResponse {}

message SetVisibilityRequest {
  cast.common.Visibility.Type visibility = 1;
}

message SetVisibilityResponse {}

message SetTouchInputRequest {
  cast.common.TouchInput.Type touch_input = 1;
}

message SetTouchInputResponse {}
