aboutsummaryrefslogtreecommitdiff
path: root/proto/blueberry/a2dp.proto
blob: a5e1b1add1ca9e5a5672451d122b86af2b309e55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
syntax = "proto3";

package blueberry;

import "blueberry/host.proto";
import "google/protobuf/wrappers.proto";

// Service to trigger A2DP (Advanced Audio Distribution Profile) procedures.
//
// Requirement for the implementor:
// - Streams must not be automaticaly opened, even if discovered.
// - The `Host` service should be implemented
//
// References:
// - [A2DP] Bluetooth SIG, Specification of the Bluetooth System,
//    Advanced Audio Distribution, Version 1.3 or Later
// - [AVDTP] Bluetooth SIG, Specification of the Bluetooth System,
//    Audio/Video Distribution Transport Protocol, Version 1.3 or Later
service A2DP {
  // Open a stream from a local **Source** endpoint to a remote **Sink**
  // endpoint.
  //
  // The returned source should be in the AVDTP_OPEN state (see [AVDTP] 9.1).
  // The function must block until the stream has reached this state
  //
  // A cancellation of this call must result in aborting the current
  // AVDTP procedure (see [AVDTP] 9.9)
  rpc OpenSource(OpenSourceRequest) returns (OpenSourceResponse);
  // Open a stream from a local **Sink** endpoint to a remote **Source**
  // endpoint.
  //
  // The returned sink must be in the AVDTP_OPEN state (see [AVDTP] 9.1).
  // The function must block until the stream has reached this state
  //
  // A cancellation of this call must result in aborting the current
  // AVDTP procedure (see [AVDTP] 9.9)
  rpc OpenSink(OpenSinkRequest) returns (OpenSinkResponse);
  // Wait for a stream from a local **Source** endpoint to
  // a remote **Sink** endpoint to open.
  //
  // If the peer has opened a source prior to this call, the server will
  // return it. The server must return the same source only once.
  rpc WaitSource(WaitSourceRequest) returns (WaitSourceResponse);
  // Wait for a stream from a local **Sink** endpoint to
  // a remote **Source** endpoint to open.
  //
  // If the peer has opened a sink prior to this call, the server will
  // return it. The server must return the same sink only once.
  rpc WaitSink(WaitSinkRequest) returns (WaitSinkResponse);
  // Get if the stream is suspended
  rpc IsSuspended(IsSuspendedRequest) returns (google.protobuf.BoolValue);
  // Start a suspended stream.
  rpc Start(StartRequest) returns (StartResponse);
  // Suspend a started stream.
  rpc Suspend(SuspendRequest) returns (SuspendResponse);
  // Close a stream, the source or sink tokens must not be reused afterwards.
  rpc Close(CloseRequest) returns (CloseResponse);
  // Get the `AudioEncoding` value of a stream
  rpc GetAudioEncoding(GetAudioEncodingRequest) returns (GetAudioEncodingResponse);
  // Playback audio by a `Source`
  rpc PlaybackAudio(stream PlaybackAudioRequest) returns (PlaybackAudioResponse);
  // Capture audio from a `Sink`
  rpc CaptureAudio(CaptureAudioRequest)returns (stream CaptureAudioResponse);
}

// Audio encoding formats.
enum AudioEncoding {
  // Interleaved stereo frames with 16-bit signed little-endian linear PCM
  // samples at 44100Hz sample rate
  PCM_S16_LE_44K1_STEREO = 0;
  // Interleaved stereo frames with 16-bit signed little-endian linear PCM
  // samples at 48000Hz sample rate
  PCM_S16_LE_48K_STEREO = 1;
}

// A Token representing a Source stream (see [A2DP] 2.2).
// It's acquired via an OpenSource on the A2DP service.
message Source {
  // Opaque value filled by the GRPC server, must not
  // be modified nor crafted.
  bytes cookie = 1;
}

// A Token representing a Sink stream (see [A2DP] 2.2).
// It's acquired via an OpenSink on the A2DP service.
message Sink {
  // Opaque value filled by the GRPC server, must not
  // be modified nor crafted.
  bytes cookie = 1;
}

// Request for the `OpenSource` method.
message OpenSourceRequest {
  // The connection that will open the stream.
  Connection connection = 1;
}

// Response for the `OpenSource` method.
message OpenSourceResponse {
  // Result of the `OpenSource` call:
  // - If successfull: a Source
  oneof result {
    Source source = 1;
  }
}

// Request for the `OpenSink` method.
message OpenSinkRequest {
  // The connection that will open the stream.
  Connection connection = 1;
}

// Response for the `OpenSink` method.
message OpenSinkResponse {
  // Result of the `OpenSink` call:
  // - If successfull: a Sink
  oneof result {
    Sink sink = 1;
  }
}

// Request for the `WaitSource` method.
message WaitSourceRequest {
  // The connection that is awaiting the stream.
  Connection connection = 1;
}

// Response for the `WaitSource` method.
message WaitSourceResponse {
  // Result of the `WaitSource` call:
  // - If successfull: a Source
  oneof result {
    Source source = 1;
  }
}

// Request for the `WaitSink` method.
message WaitSinkRequest {
  // The connection that is awaiting the stream.
  Connection connection = 1;
}

// Response for the `WaitSink` method.
message WaitSinkResponse {
  // Result of the `WaitSink` call:
  // - If successfull: a Sink
  oneof result {
    Sink sink = 1;
  }
}

// Request for the `IsSuspended` method.
message IsSuspendedRequest {
  // The stream on which the function will check if it's suspended
 oneof target {
    Sink sink = 1;
    Source source = 2;
  }
}

// Request for the `Start` method.
message StartRequest {
  // Target of the start, either a Sink or a Source.
  oneof target {
    Sink sink = 1;
    Source source = 2;
  }
}

// Response for the `Start` method.
message StartResponse {}

// Request for the `Suspend` method.
message SuspendRequest {
  // Target of the suspend, either a Sink or a Source.
  oneof target {
    Sink sink = 1;
    Source source = 2;
  }
}

// Response for the `Suspend` method.
message SuspendResponse {}

// Request for the `Close` method.
message CloseRequest {
  // Target of the close, either a Sink or a Source.
  oneof target {
    Sink sink = 1;
    Source source = 2;
  }
}

// Response for the `Close` method.
message CloseResponse {}

// Request for the `GetAudioEncoding` method.
message GetAudioEncodingRequest {
  // The stream on which the function will read the `AudioEncoding`.
  oneof target {
    Sink sink = 1;
    Source source = 2;
  }
}

// Response for the `GetAudioEncoding` method.
message GetAudioEncodingResponse {
  // Audio encoding of the stream.
  AudioEncoding encoding = 1;
}

// Request for the `PlaybackAudio` method.
message PlaybackAudioRequest {
  // Source that will playback audio.
  Source source = 1;
  // Audio data to playback.
  // The audio data must be encoded in the specified `AudioEncoding` value
  // obtained in response of a `GetAudioEncoding` method call.
  bytes data = 2;
}

// Response for the `PlaybackAudio` method.
message PlaybackAudioResponse {}

// Request for the `CaptureAudio` method.
message CaptureAudioRequest {
  // Sink that will capture audio
  Sink sink = 1;
}

// Response for the `CaptureAudio` method.
message CaptureAudioResponse {
  // Captured audio data.
  // The audio data is encoded in the specified `AudioEncoding` value
  // obained in response of a `GetAudioEncoding` method call.
  bytes data = 1;
}