1/* This file is part of Clementine.
2   Copyright 2017, David Sansome <me@davidsansome.com>
3   Copyright 2017, Andreas Muttscheller <asfa194@gmail.com>
4
5   Licensed under the Apache License, Version 2.0 (the "License");
6   you may not use this file except in compliance with the License.
7   You may obtain a copy of the License at
8
9       http://www.apache.org/licenses/LICENSE-2.0
10
11   Unless required by applicable law or agreed to in writing, software
12   distributed under the License is distributed on an "AS IS" BASIS,
13   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   See the License for the specific language governing permissions and
15   limitations under the License.
16*/
17
18// Note: this file is licensed under the Apache License instead of GPL, so
19// 3rd party applications or libraries can use another license besides GPL.
20
21syntax = "proto2";
22
23package pb.remote;
24
25// The supported message types
26enum MsgType {
27  UNKNOWN = 0;
28  // Messages generally send from client to server
29  CONNECT = 1;
30  REQUEST_PLAYLISTS = 3;
31  REQUEST_PLAYLIST_SONGS = 4;
32  CHANGE_SONG = 5;
33  SET_VOLUME = 6;
34  SET_TRACK_POSITION = 7;
35  INSERT_URLS = 8;
36  REMOVE_SONGS = 9;
37  OPEN_PLAYLIST = 10;
38  CLOSE_PLAYLIST = 11;
39  GET_LYRICS = 14;
40  DOWNLOAD_SONGS = 15;
41  SONG_OFFER_RESPONSE = 16;
42  // Lastfm
43  LOVE = 12;
44  BAN = 13;
45  STOP_AFTER = 17;
46  GET_LIBRARY = 18;
47  RATE_SONG = 19;
48  GLOBAL_SEARCH = 100;
49
50  // Messages send by both
51  DISCONNECT = 2;
52  PLAY = 20;
53  PLAYPAUSE = 21;
54  PAUSE = 22;
55  STOP = 23;
56  NEXT = 24;
57  PREVIOUS = 25;
58  SHUFFLE_PLAYLIST = 26;
59  // Messages that contain the repeat or random mode
60  // Either set by client or clementine
61  REPEAT = 27;
62  SHUFFLE = 28;
63
64  // Messages send from server to client
65  INFO = 40;
66  CURRENT_METAINFO = 41;
67  PLAYLISTS = 42;
68  PLAYLIST_SONGS = 43;
69  ENGINE_STATE_CHANGED = 44;
70  KEEP_ALIVE = 45;
71  UPDATE_TRACK_POSITION = 46;
72  ACTIVE_PLAYLIST_CHANGED = 47;
73  FIRST_DATA_SENT_COMPLETE = 48;
74  LYRICS = 49;
75  SONG_FILE_CHUNK = 50;
76  DOWNLOAD_QUEUE_EMPTY = 51;
77  LIBRARY_CHUNK = 52;
78  DOWNLOAD_TOTAL_SIZE = 53;
79  GLOBAL_SEARCH_RESULT = 54;
80  TRANSCODING_FILES = 55;
81  GLOBAL_SEARCH_STATUS = 56;
82}
83
84// Valid Engine states
85enum EngineState {
86  Empty = 0;
87  Idle = 1;
88  Playing = 2;
89  Paused = 3;
90}
91
92// Song Metadata
93message SongMetadata {
94  enum Type {
95    UNKNOWN = 0;
96    ASF = 1;
97    FLAC = 2;
98    MP4 = 3;
99    MPC = 4;
100    MPEG = 5;
101    OGGFLAC = 6;
102    OGGSPEEX = 7;
103    OGGVORBIS = 8;
104    AIFF = 9;
105    WAV = 10;
106    TRUEAUDIO = 11;
107    CDDA = 12;
108    OGGOPUS = 13;
109    WAVPACK = 14;
110    SPC = 15;
111    VGM = 16;
112    APE = 17;
113    STREAM = 99;
114  }
115
116  optional int32 id = 1; // unique id of the song
117  optional int32 index = 2; // Index of the current row of the active playlist
118  optional string title = 3;
119  optional string album = 4;
120  optional string artist = 5;
121  optional string albumartist = 6;
122  optional int32 track = 7;
123  optional int32 disc = 8;
124  optional string pretty_year = 9;
125  optional string genre = 10;
126  optional int32 playcount = 11;
127  optional string pretty_length = 12;
128  optional bytes art = 13;
129  optional int32 length = 14;
130  optional bool is_local = 15;
131  optional string filename = 16;
132  optional int32 file_size = 17;
133  optional float rating = 18; // 0 (0 stars) to 1 (5 stars)
134  optional string url = 19;
135  optional string art_automatic = 20;
136  optional string art_manual = 21;
137  optional Type type = 22;
138}
139
140// Playlist information
141message Playlist {
142  optional int32 id = 1;
143  optional string name = 2;
144  optional int32 item_count = 3;
145  optional bool active = 4;
146  optional bool closed = 5;
147}
148
149// Valid Repeatmodes
150enum RepeatMode {
151  Repeat_Off = 0;
152  Repeat_Track = 1;
153  Repeat_Album = 2;
154  Repeat_Playlist = 3;
155  Repeat_OneByOne = 4;
156  Repeat_Intro = 5;
157}
158
159// Valid Shuffle modes
160enum ShuffleMode {
161  Shuffle_Off = 0;
162  Shuffle_All = 1;
163  Shuffle_InsideAlbum = 2;
164  Shuffle_Albums = 3;
165}
166
167message RequestPlaylists {
168  optional bool include_closed = 1;
169}
170
171// A Client requests songs from a specific playlist
172message RequestPlaylistSongs {
173  optional int32 id = 1;
174}
175
176// Client want to change track
177message RequestChangeSong {
178  // In which playlist is the song?
179  optional int32 playlist_id = 1;
180  // And on which position?
181  optional int32 song_index = 2;
182}
183
184// Set the volume
185message RequestSetVolume {
186  optional int32 volume = 1;
187}
188
189// Repeat and Random messages
190message Repeat {
191  optional RepeatMode repeat_mode = 1;
192}
193
194message Shuffle {
195  optional ShuffleMode shuffle_mode = 1;
196}
197
198// Response from server
199// General info
200message ResponseClementineInfo {
201  optional string version = 1;
202  optional EngineState state = 2;
203}
204
205// The current song played
206message ResponseCurrentMetadata {
207  optional SongMetadata song_metadata = 1;
208}
209
210// The playlists in clementine
211message ResponsePlaylists {
212  repeated Playlist playlist = 1;
213}
214
215// A list of songs in a playlist
216message ResponsePlaylistSongs {
217  optional Playlist requested_playlist = 1;
218
219  // The songs that are in the playlist
220  repeated SongMetadata songs = 2;
221}
222
223// The current state of the play engine
224message ResponseEngineStateChanged {
225  optional EngineState state = 1;
226}
227
228// Sends the current position of the track
229message ResponseUpdateTrackPosition {
230  optional int32 position = 1;
231}
232
233// The connect message containing the authentication code
234message RequestConnect {
235  optional int32 auth_code = 1;
236  optional bool send_playlist_songs = 2;
237  optional bool downloader = 3;
238}
239
240// Respone, why the connection was closed
241enum ReasonDisconnect {
242  Server_Shutdown = 1;
243  Wrong_Auth_Code = 2;
244  Not_Authenticated = 3;
245  Download_Forbidden = 4;
246}
247message ResponseDisconnect {
248  optional ReasonDisconnect reason_disconnect = 1;
249}
250
251message ResponseActiveChanged {
252  optional int32 id = 1;
253}
254
255// A client requests a new track position
256// position in seconds!
257message RequestSetTrackPosition {
258  optional int32 position = 1;
259}
260
261message RequestInsertUrls {
262  // In which playlist should the urls be inserted?
263  optional int32 playlist_id = 1;
264  repeated string urls = 2;
265  optional int32 position = 3 [default=-1];
266  optional bool play_now = 4 [default=false];
267  optional bool enqueue = 5 [default=false];
268  repeated SongMetadata songs = 6;
269}
270
271// Client want to change track
272message RequestRemoveSongs {
273  // In which playlist is the songs?
274  optional int32 playlist_id = 1;
275  // And on which position?
276  repeated int32 songs = 2;
277}
278
279// Messages for opening / closing playlists
280message RequestOpenPlaylist {
281  optional int32 playlist_id = 1;
282}
283message RequestClosePlaylist {
284  optional int32 playlist_id = 1;
285}
286
287// Message containing lyrics
288message ResponseLyrics {
289  repeated Lyric lyrics = 1;
290}
291message Lyric {
292  optional string id = 1;
293  optional string title = 2;
294  optional string content = 3;
295}
296
297// Message request for downloading songs
298enum DownloadItem {
299  CurrentItem = 1;
300  ItemAlbum = 2;
301  APlaylist = 3;
302  Urls = 4;
303}
304message RequestDownloadSongs {
305  optional DownloadItem download_item = 1;
306  optional int32 playlist_id = 2;
307  repeated string urls = 3;
308}
309
310message ResponseSongFileChunk {
311  optional int32 chunk_number = 1;
312  optional int32 chunk_count = 2;
313  optional int32 file_number = 3;
314  optional int32 file_count = 4;
315  optional SongMetadata song_metadata = 6; // only sent with first chunk!
316  optional bytes data = 7;
317  optional int32 size = 8;
318  optional bytes file_hash = 9;
319}
320
321message ResponseLibraryChunk {
322  optional int32 chunk_number = 1;
323  optional int32 chunk_count = 2;
324  optional bytes data = 3;
325  optional int32 size = 4;
326  optional bytes file_hash = 5;
327}
328
329message ResponseSongOffer {
330  optional bool accepted = 1; // true = client wants to download item
331}
332
333message RequestRateSong {
334  optional float rating = 1; // 0 to 1
335}
336
337message ResponseDownloadTotalSize {
338  optional int32 total_size = 1;
339  optional int32 file_count = 2;
340}
341
342message RequestGlobalSearch {
343  optional string query = 1;
344}
345
346message ResponseGlobalSearch {
347  optional int32 id = 1;
348  optional string query = 2;
349  optional string search_provider = 3;
350  repeated SongMetadata song_metadata = 4;
351  optional bytes search_provider_icon = 5;
352}
353
354message ResponseTranscoderStatus {
355  optional int32 processed = 1;
356  optional int32 total = 2;
357}
358
359enum GlobalSearchStatus {
360  GlobalSearchStarted = 1;
361  GlobalSearchFinished = 2;
362}
363
364message ResponseGlobalSearchStatus {
365  optional int32 id = 1;
366  optional string query = 2;
367  optional GlobalSearchStatus status = 3;
368}
369
370// The message itself
371message Message {
372  optional int32 version = 1 [default=21];
373  optional MsgType type = 2 [default=UNKNOWN]; // What data is in the message?
374
375  optional RequestConnect request_connect = 21;
376  optional RequestPlaylists request_playlists = 27;
377  optional RequestPlaylistSongs request_playlist_songs = 10;
378  optional RequestChangeSong request_change_song = 11;
379  optional RequestSetVolume request_set_volume = 12;
380  optional RequestSetTrackPosition request_set_track_position = 23;
381  optional RequestInsertUrls request_insert_urls = 25;
382  optional RequestRemoveSongs request_remove_songs = 26;
383  optional RequestOpenPlaylist request_open_playlist = 28;
384  optional RequestClosePlaylist request_close_playlist = 29;
385  optional RequestDownloadSongs request_download_songs = 31;
386  optional RequestRateSong request_rate_song = 35;
387  optional RequestGlobalSearch request_global_search = 37;
388
389  optional Repeat repeat = 13;
390  optional Shuffle shuffle = 14;
391
392  optional ResponseClementineInfo response_clementine_info = 15;
393  optional ResponseCurrentMetadata response_current_metadata = 16;
394  optional ResponsePlaylists response_playlists = 17;
395  optional ResponsePlaylistSongs response_playlist_songs = 18;
396  optional ResponseEngineStateChanged response_engine_state_changed = 19;
397  optional ResponseUpdateTrackPosition response_update_track_position = 20;
398  optional ResponseDisconnect response_disconnect = 22;
399  optional ResponseActiveChanged response_active_changed = 24;
400  optional ResponseLyrics response_lyrics = 30;
401  optional ResponseSongFileChunk response_song_file_chunk = 32;
402  optional ResponseSongOffer response_song_offer = 33;
403  optional ResponseLibraryChunk response_library_chunk = 34;
404  optional ResponseDownloadTotalSize response_download_total_size = 36;
405  optional ResponseGlobalSearch response_global_search = 38;
406  optional ResponseTranscoderStatus response_transcoder_status = 39;
407  optional ResponseGlobalSearchStatus response_global_search_status = 40;
408}
409