syntax = "proto2";

package spb.tagreader;

message SongMetadata {

  enum FileType {
    UNKNOWN = 0;
    WAV = 1;
    FLAC = 2;
    WAVPACK = 3;
    OGGFLAC = 4;
    OGGVORBIS = 5;
    OGGOPUS = 6;
    OGGSPEEX = 7;
    MPEG = 8;
    MP4 = 9;
    ASF = 10;
    AIFF = 11;
    MPC = 12;
    TRUEAUDIO = 13;
    DSF = 14;
    DSDIFF = 15;
    PCM = 16;
    APE = 17;
    MOD = 18;
    S3M = 19;
    XM = 20;
    IT = 21;
    SPC = 22;
    VGM = 23;
    CDDA = 90;
    STREAM = 91;
  }

  optional bool valid = 1;

  optional string title = 2;
  optional string album = 3;
  optional string artist = 4;
  optional string albumartist = 5;
  optional int32 track = 6;
  optional int32 disc = 7;
  optional int32 year = 8;
  optional int32 originalyear = 9;
  optional string genre = 10;
  optional bool compilation = 11;
  optional string composer = 12;
  optional string performer = 13;
  optional string grouping = 14;
  optional string comment = 15;
  optional string lyrics = 16;

  optional uint64 length_nanosec = 17;

  optional int32 bitrate = 18;
  optional int32 samplerate = 19;
  optional int32 bitdepth = 20;

  optional string url = 21;
  optional string basefilename = 22;
  optional FileType filetype = 23;
  optional int64 filesize = 24;
  optional int64 mtime = 25;
  optional int64 ctime = 26;

  optional uint32 playcount = 27;
  optional uint32 skipcount = 28;
  optional int64 lastplayed = 29;
  optional int64 lastseen = 30;

  optional string art_automatic = 31;

  optional float rating = 32;

  optional bool suspicious_tags = 40;

}

message ReadFileRequest {
  optional string filename = 1;
}

message ReadFileResponse {
  optional SongMetadata metadata = 1;
}

message SaveFileRequest {
  optional string filename = 1;
  optional SongMetadata metadata = 2;
}

message SaveFileResponse {
  optional bool success = 1;
}

message IsMediaFileRequest {
  optional string filename = 1;
}

message IsMediaFileResponse {
  optional bool success = 1;
}

message LoadEmbeddedArtRequest {
  optional string filename = 1;
}

message LoadEmbeddedArtResponse {
  optional bytes data = 1;
}

message SaveEmbeddedArtRequest {
  optional string filename = 1;
  optional bytes data = 2;
}

message SaveEmbeddedArtResponse {
  optional bool success = 1;
}

message SaveSongPlaycountToFileRequest {
  optional string filename = 1;
  optional SongMetadata metadata = 2;
}

message SaveSongPlaycountToFileResponse {
  optional bool success = 1;
}

message SaveSongRatingToFileRequest {
  optional string filename = 1;
  optional SongMetadata metadata = 2;
}

message SaveSongRatingToFileResponse {
  optional bool success = 1;
}

message Message {
  optional int32 id = 1;

  optional ReadFileRequest read_file_request = 2;
  optional ReadFileResponse read_file_response = 3;

  optional SaveFileRequest save_file_request = 4;
  optional SaveFileResponse save_file_response = 5;

  optional IsMediaFileRequest is_media_file_request = 6;
  optional IsMediaFileResponse is_media_file_response = 7;

  optional LoadEmbeddedArtRequest load_embedded_art_request = 8;
  optional LoadEmbeddedArtResponse load_embedded_art_response = 9;

  optional SaveEmbeddedArtRequest save_embedded_art_request = 10;
  optional SaveEmbeddedArtResponse save_embedded_art_response = 11;

  optional SaveSongPlaycountToFileRequest save_song_playcount_to_file_request = 12;
  optional SaveSongPlaycountToFileResponse save_song_playcount_to_file_response = 13;

  optional SaveSongRatingToFileRequest save_song_rating_to_file_request = 14;
  optional SaveSongRatingToFileResponse save_song_rating_to_file_response = 15;

}
