1// Copyright (C) 2023 The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15// Note that if you add/remove methods in this file you must update 16// the metrics sql as well by running ./android/scripts/gen-grpc-sql.py 17// 18// Please group deleted methods in a block including the date (MM/DD/YY) 19// it was removed. This enables us to easily keep metrics around after removal 20// 21// List of deleted methods 22// rpc iWasDeleted (03/12/12) 23// ... 24syntax = "proto3"; 25 26option java_multiple_files = true; 27option java_package = "com.android.emulator.control"; 28option objc_class_prefix = "AEC"; 29 30package android.emulation.control.v2; 31import "google/protobuf/empty.proto"; 32 33import "google/protobuf/any.proto"; 34import "ice_config.proto"; 35 36// NEXT ID: 2 37message RtcStreamRequest { 38 // Optional, extra information needed by the server to 39 // set up a WebRTC peer connection. 40 google.protobuf.Any payload = 1; 41 // The ICE configuration to use in the PeerConnection. 42 // Optional, if not set, and network traversal is enabled in the server, 43 // server will try to get the ICE config through Network Traversal API. 44 optional IceServerConfig ice_server_config = 2; 45} 46 47// NEXT ID: 2 48message RtcStreamResponse { 49 Id id = 1; 50} 51 52// NEXT ID: 2 53message SendJsepMessageRequest { 54 JsepMsg jsep_msg = 1; 55} 56 57// NEXT ID: 1 58message SendJsepMessageResponse {} 59 60// NEXT ID: 2 61message ReceiveJsepMessageRequest { 62 Id id = 1; 63} 64 65// NEXT ID: 2 66message ReceiveJsepMessageResponse { 67 JsepMsg jsep_msg = 1; 68} 69 70// An RTC service lets you interact with the emulator through WebRTC 71// Note that this is currently an experimental feature, and that the 72// service definition might change without notice. Use at your own risk! 73// 74// The following endpoints are needed to establish the webrtc protocol 75// Due to limitiations in Javascript we cannot make use of bidirectional 76// endpoints See this [blog](https://grpc.io/blog/state-of-grpc-web) for 77// details. 78service Rtc { 79 // This function will generate a new identifier that the client 80 // should use for further interaction. It will initiate the 81 // JSEP protocol on the server side. 82 rpc RequestRtcStream(RtcStreamRequest) returns (RtcStreamResponse) {} 83 84 // Sends the given JsepMsg to the server. The RtcId in the 85 // message should point to an active stream negotiation in 86 // progress, otherwise the message will be ignored. 87 rpc SendJsepMessage(SendJsepMessageRequest) 88 returns (SendJsepMessageResponse) {} 89 90 // Reads an available jsep messages for the given client id, 91 // blocking until one becomes available. Do not use the polling version 92 // above if you opt for this one. 93 // 94 // The ice candidates for example will trickle in on this callback, 95 // as will the SDP negotation. 96 rpc ReceiveJsepMessageStream(ReceiveJsepMessageRequest) 97 returns (stream ReceiveJsepMessageResponse) {} 98 99 // [DEPRECATED] This is only here as the go grpc webproxy used 100 // by fuchsia does not support server side streaming. This method 101 // will be removed in the future and should not be relied upon. 102 // 103 // Reads an available jsep messages for the given client id, 104 // blocking until one becomes available. Do not use the polling version 105 // above if you opt for this one. 106 // 107 // The ice candidates for example will trickle in on this callback, 108 // as will the SDP negotation. 109 rpc ReceiveJsepMessage(ReceiveJsepMessageRequest) 110 returns (ReceiveJsepMessageResponse) {} 111} 112 113message Id { 114 // The unique identifier of this connection. You will have to use the same 115 // identifier when sending/receiving messages. The server will generate a 116 // guid when receiving the start message. 117 string guid = 1; 118} 119 120message JsepMsg { 121 // The unique identifier of this connection. You will have to use the 122 // same identifier when sending/receiving messages. The server will 123 // generate a guid when receiving the start message. 124 Id id = 1; 125 // The JSON payload. This usually can be directly handled by the 126 // Javascript library. 127 // 128 // The dictionary can contain the following properties 129 // 130 // - bye: 131 // You can hang up now. No new message expected for you. 132 // The server has stopped the RTC stream. 133 // 134 // - start: 135 // An RTCConfiguration dictionary providing options to 136 // configure the new connection. This can include the 137 // turn configuration the serve is using. This dictionary can be 138 // passed in directly to the 139 // [RTCPeerConnection](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection) 140 // object. 141 // 142 // - candidate: 143 // The WebRTC API's RTCIceCandidateInit dictionary, which 144 // contains the information needed to fundamentally describe an 145 // RTCIceCandidate. See 146 // [RTCIceCandidate](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceCandidate) 147 // and [Session 148 // Lifetime](https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Session_lifetime) 149 // for more details. 150 // 151 // - sdp: 152 // RTCSessionDescriptionInit dictionary containing the values 153 // to that can be assigned to a 154 // [RTCSessionDescription](https://developer.mozilla.org/en-US/docs/Web/API/RTCSessionDescription) 155 string message = 2; 156} 157